Claude Code cheat sheet: commands, flags, shortcuts, and config

Claude Code has outgrown the handful of commands most cheat sheets repeat. This page keeps the pieces that affect daily work in one scannable reference, with working syntax and the boundary conditions that stop a shortcut becoming a surprise.

By the Continuum team. We build a workbench that runs Claude Code, Codex, and their peers, so the model rates quoted here are the ones our own cost analytics ship with.

The short version

Launch with claude, resume with -c or --resume, isolate a branch with -w, and automate with -p. Inside a session, use /context before the window gets crowded, /compact to preserve one workstream, /clear between unrelated tasks, /plan before a large change, and /usage to inspect tokens and limits. Configuration is split across CLAUDE.md, settings files, skills, hooks, MCP server definitions, and permission rules; each solves a different problem.

What you need to know
  • claude -w name is the fastest safe start for parallel work; claude -p is the automation surface.
  • /clear, /compact, and /resume do different jobs. Do not use them interchangeably.
  • Use CLAUDE.md for facts, skills for procedures, hooks for invariants, and settings for policy.
  • Permission modes set the baseline; allow, ask, and deny rules handle exceptions.
  • MCP credentials define the real reach of an MCP server. A read-only prompt does not make a write credential read-only.
  • On subscriptions, token cost maps to usage limits rather than an invoice. On API billing, JSON output reports invocation cost.

Start, stop, resume, and branch

The launch form decides the session history, working directory, isolation, and whether a human interface exists. These are the forms worth memorising.

Core CLI forms. Checked against the Claude Code CLI reference, August 2026.

CommandWhat it doesUse it when
claudeStart an interactive session in the current directoryOrdinary work
claude "task"Start interactively with an initial promptYou know the first instruction
claude -cContinue the most recent session associated with this directoryReturning to the last workstream
claude --resumeOpen the local session pickerSeveral sessions exist
claude --resume auth-refactorResume a named session directlyStable, named workstreams
claude -n auth-refactorName the session at launchYou intend to resume it
claude --continue --fork-sessionCopy the latest conversation to a new session IDTrying another approach without changing the original transcript
claude -w feature-authCreate an isolated checkout and branch under .claude/worktrees/Parallel or risky code changes
claude --bg "task"Start a supervised background session and return immediatelyWork that should continue without occupying the terminal
claude agentsOpen agent view for background sessionsDispatching and monitoring several sessions
claude -p "task"Run non-interactively, print the result, and exitScripts and CI
claude --cloud "task"Create a Claude Code web sessionThe task should outlive the local process
claude --teleportPull a web session and its branch into the terminalContinuing cloud work locally
claude remote-controlExpose a local agent through outbound HTTPS to Claude.ai or mobileSteering your own machine remotely

CLI flags by job

Flags below are grouped by the decision they change. The official reference includes plan-, platform-, and version-specific options beyond this operational set; claude --help also does not list every supported flag.

Session, model, context, and tool flags.

FlagEffectExample
--modelSelect an alias or full model ID for this sessionclaude --model sonnet
--effortSet reasoning effort for the sessionclaude --effort high
--permission-modeStart in default, acceptEdits, plan, auto, dontAsk, or bypassPermissionsclaude --permission-mode plan
--add-dirGrant access to more working directories; most configuration there is not discoveredclaude --add-dir ../shared
--worktree, -wStart in an isolated git worktree; accepts a name, PR number, or PR URLclaude -w #418
--name, -nSet a resumable display nameclaude -n payments-fix
--continue, -cResume the latest session for this directoryclaude -c
--resumeResume by picker, name, or session IDclaude --resume payments-fix
--fork-sessionCreate a new transcript from resumed historyclaude -c --fork-session
--autocompactOverride the auto-compact window for one sessionclaude --autocompact 500k
--bareSkip CLAUDE.md, auto memory, hooks, skills, plugins, and MCP discoveryclaude --bare -p "summarise README.md"
--settingsOverlay a settings file or inline JSON for this invocationclaude --settings ./ci-settings.json
--allowedToolsPre-approve matching tools; does not remove other tools--allowedTools "Read" "Bash(git diff *)"
--disallowedToolsDeny matching tools for this invocation--disallowedTools "Write" "Edit"
--toolsRestrict the built-in tool set Claude can see--tools "Read,Grep,Glob"
--dangerously-skip-permissionsEnter bypass mode; intended only for an isolated container or VMclaude --dangerously-skip-permissions
--allow-dangerously-skip-permissionsAdd bypass mode to the mode cycle without selecting it--permission-mode plan --allow-dangerously-skip-permissions
--mcp-configLoad MCP definitions from JSON files or stringsclaude --mcp-config ./mcp.json
--strict-mcp-configIgnore every MCP source except the supplied config--strict-mcp-config --mcp-config ./ci-mcp.json
--agent / --agentsSelect a custom subagent or define subagents inline as JSONclaude --agent reviewer
--chrome / --no-chromeEnable or disable the Chrome integrationclaude --chrome
--append-system-promptKeep the default prompt and add instructions--append-system-prompt "Return file:line evidence"
--system-promptReplace the default prompt, including its tool guidance--system-prompt "You are a release-note writer"

