Cheat sheet
Claude Code cheat sheet
Claude Code slash commands, CLI flags, headless -p runs, permission modes including auto, keyboard shortcuts and config files, checked against Anthropic's docs.
Bookmark
Bookmarks are kept in your free account, so you can find this page again on any device.
Sign in to bookmarkOn this page
The Claude Code commands, flags, keys and files you reach for most, checked against Anthropic’s docs and version 2.1.332 of the claude command on 25 November 2026. Start with claude in your repository, run /init once to write a CLAUDE.md, and run /plan (or press Shift+Tab until the status bar shows plan mode) before a large change.
Install and start
# Native installer (macOS, Linux, WSL); updates itself in the background
curl -fsSL https://claude.ai/install.sh | bash
# Or a package manager (these do not auto-update by default)
brew install --cask claude-code
winget install Anthropic.ClaudeCode
# Start in your project folder, or start with a first prompt
claude
claude "explain how the payment module works"
claude doctor checks the install and your settings files without starting a session. claude update updates a native install.
Slash commands you will use most
| Command | What it does |
|---|---|
/init |
Write a CLAUDE.md for this project |
/plan [task] |
Enter plan mode, optionally starting on a task |
/model [model] |
Switch model and save it as your default |
/effort [level] |
Set effort: low to xhigh, max, or auto |
/permissions |
View and edit allow, ask and deny rules |
/context |
Show context usage as a grid, with suggestions |
/compact [focus] |
Summarise the conversation to free context |
/clear |
Start a new conversation with empty context |
/resume [session] |
Reopen an earlier session by ID or name |
/rewind |
Roll the conversation and code back to a checkpoint |
/diff |
Review the changes in your working tree |
/review |
Review a pull request, branch or path (alias of /code-review) |
/security-review |
Check your branch’s changes for vulnerabilities |
/mcp |
Manage MCP servers and their OAuth sign-in |
/skills, /agents, /hooks |
List skills, manage subagents, view hooks |
/memory |
Edit CLAUDE.md files and auto memory |
/usage |
Session cost, plan limits and activity (/cost is an alias) |
/btw [question] |
Ask a side question without adding it to the conversation |
/help |
List every command |
Type / to see every command available in your session, including skills and plugin commands. The docs list over a hundred built-in commands and bundled skills.
Recurring and background work
| Command | What it does |
|---|---|
/loop [interval] [prompt] |
Repeat a prompt while this session stays open |
/schedule [description] |
Create, list or run cloud scheduled tasks (formerly routines) |
/background [prompt] |
Detach this session to run as a background agent |
/tasks |
View background work in the session, including finished subagents |
claude agents |
Open agent view to watch and dispatch background sessions |
claude --bg "task" |
Start a background agent from the shell and return at once |
Command-line flags
| Flag | What it does |
|---|---|
-p, --print "<prompt>" |
Run one prompt without the interactive UI, then exit |
-c, --continue |
Continue the most recent conversation in this folder |
-r, --resume <id-or-name> |
Resume a session; without a value, opens a picker |
-n, --name <name> |
Name the session so you can resume it by name |
--model <alias-or-id> |
Model for this session, such as sonnet or opus |
--effort <level> |
Effort level for this session |
--permission-mode <mode> |
Start in default, acceptEdits, plan, auto, dontAsk or bypassPermissions |
--allowedTools "<rules>" |
Tools that run without asking, e.g. "Bash(npm test)" "Read" |
--disallowedTools "<rules>" |
Deny rules; a bare tool name removes the tool |
--add-dir <path> |
Give Claude file access to another directory |
-w, --worktree [name] |
Start in an isolated git worktree under .claude/worktrees/ |
--mcp-config <file> |
Load MCP servers from a JSON file or string |
--append-system-prompt "<text>" |
Add to the default system prompt |
--bare |
Skip hooks, skills, plugins, MCP servers and CLAUDE.md for fast scripted runs |
--safe-mode |
Start with every customisation off, to debug a broken setup |
--debug |
Debug logging, with optional categories such as --debug='mcp' |
-v, --version |
Print the version |
--enable-auto-mode was removed in v2.1.111. Use --permission-mode auto instead.
Headless runs with -p
# One prompt, plain text out
claude -p "Explain what src/auth/session.ts does"
# Pipe content in
cat build.log | claude -p "Why did this build fail? Answer in three bullets."
# JSON out (includes total_cost_usd), with tools pre-approved and a turn cap
claude -p "Fix the failing test in tests/date.test.ts" \
--output-format json \
--allowedTools "Read" "Edit" "Bash(npm test *)" \
--max-turns 10
# Continue the last conversation non-interactively
claude -c -p "Now run the linter and fix what it finds"
These flags only work with -p: --output-format (text, json, stream-json), --json-schema, --max-turns, --max-budget-usd and --no-session-persistence. A headless run cannot answer prompts, so set permissions before it starts.
Permission modes
| Mode | Runs without asking | Use it for |
|---|---|---|
default (shown as Manual) |
Reads in your working directories | Sensitive work, unfamiliar code |
acceptEdits |
Reads, file edits and common file commands such as mkdir and mv |
Iterating on code you are reviewing |
plan |
Reads, plus classifier-approved commands where auto mode is available; no edits | Exploring before a change |
auto |
Everything, with a classifier model checking each action | Long tasks with fewer prompts |
dontAsk |
Reads and pre-approved tools; anything else is denied | Locked-down CI and scripts |
bypassPermissions |
Everything | Isolated containers and VMs only |
Shift+Tab cycles default → acceptEdits → plan, then bypassPermissions if enabled and auto if available; from auto, the first press goes to default. From v2.1.283, interactive terminal and VS Code sessions start in auto on every plan. From v2.1.302, claude -p runs with no mode set start in Manual. dontAsk never appears in the cycle.
Deny rules block in every mode, including bypassPermissions.
Keyboard shortcuts
| Key | What it does |
|---|---|
Shift+Tab |
Cycle permission modes |
Esc |
Stop Claude mid-turn; it keeps the work done so far |
Esc Esc |
Clear the draft, or rewind when the prompt is empty |
Ctrl+C |
Interrupt or clear input; press again to exit |
Ctrl+D |
Exit (press twice) |
Ctrl+B |
Send running Bash commands and agents to the background |
Ctrl+O |
Toggle the transcript viewer with full tool output |
Ctrl+R |
Search earlier prompts |
Ctrl+G |
Edit the prompt in your text editor |
Ctrl+V |
Paste an image from the clipboard (Alt+V on Windows) |
Option+P / Alt+P |
Switch model without clearing the prompt |
\ then Enter, or Ctrl+J |
New line in any terminal |
/ · ! · @ |
Command or skill · run a shell command yourself · mention a file |
? on an empty prompt |
Show the shortcut help panel |
Run /terminal-setup if Shift+Enter sends instead of adding a line in VS Code, Cursor or Zed. Rebind keys in ~/.claude/keybindings.json (open it with /keybindings).
Files and folders
| What | Where |
|---|---|
| Project instructions | CLAUDE.md in the project root (or .claude/CLAUDE.md); AGENTS.md can be loaded too |
| Personal project notes | CLAUDE.local.md (add it to .gitignore) |
| Your instructions everywhere | ~/.claude/CLAUDE.md |
| Path-scoped rules | .claude/rules/*.md with paths: frontmatter |
| Settings | ~/.claude/settings.json (you), .claude/settings.json (team), .claude/settings.local.json (you, this project) |
| Project MCP servers | .mcp.json in the project root |
| Skills | .claude/skills/<name>/SKILL.md, or ~/.claude/skills/ |
| Subagents | .claude/agents/*.md, or ~/.claude/agents/ |
| Single-file commands | .claude/commands/<name>.md runs as /<name> |
| App state and user MCP servers | ~/.claude.json |
Managed settings deployed by your organisation override all of these.
Common mistakes
| Mistake | Fix |
|---|---|
claude -p stops on a tool it may not use |
Headless runs cannot ask; add --allowedTools rules or start in auto |
bypassPermissions on your own laptop |
Use it only in a container or VM; prefer auto mode plus deny rules |
One huge CLAUDE.md |
Keep it short; move path-specific rules to .claude/rules/ and procedures to skills |
Committing settings.local.json |
It is personal; keep it out of git |
| A broken plugin or hook stops every session | Start with --safe-mode, then turn things back on one at a time |
Expecting /loop to run after you close the terminal |
It lives in the session; use /schedule for cloud runs |
Check your setup
claude --version
claude doctor
claude auth status --text
claude -p "List the files in this folder" --output-format json
Inside a session, /status shows the model, account and connectivity, and /context shows what is loaded.
For hooks, use the Claude Code hooks reference. For the same page for OpenAI’s agent, see the Codex CLI cheat sheet, and to compare the agents side by side, the coding agent cheat sheet. New to Claude Code? Start with your first Claude Code session.
Check your understanding
Claude Code commands quiz
Plan mode, context commands, recurring and background work, headless runs with -p, permission modes, deny rules, settings files and fixing a broken setup.
8 questions · pass mark 70%
Review
Checked against
Related
- Your first session with Claude Code
Install it, run it in a real repository, approve its first changes, commit a reviewed edit and learn the commands you will use daily.
- Claude Code hooks cheat sheet
PreToolUse and PostToolUse events, matcher patterns, stdin JSON payload fields, exit codes and safe config examples.
- Codex CLI cheat sheet
Codex CLI commands, codex exec for scripts, sandbox and approval modes, config.toml keys, resuming sessions and slash commands, checked against codex --help.
- Permissions and sandboxing for coding agents
Set up Claude Code permission modes and rules, the Codex sandbox and approvals, and a dev container, so an agent can work without free rein.
- Permission mode
A setting in a coding agent that decides which actions it may take on its own, such as edits or shell commands, and which need approval.