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):
| Command | What it does |
|---|---|
claude | Start Claude Code |
claude -c | Continue last session |
/compact | Compress context (saves tokens) |
/clear | Start fresh conversation |
Ctrl+C | Cancel generation |
Jump to: Keyboard · Slash Commands · CLI Flags · Environment
Keyboard Shortcuts
| Shortcut | Action |
|---|---|
Ctrl+C | Cancel current generation |
Ctrl+D | Exit Claude Code |
Ctrl+L | Clear screen |
Ctrl+R | Search command history |
↑ / ↓ | Navigate command history |
Tab | Autocomplete file paths |
Esc | Cancel current input |
Slash Commands
Session Management
| Command | What it does |
|---|---|
/clear | Clear conversation history |
/compact | Compress context to save tokens |
/cost | Show session token usage & cost |
/doctor | Check installation health |
/help | Show all commands |
/init | Create CLAUDE.md in current directory |
/quit | Exit Claude Code |
Context & Memory
| Command | What it does |
|---|---|
/add-dir <path> | Add directory to context |
/memory | View/edit persistent memory |
/context | Show current context window |
Execution
| Command | What it does |
|---|---|
/run <cmd> | Run shell command |
/vim | Edit in Vim mode |
/review | Review 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
/compactwhen you hit context limits instead of starting fresh
Tip:
claude --printis perfect for CI/CD pipelines
Tip: Keep CLAUDE.md under 500 lines — it loads every session
Tip: Use
Ctrl+Ctwice 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.
Related
- Claude Code Setup Guide — Full setup walkthrough
- Tool Comparison — Compare all tools
- Tools Directory — All AI coding tools
✓ Copied to clipboard!