Claude Code Cheat Sheet (Beta)

May 26, 2026 ยท View on GitHub

Alt text

Your complete guide to mastering Claude Code - from zero to hero in minutes!

After testing Claude Code extensively, I've developed this comprehensive cheat sheet that will take you from basic to advanced user without wasting time. Whether you're completely new to Claude Code or looking to master advanced features, this guide has you covered.

Quick Start

Install Claude Code, sign in, and start it from the root of the project you want Claude to work on.

macOS, Linux, or WSL

curl -fsSL https://claude.ai/install.sh | bash
claude auth login
claude

Windows PowerShell

irm https://claude.ai/install.ps1 | iex
claude auth login
claude

Windows CMD

curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
claude auth login
claude

Package Managers

# macOS
brew install --cask claude-code
# Windows
winget install Anthropic.ClaudeCode

Check your installation:

claude --version
claude auth status

๐Ÿ“š Table of Contents

  • ๐ŸŸข Level 1: Basic Commands
  • ๐ŸŸก Level 2: Intermediate Commands
  • ๐ŸŸ  Level 3: Advanced Commands
  • ๐Ÿ”ด Level 4: Expert Commands
  • ๐Ÿ”ต Level 5: Power User Commands
  • ๐ŸŸฃ Level 6: Master Commands
  • ๐Ÿค Contributing
  • ๐Ÿ“„ License

Pages

  • ๐Ÿค– Subagents - Specialized AI agents for specific development tasks

๐ŸŸข Level 1: Basic Commands

Essential commands to get started

Installation & Getting Started

Claude Code requires an account with Claude Code access. After installing, sign in with claude auth login or start claude and follow the browser prompts.

Native Install

# Recommended native install for macOS, Linux, or WSL
curl -fsSL https://claude.ai/install.sh | bash
# Windows PowerShell
irm https://claude.ai/install.ps1 | iex
# Windows CMD
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd

Package Managers

# macOS Homebrew
brew install --cask claude-code
# Windows WinGet
winget install Anthropic.ClaudeCode

npm

# Deprecated npm fallback
npm install -g @anthropic-ai/claude-code

Authentication

# Sign in
claude auth login

# Check sign-in status
claude auth status

# Sign out
claude auth logout

First Run and Updates

# Start interactive REPL
claude

# Start with initial prompt
claude "summarize this project"

# Check version
claude --version

# Update to latest version
claude update

# Install or reinstall a specific native version
claude install stable
claude install latest
claude install 2.1.118

Basic Navigation

/help                     # Show help and available commands
/exit                     # Exit the REPL
/clear [name]             # Start a fresh conversation; previous session stays resumable
/compact [instructions]   # Summarize current history to free context
/context                  # Visualize context usage
/config                   # Open settings panel
/status                   # Show version, model, account, and connectivity
/doctor                   # Check Claude Code installation health

Basic File Operations and Print Mode

# Print mode - execute a prompt and exit
claude -p "explain this function"

# Process piped content
cat logs.txt | claude -p "explain"

# Continue most recent conversation
claude -c

# Continue in print mode
claude -c -p "Check for type errors"

Session Management

# Continue the most recent session in this directory
claude --continue

# Resume by session ID or name
claude --resume abc123 "query"
claude --resume auth-refactor

# Open the session picker
claude --resume

# Name a session at startup
claude -n auth-refactor

# Rename inside an active session
/rename auth-refactor

# Branch the current conversation
/branch try-streaming-approach

# Resume a session linked to a pull request
claude --from-pr 123

Keyboard Shortcuts

Ctrl+C                    # Interrupt; if idle, clear input, then exit on second press
Ctrl+D                    # Exit Claude Code
Ctrl+O                    # Toggle transcript viewer
Ctrl+R                    # Reverse-search command history
Ctrl+T                    # Toggle task list
Esc                       # Interrupt current response or tool call
Esc Esc                   # Clear draft, or open rewind menu when input is empty
Shift+Tab                 # Cycle permission modes
Alt+P / Option+P          # Switch model
Alt+T / Option+T          # Toggle extended thinking
Alt+O / Option+O          # Toggle fast mode
@                         # File path mention autocomplete
!                         # Shell mode
Up/Down                   # Move in multiline input or navigate command history

๐ŸŸก Level 2: Intermediate Commands

Configuration, model, and session management

Model Configuration

# Switch models
claude --model sonnet                    # Use Sonnet model
claude --model opus                      # Use Opus model
claude --model claude-sonnet-4-6         # Use a specific model

# Set reasoning effort for the session
claude --effort high
/effort high

# Change model inside a session
/model sonnet

Directory Management

# Add additional working directories
claude --add-dir ../apps ../lib

