/) that go far beyond /help and
/clear: context management, safety nets, efficiency and
cost control, project memory, code quality, and advanced
operations — plus how to combine them into workflow patterns.
Most people use Claude Code with two things: typing requests directly, and occasionally running
/help. The book's analogy: "like buying a car and only ever driving straight — never
discovering reverse, cruise control, or lane assist."
add + commit +
push together form version control./cost and /model, you have no sense of what a session costs or how to spend less./compact — smart compression, not deletionCompresses conversation history into a distilled summary, freeing context space. The key word is smart: it uses AI to summarise — keeping key decisions, code-change records, and your stated preferences, discarding only redundant intermediate steps.
When to use it:
Advanced usage — tell it what to keep:
/compact Keep all architecture decisions and bug fix records; compress away the detailed code
/context — see where your tokens are goingShows a detailed breakdown of the current context: system prompts, CLAUDE.md, Skills, and
conversation history. Its value is visibility — when you suspect the context is nearly full,
run it first to see what is consuming space (a large CLAUDE.md, too many MCP tools, or an
overgrown history). You need the data to make the right call.
/clear — a clean slateWipes the entire conversation history and returns to the initial state — equivalent to closing and
reopening claude, just faster. Recommendation: before an unrelated new task,
always /clear first. Chaining Feature A and Feature B in one session leaves A's context taking
up space; /clear is free and the tokens it saves are real.
/rewind — surgical-precision rollbackPress Esc twice or type /rewind. Three options:
| Option | What it does |
|---|---|
| Rewind conversation | Undo the last few exchanges and restart from a specific point |
| Rewind code | Keep the conversation, but restore files to their previous state |
| Rewind everything | Roll back both conversation and code together |
"Rewind code but keep conversation" is the most powerful. If Claude modified 10 files and the direction was wrong, restore the files but keep the discussion. You can then say: "That approach didn't work. Let's try a different angle; this time only touch the 3 core files." Claude still knows what you discussed and why the first attempt failed, so the second attempt is usually much better.
/fork — parallel-universe explorationBranches the current conversation into a new independent thread. Both branches share the prior history but develop independently from that point.
You: Help me design a user authentication system
Claude: Option A is JWT stateless authentication...
You: /fork
(New branch begins)
You: Let's set aside the JWT approach. What about Session + Redis?
Claude: Option B is session-based authentication...
(Both branches run in parallel; compare and pick the better fit)
There is no cost to "going down the wrong path" — explore multiple directions at once and choose the best at the end.
/cost — how much have you spentShows token consumption and approximate cost for the current session. The book says it "changed how I use Claude Code": a long session might run $2–5, a large refactor $10+. The point is not to be frugal — it is to consciously decide whether a task is worth that many tokens. Check it before a large task, when a conversation feels too long, and at the end of the day.
/model — switch models on the fly/model sonnet <- everyday tasks (fast and cheap)
/model opus <- complex architecture decisions, large-scale refactoring
Sonnet costs roughly 1/5 of Opus, and for most coding — CRUD, simple bug fixes, boilerplate — it is more than sufficient. Switch to Opus only for problems requiring deep reasoning.
/fast — toggle fast modeUses the same model but produces output more quickly. If you don't need deep thinking and just want a well-defined task done fast, fast mode gives a noticeable speed boost.
/btw — a side question without breaking the flow(Claude is refactoring your code...)
/btw What's the difference between readonly and const in TypeScript?
(Claude answers quickly, then continues refactoring)
Key detail: /btw responses don't enter the conversation history.
They are one-time — they don't pollute context or consume extra tokens. Perfect for sudden small
questions mid-task.
| Command | What it does |
|---|---|
/init | Scans the project (package.json, README, code structure) and auto-generates an initial CLAUDE.md. A starting point, not a finished product — layer in your own rules. |
/memory | Lists all memory files currently loaded: project CLAUDE.md, user ~/.claude/CLAUDE.md, and the auto-generated CLAUDE.local.md (Claude's own notebook of build commands, debugging patterns, architecture decisions). Check it periodically — sometimes what it recorded is wrong or outdated and needs manual correction. |
/permissions | Manages permissions — pre-authorize operations (e.g. allow npm test) or restrict others (e.g. prohibit file deletion). Beginners: start with defaults (every action prompts), open up gradually for high-frequency operations. |
/review — automated code reviewAfter a set of changes, type /review and Claude audits all uncommitted modifications and
suggests improvements — "a 24/7 code reviewer on call." It checks for:
/simplify — three-angle code refinementLaunches three parallel agents that each review your changes from a different angle — reusability, quality, efficiency — then consolidates the findings and auto-applies the fixes. It directly modifies your code; when done, you review the diff and confirm.
| Command | What it does |
|---|---|
/doctor | Diagnostic checks: CLI up to date? authentication valid? required tools installed? environment variables correct? Run it first when something inexplicable goes wrong — the problem is often the environment, not Claude. |
/vim | Enables Vim key bindings in the input box (motions like d, c, y, w) — no switching to an editor to modify your prompt. |
/terminal-setup | Configures your terminal so Shift+Enter inserts a newline instead of sending. Supports VS Code terminal, iTerm2, Alacritty, Warp, and others. |
/export | Exports the current session as plain text — useful for documentation, retrospectives, or sharing a conversation with a colleague. |
1. /clear <- clean starting point
2. Complete Phase 1
3. /compact <- compress Phase 1 details
4. Complete Phase 2
5. /compact <- compress again
6. Complete Phase 3
7. /cost <- check total consumption
Extends a 30–60 minute session into several hours while keeping Claude's understanding of the project intact.
1. Discuss requirements, align on direction
2. /fork <- Branch A: Approach One
3. (Implement Approach One in Branch A)
4. Return to original branch
5. /fork <- Branch B: Approach Two
6. (Implement Approach Two in Branch B)
7. Compare both results, choose the better one
1. /review <- audit current code state first
2. Have Claude begin refactoring
3. If direction is wrong -> press Esc twice -> /rewind to roll back code
4. Refactoring complete -> /simplify <- three-angle refinement
5. /review <- final audit
6. git commit
1. /model sonnet <- cheaper model for everyday tasks
2. Hit a complex problem -> /model opus <- switch to the stronger model
3. Problem solved -> /model sonnet <- switch back
4. /cost <- see how much you saved
CONTEXT MANAGEMENT /compact + /context + /clear
SAFE EXPLORATION /fork + /rewind
COST CONTROL /cost + /model (+ /fast)
PROJECT MEMORY /init + /memory + /permissions
CODE QUALITY /review + /simplify
HEALTH / SETUP /doctor + /terminal-setup + /vim + /export
/compact | /clear | |
|---|---|---|
| What survives | An AI summary: key decisions, code changes, your preferences | Nothing — full reset |
| Use when | Same task continuing, but history is long | Starting an unrelated task |
/fork | /rewind | |
|---|---|---|
| Purpose | Explore multiple approaches from one point, in parallel | Undo — roll back conversation, code, or both |
| Prior history | Shared by both branches | Restored to an earlier state |
/review | /simplify | |
|---|---|---|
| Output | Suggestions only | Three parallel agents (reuse / quality / efficiency) that auto-apply fixes |
| Changes your code? | No | Yes — you then review the diff |
/btw | A normal question | |
|---|---|---|
| Enters history? | No — one-time | Yes |
| Effect on the current task | Claude answers, then resumes where it left off | Becomes part of the ongoing thread |
/help and /clear — ignoring the rest./compact, instead of compacting per milestone./clear./context./fork to explore freely./cost, so a task's price is invisible./btw./init's output as final rather than a starting point./doctor would show an environment problem./compact about what to keep./clear before every unrelated task — it's free./context before assuming what's full./fork to compare approaches instead of committing early./cost before big tasks, on long sessions, and end of day./btw for stray questions./init then edit; audit /memory periodically./review before and after a refactor; /simplify to apply fixes./doctor first when something inexplicable breaks./compact called "smart" compression? What does it keep and drop?/compact, and why not wait until context is full?/context show, and why is that valuable?/rewind options, and why is "rewind code, keep conversation" the strongest?/fork do, and what does "no cost to a wrong path" mean?/cost change how the author works?/model opus versus /model sonnet, and what is the cost ratio?/btw responses?/init generate, and why is it "not a finished product"?/memory list, and what is CLAUDE.local.md?/simplify differ from /review?/context, then /compact with an instruction about what to keep, then /context again and compare./fork to explore two designs for the same feature, then compare and choose./cost before and after a medium task; note the number./model sonnet, switch to opus for one hard part, switch back, and check /cost./review → refactor → /simplify → /review → commit.Slash Commands: A Deep Dive
│
├── Context /compact (smart, per-milestone, can be instructed)
│ /context (what's eating space) /clear (full reset)
├── Safety nets /rewind (conversation | code | both; "code-only" is best)
│ /fork (parallel approaches, no cost to wrong paths)
├── Efficiency /cost (know the price) /model sonnet<->opus (~1/5 cost)
│ /fast (same model, faster) /btw (one-time, no history)
├── Memory /init (draft CLAUDE.md) /memory (audit files)
│ /permissions (pre-authorize / restrict)
├── Quality /review (suggestions) /simplify (3 agents, auto-apply)
├── Advanced /doctor /vim /terminal-setup /export
│
└── Patterns
1 Long session: /clear -> phase -> /compact -> ... -> /cost
2 Exploratory: discuss -> /fork A -> /fork B -> compare
3 Safe refactor: /review -> refactor -> (/rewind) -> /simplify -> /review -> commit
4 Economy: /model sonnet -> /model opus (hard bit) -> sonnet -> /cost
/compact (smart summary, per milestone, instructable), /context (visibility), /clear (full reset before unrelated tasks)./rewind rolls back conversation, code, or both — "code-only, keep conversation" is the most powerful; /fork explores multiple approaches in parallel at no cost./cost makes price visible; /model switches Sonnet↔Opus (~1/5 cost); /fast speeds the same model; /btw answers stray questions without touching history./init drafts a CLAUDE.md; /memory audits loaded memory files including CLAUDE.local.md; /permissions pre-authorizes or restricts operations./review gives suggestions; /simplify runs three agents (reuse / quality / efficiency) and auto-applies fixes./doctor, /vim, /terminal-setup, /export./compact+/context+/clear = context management; /fork+/rewind = safe exploration; /cost+/model = cost control.add, commit, and push
together form an entire version-control system. Learn the combos, not just the list.
This teaching edition is based on the supplied April 2026, 2nd edition of Claude Code: The Complete Guide (§14, "Slash Commands: A Deep Dive"). Command names, behaviours, model pricing ratios and terminal support reflect that edition and may change over time.