Claude Code Cheat Sheet
Essential commands, shortcuts, and patterns for productive Claude Code sessions.
Tip: Print this page (Ctrl/Cmd+P) for a handy desk reference
Slash Commands
/helpShow help and available commands
/clearClear conversation history and start fresh
/compactCompress conversation to save context space
/costShow token usage and cost for current session
/doctorCheck Claude Code installation and configuration
/initInitialize AGENTS.md in current project
/bugReport a bug to Anthropic
/configOpen or edit configuration
/loginSign in to your Anthropic account
/logoutSign out of your account
/memoryEdit persistent memory across sessions
/modelSwitch between Claude models
/permissionsView or modify file permissions
/reviewRequest a code review of recent changes
/statusShow current session status
/vimToggle vim keybindings
Keyboard Shortcuts
Ctrl+CCancel current operation or clear input
Ctrl+DExit Claude Code
Ctrl+LClear the terminal screen
Ctrl+RSearch command history
Up/DownNavigate through command history
TabAutocomplete file paths
EscCancel current input (vim mode)
CLI Arguments
claudeStart interactive session
e.g., claude
claude "prompt"Run single prompt and exit
e.g., claude "explain this file"
claude -cContinue previous conversation
e.g., claude -c "now add tests"
claude -pUse specific project
e.g., claude -p /path/to/project
claude --modelUse specific model
e.g., claude --model claude-3-opus
claude --versionShow version number
claude --helpShow CLI help
echo "x" | claudePipe input to Claude
e.g., cat error.log | claude "explain"
File Operations
Read [file]Read file contents
e.g., Read src/index.ts
Read [file:line]Read from specific line
e.g., Read src/index.ts:50
Write [file]Create or overwrite file
Edit [file]Make targeted edits to file
@[file]Include file in context
e.g., @package.json
@[folder/]Include folder in context
e.g., @src/components/
Common Patterns
Explain this codebaseGet an overview of the project structure and purpose
Find where X is definedLocate function, variable, or type definition
e.g., Find where handleSubmit is defined
Add [feature] to [file]Add new functionality
e.g., Add form validation to ContactForm.tsx
Fix the error in [file]Debug and fix an issue
e.g., Fix the TypeScript error in api/users.ts
Refactor [X] to [Y]Transform code structure
e.g., Refactor useAuth to use React Query
Write tests for [file]Generate test coverage
e.g., Write tests for utils/formatDate.ts
Review [file] for issuesGet code review feedback
e.g., Review api/checkout.ts for security issues
Configuration Files
AGENTS.mdProject instructions for Claude (auto-loaded)
.claudeignoreFiles to exclude from context (like .gitignore)
.claude/settings.jsonProject-specific settings
~/.claude/settings.jsonGlobal user settings
~/.claude/memory.mdPersistent memory across sessions
Context Management
/clearReset context completely
/compactSummarize and compress context
Forget about XRemove specific topic from context
Focus on X onlyNarrow context to specific area
Summarize our conversationGet compressed summary
Git Integration
What changed?Show git diff summary
Commit these changesCreate commit with AI message
Create a PR for thisGenerate pull request
Review the last commitAnalyze recent changes
Undo the last changeRevert recent modifications
Pro Tips
- Start messages with verbs: "Fix", "Add", "Refactor", "Explain"
- Be specific about files: "@src/components/Button.tsx" not "the button"
- Include context: "Following our existing patterns in auth.ts"
- Ask for confirmation: "Show me the plan before making changes"
- Chain tasks: "First lint, then test, then commit if passing"
- Reference examples: "Like we did in UserProfile.tsx"
AGENTS.md Starter Template
# Project: [Your Project Name]
## Overview
[Brief description of what the project does]
## Architecture
- `/src/app` - Next.js pages and routes
- `/src/components` - React components
- `/src/lib` - Utilities and helpers
- `/src/services` - Business logic
## Conventions
- TypeScript strict mode
- Use interfaces for object shapes
- Named exports (not default)
- Tailwind CSS for styling
## DO NOT
- Never commit secrets or API keys
- Never use `any` type
- Never skip error handling
## Common Tasks
### Adding a new page
1. Create file in /src/app/[route]/page.tsx
2. Add to navigation if needed
3. Follow existing page patterns