Non-interactive and CI flags.

FlagEffectExample
--print, -pPrint a response without the interactive UIclaude -p "review this diff"
--output-formatReturn text, json, or newline-delimited stream-json--output-format json
--input-formatRead text or stream-json input--input-format stream-json
--json-schemaValidate the final structured output against JSON Schema--json-schema "{...}"
--max-turnsStop after a bounded number of agent turns--max-turns 6
--max-budget-usdCap API spend, including subagents, in print mode--max-budget-usd 3.00
--no-session-persistenceDo not save this print-mode transcript--no-session-persistence
--verboseShow full turn-by-turn output; required for partial stream events--output-format stream-json --verbose
--include-partial-messagesInclude streaming token deltas--verbose --include-partial-messages
--include-hook-eventsInclude hook lifecycle events in stream JSON--include-hook-events
A bounded, machine-readable review run.
git diff main...HEAD | claude -p "Report only correctness bugs as JSON." --permission-mode dontAsk --allowedTools "Read" "Grep" "Glob" --output-format json --max-turns 8 --max-budget-usd 2.00

Slash commands that change the session

Type / to filter everything available in your installed version. The menu includes built-ins, bundled skills, your own skills, plugins, and MCP prompts, so the exact list is configuration-dependent.

Context, session, and navigation commands.

CommandUse
/context [all]Show what consumes the context window and where it is overloaded
/compact [focus]Replace history with a focused summary and continue the same conversation
/clear [name]Start empty context while preserving the old session for resume
/resume [name]Switch to a saved local conversation
/rename nameGive the current session a stable, resumable name
/branch [name]Copy the conversation into a new session and leave the original unchanged
/rewindRestore conversation, code checkpoints, or both
/export [file]Save the conversation as readable plain text
/cd pathMove the session and load the new directory context
/add-dir pathGrant another working directory without moving
/desktopSave and continue this session in the desktop app
/remote-controlMake the local session reachable from Claude.ai or mobile
/teleportPull a web session and branch into this terminal
/tasksInspect background Bash calls and subagents in this session
/btw questionAsk a side question without adding it to the main conversation

Configuration, inspection, and work commands.

CommandUse
/plan [task]Enter read-only plan mode and optionally start the task
/permissionsInspect or edit allow, ask, deny, and directory rules
/model [model]Switch model; use arrow keys in the picker to adjust effort
/effort [level]Set reasoning effort or reset it to auto
/usageShow session tokens or cost, subscription windows, and activity
/memoryList and edit CLAUDE.md files and auto memory
/hooksInspect hooks by lifecycle event
/mcpInspect, authenticate, reconnect, enable, or disable MCP servers
/skillsList skills and inspect their token footprint
/reload-skillsRe-scan skills added or changed during the session
/config key=valueChange supported settings without opening the UI
/doctorDiagnose installation, config, hook, MCP, plugin, and memory problems
/diffReview the current git diff and per-turn diffs
/code-review [level] [--fix]Run a fresh review subagent against a diff, branch, path, or PR
/sandboxInspect or toggle the OS-level Bash sandbox
/run / /verifyBuild and exercise the app instead of stopping at static checks
/initGenerate an initial CLAUDE.md from the repository
/helpShow commands available in this installation

Keyboard shortcuts

General controls. Terminal mappings can override these.

ShortcutActionDetail
EscInterruptStops the current response or tool call; completed work stays
Esc EscRewind or summariseOpens the checkpoint selector
Ctrl+CCancel input or generationStandard interrupt
Ctrl+DExitEOF from an empty prompt
Ctrl+OToggle transcript viewerExpands detailed tool and MCP activity
Ctrl+RReverse history searchUse Ctrl+S inside search to change scope
Ctrl+BBackground a taskPress twice under tmux
Ctrl+TToggle task listShows work in the terminal status area
Ctrl+GOpen external editorEdits the prompt or proposed plan
Ctrl+LRedrawRepairs a garbled terminal without clearing input
Ctrl+V / Cmd+VPaste imageTerminal-dependent clipboard support
Shift+TabCycle permission modesDefault cycle is Manual, Accept Edits, Plan
Option+P / Alt+PSwitch modelDoes not clear the typed prompt
Option+T / Alt+TToggle extended thinkingAvailability depends on model and version
Option+O / Alt+OToggle fast modeWhere the account and model support it
Ctrl+X Ctrl+KKill background subagentsPress twice within three seconds to confirm