# Validate directory paths
claude --add-dir /path/to/project

Output Formatting

# Output formats for print mode
claude -p "query" --output-format json
claude -p "query" --output-format text
claude -p "query" --output-format stream-json

# Input formatting for print mode
claude -p --input-format stream-json

Session Control

# Limit agentic turns in print mode
claude -p --max-turns 3 "query"

# Verbose logging
claude --verbose

# Session cost, limits, and activity stats
/usage
/cost                     # Alias for /usage
/stats                    # Alias for /usage

๐ŸŸ  Level 3: Advanced Commands

Tools and permission management

Tool Management

# Allow specific tools without prompting
claude --allowedTools "Bash(git log:*)" "Bash(git diff:*)" "Write"

# Disallow specific tools
claude --disallowedTools "Bash(rm:*)" "Bash(sudo:*)"

# Prompt for specific tool permission
claude -p --permission-prompt-tool mcp_auth_tool "query"

# Skip all permission prompts (dangerous)
claude --dangerously-skip-permissions

Slash Commands - Session Management

/compact [instructions]   # Summarize conversation with optional instructions
/clear                    # Reset conversation history and context
/exit                     # Exit the REPL
/help                     # Show available commands
/config                   # Open configuration panel

Slash Commands - System

/doctor                   # Check installation health
/usage                    # Show session cost, limits, and activity stats
/ide                      # Manage IDE integrations

๐Ÿ”ด Level 4: Expert Commands

MCP and advanced integrations

Model Context Protocol (MCP)

# Configure MCP servers
claude --mcp

# MCP server management (via slash commands)
/mcp                      # Access MCP functionality

Advanced Piping

# Complex piping operations
git log --oneline | claude -p "summarize these commits"
cat error.log | claude -p "find the root cause"
ls -la | claude -p "explain this directory structure"

Programmatic Usage

# JSON output for scripting
claude -p "analyze code" --output-format json

# Stream JSON for real-time processing
claude -p "large task" --output-format stream-json

# Batch processing
claude -p --max-turns 1 "quick query"

๐Ÿ”ต Level 5: Power User Commands

Advanced workflows and automation

Custom Slash Commands

# Create custom commands in .claude/commands/
# Example: .claude/commands/debug.md
/debug                    # Execute custom debug command
/test                     # Execute custom test command
/deploy                   # Execute custom deploy command

Complex Tool Combinations

# Advanced tool permissions
claude --allowedTools "Bash(git:*)" "Write" "Read" \
       --disallowedTools "Bash(rm:*)" "Bash(sudo:*)"

# Multiple directory access
claude --add-dir ../frontend ../backend ../shared

Performance Optimization

# Limit context for performance
claude -p --max-turns 5 "focused query"

# Clear context frequently
/clear                    # Use between tasks for better performance

# Compact conversations
/compact "keep only important parts"

๐ŸŸฃ Level 6: Master Commands

Expert automation and custom workflows

Advanced Configuration

# Complex model and tool configuration
claude --model claude-sonnet-4-6 \
       --add-dir ../apps ../lib ../tools \
       --allowedTools "Bash(git:*)" "Write" "Read" \
       --verbose \
       --output-format json

Automation Scripts

# Scripted Claude interactions
#!/bin/bash
claude -p "analyze codebase" --output-format json > analysis.json
claude -p "generate tests" --max-turns 3 --output-format text > tests.txt

Advanced Session Management

# Session ID management
SESSION_ID=$(claude -p "start analysis" --output-format json | jq -r '.session_id')
claude -r "$SESSION_ID" "continue analysis"

Complex Workflows

# Multi-step automation
claude -p "analyze project structure" | \
claude -p "suggest improvements" | \
claude -p "create implementation plan"

๐ŸŸค Level 7: Workflow Automation

Advanced automation patterns and multi-step processes

Automated Code Review Workflows

# Automated PR review process
#!/bin/bash
git diff HEAD~1 | claude -p "review this PR for security issues" > security_review.md
git diff HEAD~1 | claude -p "check for performance issues" > performance_review.md
git diff HEAD~1 | claude -p "suggest improvements" > improvements.md

Continuous Integration Integration

# CI/CD pipeline integration
claude -p "analyze test coverage" --output-format json | jq '.coverage_percentage'
claude -p "generate release notes from commits" --max-turns 2 > RELEASE_NOTES.md

Batch Processing Workflows

# Process multiple files
find . -name "*.js" -exec claude -p "analyze this file for bugs: {}" \; > bug_report.txt

