Skip to content

Browse catalog

Search catalog

[READY] Type a title, tag, or description.

Claude

Claude Code commands cheatsheet (2026)

AUTHOR
Bartłomiej Krupa
PUBLISHED
2026.07.08
UPDATED
2026.07.29
READ_TIME
11 min

The basics worth memorizing: shortcuts, prefixes, in-session slash commands, and shell CLI - not the full /commands list, just what you reach for daily. Keyboard shortcuts are described in prose, not boxed in code; the collapsible “Example” blocks only show up where there’s an actual string worth copy-pasting.

If you want the full control surface, see Claude Code tools and Claude Code plan mode for the workflow mechanics that make these shortcuts pay off. For why /compact and /clear beat buying a bigger window, see Prune the log, not the window.

Cheatsheet layout

Jump to a section:

Command cheatsheet (when you’re stuck)

Ctrl+C

  • Interrupts a running operation.
  • If nothing is running: first press clears input, second press exits.

Esc

  • Interrupts Claude mid-response / mid-tool-call so you can redirect.
  • If a dialog is open (permissions / menus), Esc closes the dialog instead.

Esc then Esc

  • If there’s text in the input: clears the draft (it’s saved; press Up to bring it back).
  • If the input is empty: opens the rewind menu.

Ctrl+R

Reverse-search your input history.


Ctrl+O

Toggles the transcript viewer: the tool calls, timestamps, and per-message model that the normal view collapses. This is where you look when the summary of what happened doesn’t match what actually happened - including MCP calls that otherwise show up as “Called slack 3 times”.


Ctrl+G

Opens your prompt - or the plan Claude just proposed - in $EDITOR. The most underused key in the tool: a long, structured first prompt is much easier to write in a real editor than in a terminal input, and editing the plan is faster than arguing with it in chat.

Shortcuts & prefixes

Slash commands: /…

Start your input with / to run a command (or invoke a skill).


Shell mode: !…

Prefix with ! to run a shell command; its output is added to the session.

Example
!git status

Multiline input: \\ + Enter

Works everywhere. It’s the portable “new line”.

Example
First line\
Second line

File mentions: @

Type @ for path autocomplete and file mentions.

Example
read @src/content/articles/claude-code-tools.md and summarize the key rules

Permission modes: Shift+Tab

Cycle permission modes (default - manual approval, acceptEdits, plan, plus any enabled extras).

Claude (shell) commands

These run in your normal terminal. They control how a session starts.

claude

Starts an interactive session.


claude "query"

Starts interactive mode with an initial prompt.

Example
claude "explain what this repo does and where the entrypoints are"

claude -p "query"

Print mode: runs non-interactively, then exits.

Example
claude -p "summarize the last 20 lines of this log" --output-format text

claude -c

Continues the most recent conversation in the current directory.


claude --add-dir ../path

Grants file access to additional directories.

Example
claude --add-dir ../shared

claude --resume / claude -r "<session>" "query"

Opens the session picker, or resumes one directly by ID or name.


claude --worktree [name]

Starts the session in an isolated git worktree, so two sessions can’t overwrite each other’s edits. Add --tmux to launch it in its own tmux session.

Example
claude --worktree oauth --name oauth-migration

claude --name "<name>"

Names the session up front, so --resume lists workstreams instead of timestamps. /rename does the same mid-session.


claude --max-budget-usd <n>

Stops the run after it has spent that much - subagent spend included. The cheapest insurance in the CLI, but print mode only: it bounds claude -p runs and does nothing in an interactive session.

Example
claude -p "fix the failing auth tests" --max-turns 20 --max-budget-usd 2

claude --safe-mode / claude --bare

--safe-mode disables every customization - the baseline you compare against when something is broken and you suspect your own configuration. --bare skips auto-discovery for the fastest possible start.

Claude commands (inside a session)

The official list is huge. These are the daily drivers.

/help

Shows help and available commands.


/usage (aliases: /cost, /stats)

Shows usage/cost and activity stats (and, on paid plans, breakdowns by skills/tools/plugins/MCP).


/export [filename]

Exports the current conversation as plain text.

Example
/export notes.txt

/clear (aliases: /reset, /new)

Starts a new conversation with empty context; the previous one stays available in /resume.

Example
/clear "before-refactor"

/exit (alias: /quit)

Exits the CLI.


/status

Opens the Status tab in Settings (version, model, account, connectivity).


/rewind (aliases: /checkpoint, /undo)

