mirror of
https://github.com/onkelbeh/cheatsheets.git
synced 2025-10-14 22:48:31 +02:00
## Summary - Add new cheatsheet for Claude Code AI assistant CLI - Include most commonly used commands first for better UX - Cover interactive mode, file operations, git integration, and advanced features - Add comprehensive sections for workflows, troubleshooting, and best practices - Follow repository formatting conventions with proper YAML frontmatter ## Features Covered - ✅ Interactive mode and core commands - ✅ File operations and git integration - ✅ Advanced features (memory, image analysis) - ✅ Slash commands and productivity features - ✅ Common workflows (code review, testing, debugging) - ✅ IDE integrations and configuration - ✅ Troubleshooting and environment variables ## Test plan - [X] Verify YAML frontmatter follows repository conventions - [X] Check markdown formatting and table structure - [X] Ensure most used commands are prioritized at the top - [X] Validate all sections use proper Jekyll formatting classes - [X] Confirm links and references are accurate 🤖 Generated with [Claude Code](https://claude.ai/code) Co-authored-by: Le Coq Francis <f.lecoq@jacquetmetals.com> Co-authored-by: Claude <noreply@anthropic.com>
9.2 KiB
9.2 KiB
title, category, tags, updated, keywords
title | category | tags | updated | keywords | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Claude Code | AI |
|
2025-01-08 |
|
Getting started
{: .-three-column}
Introduction
{: .-intro}
Claude Code is an AI-powered CLI assistant for software engineering tasks. This reference covers the most commonly used commands and features.
- Claude Code docs (docs.anthropic.com)
- GitHub repository (github.com)
Installation & Setup
# Install Claude Code
npm install -g @anthropics/claude-code
# Login with API key
claude auth login
# Check authentication status
claude auth status
Quick Start
# Start interactive session
claude
# Run a single command
claude "help me write a Python function"
# Resume previous session
claude --resume
Core Commands
{: .-three-column}
Interactive Mode
{: .-prime}
Command | Description |
---|---|
claude |
Start interactive session |
claude --resume |
Resume last session |
claude --memory |
Start with memory enabled |
/help |
Show help and available commands |
/clear |
Clear current conversation |
/exit |
Exit interactive mode |
{: .-shortcuts} |
File Operations
Command | Description |
---|---|
claude "read file.py" |
Read and analyze a file |
claude "edit file.py" |
Edit an existing file |
claude "create file.py" |
Create a new file |
claude "fix tests" |
Fix failing tests |
claude "refactor code" |
Refactor existing code |
{: .-shortcuts} |
Git Integration
Command | Description |
---|---|
claude "create commit" |
Create git commit with message |
claude "create PR" |
Create pull request |
claude "review changes" |
Review git changes |
claude "fix merge conflicts" |
Help resolve merge conflicts |
{: .-shortcuts} |
Advanced Features
{: .-three-column}
Memory Management
# Enable memory for current session
claude --memory
# View memory contents
claude "show memory"
# Clear memory
claude "clear memory"
Extended Thinking
# Enable deeper analysis
claude --think
# Complex problem solving
claude "analyze this codebase and suggest improvements"
Image Analysis
# Analyze screenshot or diagram
claude "analyze this screenshot" --image path/to/image.png
# Paste image from clipboard
claude "explain this diagram" # then paste image
Slash Commands
{: .-three-column}
Session Management
Command | Description |
---|---|
/help |
Show available commands |
/clear |
Clear conversation history |
/reset |
Reset conversation state |
/exit |
Exit interactive mode |
/version |
Show Claude Code version |
{: .-shortcuts} |
Settings
Command | Description |
---|---|
/settings |
Show current settings |
/model |
Change AI model |
/memory on |
Enable memory |
/memory off |
Disable memory |
{: .-shortcuts} |
Productivity
Command | Description |
---|---|
/save |
Save conversation |
/load |
Load previous conversation |
/export |
Export conversation to file |
{: .-shortcuts} |
Common Workflows
{: .-three-column}
Code Review
# Review specific file
claude "review this code for bugs" file.py
# Review all changes
claude "review my git changes"
# Check code quality
claude "suggest improvements" src/
Testing
# Generate tests
claude "write tests for this function"
# Fix failing tests
claude "fix these test failures"
# Test coverage analysis
claude "analyze test coverage"
Documentation
# Generate README
claude "create README for this project"
# Add code comments
claude "add documentation to this function"
# API documentation
claude "generate API docs"
Debugging
# Debug error
claude "help debug this error: [error message]"
# Performance analysis
claude "why is this code slow?"
# Code explanation
claude "explain how this works" complex_function.py
IDE Integrations
{: .-three-column}
VS Code
# Install VS Code extension
code --install-extension anthropic.claude-code
# Open in VS Code
claude --vscode
# VS Code commands
Ctrl+Shift+P -> "Claude: Ask"
Ctrl+Shift+P -> "Claude: Review"
Configuration
# Set default editor
claude config set editor code
# Set working directory
claude config set workdir /path/to/project
# View all settings
claude config list
Best Practices
{: .-three-column}
Effective Prompting
# Be specific about requirements
claude "write a Python function that validates email addresses with regex"
# Provide context
claude "in this Django project, add user authentication"
# Ask for explanations
claude "explain this code and suggest improvements"
Project Structure
# Analyze entire project
claude "analyze project structure and suggest improvements"
# Focus on specific areas
claude "review the database models in models.py"
# Architecture decisions
claude "should I use async here?"
Security
# Security review
claude "check this code for security vulnerabilities"
# Best practices
claude "make this code more secure"
# Audit dependencies
claude "review package.json for security issues"
CLI Options
{: .-three-column}
Global Options
Option | Description |
---|---|
--help |
Show help information |
--version |
Show version number |
--resume |
Resume previous session |
--memory |
Enable memory |
--think |
Enable extended thinking |
--no-color |
Disable colored output |
--verbose |
Verbose logging |
{: .-shortcuts} |
Authentication
Command | Description |
---|---|
claude auth login |
Login with API key |
claude auth logout |
Logout current session |
claude auth status |
Check authentication status |
claude auth whoami |
Show current user info |
{: .-shortcuts} |
Configuration
Command | Description |
---|---|
claude config set |
Set configuration value |
claude config get |
Get configuration value |
claude config list |
List all configuration |
claude config reset |
Reset to default configuration |
{: .-shortcuts} |
Troubleshooting
{: .-three-column}
Common Issues
# Clear authentication
claude auth logout && claude auth login
# Reset configuration
claude config reset
# Clear cache
claude --clear-cache
# Debug mode
claude --verbose --debug
Network Issues
# Check connectivity
claude "test connection"
# Use proxy
claude --proxy http://proxy:8080
# Timeout settings
claude config set timeout 30
Memory Issues
# Clear memory
claude "clear memory"
# Disable memory
claude --no-memory
# Memory usage
claude "show memory usage"
Environment Variables
Variable | Description |
---|---|
CLAUDE_API_KEY |
API key for authentication |
CLAUDE_MODEL |
Default model to use |
CLAUDE_MEMORY |
Enable memory by default |
CLAUDE_EDITOR |
Default text editor |
CLAUDE_WORKDIR |
Default working directory |
NO_COLOR |
Disable colored output |
Also see
{: .-one-column}
- Claude Code documentation (docs.anthropic.com)
- GitHub repository (github.com)
- Claude API docs (docs.anthropic.com)
- Community discussions (github.com)