πŸ“‹ Cheat Sheets
Β· 4 min read

Claude Code Cheat Sheet: Every Command and Shortcut (2026)


Some links in this article are affiliate links. We earn a commission at no extra cost to you when you purchase through them. Full disclosure.

Quick reference for Claude Code β€” Anthropic’s terminal AI coding agent.

Install & setup

# Install
npm install -g @anthropic-ai/claude-code

# Start in your project
cd your-project
claude

# With a specific prompt
claude "Explain this codebase"

Slash commands

CommandWhat it does
/helpShow all commands
/compact [focus]Summarize context, keep going. Add focus: /compact focus on auth refactor
/clearClear all context, start fresh
/rewindGo back to a previous message (also: double-tap Esc)
/modelSwitch model (Sonnet, Opus, Haiku)
/costShow token usage and cost for this session
/tokensShow current context size
/configOpen settings
/permissionsView/edit permission settings
/bugReport a bug to Anthropic
/ultrareviewπŸ†• Dedicated review session β€” reads changes, flags bugs and design issues a careful reviewer would catch. Pro/Max get 3 free.
/quitExit (also: Ctrl+C twice)

Keyboard shortcuts

ShortcutAction
Esc Esc (double-tap)Rewind to previous message
Ctrl+CCancel current generation
Ctrl+C Ctrl+CExit Claude Code
TabAccept suggestion
EnterSend message
Shift+EnterNew line in message

Context management

# Check how much context you're using
/tokens

# Summarize and compress (best before context gets too long)
/compact

# Summarize with focus
/compact Focus on the database migration. Drop the CSS debugging.

# Nuclear option: start fresh with a handoff note
/clear
# Then paste: "We're refactoring auth. Files: src/auth/. Approach: JWT. Ruled out: OAuth2."

When to use each:

  • /rewind β€” undo a bad attempt, try a different approach
  • /compact β€” session getting long, keep working on same task
  • /clear β€” switching to a completely different task

See our long-running agents guide for advanced context strategies.

Permission settings

// .claude/settings.json
{
  "permissions": {
    "allow": ["read_file", "list_directory", "search_files"],
    "ask": ["write_file", "shell_command"],
    "deny": ["delete_file"]
  }
}
LevelBehavior
allowAuto-approved, no prompt
askClaude asks before each action
denyBlocked, Claude can’t do it

Fix permission issues: Claude Code Permission Denied Fix

Subagents

# Tell Claude to use a subagent for isolated work
"Spin up a subagent to analyze the test coverage"
"Use a subagent to read the API docs and summarize the auth endpoints"

Subagents get their own context window. Only the result comes back. Use for: research tasks, file analysis, anything where you need the conclusion but not the intermediate steps.

Routines (cloud automation)

Set up at claude.ai/code/routines:

TriggerExample
Schedule”Every weekday at 9am: review new PRs”
API callPOST to trigger post-deployment checks
GitHub eventOn PR opened: automated code review

See our Claude Code Routines guide for setup.

Model selection

ModelBest forSpeedCost
SonnetDaily coding (default on free)Fast$$
Opus 4.8Complex architecture, hard bugs, agentic tasks, dynamic workflowsSlow$$$$
HaikuQuick questions, formattingFastest$
/model sonnet   # Switch to Sonnet
/model opus     # Switch to Opus for hard problems
/model haiku    # Switch to Haiku for quick tasks

Effort levels πŸ†•

Opus 4.8 supports effort levels from low to max, with high as the default. Use ultracode to enable dynamic workflows (hundreds of parallel subagents for codebase-scale tasks).

LevelWhen to useToken usage
lowSimple questions, formattingMinimal
mediumStandard coding tasksModerate
highComplex multi-file changesHigh
xhighHard bugs, architecture decisions (default)High
maxAbsolute best result, latency doesn’t matterVery high

Set effort via the API effort parameter or let Claude Code manage it automatically.

Use with other models via API

# Use GLM-5.1 through Z.ai
export ANTHROPIC_BASE_URL="https://api.z.ai/api/anthropic"
export ANTHROPIC_AUTH_TOKEN="your-zai-key"
claude

See our GLM-5.1 + Claude Code setup guide.

Common patterns

# Code review
claude "Review src/auth/ for security issues"

# Refactoring
claude "Refactor the payment module to use the strategy pattern"

# Debugging
claude "The tests in src/auth/__tests__/ are failing. Fix them."

# Documentation
claude "Add JSDoc comments to all exported functions in src/lib/"

# Git workflow
claude "Create a PR description for the changes in this branch"

Pricing

PlanPriceIncludes
Pro$20/moSonnet + Haiku, generous limits
Max$100/moOpus + Sonnet + Haiku, 5x limits
APIPay-per-tokenFull control, no subscription

Speed up your workflow β€” Raycast lets you trigger Claude Code from a keyboard shortcut.

Related: How to Use Claude Code Β· Claude Code Routines Guide Β· Claude Code Desktop App Β· What Is Claude Dispatch? Β· What Is Claude Cowork? Β· Claude Code vs Codex CLI vs Gemini CLI Β· GLM-5.1 + Claude Code Setup Β· Claude Code Permission Denied Fix