Prompt editing and multiline input.

ShortcutAction
Ctrl+A / Ctrl+EMove to start / end of the current line
Ctrl+K / Ctrl+UDelete to end / start of line
Ctrl+WDelete the previous word
Ctrl+YPaste text deleted by the readline controls
Alt+B / Alt+FMove backward / forward one word
\ then EnterInsert a newline in every terminal
Shift+EnterInsert a newline in supported terminals; run /terminal-setup elsewhere
Ctrl+JInsert a newline without terminal configuration
! at an empty promptEnter direct shell mode; command and output enter context
@Reference files and directories with autocomplete
/Open and filter commands and skills

Permission modes and rules

The six modes as of August 2026.

ModeRuns without askingUse for
default / manualReads and the built-in read-only command setSensitive or unfamiliar work
acceptEditsReads, file edits, and common local filesystem commandsNormal implementation in a reviewed branch
planRead-only explorationArchitecture and large changes before editing
autoActions approved by a background safety classifierLong interactive tasks with fewer prompts
dontAskOnly read-only operations and explicitly allowed toolsLocked-down CI
bypassPermissionsEverythingIsolated containers and VMs only

Rules use Tool(specifier). Claude Code evaluates deny, then ask, then allow; a more specific allow never overrides a broad deny.

.claude/settings.json: a small team baseline.
{
  "permissions": {
    "defaultMode": "plan",
    "allow": [
      "Bash(npm test *)",
      "Bash(npm run lint *)",
      "Bash(git diff *)",
      "Read(src/**)",
      "Edit(src/**)"
    ],
    "ask": ["Bash(git push *)"],
    "deny": [
      "Read(.env)",
      "Read(.env.*)",
      "Read(~/.ssh/**)",
      "Bash(rm -rf *)",
      "Bash(git reset --hard *)"
    ]
  }
}

CLAUDE.md, settings, rules, skills, and auto memory

Put each instruction in the mechanism that matches its lifetime.

MechanismLocationLoadsUse for
Project memory./CLAUDE.md or ./.claude/CLAUDE.mdEvery session in the projectCommands, conventions, traps
Personal project memory./CLAUDE.local.mdEvery local session; gitignore itYour non-shared notes
User memory~/.claude/CLAUDE.mdEvery projectPreferences that are genuinely universal
Path rules.claude/rules/*.mdAt launch or when a paths: glob matchesPart-of-tree constraints
Skills.claude/skills/name/SKILL.mdOnly when invoked or selectedProcedures, checklists, long reference material
Auto memory~/.claude/projects/.../memory/Index at launch, topic files on demandLearnings Claude records from corrections
Team settings.claude/settings.jsonConfiguration layer; commit itPermissions, hooks, model, sandbox, environment
Local settings.claude/settings.local.jsonHigher precedence; gitignore itPersonal overrides
MCP project config.mcp.jsonAfter workspace approvalShared external tools
A useful CLAUDE.md is short and checkable.
# Commands

- `pnpm test path/to/file.test.ts` runs one test file.
- `pnpm lint --fix` must pass before handoff.

# Conventions

- Named exports only.
- Store money as integer minor units.
- Never edit `src/generated/`.

# Traps

- Integration tests require `docker compose up -d db`.

Hooks: events and a working formatter hook

Hooks run deterministic code at lifecycle events. Use them for an invariant that must hold regardless of whether the model remembers the instruction.

The hook events used most often.

EventWhenTypical use
SessionStartA session starts or resumesLoad environment or context
UserPromptSubmitBefore Claude receives a promptValidate or enrich input
PreToolUseBefore a matching tool executesBlock dangerous commands
PermissionRequestA call needs a decisionExternal approval policy
PostToolUseAfter a tool succeedsFormat edited files
PostToolUseFailureAfter a tool failsCollect diagnostics
SubagentStart / SubagentStopA delegated worker starts or finishesAudit parallel work
StopClaude is about to finish a turnRun a final verification gate
PreCompact / PostCompactAround context compactionPersist and restore state
InstructionsLoadedA CLAUDE.md or rule enters contextDebug memory discovery
WorktreeCreate / WorktreeRemoveWorktree lifecycleReplace git setup or cleanup
SessionEndThe session terminatesCleanup and telemetry
.claude/settings.json: format JS and TS after an edit.
{
  "hooks": {
    "PostToolUse": [
      {
        "matcher": "Edit|Write",
        "hooks": [
          {
            "type": "command",
            "command": "jq -r .tool_input.file_path | xargs npx prettier --write"
          }
        ]
      }
    ]
  }
}

MCP server commands and scopes

Add and manage MCP servers without hand-editing JSON.

CommandResult
claude mcp add --transport http sentry https://mcp.sentry.dev/mcpAdd a remote HTTP server at local scope
claude mcp add --transport http shared --scope project https://example.com/mcpWrite a shared server to .mcp.json
claude mcp add --transport http hub --scope user https://example.com/mcpAdd a private server for every project
claude mcp add --env KEY=value --transport stdio local -- npx -y serverAdd a local process; -- separates Claude flags from server args
claude mcp add-json events "{...}"Add a server from a JSON definition
claude mcp listList servers and connection health
claude mcp get nameShow one server, scope, status, and failure detail
claude mcp remove nameRemove the server from the selected scope
/mcpAuthenticate, reconnect, enable, or disable from a session

MCP scopes.

ScopeStored inShared?
local (default)~/.claude.json, keyed to this projectNo
project.mcp.json at the repo rootYes; commit it
user~/.claude.jsonNo; available to all your projects

Worktrees, subagents, and parallel work

Three kinds of parallelism, three different boundaries.

MechanismContextFilesUse when
SubagentFresh window; returns a summarySame checkout unless isolatedResearch or review would flood the main context
Background sessionIndependent conversationShould use its own worktree for editsYou want to inspect and steer it separately
Worktree sessionIndependent conversationSeparate checkout and branchTwo code-changing sessions must not collide
Two isolated sessions and cleanup.
claude -w feature-auth
claude -w fix-timeout

git worktree list
git worktree remove .claude/worktrees/ci-review
git worktree prune

A worktree shares git history, refs, remotes, and objects with the main checkout. It does not share tracked file contents, untracked files, staged changes, or dependency installs. Put required gitignored setup files in .worktreeinclude; tracked files are never copied by that mechanism.

.claude/agents/reviewer.md: an isolated reviewer.
---
name: reviewer
description: Review the current branch for correctness bugs.
tools: Read, Grep, Glob, Bash
model: sonnet
isolation: worktree
---

Review the diff against the merge base. Report only reproducible correctness or security findings with file and line evidence.

Context, tokens, usage, and cost

The controls that affect context and spend.

ControlWhat it changesRule of thumb
/contextShows the current context compositionRun it when Claude rereads files or forgets constraints
/compact focusSummarises one continuing workstreamUse before forced automatic compaction
/clearStarts an empty conversationUse between unrelated tasks and after repeated failed corrections
SubagentKeeps noisy exploration in another windowDelegate searches, logs, and independent review
/modelChanges capability, latency, and limit burnUse the least expensive model reliable for the task
/effortChanges reasoning depth on supported modelsRaise for architecture; lower for mechanical work
/usageShows tokens or API cost, subscription windows, and activityCheck before another large parallel run
--max-turnsBounds automation lengthEvery CI call should have one
--max-budget-usdCaps API spend in print modePair it with max turns
--output-format jsonReturns usage metadata and total_cost_usdRecord it per CI invocation

Input is not paid once. Each turn includes the conversation, instructions, tools, relevant files, and recent output again, with prompt caching reducing the price of stable prefixes. Large MCP catalogs, verbose memory files, unbounded logs, and long correction chains therefore have a recurring cost.

Questions people ask

/context is the best diagnostic command because it shows why a session is becoming slow or forgetful. For daily navigation, name sessions with /rename and return with claude --resume <name>.

Run claude --permission-mode plan, press Shift+Tab until Plan appears, or prefix one task with /plan. Claude can read and explore but does not edit source until you approve the plan or change mode.

Use claude -p "task". Add --output-format json, --permission-mode dontAsk with explicit allowed tools, and --max-turns plus --max-budget-usd to bound the run.

Press Escape to interrupt the current response or tool call while preserving completed work. Ctrl+C cancels input or generation, and Ctrl+D exits from an empty prompt.

/clear starts a new empty conversation and preserves the old one for resume. /compact keeps the current conversation but replaces earlier history with a summary.

Project instructions live in CLAUDE.md, policy in .claude/settings.json, personal overrides in settings.local.json, shared MCP servers in .mcp.json, procedures in .claude/skills/, and lifecycle actions in hooks.

Start each code-changing session with claude --worktree <name> or claude -w <name>. Every session gets a separate checkout and branch under .claude/worktrees/.

Run /usage (/cost is an alias). API users see estimated session cost and can collect total_cost_usd from JSON output. Subscription users primarily see rolling usage windows and activity.

Sources

Every figure above was read from these pages on August 2026. Vendors reprice without notice; if you find a stale number, tell us.

  1. Claude Code CLI reference
  2. Claude Code commands reference
  3. Claude Code interactive mode and shortcuts
  4. Claude Code permission modes
  5. Claude Code hooks reference
  6. Claude Code MCP documentation
  7. Claude Code memory documentation
  8. Claude Code worktrees documentation
  9. Claude Code cost management
Try it

Every session,
one view.

Continuum adds cross-session quota and cost views around the Claude Code CLI you already run.

free app · your subscriptions · local-first