🤖 Claude Code Quick Reference

Claude Code cheat sheet / survival guide

claude [options] [prompt]
claude "explain this project"

Claude Code is Anthropic's coding agent for the terminal. It reads your files,
runs commands, edits code and talks to tools, all from a chat prompt in your
project folder. Type / to see every command available in your version. This
sheet reflects the docs as of September 2026; run /help for the live list.

Start it

claude                              # interactive session in this folder
claude "fix the failing test"       # start with a first prompt
claude -p "summarize git log"       # print mode: answer once and exit (scripts, pipes)
claude -c                           # continue the most recent conversation
claude -r                           # pick an earlier session to resume
claude -r "name" "query"            # resume a session by ID or name
claude --worktree feature-x         # work in a separate git worktree
claude --bg "long task"             # start as a background agent
cat error.log | claude -p "what went wrong?"   # pipe data in

Models (latest)

fable     Newest and most capable: long sessions, hard reasoning     claude-fable-5-1
opus      Latest Opus: complex reasoning, architecture               claude-opus-5-5
sonnet    Latest Sonnet: everyday coding, best speed/cost balance    claude-sonnet-5
haiku     Fastest and cheapest: simple, low-latency tasks            claude-haiku-4-5
best      Most capable available (Fable when you have it, else Opus)
opusplan  Opus to plan, Sonnet to do the work
default   Your account's default (or your organization's choice)
sonnet[1m], opus[1m]   Same models with a 1 million token context window
Availability depends on your plan, provider (Anthropic API, Bedrock, Vertex, Foundry) and
organization policy. If a model is missing from /model, it is not enabled for you.

Switch models

/model                              # interactive picker
/model opus                         # by alias
/model claude-opus-5-5              # by full ID
claude --model sonnet               # at startup
export ANTHROPIC_MODEL=opus         # environment variable
"model": "opus"                     # in settings.json
claude --fallback-model sonnet,haiku   # fallbacks if a model is unavailable

Effort and thinking

/effort              Pick how hard Claude reasons
low        Short, latency-sensitive tasks
medium     Cost-sensitive everyday work
high       Balanced reasoning
xhigh      Deeper reasoning, higher cost
max        Maximum reasoning for demanding problems
ultracode  Dynamic workflows at xhigh effort
Also: claude --effort high, CLAUDE_CODE_EFFORT_LEVEL=high, or the "effortLevel" setting.
Levels available vary by model. Higher effort means slower answers and more usage.
/fast [on|off]       Faster output on supported Opus models (same model, higher cost)
/advisor [model|off] Get guidance from a second model

Slash commands: sessions

/clear        Start a fresh conversation (aliases: /reset, /new)
/resume       Go back to an earlier conversation
/branch       Branch the conversation to try a different direction
/fork         Copy the session into a background session
/background   Detach the current work as a background agent (/bg)
/btw          Ask a side question without adding it to the main history
/tasks        See background tasks
/export       Save the conversation as text
/copy         Copy the last response to the clipboard

Slash commands: context and memory

/context      Show what is using your context window
/compact      Summarize the conversation to free space (add focus instructions)
/memory       Edit CLAUDE.md memory files
/init         Generate a starter CLAUDE.md for this project
/add-dir      Give Claude access to another directory
/cd           Move to a different working directory

Slash commands: code quality

/code-review  Review the current diff or a PR for bugs (alias: /review)
/security-review   Look for security problems in pending changes
/simplify     Clean up and simplify changed code
/diff         Look at working tree changes
/verify       Check that a change works end to end
/run          Launch the app and try the change for real
/batch        Split a large change across parallel agents

Slash commands: setup and diagnostics

/help         List the commands available to you
/status       Session, model and account status
/usage        Token and cost/plan usage
/config       Open settings (alias: /settings)
/permissions  View and edit permission rules
/mcp          Manage MCP servers and their sign-ins
/login        Sign in again
/doctor       Check your installation for problems
/debug        Turn on debug logging
/powerup      Interactive lessons and demos
/update-config, /fewer-permission-prompts, /keybindings-help   Configuration helper skills

Slash commands: bundled skills and automation

/loop 5m /command    Repeat a prompt or command on an interval
/schedule            Create routines that run on a schedule in the cloud
/deep-research       Fan out searches and write up a report
/dataviz             Build charts and dashboards
/design, /slides     Draft designs and slide decks as artifacts
/claude-api          Help with building on the Claude API
Skills you or your plugins add also appear as /name. Type / and start typing to filter.

Permission modes (Shift+Tab cycles them)

Auto            A classifier reviews actions and blocks risky ones (default on recent versions)
Manual          Asks before edits and shell commands. Best while you are learning
Accept edits    Auto-accepts file edits and common file commands, asks for the rest
Plan            Explores and proposes a plan without editing files
Bypass          Skips prompts. Only in disposable sandboxes
claude --permission-mode plan       # start in a mode
claude --dangerously-skip-permissions   # skips ALL prompts: use only in a container or VM

