Claude Code Cheat Sheet
Here’s a rewritten Claude Code Cheat Sheet with relevant examples for real development scenarios, showing both command usage and prompt formats:
Claude Code Cheat Sheet (with Examples)
Quick Start
Install and Launch:
npm install -g @anthropic-ai/claude-code
claude # Launch interactive shell
claude --version # Check your installed version
npm install -g @anthropic-ai/claude-code claude # Launch interactive shell claude --version # Check your installed version
Use REPL for interactive sessions or CLI flags for one-off jobs.
Basic Usage Examples
Generate Feature Boilerplate
claude -p "Create a user authentication module in Python using JWT. Include signup, login, logout, and token verification functions."
claude -p "Create a user authentication module in Python using JWT. Include signup, login, logout, and token verification functions."
Claude outputs ready-to-use Python files implementing JWT authentication.
Debug Codebase
claude -p "Diagnose and fix error: 'TypeError: unhashable type: list' found in server.py"
claude -p "Diagnose and fix error: 'TypeError: unhashable type: list' found in server.py"
Claude finds the line, explains the cause, and suggests (or directly edits) the fix.
Planning & Architecture
Prompt:
ultrathink: Plan a scalable microservices architecture for an e-commerce platform using Node.js, MongoDB, and Docker.
ultrathink: Plan a scalable microservices architecture for an e-commerce platform using Node.js, MongoDB, and Docker.
Claude breaks down modules, recommended data models, and container setup. Asks for feedback before proceeding.
Testing Workflow
Prompt:
Write tests for 'calculateTax' function in tax_utils.py. Use TDD: only write tests first, do not implement function yet.
Write tests for 'calculateTax' function in tax_utils.py. Use TDD: only write tests first, do not implement function yet.
Claude provides test cases in desired framework (e.g., pytest), waits for code to pass tests before implementing.
Audit & Documentation
Prompt:
Recommended by LinkedIn
audit: Review payment_processing.js for potential security vulnerabilities (e.g., SQL injection, XSS). List each issue with a fix.
audit: Review payment_processing.js for potential security vulnerabilities (e.g., SQL injection, XSS). List each issue with a fix.
Claude outputs a structured list of vulnerabilities and suggested code corrections.
Prompt:
git diff HEAD~1 | claude -p "Review this PR for performance bottlenecks."
doc: Generate API docstrings and usage examples for 'orderService' class in order_service.ts
Claude updates comments and provides markdown snippet for docs.
Workflow Automation
Example: Automated Code Review
for file in src/*.js; do
claude -p "Generate JSDoc comments for $file" --output-format text >> docs.md
done
git diff HEAD~1 | claude -p "Review this PR for performance bottlenecks."
Claude analyzes the patch for speed/efficiency issues and writes a markdown summary.
Example: Batch Documentation
for file in src/*.js; do
claude -p "Generate JSDoc comments for $file" --output-format text >> docs.md
done
for file in src/*.js; do claude -p "Generate JSDoc comments for $file" --output-format text >> docs.md done
Auto-generates documentation for each JavaScript file in your src directory.
Advanced Session Management
Example: Multi-step Automation
claude -p "Analyze project structure for modularity" | \
claude -p "Suggest improvements based on analysis" | \
claude -p "Create implementation plan"
claude -p "Analyze project structure for modularity" | \ claude -p "Suggest improvements based on analysis" | \ claude -p "Create implementation plan"
Chains Claude actions to build a full strategy.
Example: Visual Iteration
Hey Claude! Here's a screenshot of the app homepage. Redesign it for better user engagement using Tailwind CSS, then iterate until the design matches the mock.
Hey Claude! Here's a screenshot of the app homepage. Redesign it for better user engagement using Tailwind CSS, then iterate until the design matches the mock.
Tips and Best Practices
cat error.log | claude -p "Find root cause of repeated crash errors."
With these practical examples, Claude Code becomes a powerful interactive assistant for planning, coding, auditing, documenting, and automating your entire engineering workflow.