This comprehensive reference guide covers every discoverable Claude Code command, from basic CLI operations to advanced features and hidden commands. Whether you're a beginner or an advanced user, this guide will help you master Claude Code's extensive command set.
Claude Code commands fall into several categories:
- CLI Commands: Terminal commands to start and configure Claude Code
- Interactive Commands: Slash commands used within Claude Code sessions
- Configuration Commands: Commands to manage settings and preferences
- MCP Commands: Commands for managing Model Context Protocol servers
- Session Management: Commands for handling conversations and memory
Command |
Description |
Example |
claude |
Start interactive REPL |
claude |
claude "query" |
REPL with initial prompt |
claude "help debug this" |
claude -p "query" |
One-shot query (print mode) |
claude -p "explain function" |
Command |
Description |
Example |
claude -c |
Continue last session |
claude -c |
claude -r <id> |
Resume specific session |
claude -r abc123 |
claude --resume <name> |
Resume named session |
claude --resume project-review |
Command |
Description |
Example |
claude config |
Interactive configuration |
claude config |
claude config list |
List all settings |
claude config list |
claude config get <key> |
Get specific value |
claude config get model |
claude config set <key> <value> |
Set value |
claude config set model sonnet |
Flag |
Short |
Description |
Example |
--print |
-p |
Print response without interactive mode |
claude -p "help" |
--continue |
-c |
Load most recent conversation |
claude -c |
--help |
-h |
Show help information |
claude --help |
--version |
-v |
Show version |
claude --version |
Flag |
Options |
Description |
Example |
--output-format |
text , json , stream-json |
Control response format |
claude -p "help" --output-format json |
--json |
- |
Shorthand for JSON output |
claude -p "analyze" --json |
--verbose |
- |
Enable detailed logging |
claude --verbose |
Flag |
Risk Level |
Description |
Example |
--allowedTools <tools> |
LOW |
Whitelist specific tools |
claude --allowedTools "Edit,View" |
--disallowedTools <tools> |
LOW |
Blacklist specific tools |
claude --disallowedTools "Bash" |
--dangerously-skip-permissions |
CRITICAL |
Skip ALL permission prompts |
claude --dangerously-skip-permissions |
Flag |
Purpose |
Example |
Notes |
--add-dir <path> |
Add working directories |
claude --add-dir ../lib ../src |
|
--model <model> |
Set specific model |
claude --model sonnet |
|
--mcp-debug |
Enable MCP debugging |
claude --mcp-debug |
|
These commands are used within Claude Code's interactive mode:
Command |
Purpose |
Description |
/help |
Show all slash commands |
Lists available interactive commands |
/clear |
Clear current conversation |
Starts fresh conversation |
/exit |
Exit Claude safely |
Properly closes Claude Code |
/bug |
Report issues |
Opens bug reporting interface |
Command |
Purpose |
Description |
/doctor |
Complete health check |
Runs comprehensive system diagnostics |
/status |
System information |
Shows current status and configuration |
/cost |
Token usage stats |
Displays current session costs |
/sessions |
List all sessions |
Shows available conversation sessions |
Command |
Purpose |
Description |
/config |
Configuration menu |
Opens interactive configuration |
/permissions |
Manage tool access |
Configure tool permissions |
/memory |
Edit memory files |
Access and edit project memory |
Command |
Purpose |
Description |
/mcp |
MCP server management |
Interactive MCP configuration |
/mcp list |
List configured servers |
Shows all configured MCP servers |
/mcp status |
Check server status |
Shows MCP server health |
# View all configuration
claude config list
# Get specific setting
claude config get model
claude config get allowedTools
claude config get outputFormat
# Set configuration values
claude config set model claude-sonnet-4
claude config set verbose true
claude config set outputFormat text
# Set global settings
claude config set -g model claude-sonnet-4
claude config set -g allowedTools "Edit,View"
# Project-specific settings (in project directory)
claude config set systemPrompt "You are a senior developer"
claude config set allowedTools "Edit,View,Bash(git:*)"
# Import configuration from file
claude config import config.json
# Export current configuration
claude config export > my-config.json
# Interactive MCP setup
claude mcp
# List configured servers
claude mcp list
# Add new server
claude mcp add git "git-mcp-server"
claude mcp add postgres "postgres-mcp-server --host localhost"
# Remove server
claude mcp remove git
# Check server status
claude mcp status
claude mcp status git
# Restart servers
claude mcp restart git
claude mcp restart --all
# Debug MCP issues
claude mcp debug
claude mcp logs git
# Add server with environment variables
claude mcp add github "github-mcp-server" --env GITHUB_TOKEN=token
# Add server with specific arguments
claude mcp add db "postgres-mcp-server" --args "--host localhost --port 5432"
# Test server connection
claude mcp test git
claude mcp test --all
# Allow specific tools
claude --allowedTools "Edit,View"
# Allow tool categories
claude --allowedTools "Edit,View,Bash"
# Scoped permissions (Git operations only)
claude --allowedTools "Bash(git:*)"
# Multiple scopes
claude --allowedTools "Bash(git:*),Bash(npm:*)"
# MCP tool permissions
claude --allowedTools "mcp__git__*"
claude --allowedTools "mcp__postgres__query,mcp__postgres__schema"
# Combined permissions
claude --allowedTools "Edit,View,mcp__git__*,Bash(npm:*)"
# Restrictive (safest)
claude --allowedTools "View"
# Development mode
claude --allowedTools "Edit,View,Bash(git:*)"
# Full development access
claude --allowedTools "Edit,View,Bash,mcp__*"
# Dangerous mode (use only in containers)
claude --dangerously-skip-permissions
# List all sessions
claude sessions list
# Resume specific session
claude --resume session-name
claude -r session-id
# Create named session
claude --session my-project "Start working on authentication"
# Continue last session
claude -c
# Clear session history
claude sessions clear
claude sessions clear --before "2024-01-01"
# Export session
claude sessions export session-id > session.json
# Import session
claude sessions import session.json
# View project memory
claude /memory view
# Edit project memory
claude /memory edit
# Clear project memory
claude /memory clear
# Set project context
claude /memory set "This is a React TypeScript project"
# Add to project memory
claude /memory add "Use ESLint for code style"
# Core configuration
export ANTHROPIC_API_KEY="sk-your-key-here"
export ANTHROPIC_MODEL="claude-sonnet-4"
export ANTHROPIC_BASE_URL="https://api.anthropic.com"
# Performance settings
export MAX_THINKING_TOKENS=50000
export DISABLE_NON_ESSENTIAL_MODEL_CALLS=1
# Privacy settings
export DISABLE_TELEMETRY=1
export DISABLE_ERROR_REPORTING=1
# Cloud provider settings
export CLAUDE_CODE_USE_BEDROCK=1
export CLAUDE_CODE_USE_VERTEX=1
# Network settings
export HTTP_PROXY="http://proxy.company.com:8080"
export HTTPS_PROXY="https://proxy.company.com:8443"
export NO_PROXY="localhost,127.0.0.1,*.company.com"
# Pipe content to Claude
cat file.py | claude -p "review this code"
git diff | claude -p "explain these changes"
npm test 2>&1 | claude -p "fix these test failures"
# Chain commands
claude -p "analyze logs" < app.log && echo "Analysis complete"
# Save output
claude -p "generate documentation" > docs.md
claude -p "create README" --output-format json > readme.json
# Process multiple files
for file in *.py; do
claude -p "review $file for security issues" < "$file"
done
# Automated code review
git diff HEAD~1 | claude -p "review changes and suggest improvements"
# Documentation generation
find . -name "*.js" -exec claude -p "document this function" {} \;
# Development workflow
claude --add-dir src test \
--allowedTools "Edit,View,Bash(git:*),mcp__*" \
"Start code review session"
# Database analysis
claude --allowedTools "mcp__postgres__*,View" \
"Analyze database performance issues"
# Security audit
claude --allowedTools "View,mcp__git__*" \
"Perform security audit of recent commits"
# Health check
claude /doctor
# Version information
claude --version
claude /status
# Configuration check
claude config list
claude config get allowedTools
claude config get model
# MCP diagnostics
claude mcp status
claude mcp list
claude --mcp-debug
# Network diagnostics
curl -I https://api.anthropic.com
ping api.anthropic.com
# Reset configuration
claude config reset
claude config set --reset
# Clear sessions
claude sessions clear --all
# Restart MCP servers
claude mcp restart --all
# Clear cache
claude cache clear
# Complete reset (nuclear option)
rm ~/.claude.json
claude config
# Bypass all safety checks (dangerous)
claude --dangerously-skip-permissions --no-safety-checks
# Force specific model
claude --model claude-3-opus --force-model
# Debug mode with all flags
claude --verbose --debug --mcp-debug --trace-all
# Performance mode
claude --fast-mode --disable-thinking --no-context-window-management
# Experimental features
claude --experimental-features --enable-all-tools
# Development mode
claude --dev-mode --unsafe-tools --experimental
# Testing mode
claude --test-mode --mock-api --dry-run
# Profiling
claude --profile --timing --memory-usage
# API debugging
claude --log-api-calls --show-tokens --cost-tracking
# Morning standup
claude -c --add-dir . "Show me what I was working on yesterday"
# Code review
claude --allowedTools "View,mcp__git__*" "Review latest commits"
# Feature development
claude --allowedTools "Edit,View,Bash(git:*)" "Help implement user authentication"
# End of day
claude "Summarize today's work and plan tomorrow"
# Initial project setup
claude --add-dir . --allowedTools "Edit,View,Bash(npm:*)" \
"Set up new React TypeScript project"
# Configure MCP
claude mcp add git "git-mcp-server"
claude mcp add postgres "postgres-mcp-server"
# Set project memory
claude /memory set "React TypeScript project with PostgreSQL"
# Error analysis
tail -f app.log | claude -p "monitor for errors and suggest fixes"
# Performance debugging
claude --allowedTools "View,mcp__*" "Analyze database slow queries"
# Test debugging
npm test 2>&1 | claude -p "fix failing tests"
# Start Claude
claude # Interactive mode
claude "question" # With initial prompt
claude -p "question" # Print mode
# Sessions
claude -c # Continue last
claude --resume name # Resume named
# Configuration
claude config # Interactive config
claude /doctor # Health check
# MCP
claude mcp # MCP management
claude /mcp # In-session MCP
# Help
claude --help # CLI help
claude /help # Interactive help
--allowedTools "Edit,View" # Safe permissions
--dangerously-skip-permissions # Dangerous mode
--output-format json # JSON output
--verbose # Debug mode
--add-dir path # Add directory
This command reference provides a comprehensive overview of Claude Code's capabilities. Remember to always start with safe permissions and gradually expand access as needed. Use the /doctor
command for troubleshooting and /help
for quick assistance within Claude Code sessions.