Chapter 14
Cheat sheet
Print it. Tape it next to your monitor. Stop re-googling.
Jump to section tap to open
Daily slash commands
| /help | List everything available |
| /init | Generate starter CLAUDE.md |
| /clear | Reset context, keep session |
| /compact | Summarize history, free space |
| /cost | Running spend this session |
| /model | Switch models mid-session |
| /agents | Manage subagent definitions |
| /mcp | List MCP servers |
| /hooks | See/edit hooks |
| /plugins | Browse plugin marketplace |
| /install-ide | Wire CC into your editor |
| /resume | Pick a past session |
| /exit | Leave session (auto-saved) |
CLI flags
| claude | Interactive in current dir |
| claude --print "..." | Headless, prints answer, exits |
| claude --model opus | Pin a model for this session |
| claude --resume | Pick from past sessions |
| claude --continue | Resume most recent session |
| claude --plan | Describe-only mode, no edits |
| claude --no-update | Skip auto-update check |
| claude --version | Sanity check install |
| claude --output-format json | Parse-friendly output |
| claude --allowed-tools "..." | Launch-time allow-list |
Settings.json keys
| model | "sonnet""opus""haiku" |
| theme | "dark""light""auto" |
| telemetry | truefalse |
| autoUpdater | "weekly""daily""disabled" |
| permissions.allow | glob patterns to auto-approve |
| permissions.deny | glob patterns to block |
| permissions.disableBypassPermissionsMode | "disable" |
File paths
| ~/.claude/settings.json | Global preferences |
| ~/.claude/commands/ | Custom slash commands |
| ~/.claude/agents/ | Custom subagent definitions |
| ~/.claude/skills/ | Personal skills |
| ~/.claude/plugins/ | Installed plugin bundles |
| <repo>/CLAUDE.md | Project memory, every turn |
| <repo>/.mcp.json | MCP servers (commit it) |
| <repo>/.claude/settings.json | Repo overrides |
| <repo>/.claude/agents/ | Repo-shared subagents |
| <repo>/.claude/skills/ | Repo-shared skills |
Environment vars
| ANTHROPIC_API_KEY | Required for headless / CI |
| CLAUDE_CONFIG_DIR | Relocate ~/.claude (sandboxes) |
| CLAUDE_MODEL | Per-shell default |
| MCP_SERVER_<NAME>_<KEY> | Forwarded into MCP processes |
Keyboard shortcuts
| Ctrl-C | Interrupt generation, keep session |
| Ctrl-D / /exit | Leave session |
| ↑ | Recall last prompt |
| Esc Esc | Undo last input |
| Shift-Enter | Newline without send |
| Tab | Autocomplete file paths |
| / | Slash-command picker |
| @ | File-reference picker |
| # <text> | Append to CLAUDE.md inline |
Hook events (90% rule)
| PreToolUse | Before tool call. Validate, block. |
| PostToolUse | After success. Format, lint, test. |
| Stop | Turn ends. Commit, ship, notify. |
| SessionStart | Inject context on session boot |
| UserPromptSubmit | Before model sees a prompt |
Cron syntax
| 0 7 * * 1-5 | 7 AM every weekday |
| */15 * * * * | Every 15 minutes |
| 0 16 * * 5 | 4 PM every Friday |
| 0 9 * * 1 | 9 AM every Monday |
| 0 17 * * 1-5 | 5 PM ET weekdays (set TZ) |
| crontab.guru | Translate human ↔ cron |
Permission rule syntax
| Bash(npm test*) | Glob inside parens auto-approves |
| Edit(src/**/*) | Recursive path glob |
| Edit(src) | Matches one literal file "src" |
| WebFetch | Bare name = every invocation |
| Edit(.env*) | Common deny: secrets |
| Bash(rm -rf*) | Common deny: destructive |
| bash(...) | Wrong — names case-sensitive |
| deny → ask → allow | Eval order; deny always wins |
| ~/.ssh/** | Deny follows symlinks both ways |
Subagent frontmatter
| name | Subagent identifier |
| description | What orchestrator reads to delegate |
| tools | Allow-list, e.g. Read, Grep, Glob |
| (omit Edit/Write) | Makes it physically read-only |
| <body> | The system prompt for the job |
| ~/.claude/agents/ | User-level, every project |
| .claude/agents/ | Repo-level, commit it |
| general-purpose | Built-in, all tools |
| Explore | Built-in, read-only repo search |
| Plan | Built-in, returns plan only |
SKILL.md frontmatter
| name | Skill identifier |
| description | Trigger — literal phrases, exclusions |
| allowed-tools | Optional tool allow-list |
| SKILL.md | Only required file |
| scripts/ | Deterministic code, optional |
| templates/ | Output shapes to match |
| reference/ | Long detail pulled on demand |
| Do NOT use for | Negative space stops misfires |
| <40 line body | Past that, model skips steps |
.mcp.json shape
| mcpServers | Top-level object of servers |
| command | "npx""python" launcher |
| args | Array, e.g. ["-y", "pkg", path] |
| env | Per-server vars (never raw keys) |
| stdio | Local subprocess, zero network |
| streamable-http | Hosted SaaS transport |
| SSE | Legacy — being phased out |
| /mcp | List + confirm connected |
| <repo>/.mcp.json | Commit it, team shares servers |
Hook JSON shape
| matcher | Regex vs tool name, "Edit|Write" |
| type: command | Hook runs a shell command |
| command | The shell line to execute |
| $CLAUDE_FILE_PATH | File the tool touched |
| $CLAUDE_PROJECT_DIR | Repo root |
| $CLAUDE_TOOL_INPUT | Raw tool input for grep |
| exit 0 | Tool call proceeds |
| exit non-zero | Tool call blocked |
| stderr | Surfaces to model as error |
| stdout | Surfaces to model as context |
Headless / CI one-liners
| -p / --print | Headless, stdout, exit code |
| --output-format json | Single result object |
| --output-format stream-json | NDJSON live events |
| total_cost_usd | JSON field — spend per run |
| --allowed-tools "..." | Launch-time allow-list |
| --disallowed-tools "..." | Launch-time block-list |
| --resume <id> | Reattach prior session |
| timeout 300 claude -p | Hard cap on a loop |
| ANTHROPIC_API_KEY | Server/CI auth (not OAuth) |
Plan → Auto → /goal ladder
| Plan mode | Removes per-step surprise |
| Auto mode | Removes per-tool prompts |
| /goal <cond> | Removes per-turn prompts |
| /goal clear | Aliases: stop off reset cancel |
| or stop after N | Always cap blast radius |
| /loop 5m <prompt> | Interval-driven polling |
| Stop hook | Script-driven, settings-scoped |
| Haiku 4.5 | Default /goal evaluator |
| one goal/session | New goal replaces old |
Model routing + cost
| Haiku | Triage/classify — ~1/15 Sonnet |
| Sonnet | Default working model |
| Opus | Hard reasoning, agent loops |
| output tokens | ~5x input price |
| cache write | 1.25x input rate, one-time |
| cache read | ~0.1x input rate (10x cheaper) |
| 5-min eviction | Ephemeral cache cold window |
| append-only | New context at bottom, not top |
| Batch API | 50% off, returns within 24h |