Guide

Claude Code Commands: A Cheat Sheet That Says Where It Got Each Line

Most Claude Code cheat sheets do not tell you which version they describe, so you cannot tell a current flag from one that was removed two releases ago. This one does the opposite: every table below was transcribed from the output of a command you can run yourself, on Claude Code v2.1.260, installed and run on 2026-09-04. Where we could not confirm something, it says so instead of guessing.

By DK, Editor  ·  Last verified: 2026-09-04  · Claude Code v2.1.260 (installed and run 2026-09-04; commit e51f681183f7, darwin-arm64)  ·  How we test

Before you start

  • Claude Code installed: npm install -g @anthropic-ai/claude-code
  • Node.js 22 or later — v2.1.260 declares engines.node ">=22.0.0" (this moved up from >=18 at v2.1.183)
  • Your own version to compare against: claude --version

Steps

  1. 01

    Print the authoritative list for your build first

    Claude Code ships new subcommands and retires old ones between releases, and plugins add more, so the only list that is definitely right is the one your own install prints. Run these three before trusting any cheat sheet, including this one. claude --help lists the CLI surface; /help inside a session lists the slash commands that are actually registered for you; claude doctor tells you which build you are on and where it lives.

    # what version am I actually running?
    claude --version
    
    # the full CLI surface for that build
    claude --help
    
    # where it is installed, and whether anything is broken
    claude doctor
  2. 02

    The difference nobody spells out: CLI subcommands vs slash commands

    There are two separate command surfaces and they are not interchangeable. CLI subcommands are typed in your shell before Claude Code starts — claude mcp list, claude doctor, claude update. Slash commands are typed inside a running session — /compact, /clear, /memory — and they do not work from the shell. A cheat sheet that mixes them into one list is the single most common reason a command "does not work": you are typing a session command at a shell prompt, or the reverse. The two tables below are deliberately kept apart.

    # CLI subcommand — from your shell, Claude Code not running
    claude mcp list
    
    # slash command — typed at the prompt INSIDE a session
    claude
    > /compact
  3. 03

    One-shot mode: the flag combination worth memorising

    The -p/--print flag runs a prompt without entering the interactive shell and prints the result to stdout, which is what makes Claude Code scriptable. It combines with --output-format to get JSON instead of prose, and with --max-budget-usd to cap what a single run can spend. All four flags below are verbatim from claude --help on v2.1.260. Note the warning the help itself carries about -p: the workspace trust dialog is skipped in non-interactive mode, so only use it in directories you trust.

    # print and exit
    claude -p "Explain what this repo does"
    
    # machine-readable result
    claude -p "List every TODO in src/" --output-format json
    
    # cap the spend of this one run
    claude -p "Refactor the parser" --max-budget-usd 2
    
    # stream events as they happen
    claude -p "Fix the failing test" --output-format stream-json --include-partial-messages
  4. 04

    When something is broken, start it with everything switched off

    Two flags exist purely to answer "is it Claude Code, or is it my configuration?". --safe-mode starts a session with CLAUDE.md, skills, plugins, hooks, MCP servers, custom commands and agents all disabled, while auth, models, built-in tools and permissions keep working; admin-managed policy settings still apply. --bare goes further and skips hooks, LSP, plugin sync, auto-memory, keychain reads and CLAUDE.md auto-discovery entirely. If a session works in safe mode and fails without it, the cause is one of your customisations, and you have just cut the search space to your own config directory.

    # everything you configured, off
    claude --safe-mode
    
    # minimal mode: no hooks, no LSP, no CLAUDE.md discovery
    claude --bare
    
    # only the MCP servers in this file, ignoring every other MCP config
    claude --strict-mcp-config --mcp-config ./mcp.json
  5. 05

    Where settings live, and how to override them for one run

    Claude Code reads settings from three scopes: user (~/.claude/settings.json), project (.claude/settings.json, meant to be committed and shared) and local (.claude/settings.local.json, personal and normally git-ignored). Two flags let you control that from the command line without editing any file. --setting-sources takes a comma-separated list of which scopes to load at all, and --settings takes either a path to a JSON file or a raw JSON string layered on top. This is the pair you want in CI, where project settings should apply but a developer’s local overrides should not.

    # load only the committed project settings — ignore user and local
    claude --setting-sources project
    
    # layer an extra settings file on top
    claude --settings ./ci-settings.json
    
    # or pass the JSON inline
    claude --settings '{"model":"sonnet"}'
  6. 06

    Running Claude Code on Windows, natively or through WSL

    Both work. v2.1.260 publishes native Windows builds — its package.json lists @anthropic-ai/claude-code-win32-x64 and @anthropic-ai/claude-code-win32-arm64 as optional dependencies next to the macOS and Linux ones — so a plain npm install -g in PowerShell gets you a native binary and no Linux layer is required. WSL is still supported and is the better choice when your project already lives on a Linux filesystem, because the agent runs shell commands constantly and WSL avoids path and line-ending friction. The one combination to avoid is running Claude Code inside WSL while pointing it at a Windows-side npm installation under /mnt/c: Claude Code detects that setup specifically and complains about it, and it is the most common broken Windows install.

    # PowerShell — native Windows build
    npm install -g @anthropic-ai/claude-code
    claude --version
    
    # inside WSL — install with the LINUX npm, not the one under /mnt/c
    which npm      # expect /usr/bin/npm or ~/.nvm/..., NOT /mnt/c/...
    npm install -g @anthropic-ai/claude-code
  7. 07

    Uninstalling, and what stays behind

    Removing the npm package does not remove your data, which is usually what people actually want gone. The package removal is one command. Your account metadata lives in ~/.claude.json and your projects, transcripts, skills and settings live under ~/.claude/ — claude doctor prints that projects directory, so you can confirm it before deleting anything. The OAuth token itself is not in either place: it is in your OS keychain under "Claude Safe Storage". If you only want one project’s history gone rather than the whole install, claude project purge deletes the transcripts, tasks, file history and config entry for a single project and leaves everything else alone.

    # remove the CLI
    npm uninstall -g @anthropic-ai/claude-code
    
    # sign out first if you want the stored credential gone
    claude auth logout
    
    # just one project’s state, not the whole install
    claude project purge
    
    # then, only if you really want a clean slate:
    # rm -rf ~/.claude ~/.claude.json

Reference

CLI subcommands (typed in your shell)

Transcribed from the Commands section of claude --help on v2.1.260, 2026-09-04. Descriptions are shortened; run claude <command> --help for the full text.

CommandWhat it does
claudeStart an interactive session in the current directory.
claude "<prompt>"Start a session with the prompt already sent. The prompt is a positional argument.
claude agentsManage background agents (the ones started with --bg).
claude attach <id>Open a background session in this terminal, using the short id --bg printed.
claude authManage authentication: login, logout, status.
claude auto-modeInspect or reset the auto mode classifier configuration.
claude doctorCheck the health of the installation. Reads settings in the current directory without a trust prompt.
claude gatewayRun the enterprise auth/telemetry gateway.
claude import [source]Import config from another AI coding agent into Claude Code.
claude install [target]Install the native build. Takes stable, latest, or a specific version.
claude logs <id>Print a background session's recent terminal output.
claude mcpConfigure and manage MCP servers. See the mcp table below.
claude pluginManage plugins: install, list, update, uninstall, validate, marketplace, init, tag, prune.
claude projectManage project state. Its one subcommand is purge.
claude respawn [id]Restart a background session (or all of them with --all) on the current version.
claude rm <id>Delete a background session, and its worktree when that is safe.
claude setup-tokenSet up a long-lived authentication token. Requires a Claude subscription.
claude stop <id>Stop a background session. Its conversation is kept and can be reopened.
claude ultrareviewRun a cloud-hosted multi-agent code review of the current branch or a PR.
claude updateCheck for updates and install if available. Alias: claude upgrade.

Reference

The flags you will actually use

Verbatim flag names from the Options section of claude --help on v2.1.260. It lists far more than this; these are the ones that come up in day-to-day work.

FlagWhat it does
-p, --printRun the prompt non-interactively and print the result. The basis of every script.
-c, --continueContinue the most recent conversation in the current directory.
-r, --resume [value]Resume a conversation by session id, or open a picker.
--model <model>An alias such as opus or sonnet, or a model's full name.
--effort <level>Effort level for the session: low, medium, high, xhigh, max.
--output-format <fmt>With --print: text (default), json, or stream-json.
--permission-mode <mode>acceptEdits, auto, bypassPermissions, manual, dontAsk, or plan.
--dangerously-skip-permissionsBypass all permission checks. For sandboxes with no internet access.
--add-dir <dirs...>Additional directories the tools are allowed to touch.
--allowedTools <tools...>Comma or space separated tool names to allow, e.g. "Bash(git *) Edit".
--disallowedTools <tools...>The deny counterpart of --allowedTools.
--mcp-config <configs...>Load MCP servers from JSON files or strings.
--strict-mcp-configUse only the servers from --mcp-config, ignoring every other MCP configuration.
--settings <file-or-json>A settings JSON file path, or a JSON string, layered on top.
--setting-sources <sources>Which scopes to load at all: user, project, local (comma separated).
--safe-modeStart with all customisations disabled. The first thing to try when something breaks.
--bareMinimal mode: no hooks, LSP, plugin sync, auto-memory, keychain reads or CLAUDE.md discovery.
--max-budget-usd <n>Cap the dollars a single --print run may spend.
-w, --worktree [name]Create a new git worktree for this session.
--bg, --backgroundStart in the background and print the id that attach, logs, stop and rm take.
-v, --versionPrint the version and exit.

