Claude Code Cheat Sheet

Glossary

Session — One run of claude in a directory, from launch to exit. Each session has its own conversation history; project memory persists across sessions.

Context window — The total text the model can hold in mind at once. When it fills up, older content is compacted or dropped.

Token — The unit models use to measure text (~¾ of a word). Usage limits and billing are counted in tokens.

CLAUDE.md — A markdown file Claude reads at every session start. Holds your project’s conventions, commands, and constraints.

Plan Mode — Read-only mode: Claude explores and proposes but won’t edit files or run commands.

Accept Edits — Auto-approves file edits for the session; shell commands still prompt for approval.

Permissions — Rules governing which actions Claude can take without asking. By default it asks for everything. With “accept edits on” only the file can be changed by Claude without approbation, every tools use needs user approval (unless approved in /permissions).

Tool — A capability Claude can invoke: reading a file, editing, running bash, searching the web. Each call appears in the transcript.

MCP — Model Context Protocol — an open standard for plugging external systems (GitHub, Jira, databases) into Claude as tools.

Subagent — A secondary Claude instance spawned for a focused subtask (tests, search, review) in its own isolated context.

Hook — A shell command that runs automatically at a defined point in Claude’s lifecycle (before a tool, after an edit, on session start).

Skill — Packaged instructions that teach Claude a specific workflow. Loaded on demand, not always in context.

Slash command — Any input starting with /. Built-in ones control the session; custom ones are prompt templates in .claude/skills/.

When and what to use? Learn ⇧Tab, ⌥P, ⌥T, and Ctrl O first — they save the most time.
Context: Main chat Key: Fast, muscle-memory driven

General Controls

