Claude Code Cheat Sheet

Claude Code v2.1.247 Last updated: August 27, 2026
🔔 Recent Changes
• SendFeedback tool: Claude drafts feedback reports for /feedback review • /claude-api cost-optimize: profile API spend and work cost levers • Cross-session messages collapse to one-line preview; Ctrl+O expands • Bash permission prompts offer one-keystroke switch to auto mode • Sonnet 5 1M-window auto-compact threshold raised to ~967K tokens • spinnerTipsOverride: orgs rotate custom tips with id, priority, cooldown
⌨️ KEYBOARD SHORTCUTS
General Controls
Ctrl C Cancel input/generation
Ctrl D Exit session
Ctrl L Repaint screen; double-press /clear removed
Ctrl O Toggle verbose transcript
Ctrl R Reverse search history
Ctrl G Open prompt in editor
Ctrl B Background running task
Ctrl T Toggle task list
CtrlX CtrlK Kill bg agents; agents view: remove session + worktree, preserve unpushed commits
CtrlAltF Toggle Focus view (VSCode: hide tool activity behind expandable summary)
Esc Esc Rewind / undo
Open agents view
{ / } Jump between user prompts (transcript view)
? Show keyboard shortcuts (transcript view)
Mode Switching
Shift Tab Cycle permission modes
Alt P Switch model
Alt T Toggle thinking on/off
Input
\ Enter Newline (quick)
Ctrl J Newline (control seq)
v / V (vim mode) Visual / visual-line mode with selection
/ (vim NORMAL) Reverse history search (like Ctrl+R)
:shortcode: Emoji autocomplete in prompt; accepts alternate shortcodes (:thumbsup:, :love:)
Prefixes
/ Slash command
! Direct bash; file path autocomplete; Claude responds to output
@ File mention + autocomplete; @session cross-session msg (Ctrl+O expands) NEW
Session Picker
↑↓ Navigate
←→ Expand/collapse
R Rename
/ Search
CtrlA Show all projects (in /resume)
🔌 MCP SERVERS
Add Servers
--transport http Remote HTTP (recommended)
--transport stdio Local process
--transport sse Remote SSE
Scopes
Local settings.local.json (you only)
Project .mcp.json (shared/VCS)
User ~/.claude.json (global)
Manage
/mcp Interactive UI
claude mcp list List all servers; ⏸ pending approval, ⊘ Disabled (no health check)
claude mcp serve CC as MCP server
claude mcp login <name> Authenticate MCP server from CLI; --no-browser for SSH
claude mcp logout <name> Revoke MCP server authentication from CLI
Elicitation Servers request input mid-task
_meta maxResultSizeChars Override result size up to 500K
alwaysLoad Skip tool-search deferral for server tools
headersHelper Command minting HTTP headers for catalog/archive fetches; -y to auto-approve
workspace Reserved names — skipped: workspace, Claude Browser, Claude Preview
${CLAUDE_PROJECT_DIR} Reference project dir in MCP server commands
roots/list Additional working dirs advertised; notifications/roots/list_changed on changes
⚡ SLASH COMMANDS
Session
/clear Clear conversation
/compact [focus] Compact context
/resume Resume/switch session; agent view: picker of past sessions incl. deleted
/rename [name] Name current session
/branch [name] Branch conversation
/context Visualize context (grid)
/diff Interactive diff viewer (keyboard-scrollable detail)
/rewind Rewind conv / code checkpoint; resume from before /clear (/undo alias)
/recap Context summary when returning to session
/focus Toggle focus view
/goal [condition] Set completion condition; auto-clears on fatal; max 3 idle check-ins per batch NEW
/cd [path] Move session to new working dir; settings, hooks, MCP, skills apply immediately NEW
/fork Copy conversation into new background session with its own worktree
/subtask Launch in-session subagent (former /fork behavior)
Config
/config Open settings; key=value sets any setting; --help lists shorthand keys
/model [model] Switch model; Org/Role default when admin sets one (←→ effort, s = session only)
/fast [on|off] Toggle fast mode
/theme Change color theme; Auto matches terminal
/permissions View/update permissions; Auto mode tab; opens while Claude is working NEW
/effort [level] Set effort; interactive slider (low–max; Faster/Smarter labels)
/keybindings Customize keyboard shortcuts
/terminal-setup Configure terminal keybindings
/login Sign in: Console account (keyless, recommended) or API key NEW
Tools
/init Create CLAUDE.md
/memory Edit CLAUDE.md files
/mcp Manage MCP servers
/hooks Manage hooks
/skills List available skills
/reload-plugins Hot-reload plugins
/reload-skills Re-scan skill directories without restarting
/add-dir <path> Add working directory
/plugin [name] Browse, install, enable/disable plugins and marketplaces
/plugin list [--enabled|--disabled] List installed plugins with status filters
/ide Connect to IDE for diagnostics and editor integration
Special
/btw <question> Side question (no context); bare reopens panel; ←/→ browse answers
/plan [desc] Plan mode (+ auto-start)
/loop [interval] Recurring task (/proactive alias)
/bg [prompt] Fork current turn into an attachable background session
/voice Push-to-talk voice (20 langs)
/doctor Setup checkup: diagnose/fix issues; suggest CLAUDE.md trim (/checkup alias)
/remote-control Bridge to claude.ai/code (/rc); auto-start only via user-scope settings
/usage Usage stats with per-category breakdown, cost, rate status; loops breakdown NEW
/schedule Cloud scheduled tasks
/security-review Security analysis of changes
/usage-credits View usage credits (renamed from /extra-usage)
/feedback Submit feedback; include recent sessions (alias: /bug)
/workflows View dynamic workflow runs; press f to filter status
/status Session status, warnings, session kind; skipped sources; GitHub web connection NEW
/cost Show cost estimates; includes data-residency premium where applicable
/web-setup Connect GitHub for Claude Code on the web (Pro/Max) NEW
📁 MEMORY & FILES
CLAUDE.md Locations
./CLAUDE.md Project (team-shared)
~/.claude/CLAUDE.md Personal (all projects)
/etc/claude-code/ Managed (org-wide)
Rules & Import
.claude/rules/*.md Project rules
~/.claude/rules/*.md User rules
paths: frontmatter Path-specific rules
@path/to/file Import in CLAUDE.md
Auto Memory
~/.claude/projects/<proj>/memory/ Auto-loaded per project
MEMORY.md Memory index + topic files; errors over read limit (loaded content only)
modified (frontmatter) ISO timestamp in memory file frontmatter
💡 WORKFLOWS & TIPS
Plan Mode
Shift Tab Manual → Auto-Accept → Plan
⏸ footer badge Shows active manual permission mode
--permission-mode plan Start in plan mode
Auto mode Max & Bedrock/Vertex/Foundry; disableAutoMode; classifier adjudicates edge cases
Thinking & Effort
Alt T Toggle thinking on/off
"ultrathink" Max effort for turn
Ctrl O Toggle verbose transcript
/effort ○ low · ◐ med · ◑ xhigh · ● high/max (Faster↔Smarter)
Git Worktrees
--worktree name Isolated branch per feature
isolation: worktree Agent in own worktree; auto-commits, pushes, opens draft PR
sparsePaths Checkout only needed dirs
/batch Auto-creates worktrees
EnterWorktree (switch) Switch between Claude-managed worktrees; confirms if outside project dir
Voice Mode
/voice Enable push-to-talk
Space (hold) Record, release to send
20 languages EN, ES, FR, DE, CZ, PL…
Context Management
/context Usage + optimization tips; warns if exceeding context window
/compact [focus] Compress with focus
Auto-compact ~95% capacity; 1M-window → ~967K NEW
Summarize up to here Rewind menu option — compress earlier context, keep recent turns
1M context Sonnet 5 (default) + Opus 5 + Opus 4.8 (Max/Team/Ent)
CLAUDE.md Survives compaction!
Session Power Moves
claude -c Continue last conv
claude -r "name" Resume by name
/btw question Side Q, no context cost
SDK / Headless
claude -p "query" Non-interactive
--output-format json Structured output
--max-budget-usd 5 Cost cap; also stops background subagents when reached
cat file | claude -p Pipe input
Auto-continue (-p) Non-interactive sessions auto-continue responses cut off mid-stream NEW
Scheduling & Remote
/loop 5m msg Recurring task (/proactive)
/rc Remote Control
--remote Web session
Push notifications Mobile push via Remote Control
API key no cloud API key / non-Anthropic ANTHROPIC_BASE_URL disables RC, /schedule, MCP, notifications
Dynamic workflows Orchestrates agents; default medium (<15); triggers on 'run a workflow', 'workflow:'
Self-hosted runner Own machines/containers as CC session hosts; claude self-hosted-runner (Team/Ent)
Write tool Newer models can overwrite unread files, matching Edit tool rules
🖥️ CLI & FLAGS
Core Commands
claude Interactive
claude "q" With prompt
claude -p "q" Headless
claude -c Continue last
claude -r "n" Resume
claude update Update
claude plugin init <name> Scaffold a new plugin in .claude/skills
claude agents Agent dashboard; MRs as !N; --cwd, --add-dir, --settings, --mcp-config, --model, --effort, --json
claude agents --json List live sessions as JSON; --all includes completed; id/state fields
claude --bg --exec '<cmd>' Run shell command as attachable background session
claude plugin enable <name> Enable a plugin; force-enables its dependencies
claude plugin disable <name> Disable a plugin; refuses if a dependent is enabled
claude auto-mode reset Restore default auto-mode config; --yes skips confirmation
claude self-hosted-runner CC hosts; --base-dir, --defer-shutdown-max-min, --proxy-auth-cmd/file (Team/Ent)
archive (plugin source) Install plugins from zip over HTTPS; SHA-256 pinning
claude remote-control --continue Resume most recent Remote Control session
Key Flags
--model Set model
-w Git worktree; GitLab MR URLs
-n / --name Session name
--add-dir Add dir
--agent Use agent
--allowedTools Pre-approve
--output-format json/stream
--json-schema Structured
--max-turns Limit turns
--max-budget-usd Cost cap; also stops background subagents when reached
--verbose Verbose
--remote Web session
--from-pr Load PR/MR from GitHub/GitLab/Bitbucket/GHE
--effort low/med/xhigh/high/max
--permission-mode plan/manual/…
--dangerously-skip-permissions Skip all prompts; catastrophic rm (incl. $()/backticks) still prompts ⚠️
--chrome Chrome
--fallback-model Fallback when primary unavailable (interactive + headless)
--thinking disabled turns off thinking on default-thinking models
--plugin-dir Load plugin from directory or .zip archive
--safe-mode Start with all customizations disabled for troubleshooting
--ax-screen-reader Opt-in plain-text rendering for screen reader users
--teleport <session id> Continue a cloud session locally
🤖 SKILLS & AGENTS
Built-in Skills
/verify Verification; no longer auto-invoked by Claude
/code-review [level] [pr#] Reviews diff or PR; remembers effort; --comment, --fix; high+ runs in bg; ultra=cloud
/deep-research [topic] Deep research; no longer auto-invoked by Claude
/batch Large parallel changes (5-30 worktrees)
/debug [desc] Troubleshoot from debug log
/loop [interval] Recurring task (/proactive alias)
/claude-api API + SDK reference; cost-optimize subcmd; Admin API coverage; Python 0.x→1.x NEW
/ultrareview [PR#] Cloud code review (parallel multi-agent)
/less-permission-prompts Scan transcripts for allowlist proposals
/simplify Cleanup-only review (reuse, simplify, efficiency, altitude) and apply fixes
/dataviz Chart and dashboard design guidance; runnable color-palette validator
Custom Skill Locations
.claude/skills/<name>/ Project skills (auto-loaded as plugins)
~/.claude/skills/<name>/ Personal skills
Nested .claude/skills Nested skill dirs load; clashes show as <dir>:<name>
Nested .claude/ priority Agent/workflow/output-style closest to cwd wins on collision
Stacked invocation Chain up to 5 skills: /skill-a /skill-b do XYZ
Skill Frontmatter
description Auto-invocation trigger
allowed-tools Skip permission prompts
disallowed-tools Remove tools from model while skill is active
model Override model for skill
effort Override effort level
context: fork Run in background subagent by default; background: false to opt out
$ARGUMENTS User input placeholder
${CLAUDE_SKILL_DIR} Skill's own directory
!`cmd` Dynamic context injection
bin/ Plugin ships executables
keep-coding-instructions Frontmatter for plugin output styles
monitors Plugin background monitors (auto-arm on session/skill)
Built-in Agents
Explore Fast read-only (inherits session model, capped at opus)
Plan Research for plan mode
General Full tools, complex tasks
Bash Terminal separate context
Workflow Dynamic multi-agent orchestration (opt-in); /workflows to view runs
Nesting depth Sub-agents nest up to depth 3; set CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH=1 to disable
Agent Frontmatter
permissionMode default/acceptEdits/plan/dontAsk/bypass
isolation: worktree Run in git worktree
memory: user|project Persistent memory
background: true Background task; non-teammate spawns default to bg in interactive
maxTurns Limit agentic turns; partial output + SendMessage hint when reached NEW
SendMessage Resume agents; ListAgents incl. teammates; bare-name delivery; RC by name; refuses oversized/burst; notify_when_idle
initialPrompt Auto-submit first turn
subagent_type: fork Inherit full conversation + prompt cache; on by default
⚙️ CONFIG & ENV
Config Files
~/.claude/settings.json User settings
.claude/settings.json Project (shared)
.claude/settings.local.json Local only
~/.claude.json OAuth, MCP, state
.mcp.json Project MCP servers
Key Settings
modelOverrides Map model picker → custom IDs
worktree.sparsePaths Sparse checkout dirs
skillOverrides Control skill visibility: off/user-invocable-only/name-only
disableAllHooks Disable all hooks via settings.json / managed settings
fallbackModel Up to 3 fallback models tried in order when primary is overloaded
deny: tool-name glob * denies all; Tool(param:value) matches; Write/Glob/NotebookEdit→Edit/Read; dir/** cwd-only in hooks
disableBundledSkills Hide bundled skills, workflows, and built-in slash commands from model
sandbox.credentials Block credentials; mask, extract, JWT maskClaims, AWS SigV4; needs tlsTerminate
sandbox.network.strictAllowlist Deny non-allowlisted hosts for sandboxed commands without prompting
disableAutoMode Disable auto mode in settings.json
"owner/*" marketplaces Wildcards & bare URLs in strict/blocked; allowed/additional aliases; GitLab repos
Concise output style Built-in style: leads with results, skips preamble; select in /config Output style
keybindingFlavor readline = Bash word keys (Ctrl+W, Alt+F/D, Ctrl/Option+→); classic (default)
modelPicker Curate /model picker with ordered, labeled models; append or replace built-in lineup NEW
promptCacheTtl / subagentPromptCacheTtl 1-hour prompt cache on main conv; subagents at 5 min (API-key/cloud) NEW
modelPricing Org contracted per-model rates + discount for /cost, status line, telemetry NEW
feedbackDrafts SendFeedback tool drafts feedback for /feedback review; false to disable NEW
Key Env Vars
ANTHROPIC_API_KEY API key
ANTHROPIC_MODEL Forces model; /model picks don't persist; org restrictions can override
ANTHROPIC_DEFAULT_MODEL Set initial model for new sessions; /model picks persist across restarts
CLAUDE_CODE_EFFORT_LEVEL low/med/high
MAX_THINKING_TOKENS 0=off; disables thinking on models that think by default
CLAUDE_EFFORT Current effort level in hooks and Bash tool
CLAUDE_PROJECT_DIR Project dir passed to MCP stdio servers and hooks env
CLAUDE_CODE_WORKFLOWS Enable Workflow tool for multi-agent orchestration
CLAUDE_CODE_SUBAGENT_MODEL Set model for subagents and agent-team teammates
CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS Cap on concurrently-running subagents (default 20)
CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH Nested subagent spawning; default depth 3; set 1 to disable
CLAUDE_CODE_DISABLE_1M_CONTEXT Hold 1M-window models to 200K via auto-compaction
Hooks
PreToolUse Before tool executes
PostToolUse After tool executes (duration_ms; can replace output)
Notification When Claude sends notification; agent_needs_input / agent_completed from bg agents
Stop When Claude finishes response (background_tasks, session_crons)
SubagentStop When subagent finishes (background_tasks, session_crons)
mcp_tool type Invoke MCP tool directly from hook
args: string[] Hook exec form — spawn directly without shell
continueOnBlock PostToolUse: feed rejection reason back, continue turn
hookSpecificOutput.additionalContext Stop/SubagentStop: give Claude feedback, continue turn
SessionStart Run on session start/resume; source="fork" for forks; set title, reload skills
ConfigChange Fire when settings files change (hot-reload)
DirectoryAdded Fires after /add-dir or SDK register_repo_root registers new working dir