Claude Code Cheat Sheet

Quick reference for every command, shortcut, CLI flag, and configuration option. Bookmark this page and come back whenever you need a reminder.

Updated Feb 2026 Quick Reference

Keyboard Shortcuts

SHORTCUTACTION
EnterSubmit prompt (single-line mode)
Shift+EnterNew line in multi-line mode
EscCancel current generation / go back
Ctrl+CInterrupt running tool / cancel
Ctrl+LClear screen
Ctrl+DExit Claude Code
TabAutocomplete file paths in prompt
UpCycle through prompt history
Ctrl+RSearch prompt history

Slash Commands

COMMANDWHAT IT DOES
/helpShow help and available commands
/clearClear conversation history, start fresh
/compactCompress conversation to save context window
/costShow token usage and cost for current session
/doctorCheck Claude Code installation and diagnose issues
/initCreate a CLAUDE.md file for the current project
/loginSwitch accounts or re-authenticate
/logoutSign out of the current session
/modelSwitch between Claude models (opus, sonnet, haiku)
/permissionsView and edit tool permission settings
/reviewReview code changes and suggest improvements
/statusShow current session info (model, cost, tokens)
/vimToggle vim keybindings mode
/fastToggle fast output mode (same model, faster)
TIP

You can also create custom slash commands by adding Markdown files to .claude/commands/. See our Slash Commands Guide.

CLI Flags & Options

Starting a session

FLAGUSAGE
claudeStart interactive session in current directory
claude "prompt"Start with an initial prompt
claude -p "prompt"Print mode — single response, no interactivity
claude -cContinue the most recent conversation
claude -r "id"Resume a specific conversation by ID
cat file | claude -pPipe input as context for the prompt

Model & output

FLAGUSAGE
--model opusUse Claude Opus 4.6 (most capable)
--model sonnetUse Claude Sonnet 4.6 (balanced)
--model haikuUse Claude Haiku 4.5 (fastest, cheapest)
--output-format jsonOutput as JSON (for scripting)
--output-format stream-jsonStream JSON events
--verboseShow detailed tool execution info
--max-turns NLimit the number of agentic turns

Permissions & tools

FLAGUSAGE
--allowedTools "Bash,Read"Restrict which tools the agent can use
--disallowedTools "Edit"Block specific tools
--permission-mode planRequire approval before edits
--dangerously-skip-permissionsSkip all permission prompts (CI/CD only)

CLAUDE.md Quick Reference

The CLAUDE.md file gives Claude project-specific context and instructions. It's loaded automatically at the start of every session.

LOCATIONSCOPE
~/.claude/CLAUDE.mdGlobal — applies to all projects
./CLAUDE.mdProject root — applies to this repo
./src/CLAUDE.mdDirectory — applies when working in src/
./.claude/CLAUDE.local.mdPersonal — gitignored, your preferences

What to put in CLAUDE.md

# Project: My App

## Build & Test
- `npm run dev` to start dev server
- `npm test` to run tests
- `npm run lint` to check linting

## Architecture
- React frontend in src/components/
- Express API in src/api/
- PostgreSQL database, migrations in db/

## Conventions
- Use TypeScript strict mode
- Prefer functional components with hooks
- Write tests for all new features
- Use conventional commits (feat:, fix:, etc.)
TIP

Keep CLAUDE.md concise. Claude reads it every session — long files waste tokens. Focus on build commands, architecture overview, and coding conventions that Claude wouldn't know from the code alone.

Hook Events

Hooks let you run custom scripts when specific events occur.

EVENTWHEN IT FIRES
PreToolUseBefore a tool is executed (can block)
PostToolUseAfter a tool completes
StopWhen Claude finishes responding
SubagentStopWhen a subagent finishes
SessionStartWhen a new session begins
SessionEndWhen a session ends
UserPromptSubmitWhen user submits a prompt (can modify)
PreCompactBefore conversation context is compressed
NotificationWhen Claude sends a notification

Hook config example

// In .claude/settings.json
{
  "hooks": {
    "PreToolUse": [{
      "matcher": "Bash",
      "command": "echo 'Bash command about to run'"
    }],
    "Stop": [{
      "command": "echo 'Claude finished'"
    }]
  }
}

Agent Types

Built-in subagent types you can reference:

TYPEBEST FOR
ExploreFast codebase search, file discovery, architecture questions
BashRunning terminal commands (git, npm, docker, tests)
PlanDesigning implementation strategies, architecture decisions
general-purposeComplex multi-step research, web search, multi-tool tasks

Permission Modes

MODEBEHAVIOR
defaultAsk before file edits and shell commands
planRequire approval for the plan before any edits
acceptEditsAuto-approve file edits, still ask for bash
dontAskAuto-approve most actions (still blocks risky ones)
bypassPermissionsSkip all prompts (for CI/CD pipelines only)

Key Files & Directories

PATHPURPOSE
CLAUDE.mdProject instructions (auto-loaded)
.claude/settings.jsonProject settings, hooks, permissions
.claude/commands/Custom slash commands (Markdown files)
~/.claude/CLAUDE.mdGlobal instructions for all projects
~/.claude/settings.jsonGlobal settings (API keys, preferences)
~/.claude/projects/Auto memory, per-project persistent context
.mcp.jsonMCP server configuration for this project
~/.claude/.mcp.jsonGlobal MCP server configuration

Pro Tips

CONTEXT MANAGEMENT

Use /compact when context gets large. Claude compresses the conversation into a summary, freeing up tokens for more work. Do this proactively before hitting limits.

FILE REFERENCES

Drag files into the terminal or use Tab completion to reference files by path. Claude reads them automatically — no need to say "read the file at...".

PIPE EVERYTHING

Pipe anything into Claude: git diff | claude -p "review this" or cat error.log | claude -p "what's wrong?". Great for quick analysis without starting a full session.

MODEL SWITCHING

Start with sonnet for most tasks. Switch to opus mid-conversation with /model opus only when you need deeper reasoning. Use haiku for simple refactoring.

SKILLS & PLUGINS

Install community skills to unlock specialized capabilities: claude plugin add owner/repo. Browse available skills at Skills Playground.

CONTINUE SESSIONS

Use claude -c to continue your last conversation. All context is preserved — perfect for picking up where you left off after a break.

FAST MODE

Toggle /fast for faster output using the same model. Ideal for repetitive tasks where speed matters more than deep analysis.

MCP SERVERS

Extend Claude with MCP servers for database access, API integrations, and more. Add them to .mcp.json in your project root.