Claude Code Cheat Sheet
Quick reference for Claude Code's common commands, keyboard shortcuts, and operations.
Keyboard Shortcuts
Shift+Tab - Permission Mode Switching
Cycle through three permission modes:
Normal Mode → Auto-Accept Mode → Plan Mode → Normal Mode- Normal Mode: Default mode, each operation requires confirmation
- Auto-Accept Mode: Auto-accept edits (bottom displays
⏵⏵ accept edits on) - Plan Mode: Read-only mode (bottom displays
⏸ plan mode on), only plans without executing
Built-in Commands
Basic Commands
/help # View help information
/clear # Clear conversation history
/quit # Exit Claude CodeModel Switching
/model # View current model
/model opus # Switch to Opus 4.6 (most powerful)
/model sonnet # Switch to Sonnet 4.6 (default, balanced)
/model haiku # Switch to Haiku 4.5 (fastest)Model details:
- Opus 4.6 (
claude-opus-4-6): Most powerful, suitable for complex tasks - Sonnet 4.6 (
claude-sonnet-4-6): Default, balances performance and cost - Haiku 4.5 (
claude-haiku-4-5-20251001): Fastest, suitable for simple tasks
Fast Mode
/fast # Toggle fast mode (uses the same Opus 4.6 but outputs faster)Note: /fast does not switch to a different model, it uses the same Opus 4.6 model but with faster output.
Cost Management
/cost # View current session's API usage costDisplays:
- Input tokens
- Output tokens
- Total cost (USD)
Skills Invocation
/<skill-name> # Invoke user skillCommon Skills:
/commit- Smart commit/review- Code review/test- Generate tests/docs- Generate documentation
Permission Response Options
When Claude requests permission, you can choose:
Claude wants to:
• Read file: src/config.ts
• Write file: src/auth.ts
• Run command: npm test
Allow? [y/n/always/never]y- Allow this operationn- Deny this operationalways- Always allow this type of operation for this sessionnever- Always deny this type of operation for this session
Command Line Startup Options
Basic Startup
# Start in current directory
claude
# Specify working directory
claude /path/to/projectPermission Modes
# Auto-accept mode
claude --permission-mode auto
# Ask mode (default)
claude --permission-mode ask
# Custom mode
claude --permission-mode customModel Selection
# Use Opus model
claude --model opus
# Use Sonnet model (default)
claude --model sonnet
# Use Haiku model
claude --model haikuHeadless Mode
# For CI/CD
claude --headless "Run tests and generate report"Other Options
# View version
claude --version
# View help
claude --helpConfiguration Files
Global Configuration
Location: ~/.config/claude/config.json
{
"apiKey": "sk-ant-...",
"defaultModel": "claude-sonnet-4-6",
"permissionMode": "ask",
"theme": "dark",
"autoSave": true
}Project Configuration
Location: .claude/settings.json
{
"model": "claude-sonnet-4-6",
"permissionMode": "custom",
"allowedPaths": ["src/**", "tests/**"],
"blockedPaths": [".env", "secrets/**"],
"allowedCommands": ["npm test", "npm run build"],
"blockedCommands": ["rm -rf", "git push --force"]
}Project Description
Location: CLAUDE.md (auto-loaded into context)
# Project Name
## Tech Stack
- React 18
- TypeScript 5
## Code Standards
- Use functional components and Hooks
- All components must have TypeScript types
## Common Commands
- Development: `npm run dev`
- Testing: `npm test`Auto Memory System
Memory Directory
Location: ~/.claude/projects/<project-hash>/memory/
MEMORY.md
- Auto-loaded into context (first 200 lines)
- Used to store project-related persistent information
- Persists across sessions
Topic Files
Create topic files to organize memory:
debugging.md- Debugging experiencepatterns.md- Code patternsconventions.md- Project conventions
Environment Variables
API Key
# Anthropic API
export ANTHROPIC_API_KEY='sk-ant-...'AWS Bedrock
export AWS_ACCESS_KEY_ID='...'
export AWS_SECRET_ACCESS_KEY='...'
export AWS_REGION='us-east-1'Proxy Settings
export HTTP_PROXY='http://proxy:8080'
export HTTPS_PROXY='http://proxy:8080'Debug Mode
export ANTHROPIC_LOG=debugCommon Operation Patterns
Quick Iteration
- Press
Shift+Tabto switch to Auto-Accept Mode - Develop quickly without confirming each time
- Press
Shift+Tabto return to Normal Mode when done
Complex Task Planning
- Press
Shift+Tabtwice to switch to Plan Mode - Claude creates a detailed plan but doesn't execute
- Review the plan then press
Shift+Tabto return to Normal Mode - After confirming, Claude executes the plan
Cost Control
- Use
/costto view current cost - Use
/model haikufor simple tasks - Use
/model opusfor complex tasks - Use
/fastto speed up output
File Operations
Read Files
You: Read src/App.tsxCreate Files
You: Create src/utils/helper.ts, implement a date formatting functionModify Files
You: Add a new route after line 20 in src/App.tsxBatch Operations
You: Read all .tsx files in src/components/ directoryCommand Execution
Run Tests
You: Run all testsInstall Dependencies
You: Install axios and @types/axiosGit Operations
You: Check git status
You: Commit all changes, commit message is "Add user authentication"Code Generation
Component Generation
You: Create a React component UserCard, props include name, email, avatarAPI Endpoint
You: Create an Express API endpoint POST /api/usersTest Generation
You: Generate unit tests for src/utils/helper.tsTroubleshooting
Permission Denied
- Check permission configuration in
.claude/settings.json - Use
alwaysoption to allow similar operations
Invalid API Key
# Check environment variable
echo $ANTHROPIC_API_KEY
# Reset
export ANTHROPIC_API_KEY='sk-ant-...'Network Connection Issues
# Test connection
curl https://api.anthropic.com/v1/messages
# Use proxy
export HTTPS_PROXY=http://proxy:8080Command Not Found
# Check installation
which claude
# Reinstall
npm install -g @anthropic-ai/claude-codeBest Practices
1. Specify File Paths Clearly
✅ Good: Modify src/components/Button.tsx ❌ Bad: Modify the Button component
2. Provide Sufficient Context
✅ Good: Add a "Remember me" checkbox to the login form, use localStorage to save state ❌ Bad: Add remember me feature
3. Use CLAUDE.md
Create CLAUDE.md in project root, documenting:
- Project description
- Tech stack
- Code standards
- Common commands
4. Use Permission Modes Appropriately
- Normal Mode: Important operations, uncertain tasks
- Auto-Accept Mode: Trusted tasks, quick iteration
- Plan Mode: Complex tasks, need review first
5. Monitor Costs Regularly
Use the /cost command to monitor API usage.
Quick Reference Card
Start Claude Code
claude # Current directory
claude /path/to/project # Specified directory
claude --model opus # Use Opus modelSwitch Modes
Shift+Tab # Cycle permission modes
/model opus # Switch to Opus
/fast # Fast modeView Information
/help # Help
/cost # Cost
/model # Current modelPermission Responses
y # Allow this time
n # Deny this time
always # Always allow
never # Always denyGetting Help
- Command line help:
claude --help - Online help:
/help - Issue reporting: https://github.com/anthropics/claude-code/issues
- Full documentation: Claude Code Documentation