← Cheatsheets / Tools

Claude Code Shortcuts, Commands & CLI Reference

Complete Claude Code reference — every shortcut, slash command, and CLI flag. The essential cheat sheet for AI coding with Claude Code.

claude-code shortcuts cli productivity

Everything Claude Code can do. Bookmark this page.

Most used (memorize these):

CommandWhat it does
claudeStart Claude Code
claude -cContinue last session
/compactCompress context (saves tokens)
/clearStart fresh conversation
Ctrl+CCancel generation

Jump to: Keyboard · Slash Commands · CLI Flags · Environment


Keyboard Shortcuts

ShortcutAction
Ctrl+CCancel current generation
Ctrl+DExit Claude Code
Ctrl+LClear screen
Ctrl+RSearch command history
/ Navigate command history
TabAutocomplete file paths
EscCancel current input

Slash Commands

Session Management

CommandWhat it does
/clearClear conversation history
/compactCompress context to save tokens
/costShow session token usage & cost
/doctorCheck installation health
/helpShow all commands
/initCreate CLAUDE.md in current directory
/quitExit Claude Code

Context & Memory

CommandWhat it does
/add-dir <path>Add directory to context
/memoryView/edit persistent memory
/contextShow current context window

Execution

CommandWhat it does
/run <cmd>Run shell command
/vimEdit in Vim mode
/reviewReview pending changes

CLI Flags

Starting Claude Code

# Basic start
claude

# Start with a prompt
claude "explain this codebase"

# Continue last conversation
claude --continue

# Resume specific session
claude --resume <session-id>

# Non-interactive mode (for scripts)
claude --print "what does main.py do?"

Output Control

# Output formats
claude --output-format text      # Plain text (default)
claude --output-format json      # JSON output
claude --output-format stream-json  # Streaming JSON

# Verbose/quiet
claude --verbose    # Show all tool calls
claude --quiet      # Minimal output

Model & Context

# Use specific model
claude --model claude-sonnet-4-20250514

# Set max tokens
claude --max-tokens 8192

# Permission modes
claude --dangerously-skip-permissions  # YOLO mode
claude --permission-mode default       # Ask for dangerous ops

Session Management

# List recent sessions
claude --list

# Show session info
claude --info <session-id>

# Export session
claude --export <session-id> > session.json

Environment Variables

# API key (required)
export ANTHROPIC_API_KEY="sk-ant-..."

# Custom config location
export CLAUDE_CONFIG_DIR="~/.claude"

# Disable telemetry
export CLAUDE_CODE_DISABLE_TELEMETRY=1

# Custom model
export CLAUDE_MODEL="claude-sonnet-4-20250514"

CLAUDE.md Quick Reference

Create a CLAUDE.md in your project root:

# Project Context

## Build Commands
- `npm run dev` - Start dev server
- `npm run build` - Production build
- `npm test` - Run tests

## Architecture
- Framework: Next.js 14
- Database: PostgreSQL
- Auth: Clerk

## Conventions
- Use TypeScript strict mode
- Prefer server components
- Tests required for utils/

Pro Tips

Tip: Use /compact when you hit context limits instead of starting fresh

Tip: claude --print is perfect for CI/CD pipelines

Tip: Keep CLAUDE.md under 500 lines — it loads every session

Tip: Use Ctrl+C twice quickly to force-stop a runaway generation


🎯 Try Right Now

# If you haven't yet, set up Claude Code
claude /init

# Then start a session
claude "explain what this project does"

# Use /compact when context gets long
/compact

# Check your usage
/cost

Master these 5 commands and you’re 90% of the way there.


✓ Copied to clipboard!