Free Resource

Claude Code Cheat Sheet

The essential reference for Claude Code power users. Commands, shortcuts, CLAUDE.md patterns, and advanced techniques.

Slash Commands

Navigation & Control

  • /help- Show all available commands
  • /clear- Clear conversation context
  • /compact- Summarize and compress context
  • /cost- Show session token usage and cost
  • /quit- Exit Claude Code

Context Management

  • /init- Initialize CLAUDE.md in project
  • /memory- View/manage persistent memory
  • /context- Show current context window
  • /add-dir <path>- Add directory to context
  • /review- Review changes before commit

Thinking Modes

  • /think- Enable extended thinking
  • /ultrathink- Maximum reasoning depth
  • /thinkhard- Deep analysis mode

Session & History

  • /resume- Resume previous session
  • /history- Show command history
  • /undo- Undo last file change
  • /diff- Show uncommitted changes

Keyboard Shortcuts

Essential

  • Ctrl+CInterrupt current operation
  • Ctrl+DExit Claude Code
  • TabAutocomplete commands
  • Up/DownNavigate command history

Input

  • Shift+EnterMulti-line input
  • Ctrl+LClear terminal
  • Ctrl+RSearch history
  • EscCancel current input

Navigation

  • Ctrl+AMove to line start
  • Ctrl+EMove to line end
  • Ctrl+WDelete word backward
  • Ctrl+UClear line

CLAUDE.md Patterns

Project Context Block

# Project Overview
This is a Next.js 14 app with App Router.
Stack: TypeScript, Tailwind CSS, Prisma, PostgreSQL

# Key Directories
- /src/app - Page routes
- /src/components - React components
- /src/lib - Utilities and helpers
- /prisma - Database schema

Coding Standards Block

# Coding Standards
- Use 'use client' only when needed
- Prefer server components by default
- Use Zod for validation
- Error handling: try/catch with proper logging
- Tests: Vitest for unit, Playwright for e2e

Negative Prompt Block (Critical)

# Do NOT
- Do not add comments to unchanged code
- Do not refactor code not related to the task
- Do not add features beyond what's requested
- Do not use console.log for production code
- Do not commit without running tests

Workflow Instructions Block

# Workflow
1. Read the file before editing
2. Make minimal changes to achieve the goal
3. Run tests after changes: npm test
4. Format with: npm run format
5. If tests fail, fix before continuing

Power User Prompt Patterns

Autonomous Loop

Work autonomously until complete.
After each step, verify the result.
If something fails, debug and retry.
Only stop when fully working.

Parallel Exploration

Search for [X] in parallel:
1. Check files matching *.ts
2. Search for "keyword" in /src
3. Look at recent git commits
Report all findings together.

Structured Output

Analyze this code and respond with:
## Issues Found
## Suggested Fixes
## Code Changes
## Verification Steps

Context Preservation

Before we continue, summarize:
1. What we've accomplished
2. Current blockers
3. Next steps planned
Save this to CLAUDE.md under ## Session Notes

MCP Server Configuration

Location: ~/.claude/claude_desktop_config.json

{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": ["@whenmoon-afk/memory-mcp"]
    },
    "filesystem": {
      "command": "npx",
      "args": ["@modelcontextprotocol/server-filesystem", "/path/to/allowed"]
    },
    "github": {
      "command": "npx",
      "args": ["@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_TOKEN": "your-token-here"
      }
    }
  }
}

Popular MCP Servers

  • memory-mcp - Persistent memory
  • momentum - Context recovery
  • server-filesystem - File access
  • server-github - GitHub integration
  • server-postgres - Database queries
  • server-puppeteer - Browser automation

Config Locations

  • macOS: ~/Library/Application Support/Claude/
  • Windows: %APPDATA%\\Claude\\
  • Linux: ~/.config/Claude/

Pro Tips

๐ŸŽฏ
Be Specific

"Fix the bug" โ†’ "Fix the null pointer in handleSubmit at line 42 of UserForm.tsx"

๐Ÿ“
Reference Files

Start prompts with file paths: "In src/lib/auth.ts, update the token validation..."

๐Ÿ”„
Iterative Refinement

Don't try to do everything at once. Small, focused changes are more reliable.

๐Ÿงช
Test After Changes

Always ask Claude to run tests after making changes. Catch issues immediately.

๐Ÿ“
Use CLAUDE.md

Invest 10 minutes in a good CLAUDE.md. It saves hours of re-explaining context.

โšก
Thinking Modes

Use /ultrathink for complex architecture decisions. Normal mode for simple tasks.

๐Ÿ›‘
Negative Prompts

Tell Claude what NOT to do. "Do not modify files outside /src/components"

๐Ÿ’พ
Save Context

Before /clear, ask Claude to summarize the session to CLAUDE.md.

Get More Claude Code Tips

Join the newsletter for weekly tips, new tool announcements, and advanced techniques.

Need personalized help with Claude Code?

Book a Consulting Session