Permission rules (settings.json)

{
  "permissions": {
    "allow": ["Bash(npm test:*)", "Bash(git diff:*)"],
    "deny": ["Read(./.env)", "Bash(rm -rf:*)"]
  }
}
Deny rules win over allow rules. /permissions edits them without hand-editing JSON.

Talking to Claude: special input

@path/to/file      Include a file (type @ for a picker; folders work too)
!command           Run a shell command and put its output in the conversation
/command           Run a slash command or skill
Esc                Stop Claude mid-answer
Shift+Tab          Cycle permission modes
Ctrl+O             Toggle the detailed (verbose) transcript view
Up arrow           Recall earlier prompts
Enter while Claude is working queues your next message

CLAUDE.md and memory

CLAUDE.md                         Project instructions, checked into git
~/.claude/CLAUDE.md               Your personal instructions for every project
.claude/rules/                    Rules that load only for matching paths
~/.claude/projects/<project>/memory/   Notes Claude saves for itself (see /memory)
Keep CLAUDE.md short (about 200 lines): build commands, conventions, "always do X".
Put long reference material in skills. Run /init to generate a first draft.

Settings files

~/.claude/settings.json           You, all projects
.claude/settings.json             Project, shared through git
.claude/settings.local.json       Project, just you (gitignored)
Project settings override user settings; command-line flags override both.

Skills

.claude/skills/my-skill/SKILL.md          Project skill (~/.claude/skills/ for personal)
---
name: my-skill
description: When Claude should use this (be specific)
---
Instructions in Markdown...
Invoke with /my-skill. Claude can also load it on its own when the description matches.

Hooks (settings.json)

{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Edit|Write",
        "hooks": [{ "type": "command", "command": "npx prettier --write ." }]
      }
    ]
  }
}
Hooks run your own commands at set points (SessionStart, PreToolUse, PostToolUse,
Stop and more). Unlike a CLAUDE.md request, they always run. Use them for formatting,
notifications and guardrails.

MCP servers (connect outside tools)

claude mcp add --transport http name https://mcp.example.com
claude mcp add --transport stdio db -- npx -y some-mcp-server
claude mcp list        claude mcp get name        claude mcp remove name
/mcp                   manage and sign in from inside a session
Scopes: local (just you, this project), project (.mcp.json, shared via git), user (all projects).

Subagents and plugins

Ask Claude: "use a subagent to search the codebase for X". Subagents work in their own
context window and report back, keeping your main conversation small.
Built in: Explore (fast read-only search), Plan (design), general-purpose.
claude plugin install name@marketplace    Add a bundle of skills, hooks and MCP servers
claude plugin list / uninstall

Useful command-line options

--model <name>          Choose the model             --effort <level>   Choose the effort
--permission-mode <m>   Start in a mode              --add-dir <path>   Extra directory access
--output-format json    text, json or stream-json    --max-turns <n>    Cap agent steps
--max-budget-usd <n>    Cap spending (print mode)    --verbose          Show every step
--bare                  Skip auto-discovery of config, hooks and plugins
claude update           Update to the latest version
claude doctor           Diagnose problems without starting a session
claude auth login|status|logout

Practical workflows

# 1. Understand a new codebase
cd project && claude
> give me an overview of this repo and how to run the tests

# 2. Plan first, then build (Shift+Tab to Plan mode)
> plan how to add rate limiting to the API. Do not edit yet.

# 3. Small fix with a safety net
git commit -am "checkpoint" ; claude "fix the null pointer in parser.py"
git diff        # review exactly what changed

# 4. Use it in scripts and CI
claude -p "list TODO comments as JSON" --output-format json

# 5. Long session getting sluggish
/context        # what is eating the window?
/compact focus on the database migration

# 6. Cheap model for chores, big model for design
/model haiku    # rename variables, write commit messages
/model opus     # architecture and tricky bugs

# 7. Review before you push
/code-review high
/security-review

Tips

    Commit to git before a big task so git diff and git restore are your undo button.

    Be specific: name the file, the failing test or the error message, and say what "done" looks like.

    Use Plan mode for anything that touches many files, then approve the plan before Claude edits.

    Watch /context. A crowded window makes answers worse and costs more. /compact or /clear between unrelated tasks.

    Match the model to the job: Haiku for chores, Sonnet for daily work, Opus or Fable for hard problems, and turn effort up only when you need it.

    Read commands before approving them, especially anything with sudo, rm, dd or curl | sh.

    Never put secrets in prompts or CLAUDE.md. Deny access to .env files in your permission rules.

    Keep --dangerously-skip-permissions for throwaway containers and VMs, never your real machine.

    Commands and models change often. /help, /model and the docs at code.claude.com/docs are the source of truth.