Claude Code Cheat Sheet
Quick Reference Cardโ
๐ Launch Commandsโ
claude # Interactive mode
claude -p "prompt" # Headless (non-interactive)
claude --continue # Continue last session
claude --resume # Pick session to resume
claude --dangerously-skip-permissions # YOLO mode
โก Essential Slash Commandsโ
| Command | What it does |
|---|---|
/clear | USE OFTEN! Fresh context for new task |
/compact | Compress context, keep key info |
/init | Generate starter CLAUDE.md |
/memory | Edit memory files |
/context | Check context usage % |
/resume | Resume previous session |
/rename | Name current session |
/permissions | Manage tool allowlist |
/help | List all commands |
๐ง Thinking Triggersโ
| Say this | Get this |
|---|---|
| "think" | Basic thinking |
| "think hard" | Medium thinking |
| "think harder" | Deep thinking |
| "ultrathink" | Maximum thinking |
Example:
Think hard about the best architecture for this.
Consider tradeoffs before recommending.
๐ File Locationsโ
./CLAUDE.md โ Project context (shared, commit to git)
./CLAUDE.local.md โ Personal notes (gitignored)
~/.claude/CLAUDE.md โ Global (all projects)
./.claude/commands/ โ Project slash commands
~/.claude/commands/ โ Personal slash commands
./.claude/rules/ โ Modular rules (auto-loaded)
./.claude/settings.json โ Project settings
~/.claude.json โ Global settings
๐ Core Workflowโ
1. EXPLORE โ "Read the auth files. Don't code yet."
2. PLAN โ "Think hard and make a plan."
3. CODE โ "Implement the plan."
4. COMMIT โ "Commit and create PR."
โ TDD Workflowโ
1. "Write tests for X. Don't implement yet."
2. "Run tests, confirm they fail."
3. "Implement code to pass tests. Don't modify tests."
4. "Commit tests and implementation."
๐ฏ Pro Tipsโ
Be Specificโ
โ "add tests"
โ
"Write tests for login.ts covering logged-out edge case. No mocks."
Give Contextโ
- Images: Drag/drop or Cmd+Ctrl+Shift+4 (Mac)
- Files: Tab-complete with @filename
- URLs: Just paste them
- Data: Pipe in:
cat data.csv | claude
Course Correctโ
- Escape โ Interrupt anytime
- Escape Escape โ Go back, try different approach
- "Undo" โ Revert changes
Keep Context Freshโ
/clear # New task? Clear first!
/compact # Getting long? Compress
/resume name # Continue named session
๐ Custom Command Templateโ
File: .claude/commands/my-command.md
---
description: What this command does
allowed-tools: Bash(git:*), Edit
argument-hint: [optional-args]
---
Your prompt instructions here.
Use $ARGUMENTS for all args.
Use $1, $2 for positional args.
Use !`command` to embed shell output.
โ๏ธ CLAUDE.md Templateโ
# Project Name
## About
One-liner description.
## Commands
- `npm run dev` - Start dev
- `npm test` - Run tests
## Code Style
- TypeScript strict mode
- Functional components
## Architecture
- /src/api - Routes
- /src/models - Data
## Gotchas
- Auth uses HttpOnly cookies
๐ง Permissionsโ
# Allow specific tools
/permissions add Edit
/permissions add "Bash(git commit:*)"
/permissions add "Bash(npm test:*)"
# Or edit .claude/settings.json:
{
"allowedTools": ["Edit", "Bash(git:*)"]
}
๐ MCP (External Tools)โ
# Add MCP servers
claude mcp add puppeteer # Browser control
claude mcp add github # GitHub operations
# Debug MCP
claude --mcp-debug
๐ Quick Promptsโ
Git Operationsโ
Write a commit message based on the diff.
Search git history for why this API exists.
Help me resolve this rebase conflict.
Code Reviewโ
Review these changes for security issues.
What edge cases am I missing?
How can I simplify this function?
Learningโ
Explain how the auth system works.
Show me patterns for creating new endpoints.
Why did we choose X over Y?
Refactoringโ
Refactor to reduce duplication.
Extract this into a reusable hook.
Modernize this to use async/await.
๐ซ Don'tโ
- Skip planning phase
- Let context get stale
- Put everything in CLAUDE.md
- Duplicate linter rules
- Make huge commits
โ Doโ
- Be specific in prompts
- Use thinking triggers
- Give visual targets (mocks, tests)
- Use /clear between tasks
- Commit often
๐ Resourcesโ
- Docs: docs.anthropic.com/claude-code
- Best Practices: anthropic.com/engineering/claude-code-best-practices
- Awesome List: github.com/hesreallyhim/awesome-claude-code
Print this. Pin it. Refer to it often.