Claude Code Cheatsheet
Complete reference for Anthropic's agentic coding assistant
Claude Code is an agentic coding tool that lives in your terminal. It understands your codebase, can edit files, run commands, and help you code faster with AI. This cheatsheet covers CLI commands, keyboard shortcuts, configuration, MCP integrations, hooks, subagents, skills, plugins, and best practices.
Commands
Categories
Favorites
Sections
Terminal Native
Lives in your terminal
Codebase Aware
Understands your code
MCP Extensible
50+ integrations
Automation Ready
Hooks & headless mode
npm install -g @anthropic-ai/claude-codeInstall via npm (Node.js 18+)
curl -fsSL https://claude.ai/install.sh | bashInstall via curl (macOS/Linux)
brew install --cask claude-codeInstall via Homebrew (macOS)
irm https://claude.ai/install.ps1 | iexInstall via PowerShell (Windows)
cd your-project && claudeStart Claude Code in project
claude updateUpdate to latest version
claude --versionCheck version
claude --helpShow help
claudeStart interactive REPL session
claude "query"Start with initial prompt
claude -p "query"Print mode - execute and exit
claude -cContinue most recent conversation
claude -c -p "query"Continue in print mode
claude --resume <id> -p "query"Resume specific session
--model sonnetUse Sonnet model (faster)
--model opusUse Opus model (more capable)
--output-format jsonJSON output with metadata
--output-format stream-jsonStream JSON messages
--max-turns 3Limit agentic turns
--verboseEnable verbose logging
claude config listList current configuration
claude config get <key>Check specific setting
claude config set <key> <value>Change a setting
claude config add <key> <value>Add to array settings
claude config remove <key> <value>Remove from array
EscInterrupt/stop Claude
Esc + EscOpen rewind menu (undo changes)
Ctrl+CCancel current operation
Ctrl+DExit Claude Code
Ctrl+RFull output/context
Ctrl+VPaste image
Shift+TabAuto-accept (yolo mode)
Shift+Tab+TabPlan mode
\Line break (backslash + Enter)
Cmd+Esc / Ctrl+EscQuick launch in IDEs
Cmd+Option+K / Alt+Ctrl+KInsert file references
@file.txtReference a file
@./directory/Reference directory
!Bash mode prefix / toggle shell
!commandRun shell command
#noteAdd memory quickly
/helpShow all commands
/clearClear conversation history
/exitExit the REPL
/compact [instructions]Compact conversation with focus
/costShow token usage statistics
/statusView account and system status
/usageShow plan usage and rate limits
/configView/modify configuration
/permissionsView or update permissions
/modelSelect or change AI model
/vimEnter vim editing mode
/terminal-setupInstall Shift+Enter binding
/sandboxEnable sandboxed bash tool
/mcpManage MCP servers and OAuth
/agentsManage custom subagents
/pluginManage plugins
/memoryEdit CLAUDE.md memory files
/initInitialize project with CLAUDE.md
/doctorCheck installation health
/bugReport bugs to Anthropic
/reviewRequest code review
/pr_commentsView pull request comments
/add-dirAdd working directories
/rewindRewind conversation/code
/loginSwitch Anthropic accounts
/logoutSign out
Esc + EscOpen rewind menu
/rewindOpen rewind via slash command
Conversation RewindRestore to previous message, keep code
Code RewindRevert file changes, keep conversation
Full RewindRestore both code and conversation
💡 Every user prompt creates a checkpoint automatically
Bash changes not trackedrm, mv, cp cannot be undone
External changes not trackedManual edits outside Claude
Not version controlUse Git for permanent history
/etc/claude-code/managed-settings.jsonEnterprise (highest priority)
.claude/settings.local.jsonProject local (git-ignored)
.claude/settings.jsonProject shared (team)
~/.claude/settings.jsonUser global (defaults)
~/.claude/CLAUDE.mdGlobal memory file
./CLAUDE.mdProject memory file
.claude/commands/Project slash commands
~/.claude/commands/Personal slash commands
.claude/agents/Project subagents
~/.claude/agents/Personal subagents
.claude/skills/Project skills
~/.claude/skills/Personal skills
.mcp.jsonProject MCP servers
--allowedToolsAllow specific tools
--disallowedToolsBlock specific tools
--dangerously-skip-permissionsSkip all prompts (caution!)
allowAuto-approve without asking
askPrompt user for approval
denyBlock completely
💡 Use glob patterns: Write(src/**), Bash(npm *)
Read(./.env*)Block env files
Read(./secrets/**)Block secrets directory
Bash(rm -rf:*)Block destructive commands
Bash(curl:*)Block network requests
claude mcp add <name> <cmd> [args]Add stdio MCP server
claude mcp add --transport sse <name> <url>Add SSE server
claude mcp add --transport http <name> <url>Add HTTP server
claude mcp listList installed servers
claude mcp remove <name>Remove server
GitHubRepos, PRs, issues
FigmaDesign context for code
NotionDocs, pages, tasks
LinearIssue tracking
SentryError monitoring
VercelDeployments, logs
SupabaseDatabase operations
PlaywrightBrowser automation
StripePayments
SlackMessages, channels
Zapier8,000+ app connections
PreToolUseBefore tool calls (can block)
PostToolUseAfter tool calls complete
UserPromptSubmitBefore processing user input
NotificationWhen Claude sends notifications
StopWhen Claude finishes responding
SubagentStopWhen subagent tasks complete
SessionStartWhen session starts/resumes
SessionEndWhen session ends
PreCompactBefore compact operation
/hooksOpen hooks configuration
claude --debugDebug hook execution
chmod +x .claude/hooks/script.shMake hook executable
💡 Exit codes: 0=success, 2=block & show to Claude
/agentsOpen subagents management
.claude/agents/Project subagents (team shared)
~/.claude/agents/Personal subagents
claude "Use the [name] subagent"Explicitly invoke subagent
name:Subagent identifier
description:When to invoke (include 'proactively')
tools:Allowed tools (Read, Edit, Bash...)
model:Model override (sonnet, opus, inherit)
💡 Include 'proactively' in description for auto-invocation
.claude/skills/skill-name/SKILL.mdProject skill definition
~/.claude/skills/skill-name/SKILL.mdPersonal skill
💡 Skills are model-invoked (automatic), not user-invoked
name:Skill identifier
description:When Claude should use this skill
allowed-tools:Tool restrictions (Read, Grep, Glob)
/pluginOpen plugin management
/plugin marketplace add <url>Add plugin marketplace
/plugin install <name>@<marketplace>Install plugin
/plugin enable <name>@<marketplace>Enable plugin
/plugin disable <name>@<marketplace>Disable plugin
/plugin uninstall <name>@<marketplace>Remove plugin
Custom CommandsAdd slash commands
Specialized AgentsDeploy expert subagents
Agent SkillsPackage discoverable capabilities
Automation HooksRun scripts on events
MCP ServersConnect external tools
git worktree add <path> <branch>Create with existing branch
git worktree add <path> -b <branch>Create with new branch
git worktree listList all worktrees
git worktree remove <path>Remove worktree
git worktree pruneClean up references
Parallel FeaturesWork on multiple features simultaneously
Hotfix While DevelopingHandle urgent fixes without context loss
Safe ExperimentsTest risky changes in isolation
Model ComparisonCompare Sonnet vs Opus on same task
💡 Each worktree keeps full Claude context
claude -p "query"Non-interactive, print and exit
claude -p --output-format json "query"JSON output with metadata
echo "query" | claude -pProcess piped input
--append-system-prompt "..."Add system context
--max-turns 3Limit agentic turns
SRE Incident ResponseAutomated investigation
Security AuditPR security review
Multi-turn SessionMaintain context across commands
💡 Use JSON formats for programmatic parsing
Use /clear oftenClear chat between tasks
Start different sessionsSeparate sessions for tasks
Queue multiple promptsClaude works through them
Use /compactSummarize long conversations
Deny dangerous toolsBlock "Bash(rm *)", "Bash(sudo *)"
Use .local.json for secretsKeep sensitive settings git-ignored
Review changesAlways verify modifications
Review hooks before addingHooks execute with your credentials
Quick Workflow
npm i -g @anthropic-ai/claude-code
cd project && claude
@file or @dir/
"fix the bug"
verify changes
/clear
CLAUDE.md Memory File
# Project Context ## Tech Stack - Next.js 15 with App Router - TypeScript, Tailwind CSS ## Commands - `pnpm dev` - Start dev server - `pnpm test` - Run tests ## Coding Standards - Use TypeScript for all new code - Follow ESLint configuration
Auto-Format Hook
{
"hooks": {
"PostToolUse": [{
"matcher": "Edit|Write",
"hooks": [{
"type": "command",
"command": "npx prettier --write $FILE_PATH"
}]
}]
}
}Custom Slash Command
.claude/commands/review.md:
--- allowed-tools: Read, Grep, Glob description: Review code for issues argument-hint: [file-or-feature] --- Review this code for: 1. Security vulnerabilities 2. Performance issues 3. Best practices Focus on: $ARGUMENTS
Subagent Definition
.claude/agents/code-reviewer.md:
--- name: code-reviewer description: Expert code review. Use proactively after writing code. tools: Read, Grep, Glob model: inherit --- You are a senior code reviewer. Review checklist: - Code is simple and readable - Proper error handling - No exposed secrets - Good test coverage
Permission Settings
.claude/settings.json:
{
"permissions": {
"allow": [
"Bash(npm run *)",
"Bash(git *)"
],
"deny": [
"Read(./.env*)",
"Read(./secrets/**)",
"Bash(rm -rf:*)",
"Bash(curl:*)"
]
}
}MCP Configuration
.mcp.json:
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@anthropic-ai/mcp-server-github"],
"env": { "GITHUB_TOKEN": "${GITHUB_TOKEN}" }
},
"notion": {
"transport": "http",
"url": "https://mcp.notion.com/mcp"
}
}
}Pricing Tiers
Pro - $20/mo
Medium-high workload, limited Opus
Max5 - $100/mo
5x tokens, full Opus access
Max20 - $200/mo
20x tokens, larger context
💡 Sessions last 5 hours. Opus burns tokens faster. Use /clear between tasks and separate sessions for different work.