Skip to content

Claude Code Cheatsheet

Last updated: May 2025 · Official Docs

A PDF version of this cheat sheet can be found here.

🚀 CLI — Session Management

Commands run from your terminal to start and manage sessions.

CommandDescriptionExample
claudeStart an interactive sessionclaude
claude "query"Start a session with an initial promptclaude "explain this project"
claude -p "query"Print response and exit (non-interactive)claude -p "explain this function"
cat file | claude -p "query"Process piped contentcat logs.txt | claude -p "explain"
claude -cContinue the most recent conversationclaude -c
claude -r "<session>" "query"Resume a session by ID or nameclaude -r "auth-refactor" "Finish this PR"
claude -n "name"Name the current sessionclaude -n "my-feature-work"
claude updateUpdate to the latest versionclaude update
claude install [version]Install a specific version (stable, latest, or 2.x.x)claude install stable

🔐 CLI — Authentication

CommandDescriptionExample
claude auth loginSign in to your Anthropic accountclaude auth login --console
claude auth logoutLog out from your Anthropic accountclaude auth logout
claude auth statusShow authentication statusclaude auth status --text
claude setup-tokenGenerate a long-lived OAuth token for CI/scriptsclaude setup-token
claude auth login --ssoForce SSO authenticationclaude auth login --sso

⚙️ CLI — Configuration Flags

Pass these flags when launching Claude Code to customize behavior.

FlagDescriptionExample
--model <model>Set model for the session (sonnet, opus, or full name)claude --model claude-opus-4-6
--effort <level>Set effort level: low, medium, high, xhigh, maxclaude --effort high
--permission-mode <mode>Start in a permission mode: default, acceptEdits, plan, auto, bypassPermissionsclaude --permission-mode plan
--add-dir <path>Add additional working directoriesclaude --add-dir ../apps ../lib
--append-system-prompt "..."Append custom text to the system promptclaude --append-system-prompt "Always use TypeScript"
--system-prompt "..."Replace the entire system promptclaude --system-prompt "You are a Python expert"
--system-prompt-file <file>Load system prompt from a fileclaude --system-prompt-file ./custom-prompt.txt
--tools "..."Restrict which tools Claude can useclaude --tools "Bash,Edit,Read"
--allowedTools "..."Tools that run without a permission prompt"Bash(git log *)" "Read"
--disallowedTools "..."Tools that are denied or removed"Bash(rm *)" "Edit"
--mcp-config <file>Load MCP servers from a JSON fileclaude --mcp-config ./mcp.json
--plugin-dir <path>Load a plugin for this sessionclaude --plugin-dir ./my-plugin
--bareMinimal mode — skips hooks, skills, MCP, CLAUDE.mdclaude --bare -p "query"
--debugEnable debug mode (optional category filter)claude --debug "api,mcp"
--verboseShow full turn-by-turn outputclaude --verbose
--max-turns <n>Limit agentic turns (print mode only)claude -p --max-turns 3 "query"
--max-budget-usd <n>Budget cap in dollars (print mode only)claude -p --max-budget-usd 5.00 "query"
--bgStart as a background agent and return immediatelyclaude --bg "investigate the flaky test"
--output-format <fmt>Output format: text, json, stream-jsonclaude -p "query" --output-format json
--worktree, -wStart in an isolated git worktreeclaude -w feature-auth
--chromeEnable Chrome browser integrationclaude --chrome
--version, -vOutput the version numberclaude -v

🔧 Configuration (Inside Session)

Use these slash commands to configure Claude from within an active session.

CommandDescription
/configOpen Settings UI (theme, model, output style, etc.). Alias: /settings
/model [model]Select or change the AI model interactively
/effort [level|auto]Set effort level (low, medium, high, xhigh, max) or use the interactive slider
/themeChange the color theme (light, dark, daltonized, ANSI, custom)
/permissionsManage allow/ask/deny rules for tools. Alias: /allowed-tools
/hooksView hook configurations for tool events
/mcpManage MCP server connections and OAuth
/agentsManage subagent configurations
/terminal-setupConfigure Shift+Enter and other terminal keybindings
/keybindingsOpen or create your keybindings configuration file
/statuslineConfigure the Claude Code status line

📄 Context Management

Commands to understand and manage the context window.

CommandDescription
/context [all]Visualize context usage as a colored grid with optimization tips
/compact [instructions]Summarize the conversation to free up context. Pass focus instructions: /compact keep only the plan and diff
/clear [name]Start a fresh conversation (previous stays in /resume). Aliases: /reset, /new
/btw <question>Ask a side question without adding it to conversation history

ℹ️ Information & Status

CommandDescription
/helpShow help and all available commands
/doctorDiagnose installation, settings, MCP servers, and context usage
/statusShow version, model, account, and connectivity (works while Claude is responding)
/usageShow session cost, plan limits, and activity stats. Aliases: /cost, /stats
/skillsList available skills (press t to sort by token count)
/memoryEdit CLAUDE.md memory files and manage auto-memory
/contextShow current context window usage
/release-notesView the changelog in an interactive version picker
/insightsAnalyze your Claude Code sessions for patterns and friction points

🗄️ Memory & Project Setup

