Skip to content
phin.dev
Go back

Claude Code Cheat Sheet

1. Session Management

CommandWhat it doesWhen to use
/clearWipe the entire conversationSwitching to a completely different task
/compactCompress context, keep what mattersWhen context > 60% — e.g. /compact focus on API changes
/resumeContinue a previous sessionPick from the session list
/renameName the session so you can find it laterUse before exiting — e.g. /rename oauth-migration
/rewindRoll back to the last checkpointUndo button — Esc+Esc or /rewind

Optimal workflow: /rename 'task-name' → work → /clear → new task Fixed the same issue twice? → /clear and rewrite the prompt.


2. Model & Mode

Picking the right model saves 40–80% on cost.

CommandWhat it doesWhen to use
/modelSwitch model mid-conversationContext stays intact — e.g. /model claude-sonnet-4-6
/effortSet thinking level: low / medium / highPersistent for the session — /effort high/effort medium to reset
/fastFaster replies, fewer tokensBrainstorming, simple questions
/planPlan before codingApprove the plan, then execute — Shift+Tab toggle in VS Code
ModelBest forCost
Haiku 4.5Brainstorm, sub-agentsCheapest
Sonnet 4.6Daily coding, 90% of tasks$3/MTok
Opus 4.6Architecture, complex problems$5/MTok

Thinking depth:

think       →   4K tokens   →   design patterns
think hard  →   10K tokens  →   DB migration
ultrathink  →   31K tokens  →   architecture

⚠ CLI only — does not work on the web


3. Context & Cost

CommandWhat it doesNotes
/costView cost for current sessionTotal, duration, tokens — e.g. Total cost: $0.55
/statsDetailed usage statsCache hits, model used
/contextSee how much context window is usedLike a fuel gauge — /compact when > 60%
@file.tsReference a specific file in your promptAutocompletes with @
@file#5-20Reference specific linesSaves context — e.g. @utils.py#47-55 fix this function

Real token savings:


4. Keyboard Shortcuts (VS Code)

ShortcutWhat it doesTip
Ctrl+IInline edit selected codeSelect code → Ctrl+I → describe the change
Ctrl+Shift+CToggle sidebar chatMost used shortcut daily
Ctrl+EnterSend messageInstead of clicking Send
Ctrl+Shift+NOpen new chatClean context for a new task
Ctrl+RSearch prompt historyFuzzy search — type a few keywords
Ctrl+GOpen plan in text editorPlan Mode → Ctrl+G → edit → save

Plan Mode workflow: Shift+Tab → Plan Mode → Claude generates plan → Ctrl+G to edit → Shift+Tab → Implement


5. Quick Prefixes

PrefixWhat it doesExample
!Run bash without Claude’s approval!git status · !npm install
#Save directly to CLAUDE.md memory# Always use snake_case for DB columns
@Autocomplete file pathLook at @src/auth/middleware.ts
/btwAsk a side question without polluting context/btw what's the diff between access_token and refresh_token?
ultrathink31K tokens for complex problemsultrathink about this architecture

When to use what:


6. CLI Pipes & Flags

# Run a single prompt and exit (no interactive session)
claude -p "Explain this project" --output-format json

# Continue a named session
claude --resume

# Specify a model on startup
claude --model claude-opus-4-6

# Pipe git log for analysis
git log --oneline -20 | claude -p "summarize for standup"

# Pipe a file for review
cat error.log | claude -p "find the root cause"

In CI/CD:

claude -p "Review PR for security" --output-format json
git diff | claude -p "flag issues"        # Pre-commit hook
claude -p "check for regressions"         # Nightly review

7. Workflow Combos

Plan → Code

Shift+Tab (Plan Mode) → Claude generates plan → Ctrl+G to edit → Shift+Tab (implement)

Save & resume a complex task

/rename 'oauth-migration' → work → exit terminal → claude --resume → pick 'oauth-migration'

Optimize cost per task

/fast → brainstorm → /model sonnet → implement → /model opus → architecture → /clear between tasks

Free up context in a long session

/context → check % used → over 60%? → /compact focus on X → continue without losing important context

Debug loop (when Claude goes off track)

Claude does something wrong → /rewind → same issue twice? → /clear → rewrite with a more detailed prompt

Pro Tips

Two-Correction Rule — Fix the same issue max 2 times. On the 3rd attempt → /clear and rewrite the prompt with more detail.

CLAUDE.md — Claude reads this every session. Keep it under 200 lines. Structure: ## Tech Stack ## Commands ## Rules ## Avoid.

Hooks > Memory — Use hooks for mandatory rules. They run every time without reminders. Example: PostToolUse → eslint --fix {{file}}.

Turn good prompts into Skills — Write once, trigger automatically. Type publish blog → skill runs automatically.

Search old sessionsgrep -r "ultrathink" ~/.claude/projects/


Power User Checklist


Share this post on: