Claude Code CLI cheat sheet
The claude CLI has grown past what fits in its own help screen. This page puts the commands you type every day first, then the flags, slash commands, shortcuts and file locations, each checked against Claude Code 2.1.311 and the official reference. Not installed yet? Start with the Mac install guide.
Start, continue and resume
These are the commands you type every day. Each one starts in the folder you are in, and that folder decides which project, memory files and sessions Claude Code sees.
| Command | What it does |
|---|---|
claude | Starts an interactive session. |
claude "query" | Starts an interactive session with a first prompt. |
claude -p "query" | Answers once and exits. Print mode, for scripts and CI. |
cat file | claude -p "query" | Sends piped content along with the prompt. |
claude -c | Continues the most recent conversation in this folder. |
claude -c -p "query" | Continues it without opening the interface. |
claude -r <name> "query" | Resumes a session by ID or name. Without a value, -r opens the session picker. |
claude -n <name> | Starts a session with a display name, which is what you resume it by later. |
claude -r <name> --fork-session | Resumes into a new session ID and leaves the original untouched. |
claude -w <name> | Starts in a new git worktree at .claude/worktrees/<name>, on branch worktree-<name>. |
claude -n checkout-refactor # name it at start
claude -r checkout-refactor # resume it tomorrow
claude -w feature-auth # own checkout, own branch
cat error.log | claude -p "explain this stack trace"
-c takes the latest conversation in the folder, which is ambiguous once several sessions live there. -r <name> always brings back the one you mean. Name sessions with -n or /rename and resume by name.
Commands outside a session
Subcommands of claude that do a job and return to the shell.
| Command | What it does |
|---|---|
claude update | Checks for an update and installs it. Homebrew and npm installs update through their package manager. |
claude install [stable|latest|version] | Installs the native build, at a channel or a specific version. |
claude doctor | Checks the health of the installation. Inside a session, /doctor goes further and proposes fixes. |
claude auth login, logout, status | Signs in to your Anthropic account, signs out, or shows how you are signed in. |
claude setup-token | Creates a long-lived token for CI, which needs a Claude subscription. |
claude mcp add, list, get, remove | Configures MCP servers. claude mcp serve runs Claude Code itself as an MCP server. |
claude plugin install, list, update | Manages plugins and plugin marketplaces. |
claude agents | Lists background agents. claude attach <name> opens one in this terminal and claude logs <name> prints its recent output. |
claude import codex|gemini|cursor | Imports configuration from another coding agent. Add --dry-run to see what it would change. |
claude purge [path] | Deletes a project's Claude Code data from this computer only. |
Flags worth knowing
claude --help says itself that it does not list every flag. These are the ones that change how a session behaves, grouped by what they touch.
Session
| Flag | Effect |
|---|---|
-c, --continue | Continue the most recent conversation in this folder. |
-r, --resume [id or name] | Resume a session, or open the picker. |
--fork-session | With a resume, create a new session ID instead of reusing the old one. |
-n, --name | Display name for the session. |
-w, --worktree [name] | Start in a new git worktree. Passing a PR number or URL branches from that pull request. |
--tmux | With -w, also create a tmux session for the worktree. |
--add-dir <dirs> | Let the session read and edit directories outside the one it started in. |
Model and effort
| Flag | Effect |
|---|---|
--model <model> | Model for this session: an alias such as sonnet, opus or haiku, or a full model name. |
--effort <level> | How much reasoning to apply: low, medium, high, xhigh or max. |
--fallback-model <model> | Switch to this model automatically when the main one is overloaded. |
Permissions and tools
| Flag | Effect |
|---|---|
--permission-mode <mode> | Start in a mode: default (also called manual), acceptEdits, plan, auto, dontAsk or bypassPermissions. |
--allowedTools, --disallowedTools | Allow or deny tools without a prompt, with patterns such as "Bash(git log *)" or "Edit". |
--tools <list> | Limit the tools the session has at all, for example "Bash,Edit,Read". |
--dangerously-skip-permissions | Same as --permission-mode bypassPermissions: no prompts at all. Keep it for places where a mistake cannot hurt, such as a throwaway container. What it skips and what still asks. |
Print mode, for scripts
| Flag | Effect |
|---|---|
-p, --print | Answer and exit instead of opening the interface. |
--output-format text|json|stream-json | Shape of the answer. JSON includes the result and session metadata. |
--input-format text|stream-json | Shape of what you pipe in. |
--max-turns <n> | Stop after that many agent turns. There is no limit by default. |
--max-budget-usd <amount> | Stop when the run has spent that much on API calls. |
--json-schema <schema> | Ask for structured output that matches a JSON Schema. |
--append-system-prompt, --system-prompt | Add to the system prompt, or replace it. |
--bare | A minimal run that skips most of the discovery a normal session does. The docs say it will become the default for -p. |
Configuration and debugging
| Flag | Effect |
|---|---|
--settings <file or json> | Load extra settings for this session. |
--mcp-config <files> | Load MCP servers from JSON files. Add --strict-mcp-config to use only those. |
--agents <json> | Define subagents for this session only. |
--plugin-dir <dir> | Load a plugin from a folder, for testing it. |
--ide | Connect to your IDE on startup when exactly one is available. |
--verbose, -d, --debug [filter] | Full turn-by-turn output, or debug logs such as --debug=mcp. |
Slash commands inside a session
Type / at the prompt to see every command available to you; availability varies by plan and platform. The ones below are built in.
| Command | What it does |
|---|---|
/clear | Start a new conversation with empty context. Aliases /reset and /new. |
/compact [focus] | Summarize the conversation so far to free context, optionally around a focus you give. |
/context | Show what fills the context window, as a colored grid. |
/rewind | Go back to an earlier point in the conversation, the code, or both. |
/btw [question] | Ask a side question without adding it to the conversation. |
/resume [session] | Return to an earlier conversation, or open the picker. |
/rename [name] | Rename the session; without a name, one is generated. |
/branch [name] | Branch the conversation here and try another direction. The original stays in /resume. |
/fork [prompt] | Copy the conversation into a new background session and keep working here. |
/background, /tasks | Detach the session to keep running as a background agent; list the background work of this session. |
/model [model], /effort [level], /fast | Switch model and save it as the default, set the effort level, toggle fast mode. |
/plan [task] | Enter plan mode, optionally starting on a task. |
/permissions | Manage allow, ask and deny rules for tools. |
/init | Write a CLAUDE.md for the project. If it finds Codex or Gemini CLI configuration, it offers to carry it over. |
/memory | Edit CLAUDE.md files and manage auto memory. |
/add-dir <path> | Give the session access to another directory. |
/mcp, /hooks, /plugin, /skills | Manage MCP connections, view hooks, manage plugins, list skills. |
/diff | Review the changes in your working tree, including Claude's edits. |
/code-review, /security-review | Check the current diff for bugs (/review is an alias), or the branch for security issues. |
/loop [interval] [prompt] | Run a prompt repeatedly while the session stays open. |
/usage | Session cost, plan usage limits and activity stats. /cost and /stats are aliases. |
/status, /config | Version, model, account and connectivity; the settings interface. |
/login, /logout | Sign in to or out of your Anthropic account. |
/doctor | A setup checkup that diagnoses problems and proposes fixes. |
/export [file] | Export the conversation as plain text. |
/statusline, /terminal-setup, /theme, /keybindings | Status line, the Shift+Enter newline key, color theme, your shortcuts file. |
/exit | Quit. Alias /quit. |
/vim is gone; editor mode lives in /config. /agents now only reminds you to ask Claude for a subagent or to edit .claude/agents/. The # shortcut for memory is no longer documented: ask Claude to remember something, or use /memory.
Keyboard shortcuts
| Key | Action |
|---|---|
Esc | Interrupt Claude and keep the work so far, or close a dialog. |
Esc Esc | With text typed: clear it (it stays in history). With an empty prompt: open the rewind menu. |
Shift+Tab | Cycle permission modes: default, acceptEdits, plan, then bypassPermissions and auto where available. |
Ctrl+C | Interrupt or clear the input. Press again to exit. |
Ctrl+D | Exit, with a second press. |
Ctrl+R | Search your prompt history. |
Ctrl+O | Toggle the transcript viewer. |
Ctrl+B | Send running shell commands and agents to the background. Inside tmux, press it twice. |
Ctrl+T | Show or hide Claude's task checklist. |
Ctrl+G | Open the prompt in your editor. |
Ctrl+V | Paste an image. |
Option+P, Option+T, Option+O | Switch model, toggle extended thinking, toggle fast mode. |
/, !, @, ? | At the start of the prompt: a command or skill, a shell command, a file mention, the shortcut help. |
New lines in a prompt: a backslash then Return works in every terminal. Shift+Return works natively in iTerm2, Ghostty, WezTerm, Kitty, Warp and Apple Terminal; /terminal-setup adds it to others. Option+Return and Ctrl+J work too.
Files and environment variables
| Where | What lives there |
|---|---|
~/.claude/settings.json | Your settings for every project. |
.claude/settings.json | Project settings, meant to be committed and shared. |
.claude/settings.local.json | Your project settings that stay out of git. |
~/.claude.json | Account details, MCP configuration and per-project state. |
~/.claude/CLAUDE.md | Instructions for every project. |
./CLAUDE.md or ./.claude/CLAUDE.md | Project instructions. Claude Code also reads the ones in parent folders, and CLAUDE.local.md for your private notes. |
.claude/rules/ | Extra rule files, per project or in ~/.claude/rules/. |
Precedence runs managed settings, then command-line flags, then local, project and user files. Environment variables can go in your shell or under "env" in a settings file:
| Variable | Meaning |
|---|---|
CLAUDE_CONFIG_DIR | Use another configuration folder instead of ~/.claude. This is how two accounts run side by side. |
ANTHROPIC_API_KEY | Bill the API with this key, even when you are signed in with a subscription. |
ANTHROPIC_MODEL | Default model; --model overrides it. |
CLAUDE_CODE_OAUTH_TOKEN | The subscription token for CI that claude setup-token creates. |
CLAUDE_CODE_USE_BEDROCK, CLAUDE_CODE_USE_VERTEX | Run through Amazon Bedrock or Google Cloud instead of Anthropic's API. |
When one terminal is not enough
Every claude process is its own session, so the flags above compose: -n to name each one, -w to give each its own checkout, -r to bring them back. How to run multiple Claude Code sessions at once covers tabs, tmux and worktrees in detail.
Symvibe, which we make, is the board for that stage: each console is the real claude from your PATH in a real terminal, so every command on this page works in it unchanged. Consoles relaunch when you reopen the app and offer Claude Code's own resume, and Codex, Gemini CLI and other agents get consoles next to it.
Questions people ask
Where is the complete list of flags?
In the CLI reference of the Claude Code docs. claude --help on version 2.1.311 leaves some out, and says so. This page lists the ones that change how a session behaves.
What is the difference between claude -c and claude -r?
-c continues the most recent conversation in the current folder. -r resumes a specific one by ID or name, or opens a picker without a value. With more than one session per folder, resume by name.
How do I run Claude Code in a script or in CI?
Use print mode: claude -p "query", with --output-format json if a program reads the answer, and --allowedTools or --permission-mode so it never waits for a prompt. For a subscription in CI, claude setup-token creates the token that CLAUDE_CODE_OAUTH_TOKEN carries.
How do I see how much of my plan I have used?
Run /usage inside a session; /cost and /stats open the same screen. What each plan includes is in the Claude Code pricing guide.
How do I change the model?
/model inside a session switches it and saves it as your default. --model sets it for one session, and ANTHROPIC_MODEL sets a default from the environment.
Can I bring over my Codex or Gemini CLI setup?
Yes. claude import codex, gemini or cursor imports their configuration, and /init offers to do it when it finds one. To keep both tools instead, see Codex vs Claude Code.
Every claude session on one board
Symvibe runs the real claude CLI in real terminals on one canvas, with names, resume on reopen and other agents next to it. Your login, your plan, your Mac.
macOS 14 or later · Apple Silicon · USD 19 a month or USD 190 a year