CommandDescription
/initInitialize project with a CLAUDE.md guide
/memoryEdit CLAUDE.md files, enable/disable auto-memory, view entries
/team-onboardingGenerate a team onboarding guide from your usage history

CLAUDE.md locations:

ScopePath
Global (personal)~/.claude/CLAUDE.md
Project.claude/CLAUDE.md or CLAUDE.md in repo root

🔀 Session Navigation

CommandDescription
/resume [session]Resume a conversation by ID or name. Alias: /continue
/branch [name]Fork the current conversation at this point. Alias: /fork
/rename [name]Rename the current session
/clearStart a new conversation with empty context
/export [filename]Export the current conversation as plain text
/rewindRoll back code and conversation to a checkpoint. Aliases: /checkpoint, /undo

📋 Workflow Commands (Slash)

Commands to manage and accelerate your development workflow.

CommandDescription
/plan [description]Enter plan mode. Pass a description to start immediately
/diffOpen an interactive diff viewer for uncommitted changes and per-turn diffs
/copy [N]Copy the last assistant response to clipboard. Pass N to copy the Nth-latest
/goal [condition]Set a persistent goal; Claude works across turns until it's met
/background [prompt]Detach session to run as a background agent. Alias: /bg

⚡ Parallel Work & Agents

CommandDescription
/agentsOpen the agent manager to monitor and dispatch parallel sessions
/tasksList and manage background tasks. Alias: /bashes
/batch <instruction>[Skill] Break a large change into parallel units, each running in its own worktree
/backgroundDetach the current session to keep running in the background. Alias: /bg
claude agentsOpen agent view from the terminal (CLI command)
claude attach <id>Attach to a background session in this terminal
claude stop <id>Stop a background session
claude logs <id>Print recent output from a background session
claude respawn <id>Restart a background session with its conversation intact
claude rm <id>Remove a background session from the list

🔍 Code Quality (Bundled Skills)

These are built-in skills invoked with / commands.

CommandDescription
/review [PR]Review a pull request locally in the current session
/security-reviewAnalyze pending changes for security vulnerabilities
/simplify [focus][Skill] Review recently changed files for reuse, quality, and efficiency issues, then fix them
/ultrareview [PR]Deep multi-agent cloud-based code review
/debug [description][Skill] Enable debug logging and troubleshoot session issues
/fewer-permission-prompts[Skill] Scan transcripts and add allowlist rules to reduce permission prompts

🛠️ Debugging & Diagnostics

CommandDescription
/doctorRun an automated check of installation, settings, MCP, and context
claude doctorSame as /doctor but from the shell (use when claude won't start)
/debug [description]Enable debug logging mid-session
/heapdumpWrite a JS heap snapshot to ~/Desktop for memory diagnostics
/feedback [report]Submit feedback or bug reports to Anthropic. Alias: /bug
claude --debug "api,mcp"Start with debug output (category-filtered)
claude --debug-file <path>Write debug logs to a specific file

🧰 MCP & Plugins

CommandDescription
/mcpManage MCP server connections and OAuth
claude mcpConfigure MCP servers from the CLI
/pluginManage Claude Code plugins
claude plugin install <name>Install a plugin
/reload-pluginsReload all active plugins without restarting
--mcp-config <file>Load MCP servers from a JSON file at launch
--strict-mcp-configUse only MCP servers from --mcp-config

🌐 Remote & Web

CommandDescription
/remote-controlMake this session available for remote control from claude.ai. Alias: /rc
claude remote-controlStart a Remote Control server (CLI)
claude --remote "task"Create a new web session on claude.ai
/teleportPull a Claude Code web session into this terminal. Alias: /tp
/autofix-pr [prompt]Spawn a web session that watches the current PR and pushes fixes
/desktopContinue this session in the Claude Code Desktop app

⌨️ Keyboard Shortcuts (Interactive Mode)

ShortcutAction
Ctrl+CCancel current operation
Shift+TabCycle through permission modes (default → plan → auto → bypassPermissions)
Ctrl+RSearch prompt history
/ Navigate prompt history
TabAutocomplete skill/command name

📁 Key File Locations

File / DirectoryPurpose
CLAUDE.md (project root)Project-level memory and instructions
~/.claude/CLAUDE.mdPersonal global memory
.claude/settings.jsonProject settings
.claude/settings.local.jsonLocal (gitignored) project settings
~/.claude/settings.jsonUser-level settings
~/.claude/skills/<name>/SKILL.mdPersonal custom skills
.claude/skills/<name>/SKILL.mdProject-specific custom skills
~/.claude/themes/Custom themes

💡 Quick Tips

  • Type / in a session to see all available commands with live filtering.
  • Use Shift+Tab to cycle permission modes without restarting.
  • /compact with instructions (e.g., /compact keep only the plan) lets you surgically preserve what matters.
  • CLAUDE.md is read at every session start — keep it focused and under 500 lines.
  • Use disable-model-invocation: true in a skill's frontmatter to require manual /skill-name invocation.
  • claude -p (print mode) is ideal for scripting and CI pipelines.
  • Background sessions (--bg) let you run long tasks without tying up a terminal.

Sources: CLI Reference · Commands · Skills · Settings