# Automated documentation generation
for file in src/*.py; do
    claude -p "generate docstring for $file" --output-format text >> docs.md
done

โšซ Level 8: Integration & Ecosystem

IDE integrations, Git workflows, and third-party tool connections

IDE Integration Commands

# VS Code integration
/ide vscode                # Configure VS Code integration
/ide configure             # Setup IDE configurations

# Custom IDE commands
claude --ide-mode "explain selected code"
claude --ide-mode "refactor this function"

Git Workflow Integration

# Git hooks integration
claude -p "create pre-commit hook for code quality" > .git/hooks/pre-commit

# Advanced Git operations
git log --oneline -10 | claude -p "create changelog from these commits"
git diff --name-only | claude -p "explain what changed in this commit"

Third-Party Tool Connections

# Database integration
mysql -e "SHOW TABLES" | claude -p "analyze database structure"

# Docker integration
docker ps | claude -p "analyze running containers"
docker logs container_name | claude -p "find errors in logs"

โšช Level 9: Performance & Optimization

Advanced performance tuning, resource management, and efficiency tips

Memory & Resource Management

# Optimize memory usage
claude -p --max-turns 1 "quick analysis"      # Single turn for efficiency
claude -p --compact-mode "analyze with minimal context"

# Resource monitoring
/usage                     # Check current session costs, limits, and activity stats
/doctor --performance      # Performance diagnostics

Caching & Optimization

# Efficient session reuse
claude -c -p "continue previous analysis"      # Reuse existing context in print mode
claude --cache-results "repetitive task"      # Cache common operations

# Parallel processing
claude -p "task 1" & claude -p "task 2" & wait  # Parallel execution

Large-Scale Processing

# Handle large codebases efficiently
claude --add-dir . --max-context 50000 "analyze entire project"
claude --stream-output "process large dataset" | head -100

๐Ÿ”˜ Level 10: Enterprise & Production

Production-ready configurations, team workflows, and enterprise features

Team Collaboration

# Shared team configurations
claude --config-file team-config.json "standardized analysis"

# Team session sharing
claude -r "team-session-id" "continue team discussion"

Production Environment Setup

# Production-ready configuration
claude --production-mode \
       --security-enabled \
       --audit-logging \
       --max-turns 10 \
       "production analysis"

Enterprise Security

# Security-focused operations
claude --disallowedTools "Bash(rm:*)" "Bash(sudo:*)" "Bash(chmod:*)" \
       --audit-mode \
       --no-external-calls \
       "secure code review"

Monitoring & Compliance

# Audit and compliance
claude --audit-log /var/log/claude-audit.log "compliance check"
claude --compliance-mode "analyze for security compliance"

Command Reference Tables

CLI Commands

CommandDescriptionExample
claudeStart interactive REPLclaude
claude "query"Start REPL with promptclaude "explain this project"
claude -p "query"Print mode: run a prompt and exitclaude -p "explain function"
cat file | claude -p "query"Process piped contentcat logs.txt | claude -p "explain"
claude -c / claude --continueContinue the most recent conversation in the current directoryclaude --continue
claude -r "<session>" / claude --resume <session>Resume by session ID or nameclaude --resume auth-refactor
claude --resumeOpen the session pickerclaude --resume
claude -n <name>Name a session at startupclaude -n auth-refactor
claude --from-pr <PR>Resume the session linked to a pull requestclaude --from-pr 123
claude auth loginSign in to Claude Codeclaude auth login
claude auth statusCheck authentication statusclaude auth status
claude auth logoutSign outclaude auth logout
claude updateUpdate to latest versionclaude update
claude install [version]Install or reinstall the native binaryclaude install stable
claude mcpConfigure MCP serversclaude mcp

CLI Flags

FlagDescriptionExample
--modelSet the model for this session--model sonnet
--effortSet reasoning effort for this session--effort high
--add-dirAdd working directories for file access--add-dir ../apps ../lib
--allowedToolsAllow tools without prompting--allowedTools "Bash(git:*)"
--disallowedToolsDisallow specific tools--disallowedTools "Bash(rm:*)"
--output-formatSet output format--output-format json
--input-formatSet input format--input-format stream-json
--max-turnsLimit agentic turns in print mode--max-turns 3
--verboseEnable verbose logging--verbose
--continueContinue session--continue
--resumeResume session--resume abc123
--from-prResume a session linked to a pull request--from-pr 123
--fork-sessionResume into a copied session branch--continue --fork-session
--dangerously-skip-permissionsSkip all permission prompts--dangerously-skip-permissions

Slash Commands

CommandDescription
/helpShow help and available commands
/exitExit the CLI; in an attached background session, detach
/clear [name]Start a new conversation; previous session remains resumable
/compact [instructions]Summarize the current conversation to free context
/context [all]Show current context usage
/configOpen settings panel
/statusShow version, model, account, and connectivity
/doctorCheck installation health
/usageShow session cost, limits, and activity stats
/costAlias for /usage
/statsAlias for /usage
/model [model]Change model inside the session
`/effort [levelauto]`
/resume [session]Resume another conversation
/rename [name]Rename the current session
/branch [name]Fork the conversation from the current point
/export [filename]Export the current conversation
/diffOpen an interactive diff viewer
/ideManage IDE integrations
/mcpAccess MCP functionality

Keyboard Shortcut

ShortcutAction
Ctrl+CInterrupt; if idle, clear input, then exit on second press
Ctrl+DExit Claude Code
Ctrl+OToggle transcript viewer
Ctrl+RReverse-search command history
Ctrl+TToggle task list
EscInterrupt current response or tool call
Esc EscClear draft, or open rewind menu when input is empty
Shift+TabCycle permission modes
Alt+P / Option+PSwitch model
Alt+T / Option+TToggle extended thinking
Alt+O / Option+OToggle fast mode
@File path mention autocomplete
!Shell mode
Up/DownMove in multiline input or navigate command history

Best Practices

Performance Tips

  • Use /clear frequently between tasks
  • Limit context with --max-turns
  • Use /compact for long conversations
  • Specify exact tools with --allowedTools

Security Tips

  • Avoid --dangerously-skip-permissions
  • Use --disallowedTools for dangerous commands
  • Review tool permissions regularly
  • Keep Claude Code updated

Workflow Tips

  • Create custom slash commands in .claude/commands/
  • Use --output-format json for automation
  • Pipe commands for complex workflows
  • Use session IDs for long-running tasks

Best Practices by Level

Beginner Best Practices (Levels 1-3)

  • Start with basic commands and gradually progress
  • Use /help frequently to discover new features
  • Practice with simple queries before complex ones
  • Keep sessions focused with /clear between tasks

Intermediate Best Practices (Levels 4-6)

  • Master tool permissions for security
  • Use JSON output for automation scripts
  • Learn MCP for advanced integrations
  • Create custom slash commands for repeated tasks

Advanced Best Practices (Levels 7-10)

  • Implement automated workflows for repetitive tasks
  • Use enterprise features for team collaboration
  • Monitor performance and optimize resource usage
  • Follow security best practices in production

Pro Tips & Tricks

Efficiency Tips

  • Use Ctrl+C to cancel long-running operations
  • Combine multiple flags for complex configurations
  • Use piping for multi-step data processing
  • Cache common operations for better performance

Security Pro Tips

  • Always use --disallowedTools for dangerous commands
  • Enable audit logging in production environments
  • Review tool permissions regularly
  • Use --security-enabled for sensitive operations

Workflow Pro Tips

  • Create templates for common automation patterns
  • Use session IDs for long-running collaborative tasks
  • Implement proper error handling in automation scripts
  • Document custom workflows for team sharing

Troubleshooting Common Issues

Installation Issues

# Check installation
claude --version
claude auth status
claude doctor

# Reinstall native Claude Code
claude install stable

# Native install for macOS, Linux, or WSL
curl -fsSL https://claude.ai/install.sh | bash

# Windows PowerShell
irm https://claude.ai/install.ps1 | iex

# Windows CMD
curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd

# If you installed through npm previously
npm uninstall -g @anthropic-ai/claude-code
npm install -g @anthropic-ai/claude-code

Performance Issues

# Clear context for better performance
/clear

# Limit context size
claude -p --max-turns 3 "focused query"

# Use compact mode
/compact "keep only essentials"

Permission Issues

# Check current permissions
claude --list-permissions

# Reset permissions
claude --reset-permissions

# Configure specific permissions
claude --allowedTools "Bash(git:*)" --disallowedTools "Bash(rm:*)"

๐Ÿค Contributing

We welcome contributions! Please see the Claude Code documentation for guidelines.

Ways to Contribute

  • ๐Ÿ› Report bugs or issues
  • ๐Ÿ“ Improve documentation
  • โœจ Add new command examples
  • ๐Ÿ”ง Test commands and report results

๐Ÿ“„ License

This cheat sheet is provided under the MIT License.

โญ Support

If this cheat sheet helped you, please share it with other developers! If this cheat sheet helped you master Claude Code, please:

  • โญ Star our GitHub repository
  • ๐Ÿ“ข Share it with other developers
  • ๐Ÿ’ฌ Leave feedback in the comments
  • ๐Ÿ”„ Follow for updates

Resources & Further Learning

For more Claude Code resources, visit the official Anthropic documentation at

Last verified against official Claude Code docs: May 26, 2026