Shortcut Action
Ctrl C Cancel input/generation
Ctrl D Exit session
Ctrl L Clear prompt input
Ctrl O Toggle transcript viewer / focus view
Ctrl R Reverse search history
Ctrl G Open prompt in editor
Ctrl X Ctrl E Open in editor (alias)
Ctrl B Background running task
Ctrl T Toggle task list
Ctrl V Paste image ([Image #N] chip)
Ctrl X Ctrl K Kill background agents
Esc Esc Rewind or summarize

Mode Switching

Shortcut Action
⇧Tab Cycle permission modes
⌥P Switch model
⌥T Toggle thinking
⌥O Toggle fast mode

Input

Shortcut Action
\ Enter Newline (quick)
Ctrl J Newline (control seq)

Prefixes

Prefix Action
/ Slash command
! Direct bash
@ File mention + autocomplete

Transcript / Focus View (Ctrl O)

Shortcut Action
Ctrl E Toggle show all
Q / Ctrl C / Esc Exit transcript
When and what to use? When Claude needs to connect to external systems — databases, APIs, Jira, Slack, Google Drive. Project scope (.mcp.json) shares with team; local scope is personal only.
Context: Injects external data Key: Standardized integration protocol

Add Servers

Flag Transport
--transport http Remote HTTP (recommended)
--transport stdio Local process
--transport sse Remote SSE

Scopes

Scope Location
Local ~/.claude.json (you only)
Project .mcp.json (shared/VCS)
User ~/.claude.json (global)

Manage

Command Action
/mcp Interactive UI
claude mcp list List all servers
claude mcp serve Run Claude Code itself as a stdio MCP server

Limits & Features

Feature Detail
Elicitation Servers can request user input mid-task
2KB each Tool descriptions and server instructions are each truncated at 2KB
maxResultSizeChars _meta["anthropic/maxResultSizeChars"] raises per-tool text threshold (up to 500K chars)
When and what to use? Specialized commands you invoke manually when you need quick, parameterized shortcuts. Use them when you specifically know you’ll want to trigger something at certain moments. Top 3: /compact, /context, /plan.
Trigger: Manual /command Context: Shared with main chat Key: Fast, user-controlled

Session

Command Action
/clear Clear conversation
/compact [focus] Compact context
/resume Resume/switch session
/rename [name] Name current session
/branch [name] Branch conversation (/fork alias)
/cost Token usage (per-model + cache breakdown)
/context Visualize context (grid)
/diff Interactive diff viewer
/copy [N] Copy last (or Nth) response
/rewind Rewind conv / code checkpoint
/export Export conversation

Config

Command Action
/config Open settings
/model [model] Switch model
/fast [on|off] Toggle fast mode
/theme Change color theme
/permissions View/update permissions
/effort [level] Set effort (low/medium/high/max/auto)
/color [color] Set prompt-bar color
/keybindings Customize keyboard shortcuts
/terminal-setup Configure terminal keybindings

Tools

Command Action
/init Create CLAUDE.md
/memory Edit CLAUDE.md files, toggle auto memory, view entries
/mcp Manage MCP servers
/hooks Manage hooks
/skills List available skills
/agents Manage agent configurations
/chrome Chrome integration
/reload-plugins Hot-reload plugins
/add-dir <path> Add working directory

Special

Command Action
/powerup Interactive feature lessons
/btw <question> Ask a side question without adding to the conversation
/plan [desc] Plan mode (+ auto-start)
/loop [interval] Schedule recurring task
/voice Toggle push-to-talk voice dictation
/doctor Diagnose installation
/stats Usage streaks & prefs
/insights Analyze sessions report
/desktop Continue in Desktop app
/remote-control Bridge to claude.ai/code (/rc)
/usage Plan limits & rate status
/schedule Cloud scheduled tasks
/ultraplan <prompt> Draft a plan in a browser session; auto-creates a default cloud environment if needed
/security-review Security analysis of changes
/help Show help + commands
/feedback Submit feedback (alias: /bug)
/release-notes Interactive version changelog
/stickers Order stickers!
When and what to use? To give Claude persistent instructions across sessions. CLAUDE.md is your “project brain” — it survives compaction and is loaded every session. Use rules for filetype-specific memory.
Context: Always in context, survives compaction Key: Persistent project knowledge

CLAUDE.md Locations

Path Scope
./CLAUDE.md Project (team-shared)
./CLAUDE.local.md Local personal project notes (gitignored)
~/.claude/CLAUDE.md Personal (all projects)
/etc/claude-code/CLAUDE.md Managed policy (Linux/WSL, org-wide)

Rules & Import

Path / Syntax Purpose
.claude/rules/*.md Project rules
~/.claude/rules/*.md User rules
paths: frontmatter Path-specific rules
@path/to/file Import in CLAUDE.md

Auto Memory

Path Detail
~/.claude/projects/<proj>/memory/ MEMORY.md auto-loads at startup (first 25KB or 200 lines); topic files load on demand
When and what to use? Plan mode for safe analysis, worktrees for parallel features, headless for CI.
Context: Varies per workflow Key: Patterns for common tasks

Plan Mode

Command Action
⇧Tab Normal → Auto-Accept → Plan
--permission-mode plan Start in plan mode

Thinking & Effort

Command Action
⌥T Toggle thinking on/off
"ultrathink" Max effort for turn
Ctrl O See thinking (verbose)
/effort ○ low · ◐ medium · ● high · ★ max

Auto Mode Denied

Action Detail
/permissions → Recent Retry denied with R

Git Worktrees

Option Action
--worktree name Isolated branch per feature
isolation: worktree Agent in own worktree
sparsePaths Checkout only needed dirs
workspace.git_worktree Status line JSON: linked worktree path
/batch Auto-creates worktrees

Voice Mode

Option Action
/voice Enable push-to-talk
Space (hold) Record, release to send
20 languages EN, ES, FR, DE, CZ, PL…

Context Management

Option Action
/context Usage + optimization tips
/compact [focus] Compress with focus
Auto-compact ~95% capacity (thrash detection: 3x)
1M context Opus 4.6 (Max/Team/Ent)
CLAUDE.md Survives compaction!

Session Power Moves

Command Action
claude -c Continue last conv
claude -r "name" Resume by name
/btw question Side Q, no context cost

SDK / Headless

Command Action
claude -p "query" Non-interactive
--output-format json Structured output
--max-budget-usd 5 Cost cap
cat file | claude -p Pipe input

Scheduling & Remote

Command Action
/loop 5m msg Recurring task
/rc Remote control (hostname prefix default)
/ultraplan Draft plan in browser, auto-create default cloud env if needed
--remote Web session on claude.ai
⚙️ Config & Env
When and what to use? To customize Claude Code’s behavior globally or per-project. Settings cascade: managed > user > project > local. Env vars override everything.
Context: Loaded at startup Key: Cascading settings hierarchy

Config Files

File Purpose
~/.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
managed-settings.d/ Drop-in policy fragments

Key Settings

Setting Effect
modelOverrides Map model picker → custom IDs
autoMemoryDirectory Custom memory dir
worktree.sparsePaths Sparse checkout dirs
sandbox.failIfUnavailable Exit if sandbox fails
hooks: if Conditional hooks (permission rule syntax)
Monitor tool Stream events from background scripts
PermissionDenied Hook: auto-mode denial
showThinkingSummaries Opt-in (off by default now)
allowedChannelPlugins Admin channel plugin allowlist
hooks: "defer" Pause headless → resume later
disableSkillShellExec Block !`cmd` in skills/plugins
forceRemoteSettingsRefresh Fail-closed: block startup until fresh
refreshInterval Re-run custom status line every N sec

Key Env Vars

Variable Effect
ANTHROPIC_API_KEY API key
ANTHROPIC_MODEL Model override
CLAUDE_CODE_EFFORT_LEVEL low/medium/high/max/auto
MAX_THINKING_TOKENS 0=off
ANTHROPIC_CUSTOM_MODEL_OPTION Custom /model entry
CLAUDE_CODE_SUBPROCESS_ENV_SCRUB Strip creds from Bash, hooks, MCP subprocesses; Linux isolates PID namespace
CLAUDE_CODE_SCRIPT_CAPS JSON caps for specific script invocations when env scrubbing is enabled
CLAUDE_CODE_PERFORCE_MODE Enable Perforce-aware write protection with p4 edit hint
CLAUDE_STREAM_IDLE_TIMEOUT_MS Streaming watchdog (def 90s)
CLAUDE_CODE_NO_FLICKER Alt-screen rendering (=1)
MCP_CONNECTION_NONBLOCKING Skip MCP wait in -p
CLAUDE_CODE_USE_MANTLE Use Mantle for Bedrock (=1)
CLAUDE_CODE_CERT_STORE Comma-separated TLS CA sources: bundled, system (default: both)
CLAUDECODE Detect CC shell (=1)
🔧 Skills
When and what to use? Skills are specialized instructions that may not always be relevant. Use them when you want to sometimes provide your primary agent with a relevant skillset — repeatable SOPs to apply across sessions. Description always loaded; full body loads only when invoked. Survives compaction (5K tokens each, 25K combined).
Trigger: Auto-triggered by AI or manual Context: Shared, progressively loaded Key: Token-efficient, automatic activation

Built-in Skills

Command Action
/simplify Code review (3 parallel agents)
/batch Large parallel changes (5–30 worktrees)
/debug [desc] Troubleshoot from debug log
/loop [interval] Recurring scheduled task
/claude-api Load API + SDK reference

Custom Skill Locations

Path Scope
.claude/skills/<name>/ Project skills
~/.claude/skills/<name>/ Personal skills

Skill Frontmatter

Key Effect
description Auto-invocation trigger
allowed-tools Skip permission prompts
model Override model for skill
effort Override effort level
paths: [globs] Path-specific (YAML list)
context: fork Run in subagent (fresh context)
$ARGUMENTS User input placeholder
${CLAUDE_SKILL_DIR} Skill’s own directory
!`cmd` Dynamic context injection
plugin bin/ Ship executables for Bash tool
🤖 Subagents
When and what to use? Subagents are specialized personas you offload work to — code reviewer, skeptic, testing specialist, architect. Use them to keep your context clean for isolated tasks that don’t need context from others: “run tests on this file”, “refactor this function”. Results summarized back one-way; subagents cannot talk to each other. ⚠ Can burn tokens going down rabbit holes unchecked.
Trigger: Dispatched by user/AI Context: Isolated context (fresh) Key: Independent execution, no context pollution

Built-in Agents

Agent Role
Explore Fast read-only (Haiku)
Plan Research for plan mode
General Full tools, complex tasks
Bash Terminal separate context

Agent Frontmatter Fields

Key Values / Effect
permissionMode default / acceptEdits / plan / dontAsk / bypassPermissions
isolation: worktree Run in git worktree
memory: user|project|local Persistent memory
background: true Background task
maxTurns Limit agentic turns
initialPrompt Auto-submit first turn
SendMessage Resume agents (replaces resume)
@agent-name Mention named subagents
When and what to use? When you need a coordination layer — a lead reviewing output from code agents and deciding what to merge. Teams shine for parallel exploration, competing hypotheses, cross-layer changes. The lead’s context acts as a natural check on scope creep — unlike subagents, teammates don’t go unchecked. Experimental.
Trigger: User requests team creation Context: Independent + peer-to-peer messaging Key: Coordinated parallel work, shared task list

Setup

Setting Action
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS Enable in env or settings.json (=1)

Architecture

Role Description
Team lead Main session: spawns teammates, coordinates work
Teammates Separate Claude instances, each with own context
Task list Shared across team; teammates self-claim pending tasks
Mailbox Direct messaging between any teammates

Display Modes

Mode Detail
in-process All in one terminal; ⇧↓ to cycle teammates
tmux / iTerm2 Split panes, one per teammate
--teammate-mode Override per-session

Coordination

Primitive Effect
message Send to one specific teammate by name
broadcast Send to all teammates (costly — use sparingly)
Plan approval Require teammates to plan before implementing

Quality Hooks

Hook Trigger
TeammateIdle Runs when teammate about to go idle; exit 2 to keep working
TaskCreated Runs on task creation; exit 2 to prevent
TaskCompleted Runs on task completion; exit 2 to block
🖥️ CLI & Flags
When and what to use? For launching, scripting, and composing Claude Code. Key patterns: -p for headless/CI, -c to continue, --remote for web, --max-budget-usd to cap costs.
Context: New or resumed session Key: Unix-composable, scriptable

Core Commands

Command Action
claude Interactive
claude "q" With prompt
claude -p "q" Headless
claude -c Continue last
claude -r "n" Resume
claude update Update

Key Flags

Flag Effect
--model Set model
-w Git worktree
-n / --name Session name
--add-dir Add dir
--agent Use agent
--allowedTools Pre-approve
--allow-dangerously-skip-permissions Add bypassPermissions to ⇧Tab cycle
--output-format text/json/stream-json
--json-schema Structured
--max-turns Limit turns
--max-budget-usd Cost cap
--exclude-dynamic-system-prompt-sections Print mode: improve cross-user prompt caching
--verbose Verbose
--bare Minimal mode (skips hooks/skills/plugins/MCP/auto-memory/CLAUDE.md)
--channels Permission relay / MCP push
--remote Create web session on claude.ai
--remote-control / --rc Interactive session with Remote Control enabled
--effort low/medium/high/max
--permission-mode plan/default/…
--dangerously-skip-permissions Skip all prompts ⚠️
--chrome Chrome
Claude Code - Useful Skills and Tools

Tools

Skills

About LLMs and Agentic AI

The Foundations

Embeddings & Tokenizers

LLM

RAG

Context Engineering

Agents

Claude Code - Reports & Courses

AI Agent Security

AI User Experience

The Evolving Developer Role & Human ↔ AI Collaboration

Books

Math