Rewinds code and/or conversation to a previous point, or summarizes from a selected message.


/plan [description]

Enters plan mode (optionally with a task description).

Example
/plan refactor src/lib/ without changing behavior

/doctor

Diagnoses and verifies your Claude Code installation and settings (and can offer to fix issues): duplicate installs, PATH problems, unparseable settings, slow hooks, and unused skills, MCP servers, and plugins measured against what they cost you in context. It reports first and changes nothing without confirmation.


/resume [session] (alias: /continue)

Returns to an earlier conversation by ID, by name, or from the picker. Background sessions show up marked bg; a running one has to be attached or stopped from claude agents first.


/rename [name]

Names the current session and shows it on the prompt bar. Without a name, it generates one from the conversation.


/diff

Interactive viewer for uncommitted changes and per-turn diffs - left/right switches between the git diff and what each individual turn changed.


/code-review [level] [--fix] [--comment]

Reviews the current diff in a fresh subagent for correctness bugs and cleanup opportunities. --fix applies the findings, --comment posts them as inline PR comments. Its sibling /simplify runs four parallel agents on reuse, simplification, efficiency, and level of abstraction - and deliberately does not look for bugs, which is what /code-review is for.


/btw [question]

Asks a side question in an overlay that never enters conversation history. Use it for “what does this flag do again?” mid-task instead of spending permanent context on it.


/copy [N]

Copies the last assistant response; /copy 2 takes the one before it. When code blocks are present you get a picker - press w to write the selection to a file instead of the clipboard, which is how you get output off a remote box over SSH.

Session commands

/context

Shows context usage as a colored grid, with optimization suggestions and - when the conversation has run past the window - the exact number you’re over by. Run it before you optimize anything.


/compact [instructions]

Summarizes the conversation to free context window space. Run it at roughly 60% of the window rather than waiting for the automatic compaction at the limit, which tends to fire mid-task and summarize away the constraints you set at the start.

Example
/compact keep only decisions, file paths, and open questions

/model and /effort [level]

/model switches model and saves it as your default; press s on a row to switch for this session only. /effort sets the token-spend dial - low, medium, high, xhigh, max, ultracode, or auto to reset to the model default. Both apply immediately, without waiting for the current response to finish.


/skills

Lists available skills. Press t to sort by token count - the fastest way to find what’s inflating your startup - and Space to cycle a skill’s visibility. /reload-skills re-scans the directories so edits you make on disk apply without restarting.


/init

Initializes a repo with a starter CLAUDE.md.


/memory

Edits/views CLAUDE.md memory files and auto-memory entries.


/config (alias: /settings)

Opens settings (or sets keys via key=value).

Example
/config theme=dark

/permissions (alias: /allowed-tools)

Manages allow/ask/deny rules for tool permissions.

Context & memory

/hooks

Shows hook configurations for tool events.


/mcp

Manages MCP server connections and authentication.


/agents

Points you at your subagent configurations. From v2.1.198 it prints a reminder to ask Claude to create or manage them, or to edit .claude/agents/ and ~/.claude/agents/ directly; earlier versions opened an interactive editor.


/tasks

Lists background work in the current session - running shell commands and subagents, finished ones included. Also available as /bashes.


/insights

Generates a report over your own session history: which project areas you spend time in, how you interact, and where the friction is. It’s the evidence for what to fix in your setup, rather than a guess.

Splitting a session

Four commands sound like “copy this conversation” and do four different things. Pick by where you end up, not by the verb.

CommandWhere the copy runsWhere you end up
/branchForeground, same terminalYou move into the branch; the original waits
/forkBackground, independentYou stay; the copy never reports back
/subtaskBackground subagentYou stay; the result lands in this conversation
/backgroundThis session, detachedTerminal freed; monitor with claude agents

/subtask is the one you want when the answer matters to what you’re doing now; /fork is the one you want when it doesn’t. Both need v2.1.212 or later - on builds between v2.1.161 and v2.1.211, /fork behaves like today’s /subtask.

Removed commands

Two commands still turn up in guides written against older builds:

  • /vim - removed in v2.1.92. Toggle Vim editing from /configEditor mode, or set editorMode: "vim" in settings.
  • /pr-comments - removed in v2.1.91. Ask Claude to read the PR comments directly, or use /code-review --comment to write them.

Which is the general lesson: the tool ships several releases a week, so /help is the authoritative list for the build you actually have, and /release-notes tells you when something changed.

Bottom line

