Mar 24, 2026
5 min read
The Claude Code Cheat Sheet
Every Claude Code command, shortcut, and flag I actually use — slash commands, CLI flags, context management, and workflow tools in one printable reference.
By Cathryn Lavery
TL;DR: Every slash command, CLI flag, context trick, and workflow shortcut I actually use in Claude Code — organized into tables you can bookmark or print. Not a tutorial, just the reference I wish existed when I started.
I’ve been using Claude Code daily for months. Still look up commands. So I made this.
Not a tutorial. Not a think piece. Just the reference I wish existed when I started.
Slash Commands
Session Management
| Command | What it does |
|---|---|
/clear | Wipe conversation, start fresh |
/compact [focus] | Compress context window — add a focus keyword to keep the relevant stuff |
/resume | Resume or switch to a previous session |
/rename [name] | Name the session so you can find it later |
/branch [name] | Fork the conversation (alias: /fork) |
/rewind | Roll back conversation and code to a checkpoint |
/export | Export the full conversation |
/copy [N] | Copy the last (or Nth) response to clipboard |
Context and Files
| Command | What it does |
|---|---|
/init | Create a CLAUDE.md — Claude reads this automatically every session |
/memory | Edit CLAUDE.md files across your workspace |
/add-dir <path> | Give Claude access to another directory |
/context | Visualize your context window as a grid |
/mcp | Manage MCP server connections |
Workflow
| Command | What it does |
|---|---|
/plan [desc] | Enter plan mode — think before building |
/loop [interval] | Schedule a recurring task in the session |
/schedule | Cloud-scheduled tasks that run when you’re away |
/hooks | Automate actions on events |
/skills | List available skills |
/agents | Manage agents |
Review
| Command | What it does |
|---|---|
/diff | Interactive diff viewer |
/security-review | Analyze changes for vulnerabilities |
/pr-comments [PR] | Pull in GitHub PR feedback |
Model and Config
| Command | What it does |
|---|---|
/model [model] | Switch models mid-session |
/effort [level] | Set reasoning effort: low / med / high / max / auto |
/fast [on|off] | Toggle fast mode |
/config | Open settings |
/permissions | View or update what Claude can access |
/vim | Toggle vim keybindings |
/theme | Change color theme |
Utilities
| Command | What it does |
|---|---|
/cost | Token usage for this session |
/stats | Usage streaks and preferences |
/insights | Analyze session patterns |
/btw <question> | Side question that doesn’t pollute your main context |
/doctor | Diagnose installation issues |
/voice | Push-to-talk (supports 20 languages) |
/usage | Plan limits and rate status |
/help | Full command reference |
CLI Flags
The stuff you type before Claude starts.
# Start a new session
claude
# Resume your last session
claude --resume
# One-shot: run a task and print the result
claude --print "Fix all TypeScript errors in src/"
# Full auto mode — no confirmation prompts
claude --dangerously-skip-permissions "Run tests and fix failures"
# Continue from a specific session
claude --resume --session-id <id>
CLAUDE.md — The File That Changes Everything
Claude reads CLAUDE.md at the start of every session. Automatically. No prompting required.
This is where you write the things you’re tired of repeating.
# My Project
## What this is
SaaS billing dashboard built with Next.js and Stripe.
## Stack
Next.js 14, TypeScript, Supabase, Stripe, Tailwind v4, Vercel.
## Rules
- Always write tests before implementation
- Use pnpm, not npm
- Never modify the database schema directly — use migrations
- Components go in components/ui/
## Key files
- src/app/api/ — API routes
- supabase/migrations/ — schema changes go here
- src/lib/stripe.ts — Stripe integration
## Gotchas
- Auth uses httpOnly cookies, not JWT. Don't replace it.
- The analytics endpoint is rate-limited to 10 req/s.
- We're on Tailwind v4 — no arbitrary values.
The Multi-File Trick
CLAUDE.md files stack:
- Root
CLAUDE.md— global rules for the whole repo - Subfolder
CLAUDE.md— rules for that module only - Claude inherits parent files automatically
This is how I keep different agents working on the same codebase without stepping on each other.
Keyboard Shortcuts
| Shortcut | Action |
|---|---|
↑ | Recall last message |
Shift + Enter | New line without sending |
Esc | Cancel current generation |
Cmd + K | Clear input |
Customize everything: /keybindings
MCP Servers — Give Claude Real Tools
MCP (Model Context Protocol) lets Claude talk to your actual infrastructure. Database, GitHub, file system — live data, not copy-paste.
The ones I use:
| Server | What it does |
|---|---|
@modelcontextprotocol/server-filesystem | File access beyond the project directory |
@modelcontextprotocol/server-postgres | Live database queries |
@modelcontextprotocol/server-github | Issues, PRs, repos — all from inside the session |
@modelcontextprotocol/server-brave-search | Web search without leaving Claude |
| Supabase MCP | Direct access to tables, auth, and storage |
Set up: /mcp → add server → restart.
Prompt Patterns That Actually Work
After hundreds of sessions, these are the patterns that consistently get better results.
Be the PM, Not the Coder
“The checkout page shows a blank screen after clicking ‘Pay’. Look at the error logs, find the root cause, fix it, and write a regression test.”
Better than: “Fix the checkout page.”
Scope Hard
“Only touch
src/checkout/PaymentForm.tsx. Don’t refactor anything else.”
Claude will refactor your entire codebase if you let it. Set boundaries.
Give Context It Can’t See
“The Stripe webhook is failing. Here’s the error from our logs: [paste]. Here’s our current handler: [paste]. Fix it.”
Claude can’t read your server logs. Bring the context to it.
Plan Before You Build
/plan Build a usage-based billing feature using Stripe metered billing
Plan mode forces Claude to think before coding. Use it for anything complex.
Enforce Standards
“We use Tailwind v4. No arbitrary values. All components go in
components/ui/. Usecn()for class merging.”
Agentic Mode — Letting Claude Run
When you trust the guardrails:
# Fully automated
claude --dangerously-skip-permissions "Run the test suite, fix any failures, and commit"
Make it safe:
- Set limits in
CLAUDE.md(“never delete files”, “never force push”, “never modify production env”) - Scope the task — vague prompts get unpredictable results
- Run in a branch
- Check
/diffbefore you merge
Quick Reference
claude Start new session
claude --resume Resume last session
claude --print "task" One-shot (no interactive)
claude --dangerously-skip-permissions Full auto mode
/init Create CLAUDE.md
/compact Compress context
/plan Plan before coding
/diff See what changed
/rewind Undo changes
/btw Side question
/cost Token usage
/effort high Crank up reasoning
/doctor Fix setup issues
Three Rules I Follow
1. Write CLAUDE.md first. Before you prompt anything on a new project, write the context file. It compounds over every session.
2. Scope every task. “Fix the login bug” gets worse results than “The JWT is expiring too early in src/auth/session.ts — fix the expiry logic and add a test.”
3. Review the diff. Always. /diff before you accept. No exceptions.
Written by
Cathryn Lavery
Cathryn built and sold BestSelf, bought it back from private equity, and still runs it. She writes Little Might so she doesn't have to keep these lessons in her head.
Related reading
-
Apr 4, 2026
The Codex Cheat Sheet
-
Apr 5, 2026
The Garry Tan Stack: A Definitive Guide to gstack
-
Mar 25, 2026
Claude Code Tutorial: Hooks, Commands, Plugins, Skills, and MCP Explained
-
Mar 15, 2026
How I built my wife a personal AI assistant on OpenClaw (and what actually took time)
-
Mar 9, 2026
Everything You Need Before Your AI Employee Starts