Skip to content

Claude Code Complete Command Reference: All CLI Flags and Slash Commands

Purpose

I use Claude Code daily, but sometimes I forget the exact syntax for commands or flags. This post is my complete reference for quick lookup.

All Claude Code commands fall into these categories:

┌─────────────────────────────────────────────────────────────┐
│ Claude Code Command Categories │
├──────────────┬──────────────────────────────────────────────┤
│ Basic CLI │ Start, run tasks, continue sessions │
│ Advanced │ Flags for performance, debug, permissions │
│ Session │ Slash commands inside Claude Code │
│ MCP │ Manage Model Context Protocol servers │
│ Auth │ Login, logout, check status │
│ Config │ View and modify settings │
│ Cache/Logs │ Manage local data │
└──────────────┴──────────────────────────────────────────────┘

Basic CLI Commands

Basic CLI commands
# Start interactive mode
claude
# Execute a single task and exit
claude -p "your task here"
# Continue last conversation (shortcut: -c)
claude --continue
claude -c
# Select from history to resume (shortcut: -r)
claude --resume
claude -r
# Show help (shortcut: -h)
claude --help
claude -h
# Show version (shortcut: -v)
claude --version
claude -v

Advanced CLI Flags

These flags modify Claude Code’s behavior:

Advanced flags
# Skip permission confirmations (faster but less safe)
claude --dangerously-skip-permissions
# Specify configuration file
claude --config /path/to/config.json
# Enable debug mode
claude --debug
# Quiet mode (minimal output)
claude --quiet
# Specify working directory
claude --cwd /path/to/project
# Auto-compress context periodically
claude --auto-compact
# MCP debug mode
claude --mcp-debug
# Combine multiple flags
claude --dangerously-skip-permissions --auto-compact --debug

Important flags explained:

FlagPurposeWhen to Use
--dangerously-skip-permissionsSkip all confirmationsTrusted tasks only
--auto-compactAuto-compress contextLong sessions
--debugShow detailed logsTroubleshooting
--mcp-debugMCP-specific logsMCP issues

Session Slash Commands

Inside Claude Code, use these slash commands:

Session slash commands
# Compress conversation (preserves key info)
/compact
# Clear conversation history completely
/clear
# View and select past conversations
/history
# Edit user memory file
/edit
# Edit project memory file (in project directory)
/edit project
# Switch AI model
/model
# Show all available commands
/help
# Exit Claude Code
/exit
# Check MCP server status
/mcp
# View token usage statistics
/stats

Keyboard Shortcuts

Keyboard shortcuts
ESC # Interrupt current operation
Ctrl+Z # Exit Claude mode (return to terminal)
Ctrl+V # Paste image (screenshot analysis)
Ctrl+C # Force quit
Tab # Auto-complete commands and paths

MCP Management Commands

Manage Model Context Protocol servers:

MCP management commands
# Add MCP server
claude mcp add <name> [options] -- <command> [args...]
# Example: Add filesystem server
claude mcp add filesystem -s user -- npx -y @anthropic-ai/server-filesystem ~/Documents
# Example: Add GitHub server with environment variable
claude mcp add github -s user -e GITHUB_TOKEN=xxx -- npx -y @anthropic-ai/server-github
# List installed servers
claude mcp list
# Remove server
claude mcp remove <name>
# Test server connection
claude mcp test <name>
# View server logs
claude mcp logs <name>
# Restart MCP services
claude mcp restart [name]

MCP scopes:

ScopeConfig LocationUse Case
-s user~/.claude.jsonPersonal tools
-s project.claude.json in projectTeam shared

Authentication Commands

Authentication commands
# Initialize/authentication
claude init
# Login
claude auth login
# Logout
claude auth logout
# Check auth status
claude auth status
# Refresh token
claude auth refresh
# Manual login (if browser doesn't open)
claude auth login --manual

Configuration Commands

Configuration commands
# View current config
claude config show
# Set config value
claude config set <key> <value>
# Reset to defaults
claude config reset
# Export configuration
claude config export > config.json
# Import configuration
claude config import config.json

Cache Management

Cache management
# Clear all caches
claude cache clear
# View cache size
claude cache size
# Cache statistics
claude cache stats

Log Management

Log management
# View logs
claude logs show
# Clear logs
claude logs clear
# Set log level
claude logs level debug|info|warn|error

Complete Quick Reference Table

┌─────────────────────────────────────────────────────────────────────────────┐
│ Claude Code Complete Command Reference │
├──────────┬───────────────────────────┬───────────────────────────────────────┤
│ Category │ Command │ Purpose │
├──────────┼───────────────────────────┼───────────────────────────────────────┤
│ Basic │ claude │ Start interactive mode │
│ │ claude -p "task" │ Quick task execution │
│ │ claude -c │ Continue last session │
│ │ claude -r │ Resume from history │
│ │ claude -h │ Show help │
│ │ claude -v │ Show version │
├──────────┼───────────────────────────┼───────────────────────────────────────┤
│ Advanced │ --dangerously-skip-perms │ Skip confirmations │
│ │ --auto-compact │ Auto compress context │
│ │ --debug │ Debug mode │
│ │ --mcp-debug │ MCP debug mode │
│ │ --config <path> │ Use specific config │
│ │ --cwd <path> │ Set working directory │
├──────────┼───────────────────────────┼───────────────────────────────────────┤
│ Session │ /compact │ Compress conversation │
│ │ /clear │ Clear history │
│ │ /history │ View past conversations │
│ │ /edit │ Edit memory file │
│ │ /model │ Switch AI model │
│ │ /mcp │ Check MCP status │
│ │ /stats │ Token usage │
├──────────┼───────────────────────────┼───────────────────────────────────────┤
│ MCP │ mcp add │ Add server │
│ │ mcp list │ List servers │
│ │ mcp remove │ Remove server │
│ │ mcp test │ Test connection │
│ │ mcp logs │ View logs │
│ │ mcp restart │ Restart services │
├──────────┼───────────────────────────┼───────────────────────────────────────┤
│ Auth │ init │ Authenticate │
│ │ auth login │ Login │
│ │ auth logout │ Logout │
│ │ auth status │ Check status │
│ │ auth refresh │ Refresh token │
├──────────┼───────────────────────────┼───────────────────────────────────────┤
│ Config │ config show │ View config │
│ │ config set │ Set value │
│ │ config reset │ Reset defaults │
├──────────┼───────────────────────────┼───────────────────────────────────────┤
│ Cache │ cache clear │ Clear caches │
│ │ cache size │ View size │
│ │ cache stats │ Statistics │
├──────────┼───────────────────────────┼───────────────────────────────────────┤
│ Logs │ logs show │ View logs │
│ │ logs clear │ Clear logs │
│ │ logs level │ Set level │
└──────────┴───────────────────────────┴───────────────────────────────────────┘

Summary

In this post, I provided a complete reference for all Claude Code commands. The key efficiency boosters are:

  • --dangerously-skip-permissions for faster execution on trusted tasks
  • /compact for context management during long sessions
  • claude mcp commands for server configuration
  • claude --help or /help for built-in quick reference

Bookmark this page for daily reference.

Final Words + More Resources

My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me

Here are also the most important links from this article along with some further resources that will help you in this scope:

Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!

Comments