If you only memorize a few: Esc interrupts, Esc Esc rewinds, /export saves, /rewind restores, /context tells you what’s filling the window.

Related notes: effort vs fast mode, plan mode decision tree, verify before done.

Three habits turn that into a workflow. Compact at around 60% of the window rather than at the limit. Reach for /rewind instead of stacking “that didn’t work, try this instead” on top of a context that now contains the failed attempt as an example. And name every session, so /resume is a list of workstreams rather than a wall of timestamps.

FAQ

How do I stop Claude mid-response without losing progress?
Press `Esc`. It interrupts the current response or tool call and keeps the work done so far, so you can redirect. If a dialog is open, `Esc` closes the dialog instead.
What’s the fastest way to undo a bad turn?
Use `/rewind` (aliases: `/checkpoint`, `/undo`) to restore code, conversation, or both back to a selected point - or to summarize part of the conversation to free context. With an empty input, `Esc` then `Esc` opens the rewind menu.
How do I run Claude Code from scripts?
Use print mode: `claude -p "summarize the last 20 lines of this log" --output-format text` runs non-interactively and exits. Add `--output-format json` when a script needs structured output, and combine with other CLI flags (`--add-dir`, `-c`) the same way you would in an interactive session.
How do I run a shell command without leaving the session?
Prefix with `!` - e.g. `!git status`. The command runs in your shell and its output is added to the conversation.
How do I point Claude at a specific file?
Type `@` for path autocomplete - e.g. `read @src/content/articles/claude-code-tools.md and summarize the key rules`.
How do I free context when the window is getting full?
Run `/compact` with optional instructions - e.g. `/compact keep only decisions, file paths, and open questions`. To see what's using space first, run `/context`. For the agent-side version of the same idea (mask older tool output instead of growing the window), see the context-management article linked in the body.
How do I start a fresh conversation without losing the old one?
Use `/clear` (aliases: `/reset`, `/new`) - e.g. `/clear "before-refactor"`. The previous conversation stays available via `/resume`; `/clear` resets the window, it does not delete the saved session.
How do I pick up where I left off?
From the project directory, run `claude -c` to continue the most recent conversation. Use `claude --resume` (or `/resume` inside a session) when you need to pick a specific older thread instead of the latest one.
How do I switch to plan mode mid-session?
Press `Shift+Tab` to cycle permission modes, or run `/plan` with an optional task - e.g. `/plan refactor src/lib/ without changing behavior`.
How do I export the current conversation?
Run `/export` with an optional filename - e.g. `/export notes.txt` saves the thread as plain text.
How do I type multiline prompts?
End a line with `\` then press `Enter` - e.g. `First line\` on one line, then `Second line` on the next. Works everywhere in the input.
How do I grant Claude access to another directory?
Start the session with `claude --add-dir ../shared` to grant file access beyond the current working directory.
What's the difference between /branch, /fork, /subtask, and /background?
They differ in where the copy runs and where you end up. `/branch` moves you into a branch of the conversation and leaves the original behind. `/fork` copies the conversation into an independent background session while you keep working - it never reports back. `/subtask` runs a background subagent that inherits the whole conversation and returns its result *into* this conversation. `/background` detaches the session you're in so the terminal is free; you monitor it with `claude agents`. Pick by the last part: use `/subtask` when the answer matters to what you're doing now.
Does /vim still work?
No - `/vim` was removed in v2.1.92. Toggle Vim editing from `/config` → Editor mode, or set `editorMode: "vim"` in settings. `/pr-comments` was removed too (v2.1.91); ask Claude to read the PR comments, or use `/code-review --comment` to write them.
When should I run /compact?
At roughly 60% of the window, not at 95%. A summary written under pressure keeps less of what mattered, and the automatic compaction that fires at the limit tends to land mid-task. Always pass instructions - e.g. `/compact keep decisions, file paths, and open questions`.
Which command shows what's inflating my startup context?
`/context` for the whole window, then `/skills` and press `t` to sort skills by token count. `/doctor` goes further and flags unused skills, MCP servers, and plugins against what they cost you.

Sources

  1. Slash commands — the full built-in command listAnthropic
  2. Interactive mode — keyboard shortcuts, prefixes, and multiline inputAnthropic
  3. CLI reference — flags, print mode, and output formatsAnthropic
  4. Checkpointing — /rewind and restoring conversation or codeAnthropic
  5. Choose a permission mode — Shift+Tab and /planAnthropic