Skip to main content

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โ€‹

CommandWhat it does
/clearUSE OFTEN! Fresh context for new task
/compactCompress context, keep key info
/initGenerate starter CLAUDE.md
/memoryEdit memory files
/contextCheck context usage %
/resumeResume previous session
/renameName current session
/permissionsManage tool allowlist
/helpList all commands

๐Ÿง  Thinking Triggersโ€‹

Say thisGet 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.