Reference

claude mcp subcommands

From claude mcp --help and claude mcp add --help on v2.1.260. The full walkthrough is on our claude mcp add guide.

CommandWhat it does
claude mcp add <name> <cmd|url> [args...]Register a server. -s local|user|project, -t stdio|sse|http, -e KEY=value, -H "Header: value".
claude mcp add-json <name> <json>Register a stdio, SSE, HTTP or WebSocket server from a JSON string.
claude mcp add-from-claude-desktopImport servers from Claude Desktop. macOS and WSL only.
claude mcp listList configured servers. Unapproved .mcp.json servers show as pending approval.
claude mcp get <name>Details for one server, health-checked if approved.
claude mcp remove <name>Remove a server.
claude mcp login <name>Authenticate with an HTTP, SSE or claude.ai connector server.
claude mcp logout <name>Clear stored OAuth credentials for a server.
claude mcp reset-project-choicesReset every approved and rejected project-scoped (.mcp.json) server in this project.
claude mcp serveRun Claude Code itself as an MCP server for another agent to call.

Reference

Slash commands (typed inside a session)

Descriptions below are verbatim from the command registry inside the v2.1.260 binary. This is not the complete list — plugins and skills register more, and a handful of built-ins define themselves in a shape our extraction could not read (see the note under the table). /help inside your own session is always authoritative.

CommandRegistry description (verbatim, v2.1.260)
/helpShow help and available commands
/clearStart a new session with empty context; previous session stays on disk (resumable with /resume)
/compactFree up context by summarizing the conversation so far
/autocompactSet how full the context gets before auto-summarizing
/contextVisualize current context usage as a colored grid
/resumeResume a previous conversation
/branchCreate a branch of the current conversation at this point
/forkCopy this conversation into a new background session and keep working here
/subtaskSend a subagent off with your full context; its result comes back here
/btwAsk a quick side question without interrupting the main conversation
/planEnable plan mode or view the current session plan
/goalSet a goal Claude checks before stopping
/effortSet effort level for model usage
/memoryEdit CLAUDE.md files and memory settings
/add-dirAdd a new working directory
/cdMove this session to a new working directory
/configOpen settings
/hooksView hook configurations for tool events
/mcpManage MCP servers
/skillsList available skills
/reload-skillsPick up skills added or changed on disk during this session
/reload-pluginsActivate pending plugin changes in the current session
/ideManage IDE integrations and show status
/exportExport the current conversation to a file or clipboard
/copyCopy Claude's last response to clipboard (or /copy N for the Nth-latest)
/statusShow Claude Code status including version, model, account, API connectivity, and tool statuses
/install-github-appSet up Claude GitHub Actions for a repository
/security-reviewComplete a security review of the pending changes on the current branch
/privacy-settingsView and update your privacy settings
/bugReport a bug or share your conversation
/logoutSign out from your Anthropic account

Troubleshooting

command not found: claude, right after npm install -g succeeded
npm's global bin directory is not on your PATH, so this is a shell problem and not a Claude Code problem. Find the directory with npm config get prefix, add /bin to it, and put that on your PATH: export PATH="$(npm config get prefix)/bin:$PATH" in ~/.zshrc or ~/.bashrc, then source it. On macOS with Homebrew-managed Node the prefix is usually /opt/homebrew. Confirm with which claude before trying anything else.
npm ERR! EACCES permission denied on the global install
You are writing to a system-owned directory. Do not fix this with sudo — sudo npm install -g leaves root-owned files in your npm tree and breaks later installs. Point npm at a directory you own instead: mkdir -p ~/.npm-global && npm config set prefix ~/.npm-global, then add export PATH="$HOME/.npm-global/bin:$PATH" to your shell profile. Using nvm or Volta avoids the whole class of problem because they install Node under your home directory.
npm ERR! engine: requires node >=22
The floor moved. v2.1.183 required Node >=18; v2.1.260 declares engines.node ">=22.0.0", so a machine that installed Claude Code earlier in 2026 will now fail on upgrade rather than on first install. Check with node --version, then nvm install --lts && nvm use --lts, and re-run the install.
A slash command "does not exist" — /vim, /todos, /output-style, /agents
Check them against your own build before assuming it is broken. In v2.1.260, /agents is still registered but its own description begins with "(removed)". None of /vim, /todos or /output-style is in the v2.1.260 command registry: /todos does not occur in the binary at all, and the only occurrences of the literal strings "/vim" and "/output-style" are inside unrelated text (a ripgrep option description and a docs URL). Treat all three as gone rather than as something you are typing wrong. This is also why an undated cheat sheet is worse than none: we fetched the one currently ranking on page one for this query on 2026-09-04, and it still lists --think, /save and a CLAUDE_API_KEY environment variable, with no "last updated" anywhere in its 103,889 bytes. Run /help; that list is the only one that is current for you.
An MCP server shows as failed to start, or its tools never appear
Work through it in this order. claude mcp get <name> health-checks an approved server and tells you what it is doing. If the server came from a project .mcp.json, it needs explicit approval before its tools are exposed — if you rejected it by accident, run claude mcp reset-project-choices in the project directory and restart claude to get the prompt back. If it is a stdio server, run the command by hand in the same shell first: most "failed to start" cases are just npx not finding the package. If it is an HTTP or SSE server that needs OAuth, claude mcp login <name> is a separate step from adding it.
Claude Code behaves differently in one repo than everywhere else
Something in that repo’s configuration is loading. Start with claude --safe-mode, which disables CLAUDE.md, skills, plugins, hooks, MCP servers and custom commands in one go. If the odd behaviour disappears, narrow it by scope: claude --setting-sources user ignores the project and local settings files, and --strict-mcp-config ignores every MCP config except the one you pass. Working outward from safe mode is much faster than reading four settings files.
Claude Code is not working at all — how do I tell if it is me?
Check the service first: status.claude.com is the status page for the API that Claude Code calls, and downdetector-style reports will not tell you anything it does not. If the service is fine, run three commands. claude --version proves the binary runs. claude doctor prints the install path, the build, and whether settings and search are healthy. claude auth status prints JSON with a loggedIn field — an expired login shows up as a refusal the moment you send a prompt, not at startup, which is why it is so often mistaken for an outage.

