Skip to main content

Claude Code Quick Reference: Commands & Shortcuts

The essential Claude Code cheatsheet. Print-friendly quick reference cards for slash commands, keyboard shortcuts, CLI flags, and common workflows.

Keep this page bookmarked. Everything you need to use Claude Code efficiently, organized for quick lookup.

Keyboard Shortcuts

Essential Shortcuts

ShortcutAction
EscapeCancel current generation
Ctrl+CInterrupt Claude / Exit
Ctrl+LClear screen
Up/DownNavigate command history
TabAutocomplete commands
Shift+EnterMulti-line input

macOS Specific

ShortcutAction
Opt+PSwitch model
Cmd+KClear conversation

Windows/Linux Specific

ShortcutAction
Alt+PSwitch model
Ctrl+KClear conversation

Slash Commands

Built-in Commands

CommandDescription
/helpShow all available commands
/clearClear conversation history
/compactCompact conversation (reduce tokens)
/initInitialize CLAUDE.md for project
/modelShow or change current model
/memoryShow memory status
/costShow session cost
/doctorDiagnose configuration issues
/configOpen configuration
/bugReport a bug

File Commands

CommandDescription
/add <path>Add file to context
/add-dir <path>Add directory to context

Review & Version Control

CommandDescription
/reviewReview staged changes
/pr-commentsReview PR comments

CLI Flags

Starting Claude Code

# Basic
claude                    # Start interactive session
claude "prompt"           # Run single prompt
claude -c                 # Continue last session
claude --resume           # Resume from specific session

# Model Selection
claude --model sonnet     # Use Claude Sonnet
claude --model opus       # Use Claude Opus
claude --model haiku      # Use Claude Haiku

# Output Control
claude -p "prompt"        # Print mode (no interactive)
claude --output-format json  # JSON output
claude --verbose          # Verbose logging
claude --quiet            # Minimal output

# Session Management
claude --no-memory        # Disable memory for session
claude --dangerously-skip-permissions  # Skip all permission prompts

MCP Management

# List and manage MCP servers
claude mcp list                    # List all MCP servers
claude mcp add <name> <command>    # Add MCP server
claude mcp remove <name>           # Remove MCP server
claude mcp reset-project-choices   # Reset MCP permissions

# Scoped MCP
claude mcp add --scope project <name> <command>
claude mcp add --scope user <name> <command>

Configuration

# Settings
claude config list         # Show all settings
claude config set <key>    # Set configuration
claude config get <key>    # Get configuration value

# Login/Auth
claude login              # Authenticate
claude logout             # Log out

Common File Patterns

@ References

# In prompts or CLAUDE.md
See @README.md for project overview.
Check @src/lib/auth.ts for auth utilities.
Reference @package.json for dependencies.

CLAUDE.md Templates

# Minimal CLAUDE.md
## Project
[Brief description]

## Commands
- npm run dev
- npm test

## Standards
- TypeScript strict mode
- Tests required for features
# Full CLAUDE.md
## Overview
[Project description]

## Tech Stack
- [Framework]
- [Language]
- [Database]

## Directory Structure
src/
├── [folder]/  # [purpose]
└── [folder]/  # [purpose]

## Commands
- [command] - [description]

## Autonomous Operations
- [allowed actions]

## Requires Confirmation
- [restricted actions]

Permission Patterns

settings.json

{
  "permissions": {
    "allow": [
      "Read",
      "Write",
      "Edit",
      "Bash(npm:*)",
      "Bash(git:*)"
    ],
    "deny": [
      "Read(.env*)",
      "Write(.env*)",
      "Bash(rm -rf:*)"
    ]
  }
}

Pattern Syntax

PatternMatches
ReadAll read operations
Write(src/**)Write in src/ and subdirs
Bash(npm:*)All npm commands
Bash(git diff:*)git diff with any args
Read(.env*)Any .env file

Model Comparison

ModelBest ForSpeed
Fable 5Complex reasoning, critical tasksSlower
Opus 4.8Frontier workhorse, long-running sessionsFast with /fast
Sonnet 5General coding, balancedFast
Haiku 4.5Quick tasks, explorationFastest

When to Use Each

  • Fable 5: Architecture decisions, security reviews, complex refactoring
  • Opus 4.8: Frontier workhorse — toggle /fast for faster output when latency matters
  • Sonnet 5: Day-to-day development, feature implementation
  • Haiku 4.5: Quick questions, file exploration, simple edits

Memory System

Memory Files

LocationScopeUse Case
~/.claude/CLAUDE.mdGlobalPersonal preferences
./CLAUDE.mdProjectTeam standards
./.claude/CLAUDE.mdProjectTeam standards (hidden)
./CLAUDE.local.mdPersonalIndividual overrides

Priority Order

1. CLAUDE.local.md (highest)
2. ./CLAUDE.md
3. ~/.claude/CLAUDE.md (lowest)

Common Workflows

Start New Feature

claude
> Implement [feature description]
> Follow TDD - write tests first

Debug Issue

claude
> Debug: [error message]
> Check logs at [path]

Code Review

claude
> Review changes in [files]
> Focus on: security, performance, maintainability

Refactor

claude
> Refactor [component] to [pattern]
> Maintain backward compatibility

Troubleshooting Quick Fixes

ProblemSolution
CLAUDE.md ignoredCheck file location (./CLAUDE.md or ./.claude/CLAUDE.md)
MCP not loadingclaude mcp reset-project-choices
Permission deniedAdd to settings.json allow list
High token usageUse /compact or start new session
Wrong modelOption+P (Mac) or Alt+P (Win/Linux)
Config not appliedRestart Claude Code

Environment Variables

# API Configuration
ANTHROPIC_API_KEY=sk-...

# Proxy (if needed)
HTTP_PROXY=http://...
HTTPS_PROXY=https://...

# Debug
CLAUDE_CODE_DEBUG=1

CLAUDE CODE QUICK REFERENCE
===========================

SHORTCUTS
---------
Escape      Cancel generation
Ctrl+C      Interrupt / Exit
Ctrl+L      Clear screen
Opt/Alt+P   Switch model

COMMANDS
--------
/help       Show commands
/clear      Clear history
/init       Create CLAUDE.md
/doctor     Diagnose issues

CLI
---
claude              Start session
claude "prompt"     Single prompt
claude -c           Continue session
claude --model X    Use model X

FILES
-----
./CLAUDE.md         Project config
~/.claude/CLAUDE.md Global config
CLAUDE.local.md     Personal overrides
.claude/settings.json  Permissions

MCP
---
claude mcp list     Show servers
claude mcp add      Add server
claude mcp remove   Remove server

Bookmark this page and keep it handy. You’ll reference it more than you think.

Sources: Claude Code Documentation, Claude Code GitHub