Claude Code Commands Cheat Sheet: Slash Commands and CLI Flags

The slash commands, CLI flags and keyboard shortcuts you will actually use, grouped by job and one line each, with a link to the guide that goes deep on every group.

7 min read

Claude Code has two kinds of command. Slash commands such as /clear or /model are typed inside a session; CLI flags such as -p or --permission-mode are passed when you start claude from a terminal. The ones worth knowing by heart are below, grouped by the job they do, one line each. For the complete list on your machine, type / in a session, which shows only the commands available to your plan, platform and version, and run claude --help for flags. Anthropic’s CLI reference (opens in a new tab) warns that --help does not list every flag, so the reference is the place to check.

Everything here matches Anthropic’s commands reference (opens in a new tab) as of late September 2026. Claude Code changes most weeks, so if a command is missing on your machine, run claude update before assuming it has gone. Commands are only recognised at the start of a message, and anything after the name is passed as its arguments.

Starting and resuming sessions

Terminal
claude                        start an interactive session
claude "explain this repo"    start with a first prompt
claude -c                     continue the latest conversation in this folder
claude -r auth-refactor       resume a session by name or ID
claude -n auth-refactor       name the session as it starts
claude -w feature-auth        start in an isolated git worktree
claude --add-dir ../api       also give it access to another directory
claude update                 update to the latest version
claude doctor                 installation diagnostics, no session
  • /rename <name> names the current session so you can find it again in /resume.
  • /resume opens the session picker, or resumes one by name or ID (alias /continue).
  • /branch branches the conversation at this point so you can try another direction and come back.
  • /cd <path> moves the session to another directory and keeps the conversation; /add-dir <path> adds a directory instead.
  • /exit leaves Claude Code (alias /quit).

Names matter more than they look: a session called pay-retry is one you can pick up tomorrow, which is the habit handing work between AI agents and people builds on. Working across several repositories at once is covered in Claude Code across multiple projects.

Context and usage

  • /context shows what is filling the context window as a coloured grid, with suggestions; /context all expands the breakdown.
  • /compact [focus] summarises the conversation to free space, keeping what you name, for example /compact keep the API changes.
  • /clear starts a new conversation with empty context (aliases /reset, /new); the old one stays in /resume.
  • /btw <question> asks a side question whose answer never enters the conversation history.
  • /memory opens your CLAUDE.md files and turns auto memory on or off; /init drafts a starter CLAUDE.md.
  • /autocompact 500k sets how full the window gets before Claude Code compacts on its own; /autocompact auto resets it.
  • /usage shows session cost, plan usage limits and activity (aliases /cost and /stats).

How each of these changes what Claude sees is the subject of context engineering for Claude Code. What they cost, and how to spend less, is in how to reduce Claude Code token usage.

Planning, review and undo

  • /plan [task] enters plan mode, optionally starting on the task you give it: /plan fix the auth bug.
  • /diff reviews the changes in your working tree, including the edits Claude has made so far.
  • /code-review reviews the current diff for correctness bugs (alias /review); add --fix to apply the findings, or pass a PR number to review a pull request.
  • /simplify reviews changed code for reuse and cleanup; it does not look for bugs.
  • /security-review checks the changes on your branch for vulnerabilities, and needs an origin remote to compare against.
  • /rewind rolls code, conversation or both back to a checkpoint, or summarises part of the conversation (aliases /checkpoint, /undo).

One limit to remember: according to Anthropic’s checkpointing documentation (opens in a new tab), checkpoints track only edits made through Claude’s file tools, not files changed by shell commands, so /rewind is not a replacement for git. Claude Code plan mode covers planning in depth, and how to stop a Claude Code task covers interrupting and undoing.

Models, permissions and configuration

  • /model [alias] switches model and saves it as your default; in the picker, press s on a row to switch for this session only.
  • /effort [level] sets reasoning effort: low, medium, high, xhigh, max or auto, where the model supports them.
  • /permissions manages allow, ask and deny rules by scope (alias /allowed-tools).
  • /sandbox toggles the Bash sandbox on supported platforms.
  • /config opens the settings panel; /config theme=dark sets a key directly (alias /settings).
  • /status shows version, model, account and connectivity, and works while Claude is responding.
  • /doctor runs a setup checkup that reports problems and offers fixes before changing anything.
  • /hooks shows configured hooks; /statusline sets up the status line; /keybindings opens your shortcuts file.
  • /skills lists skills and can sort them by token cost; /plugin installs and manages plugins.
Launch flags for one session
--model sonnet                     model for this session only
--effort high                      reasoning effort for this session
--permission-mode plan             default | acceptEdits | plan | auto | dontAsk | bypassPermissions
--allowedTools "Bash(npm test *)"  calls that run without a prompt
--disallowedTools "Bash(rm *)"     deny rules for this session
--append-system-prompt "..."       add text to the default system prompt
--settings ./ci-settings.json      extra settings that override your files
--verbose                          full turn-by-turn output
--debug                            debug logging

