⌘
Claude Code Cheat Sheet
CLI · Slash Commands · Shortcuts · Pro Tips
Updated · Sep 2026
CLI Launch Commands
claudeStart interactive session
claude "prompt"One-shot query, non-interactive
claude -cResume last conversation
claude -r <id>Resume a specific session by ID
claude -p "prompt"Print mode: pipe output to stdout
claude --bg "task"Start a background session (detached)
claude agentsDashboard: manage all running sessions
claude agents --jsonList live sessions as JSON (for scripting)
claude project purgeDelete all CC state for a project (--dry-run safe)
claude --model <m>Specify model at launch
claude --add-dir <path>Add extra working directory
claude --dangerously-skip-permissionsAuto-approve all (trusted CI only)
Core Slash Commands
/helpShow all available commands
/initScan project, create CLAUDE.md
/clearReset conversation history
/compactSummarize history, free context window
/modelSwitch model (session only; press d to set default)
/effort <level>Set effort mid-session: low · medium · high · max
/fastEnable Fast Mode (Opus at 2.5x speed)
/planSwitch to planning / read-only mode
/code-review [high]Review for correctness bugs; --comment posts inline to PR
/security-reviewAudit the diff/PR for security vulnerabilities
/simplify [level]Suggest cleanup & refactors for the current diff
/usagePer-category limits breakdown: skills, subagents, plugins, MCP
More Slash Commands
/todosScan for TODO/FIXME markers, build a prioritized artifact
/add-dir <path>Add working directory to session
/doctorHealth check installation
/rewind [N]Roll back to a checkpoint in code or conversation
/memoryEdit CLAUDE.md files and manage auto memory
/permissionsManage allow/ask/deny rules for tool access
/install-github-appEnable auto PR review via GitHub
/keybindingsEdit custom keyboard bindings
/mobileQR code to install the Claude mobile app
Keyboard Shortcuts
Esc
Stop Claude (do not use Ctrl+C!)
EscEsc
Browse and jump to previous messages
↑
Navigate past prompts and sessions
ShiftTab
Cycle: normal → auto-accept → plan
CtrlV
Paste image from clipboard
Shift+drag
Reference a file in chat (not open it)
!
Run shell command directly in session
@
Reference file or directory inline
CLAUDE.md — Project Memory

Run /init to auto-generate. Claude reads this on every session — add anything it must always know.

# CLAUDE.md
## Stack
Next.js 15, TypeScript, Postgres

## Commands
Build: npm run build
Test: npm test
Lint: npm run lint

## Conventions
- Use pnpm, not npm
- No default exports
- Tests alongside source files
Model Selection Guide — Sorted by Capability
Model
$/MTok in·out
Best for
Haiku 4.5 $1 · $5 Fastest, near-frontier intelligence — simple or token-heavy tasks Sonnet 5 $2 · $10 Default — best balance of speed and intelligence Opus 5.5 $4 · $20 Recommended for most workloads — long-running agentic coding Fable 5.1 ✨ $10 · $50 Most capable — demanding reasoning & long-horizon agentic work beyond Opus
Pricing is Claude API pay-as-you-go, per million tokens (input · output) — Pro/Max/Team plan usage is covered by your subscription instead, subject to usage limits. Pro tip: Use /fast for Opus at 2.5x speed. /model changes the current session only — press d to set a new default.
🔀 Model Providers — Anthropic Models Only
Short answer
Claude Code only runs Claude models. There's no supported way to swap in GPT, Gemini, Llama, or any other non-Anthropic model — not even through a custom endpoint.
Run Claude via another cloud
CLAUDE_CODE_USE_BEDROCK=1Route to Claude on Amazon Bedrock
CLAUDE_CODE_USE_VERTEX=1Route to Claude on Google Cloud's Agent Platform (Vertex AI)
Also available: Microsoft Foundry, Claude Platform on AWS. Same Claude models, different billing/infra.
Route through your own gateway
ANTHROPIC_BASE_URL=<url>Point at a self-hosted or corporate LLM gateway
For centralized auth, usage tracking & budgets. The gateway must speak Anthropic's API format and still serve Claude models — Anthropic doesn't support or audit routing to non-Claude models this way.
In-Session Syntax and References
@src/app.tsReference a specific file
@src/Reference an entire directory
!npm testRun shell command (saves tokens)
!git diff HEADRun git commands inside session
"fix @auth/login.ts"Natural language + file reference
/model opusSwitch models on the fly mid-task
Custom Commands and Skills

Store prompts as Markdown files, invoke with /name

