Appendices
Appendix A: The Claude Code Cheat Sheet
Print this. Tape it to the side of your monitor. Don’t try to memorize it; just know where to look.
Open / close / reset
| What | How |
|---|---|
| Open Claude Code | Type claude at your terminal |
| Close | Press Ctrl+C twice |
| Clear the conversation (keep the project) | /clear |
| Resume the most recent session | claude --continue |
| Pick an earlier session to resume | claude --resume |
| List every slash command | /help |
The ten essential slash commands
| Command | What it does |
|---|---|
/init |
Generate a starter CLAUDE.md by scanning the project (then cut it in half) |
/clear |
Wipe the conversation; keep the project open |
/compact <focus> |
Summarize history and continue; always pass a focus |
/rewind |
Restore code or conversation to any earlier point in the session |
/model <name> |
Switch model: haiku / sonnet / opus (alone, shows the current menu) |
/cost |
Session spend in dollars |
/permissions |
Edit the allow and deny lists with a UI |
/agents |
Create or manage subagents |
/btw <question> |
Ask a side question without polluting the main history |
/statusline |
Install a live status display at the bottom of the terminal |
Keystrokes worth knowing
| Key | What it does |
|---|---|
Shift+Tab |
Cycle permission modes, including Plan Mode (Claude writes a plan first) |
Ctrl+G |
Open your draft prompt — or a proposed plan — in your text editor to edit before sending (Chapter 9) |
Esc |
Stop Claude mid-action |
Esc Esc |
Open the /rewind menu (when the input line is empty) |
Ctrl+R |
Search your prompt history |
Ctrl+B |
Background a long-running task |
!cmd |
Run a shell command and put its output into Claude’s context |
@path/to/file |
Reference a specific file directly in the prompt |
Ctrl+V |
Paste a screenshot (Cmd+V in some Mac terminals) |
Models, at a glance
| Model | Use when |
|---|---|
| Haiku | Bulk classification, simple file operations, mechanical work |
| Sonnet | Daily default for most coding |
| Opus | Hard reasoning, suspicious bugs, architecture decisions |
Opus + ultrathink |
Adaptive deep reasoning when you don’t know how hard the problem is |
Long-context option in /model |
When one task needs the 1-million-token context window (plan-dependent) |
The 8 built-in tools
The eight tools you’ll see most (Chapter 5 has the long version):
Read Write Edit Bash Glob Grep WebSearch WebFetch
There are a few more — notably Task, which spawns subagents (Chapter 13).
File layout
~/.claude/ # personal, lives across all projects
├── CLAUDE.md # your global preferences
├── settings.json # global permissions + hooks
├── commands/ # your personal slash commands
└── agents/ # your personal subagents
<your-project>/
├── CLAUDE.md # project preferences
├── .claude/
│ ├── settings.json # project allow/deny + hooks
│ ├── commands/ # project slash commands
│ ├── agents/ # project subagents
│ ├── skills/<name>/SKILL.md # project skills
│ └── rules/ # conditional rules
Permissions one-liner (.claude/settings.json)
{
"permissions": {
"allow": [
"Read(*)",
"Bash(npm test)",
"Bash(pytest *)",
"Bash(pre-commit run *)",
"Bash(git status)",
"Bash(git diff *)",
"Bash(gh pr *)"
],
"deny": [
"Read(.env)",
"Read(secrets/**)",
"Read(data/patients/**)",
"Read(*.key)",
"Read(*.pem)"
]
}
}
Auto-format hook (.claude/settings.json)
{
"hooks": {
"PostToolUse": [{
"matcher": "Edit|Write",
"hooks": [{
"type": "command",
"command": "jq -r '.tool_input.file_path' | xargs -r npx prettier --write 2>/dev/null || true"
}]
}]
}
}
The hook receives a JSON description of the tool call on stdin; jq -r '.tool_input.file_path' pulls out the path of the file Claude just edited. (jq is a small command-line tool for reading JSON.)
Headless and scripting
# One-shot, no prompts
claude -p "fix the failing tests" --allowedTools Read,Edit,Bash
# Pipe a log file in
cat error.log | claude -p "explain this error and suggest a fix"
# Run three parallel worktrees on different branches
claude --worktree feature-auth
claude --worktree bugfix-login
claude --worktree refactor-api
Pricing (as of writing)
| Plan | Cost | When |
|---|---|---|
| Pro | $20/mo | Light daily use |
| Max 5× | $100/mo | Regular development work |
| Max 20× | $200/mo | Heavy power user, long sessions |
| API pay-as-you-go | Per token | Irregular use, or scripted batches |
The starter CLAUDE.md
# CLAUDE.md
## Stack
<your stack in one sentence>
## Run / test
- Tests: <command>
- Eval: <command>
- Lint: <command>
## Behavior rules
1. Think before coding: verify, don't guess.
2. Simplicity first: minimum code that solves the problem.
3. Surgical changes: don't touch adjacent code.
4. Tests encode intent.
5. Fail loud: surface every skipped row, null, partial success.
## PHI rules (KHCC)
- MRNs: Optimus-encoded only in outputs.
- Names: Fernet-encrypted, never in logs.
- Eval cohort: frozen deceased-patient set only.
Daily flow
claudeto open (orccif you’ve configured the alias)./statusline— one-time per laptop.Shift+Tabinto Plan Mode for anything bigger than a one-liner.- Read the plan; ask for changes before approving.
- Watch the diff before approving each change.
/clearbetween unrelated tasks./costbefore lunch;/costagain before you leave.
Glossary
A one-line definition for the vocabulary used in this book.
- Terminal — the window you type commands into. The room Claude Code lives in.
- LLM (large language model) — the AI engine that reads and writes text. Claude is one.
- Agent — an LLM given tools and a loop: it reads, acts, checks the result, and repeats until the job is done.
- Token — the unit models read and bill in; roughly three-quarters of an English word.
- Context window — the model’s working memory for one conversation. When it fills, older detail is summarized or lost.
- Prompt (in the terminal) — the symbol that says “ready for your next command” (
$,>, or%). Not to be confused with a prompt to the model, which is the sentence you type to Claude. - Command — the verb you type at the terminal (
ls,git,claude). - Argument — the noun after the verb (
cd Documents—Documentsis the argument). - Flag — a modifier on a command, written with one or two dashes (
ls -l,claude --resume). - Directory — a folder. The terminal calls folders “directories” because it’s old.
- Repo (short for repository) — a folder tracked by
gitfor version history. - Branch — a parallel timeline of changes in a repo. You can have many.
mainis the default. - Commit — a snapshot of the repo at a moment in time, with a message describing what changed.
- Push — send your commits from your laptop up to a remote server (e.g., GitHub).
- Pull — fetch other people’s commits from the remote into your local copy.
- Allowlist — the list of commands Claude can run without asking, written in
.claude/settings.json. - Deny list — the list of paths Claude is forbidden to read or write.
- Slash command — a Claude Code shortcut typed with a leading
/(e.g.,/clear). - Hook — a small program Claude Code runs automatically at certain moments (before a tool, after a tool, at session end).
- Checkpoint — an automatic snapshot of your files taken as Claude works, separate from git. Restore one with
/rewind. - Plan Mode — a permission mode (reached with
Shift+Tab) where Claude proposes a plan and edits nothing until you approve. - Subagent — a separate Claude instance the main session can spawn for a self-contained job; has its own context, tools, and model.
- MCP (Model Context Protocol) — a standard way for Claude to talk to external tools and databases via small servers.
- Worktree — a separate working copy of the same repo, on a different branch, so you can run two sessions in parallel.
- Headless mode — running Claude Code non-interactively with
claude -p, for scripts and scheduled jobs. - Ralph loop — a pattern that keeps relaunching Claude on a task until a completion promise is met; always guarded by a max-iterations limit.
- CLAUDE.md — the project’s instruction file; Claude reads it every session.
- Skill — a packaged capability under
.claude/skills/<name>/SKILL.mdthat Claude can invoke. - PHI — Protected Health Information; anything that identifies a patient.
- Fernet — symmetric encryption used at the AI Office to protect patient names.
- Optimus encoding — reversible scrambling of MRNs into non-human-readable identifiers.
- Eval cohort — at the AI Office, the frozen list of deceased patients with hand-curated ground truth, used to grade every prompt change.