Which permission mode to run in, and how to write rules that approve the safe commands and nothing else, is covered in auto-approve in Claude Code. Where settings files live, and which to commit, is in Claude Code project structure.

MCP servers

Terminal
claude mcp add --transport http <name> <url>   add a remote server
claude mcp add --scope user ...                 add it for every project
claude mcp list                                 list configured servers
claude mcp get <name>                           details for one server
claude mcp remove <name>                        remove a server
claude mcp login <name>                         run a server's sign-in without /mcp
  • /mcp in a session lists servers, shows their status and runs browser sign-in for servers that need it.
  • /mcp reconnect <server> reconnects one server; /mcp disable <server> or /mcp disable all switches servers off without opening the list.

A task board is a typical first server. For fenbs it is one line, claude mcp add --transport http fenbs https://fenbs.ai/api/mcp, then /mcp to sign in and choose the scopes the assistant gets. From then on Claude Code can call tools such as fenbs_list_items and fenbs_comment, and each change it makes is recorded in the board’s history as “Claude via” you. The Claude Code integration page has the steps, and a task-tracking workflow for Claude Code shows what to put in CLAUDE.md so it uses the board without being asked.

Headless runs and scripts

Terminal
claude -p "list the API endpoints"            answer once, then exit
cat error.log | claude -p "explain"            pipe content in
claude -p "..." --output-format json           text | json | stream-json
claude -p "..." --max-turns 10                 stop after 10 agentic turns
claude -p "..." --max-budget-usd 5             stop at a spending cap
claude -p "..." --permission-mode dontAsk      deny anything not pre-approved
claude -p "..." --bare                         skip hooks, skills, MCP and CLAUDE.md
claude -p "..." --no-session-persistence       do not save the session

--max-turns, --max-budget-usd, --json-schema and --no-session-persistence apply in print mode only. Putting these together into a safe unattended run is covered in how to automate Claude Code tasks, and running them on a timetable in Claude Code scheduled tasks.

Background and parallel work

  • /tasks lists background work in this session, including finished subagents (alias /bashes).
  • /background [prompt] detaches the whole session to keep running as a background agent (alias /bg); claude agents shows them all.
  • /fork [prompt] copies the conversation into a new background session while you keep working here.
  • /batch <instruction> splits a large change into independent units, each run by a subagent in its own worktree, after you approve the plan.
  • Ctrl+B sends a running shell command or agent to the background.

Seeing and stopping background work is covered in Claude Code background tasks, and keeping several sessions from colliding in running Claude Code tasks in parallel.

Keyboard shortcuts

The interactive mode reference (opens in a new tab) lists these among the defaults. On macOS, the Alt shortcuts are Option, and some need Option set as Meta in your terminal.

In a session
Esc              interrupt Claude; work so far is kept
Esc Esc          on an empty prompt, open the rewind menu
Shift+Tab        cycle permission modes (Alt+M on some Windows setups)
Ctrl+C           interrupt, or clear input; twice to exit
Ctrl+O           transcript viewer with full tool output
Ctrl+R           search your prompt history
Ctrl+G           open the prompt, or a proposed plan, in your editor
Ctrl+B           background the running command or agent
Ctrl+T           show or hide Claude's to-do checklist
Ctrl+S           stash the prompt; press again to restore it
Alt+P            switch model without clearing the prompt
\ then Enter     new line (Ctrl+J works in any terminal)
!                at the start: run a shell command directly
@                mention a file, with autocomplete
?                on an empty prompt: shortcut help

Shortcuts can be rebound with /keybindings. If a shortcut does nothing in your terminal, /terminal-setup installs a Shift+Enter binding for newlines in terminals such as VS Code’s, and in Apple Terminal turns on Option+Enter instead.

Related

Habits that make these commands pay off are in Claude Code best practices. To give Claude Code a board it reads at the start of a session and updates as it works, connect it on the Claude Code integration page; MCP explains the protocol it uses.

Questions people ask.

How do I see every Claude Code slash command?

Type a forward slash at the start of the prompt. The menu lists every command available to you, filtered as you type, and leaves out commands your plan, platform or version does not support. A few diagnostic commands are hidden until you type their full name.

What is the difference between /clear and /compact?

The /clear command starts a new conversation with empty context, and the old one stays available in /resume. The /compact command keeps the same conversation but replaces its history with a summary, optionally focused on what you name.

Which command shows Claude Code token usage?

Run /usage. It shows the session’s token use and estimated cost, plan usage limits on subscription plans, and activity stats. /cost and /stats are aliases for it. /context shows what is filling the context window right now.

Can I add my own slash commands?

Yes. Custom commands are skills: a folder in .claude/skills/ or ~/.claude/skills/ with a SKILL.md file becomes a command named after the skill. Older files in .claude/commands/ still work.

Start with one thing.

There is nothing to set up first. Write one line and you’ve started.