~/.claude/commands/Global — all projects
.claude/commands/Project-scoped only
.claude/skills/New format — supports auto-invoke
# .claude/commands/review.md
Review this code for bugs,
security issues, and edge cases.
Be concise. Skip style nits.
settings.json — Key Config
// .claude/settings.json
"model": "claude-sonnet-5",
"permissions": {
  "allowedTools": ["Read","Write","Bash(git *)"],
  "deny": ["Read(./.env)"]
},
"hooks": {
  "PostToolUse": [{
    "matcher": "Write(*.py)",
    "command": "black $file"
  }],
  "PostCompact": [{
    "command": "echo compacted"
  }]
}
GitHub and PR Integration
/install-github-appEnable auto-review of all PRs
/pr-comments [pr#]Post review findings to a PR, one comment per issue

Customize the review prompt to keep it focused:

# claude-code-review.yml
direct_prompt: |
  Review for bugs and security
  issues only. Be concise.
  Skip style and nit comments.
MCP Servers and Extensions
claude mcp add <name>Add MCP server to config
claude mcp listShow all configured servers
claude mcp remove <n>Remove a server
/mcpManage connections & OAuth mid-session
GitHub MCP — PRs, issues, repos
Filesystem MCP — Extended access
Postgres MCP — Query DB directly
Browser MCP — Web automation
System Prompt Flags
--append-system-promptAdd to default prompt (recommended)
--system-promptReplace default prompt entirely
--append-system-prompt-fileAppend instructions from a file
--system-prompt-fileReplace prompt with file contents
Use --append to preserve built-in CC capabilities. Use --system-prompt only when you need full control.
More Useful CLI Flags
-n / --name <name>Set a display name for the session
--worktree / -wIsolated git worktree; auto-cleaned if no changes
--from-pr <#>Resume or start a PR-linked session
--effort <level>Set effort: low · medium · high · max
--bareSkip hooks, LSP & plugins — lean scripting mode
--output-formatjson · text · stream-json (use with -p)
💡 --worktree is great for risky refactors — work in isolation, then merge. --bare pairs with --dangerously-skip-permissions for fast, headless CI pipelines.
🔌 Plugins & Background Sessions — NEW (2026)
Plugin Commands
claude plugin install <name>Install from marketplace
claude plugin listShow installed plugins
claude plugin details <name>Inventory + per-session token cost
claude plugin validateValidate plugin manifest
/pluginBrowse & manage in-session
Background Sessions
claude --bg "task"Start detached background session
claude agentsDashboard: all running sessions
claude agents --jsonList sessions as JSON for scripting
Ctrl+TPin session (keeps alive when idle)
/resumeResume background sessions (marked bg)
New Hooks (2026)
PostToolUse — after file write
PreToolUse  — before any action
PostCompact — after /compact
SessionStart — on session open
SubagentStop — when agent ends
Notification — custom alerts
🔁 /loop & /schedule — Automation
Repeat & Schedule
/loop [interval] [prompt]Repeat a prompt while the session stays open; omit interval to self-pace
/schedule <interval> <prompt>e.g. /schedule 1h check if tests pass
Branch & Detach
/background [prompt]Detach current session to run as a background agent
/fork [prompt]Copy conversation into a new background session
/branch [name]Branch the conversation at this point
Goals & Scale
/goal [condition]Set a goal Claude keeps working toward until met
/batch <instruction>Orchestrate large changes across a codebase in parallel
/statusModel, dir, permissions, MCP, background tasks
/loop vs /schedule: /loop re-runs a prompt on a fixed or self-chosen interval for as long as the session is open. /schedule takes an explicit interval up front — good for recurring checks like a daily PR review.
Other Handy Commands
/context [all]Visualize context usage as a colored grid
/export [file]Export the conversation as plain text
/theme [dark|light]Switch the UI theme
/vimToggle Vim keybindings (alias /vi)
/sandbox [name]Manage sandboxes for testing/running code
/web-search <query>Search the web, cite sources
/release-notesShow what's new in Claude Code
/hooksView hook configurations
/ideManage IDE integrations
/agentsReminder to create/manage subagents
✨ Auto Mode — NEW (Research Preview · Mar 2026)
What it is
A middle path between manual approval and --dangerously-skip-permissions. A classifier reviews every tool call before it runs, blocking destructive actions while letting safe ones proceed automatically.
What it blocks
Mass file deletion · sensitive data exfiltration · malicious code execution. If Claude keeps hitting blocks, it eventually prompts the user instead of looping.
How to enable
--enable-auto-modeLaunch flag to turn it on
Shift+TabCycle to auto mode in-session
VS Code / Desktop: Settings → Claude Code → toggle on, then select from the permission mode drop-down. Works with Sonnet 5 & Opus 5.5. Available on Team plan now; Enterprise & API coming soon.
⚠️ Auto mode reduces risk vs. --dangerously-skip-permissions but doesn't eliminate it — still recommended to use in isolated/sandboxed environments. The classifier may occasionally allow borderline actions or block benign ones.
Pro Tips — From Anthropic's Best-Practices Guide
01
Give Claude a way to verify its workA test, a build, a screenshot to diff. Without a pass/fail signal, "looks done" is the only signal — and you become the verification loop.
02
Explore, then plan, then codeUse plan mode (Shift+Tab) to research and agree a plan before Claude edits anything. Skip it when you could describe the diff in one sentence.
03
Two failed corrections? /clear, don't try a thirdContext polluted with failed approaches rarely self-corrects. A clean session with a sharper prompt beats a long one full of dead ends.
04
Delegate research to subagents"Use subagents to investigate X" keeps exploration out of your main context — they read the files and report back a summary instead of the whole trail.
05
Add an adversarial review stepBefore calling work done, have a fresh subagent review the diff against your plan. A reviewer with no attachment to the code it just wrote catches more.
06
Treat CLAUDE.md like code, not a wishlistFor every line ask: "would removing this cause mistakes?" A bloated file makes Claude ignore half of it — prune ruthlessly and check it into git.
07
Feed rich context instead of describing it@file to point at code, paste screenshots directly, or pipe logs with cat error.log | claude.
08
Let Claude interview you before big featuresAsk it to use AskUserQuestion to dig into edge cases and tradeoffs, write a spec, then implement in a fresh session with clean context.
09
Use hooks for zero-exception rulesCLAUDE.md instructions are advisory; hooks are deterministic. Try "write a hook that runs eslint after every file edit."
10
Fan out for large migrationsRun /batch <instruction> to split work across parallel subagents, or script claude -p in a loop with --allowedTools scoped to the task.