Claude Code Cheatsheet
Quickly look up commands, shortcuts, real-world workflows, and go-to prompts. Search by keyword or filter by category to copy fast.
Installation
8 itemscurl -fsSL https://claude.ai/install.sh | bash Install on macOS/Linux (auto-updates). No Node.js required.
brew install --cask claude-code Install via Homebrew (manual updates).
irm https://claude.ai/install.ps1 | iex Install on Windows PowerShell.
claude --version Check the installed version.
/doctor Health check: verify install, network, and config (inside a Claude Code session).
claude update Update to the latest version.
claude Launch → sign in for the first time via browser.
/login Log in or switch CLI accounts.
Plans & Pricing
6 itemsPro: $20/month Basic plan, enough for individual use (usage limits apply).
Max 5x: $100/month 5x the usage of Pro (for devs working all day).
Max 20x: $200/month 20x the usage of Pro (small teams/power users).
API (Console) Pay per token (~$100-200/dev/month). Use --max-budget-usd to set a limit.
Teams / Enterprise Centralized management, SSO, team billing.
Best practice Prefer subscription plans for predictable billing; use the API only for CI/CD or headless workflows.
Essential Commands
12 items/compact Compact context: the most important command (do not wait until context runs out).
/clear Clear everything, start a new session.
Shift+Tab → Plan Enter Plan Mode: Claude only reads, it does not edit code.
/model sonnet Switch models (haiku/sonnet/opus/opusplan).
/fast Enable fast mode.
/init Initialize a project: auto-generate CLAUDE.md.
/cost View token cost (API users).
/insights Analyze your work session: patterns, friction points.
/config Open settings: theme, model, output style.
Shift+Tab Switch permission mode (Default/Auto/Plan).
Esc × 2 Undo: go back to the previous step.
Alt+T Toggle thinking: deeper reasoning.
Permission Modes
6 itemsDefault Asks before editing files or running commands (safest).
Auto-accept (acceptEdits) Auto-edits files, asks before running commands.
Plan Mode Read only: no edits, no execution.
--dangerously-skip-permissions Skips everything: only use inside a container/VM (DANGEROUS).
Shift+Tab Quickly switch between modes.
--permission-mode plan Choose the mode when launching the CLI.
Syntax & CLI
12 items@path/to/file.ts Attach a file: Claude reads and understands it.
!npm test Quickly run a shell command.
/btw follow-up question Quick question that does not affect context.
claude -p "question" Quick headless question: use in scripts/CI/CD.
claude -c Continue the previous session.
claude -r <id> Return to a specific session by ID.
claude --model sonnet Choose a model at startup.
claude --add-dir ../lib Add a directory outside the project.
claude --teleport Pull a session from the web into the terminal.
--output-format json Output JSON (text/json/stream-json).
--max-turns 10 Limit the number of agent turns (headless).
--max-budget-usd 5 Limit cost per session.
Memory & Config
7 itemsCLAUDE.md Project memory (repo root or .claude/). Commit to git.
~/.claude/CLAUDE.md Personal memory: only you can see it.
/init Auto-generate CLAUDE.md for the project.
.claude/settings.json Hooks and permissions for the project (commit this).
.claude/settings.local.json Personal permissions (gitignore this).
.claude/skills/ Skill modules: in-depth expertise.
.claude/rules/ Rules automatically loaded into context.
Lesser-Known Features
11 items/simplify Detects over-engineering and auto-fixes it.
/loop 5m /compact Runs a command repeatedly at an interval.
/rename session-name Name a session so it is easy to find again.
/copy Select and copy a code block from the conversation.
/stats View usage graph, streaks, and favorite model.
/resume Pick and return to an older session.
Session forking Esc×2 to rewind → creates a parallel timeline.
Background agents Sub-agents run in the background while you keep coding.
Hooks system Scripts that auto-run on events (SessionStart, PreToolUse...).
claude auth status Check login status.
claude mcp add <name> <cmd> Add an MCP server (e.g., context7).
Context & Model
7 itemsLow context Comfortable: safe zone.
High context Careful: run /compact soon.
Context full URGENT: /compact or /clear right now.
Haiku $ Small fixes, review: cheapest.
Sonnet $$ Everyday coding: best value.
Opus $$$ Hard debugging, architecture: most powerful.
Thinking (Alt+T) Enable when you need deeper analysis.
Writing Good Prompts
4 itemsWHAT The concrete deliverable to create.
WHERE A clear file path.
HOW Constraints, tech, approach.
VERIFY Pass/fail criteria.
Full Keyboard Shortcuts
11 itemsShift+Tab Switch permission mode.
Esc × 2 Undo / rewind the previous step.
Alt+T Toggle thinking.
Ctrl+C Stop Claude while it is processing.
Ctrl+R Search command history.
Ctrl+L Clear the screen (keeps context).
Ctrl+B View background tasks.
Ctrl+F × 2 Cancel all agents.
Tab Autocomplete.
Shift+Enter New line (does not send).
Ctrl+D Exit.
IDE & MCP
7 itemsVS Code: Alt+K Open Claude Code in VS Code.
JetBrains: Cmd+Option+K Open Claude Code in JetBrains.
/mcp View and manage connected MCP servers.
claude --debug Debug mode: view detailed logs at startup.
Context7 MCP for library documentation.
Playwright MCP for browser automation.
Postgres MCP for database queries.
Golden Rules
- Always review the diff before accepting
- Use /compact before context fills up
- Clear prompts: WHAT + WHERE + HOW + VERIFY
- Use Plan Mode before complex or risky code
- Create CLAUDE.md for every project
- Commit frequently after each task
What Should You Do?
- Quick question / fix: Just ask Claude: type your prompt, hit Enter
- Big changes: Plan ahead: Shift+Tab to Plan Mode
- Tricky bugs / complex logic: Enable extended thinking: Alt+T
- Repetitive work: Automate it: create a custom slash command
- Review diff + Test: Read the plan carefully, then Shift+Tab to execute
- Context nearly full: Use /compact then continue
- Commit: Ask Claude to commit for you