by Njengah
Ultimate collection of Claude Code tips, tricks, hacks, and workflows that you can use to master Claude Code in minutes
# Add to your Claude Code skills
git clone https://github.com/Njengah/claude-code-cheat-sheet
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.
# Windows users
wsl
# Install Claude Code
npm install -g @anthropic-ai/claude-code
# Launch interactive REPL
claude
# Check version
claude --version
Essential commands to get started
# Install Claude Code
curl -sL https://install.anthropic.com | sh
# Start interactive REPL
claude
# Start with initial prompt
claude "summarize this project"
# Check version
claude --version
# Update to latest version
claude update
No comments yet. Be the first to share your thoughts!
/help # Show help and available commands
/exit # Exit the REPL
/clear # Clear conversation history
/config # Open config panel
/doctor # Check Claude Code installation health
# Print mode (SDK) - execute and exit
claude -p "explain this function"
# Process piped content
cat logs.txt | claude -p "explain"
# Continue most recent conversation
claude -c
# Continue via SDK
claude -c -p "Check for type errors"
# Resume session by ID
claude -r "abc123" "Finish this PR"
# Resume with flag
claude --resume abc123 "query"
# Continue session
claude --continue
Ctrl+C # Cancel current operation
Ctrl+D # Exit Claude Code
Tab # Auto-complete
Up/Down # Navigate command history
Configuration and model management
# Switch models
claude --model sonnet # Use Sonnet model
claude --model opus # Use Opus model
claude --model claude-sonnet-4-20250514 # Use specific model version
# Add additional working directories
claude --add-dir ../apps ../lib
# Validate directory paths
claude --add-dir /path/to/project
# Different output formats
claude -p "query" --output-format json
claude -p "query" --output-format text
claude -p "query" --output-format stream-json
# Input formatting
claude -p --input-format stream-json
# Limit conversation turns
claude -p --max-turns 3 "query"
# Verbose logging
claude --verbose
# Session cost and duration
/cos # Show total cost and duration
Tools and permission 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
/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
/doctor # Check installation health
/cos # Show cost and duration of current session
/ide # Manage IDE integrations
MCP and advanced integrations
# Configure MCP servers
claude --mcp
# MCP server management (via slash commands)
/mcp # Access MCP functionality
# 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"
# 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"
Advanced workflows and automation
# 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
# Advanced tool permissions
claude --allowedTools "Bash(git:*)" "Write" "Read" \
--disallowedTools "Bash(rm:*)" "Bash(sudo:*)"
# Multiple directory access
claude --add-dir ../frontend ../backend ../shared
# 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"
Expert automation and custom workflows
# Complex model and tool configuration
claude --model claude-sonnet-4-20250514 \
--add-dir ../apps ../lib ../tools \
--allowedTools "Bash(git:*)" "Write" "Read" \
--verbose \
--output-format json
# 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
# Session ID management
SESSION_ID=$(claude -p "start analysis" --output-format json | jq -r '.session_id')
claude -r "$SESSION_ID" "continue analysis"
# Multi-step automation
claude -p "analyze project structure" | \
claude -p "suggest improvements" | \
claude -p "create implementation plan"
Advanced automation patterns and multi-step processes
# 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
# 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
# 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
IDE integrations, Git workflows, and third-party tool connections
# 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 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"
# 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"
Advanced performance tuning, resource management, and efficiency tips
# Optimize memory usage
claude -p --max-turns 1 "quick analysis" # Single turn for efficiency
claude -p --compact-mode "analyze with minimal context"
# Resource monitoring
/cos # Check current session costs
/doctor --performance # Performance diagnostics
# Efficient session reuse
claude -c "continue previous analysis" # Reuse existing context
claude --cache-results "repetitive task" # Cache common operations
# Parallel processing
claude -p "task 1" & claude -p "task 2" & wait # Parallel execution
# Handle large codebases efficiently
claude --add-dir . --max-context 50000 "analyze entire project"
claude --stream-output "process large dataset" | head -100
Production-ready configurations, team workflows, and enterprise features
# Shared team configurations
claude --config-file team-c