FAQ

How do I see every Claude Code command?
There are two lists and you need both. claude --help prints the CLI surface — the subcommands and flags you type in your shell. /help, typed inside a running session, prints the slash commands registered for your build, including any that plugins and skills added. Neither list includes the other, which is why a single "all commands" cheat sheet is always slightly wrong.
What is the difference between claude mcp and /mcp?
They manage the same servers from different places. claude mcp is the CLI subcommand family — add, list, get, remove, login, logout, reset-project-choices, serve — and you run it from your shell, with Claude Code not running. /mcp is the in-session command for managing servers while you work. Use the CLI form in scripts and setup docs, and the slash form when you are already in a session.
Where does Claude Code store its settings?
In three scopes. ~/.claude/settings.json is your user-level configuration and applies everywhere. .claude/settings.json in a repository is the project scope, meant to be committed and shared with the team. .claude/settings.local.json in the same repository is your personal override and is normally git-ignored. Two flags control this from the command line without editing files: --setting-sources takes a comma-separated list of which scopes to load at all (user, project, local), and --settings takes a file path or a raw JSON string layered on top. Account metadata is separate and lives in ~/.claude.json.
How do I uninstall Claude Code completely?
npm uninstall -g @anthropic-ai/claude-code removes the CLI, but not your data. Run claude auth logout first if you want the stored credential gone — the OAuth token is not in a file, it is in your OS keychain under "Claude Safe Storage". Your account metadata is in ~/.claude.json and your projects, transcripts, skills and settings are under ~/.claude/; claude doctor prints that projects directory so you can confirm the path before deleting it. If you only want one project forgotten rather than the whole install, claude project purge deletes that project’s transcripts, tasks, file history and config entry and leaves everything else in place.
Does Claude Code work on Windows without WSL?
Yes. v2.1.260 publishes native Windows binaries — @anthropic-ai/claude-code-win32-x64 and @anthropic-ai/claude-code-win32-arm64 are listed as optional dependencies in its package.json next to the macOS and Linux ones — so npm install -g in PowerShell gets a native build. WSL remains supported and is the better fit when your project already lives on a Linux filesystem. The setup to avoid is Claude Code running inside WSL against a Windows-side npm install under /mnt/c; the CLI detects that specific arrangement and complains, and it is the most common broken Windows install.
How do I run Claude Code non-interactively, in CI or a script?
Use -p/--print, which runs the prompt and exits instead of opening the interactive shell. Add --output-format json for a machine-readable result, or stream-json to consume events as they arrive. --max-budget-usd caps what one run may spend. In CI you usually also want --setting-sources project so a developer’s local overrides do not leak into the build. One warning straight from the help text: the workspace trust dialog is skipped whenever stdout is not a TTY, so only run -p in directories you trust.
Why does this cheat sheet name a version, when most do not?
Because the surface changes fast enough that an undated list is actively misleading. Between v2.1.183 (2026-06-20) and v2.1.260 (2026-09-04) the top-level claude config subcommand disappeared, agents, attach, auth, import, logs, project, respawn, rm, stop and ultrareview were added, and the Node floor moved from 18 to 22. A cheat sheet that does not say which build it describes cannot tell you whether a missing command is your mistake or its own.