Claude Code cheat sheet

The stuff you actually need. Updated 2026-03-23.

🚀 Get productive in 30 seconds

  1. 1. From your repo root, run `claude` for interactive work or `claude -p "your task"` for one-shot/headless work.
  2. 2. For anything non-trivial, start with a verification target: tell Claude what command proves success, like `npm test`, `pnpm lint`, or a screenshot comparison.
  3. 3. Use `@path/to/file` to point Claude at the exact file instead of describing it vaguely.
  4. 4. For bigger changes, enter Plan Mode first with `/plan` or `--permission-mode plan` so Claude explores before editing.
  5. 5. After changes, ask Claude to run the relevant tests, summarize risks, and create the commit or PR if you want the full workflow handled.

// daily_workflows

The things you'll actually do every day.

Fix a bug from an error message

debuggingquickhigh-value

Paste the real error, give the reproduce command, and make Claude verify the fix instead of guessing.

claude "The app fails when I run npm test with this error: [paste stack trace]. Reproduce it, find the root cause, fix it, and verify the failing test passes."

Understand an unfamiliar codebase fast

onboardingexplorationplanning

Have Claude map the architecture, key flows, and hotspots before you touch code.

claude --permission-mode plan "Give me a high-level overview of this codebase, identify the main architecture patterns, trace the auth flow, and list the files I should read first."

Targeted code explanation with exact files

readingpreciseeveryday

Use `@` references so Claude starts with the right context instead of scanning the whole repo.

claude "Explain how @src/auth/session.ts and @src/api/login.ts work together, and point out likely failure points."

Write tests for an existing module

testingqualitycommon

Ask for missing coverage plus edge cases, then have Claude run and fix the new tests.

claude "Find gaps in test coverage for @src/services/notifications.ts, add meaningful tests for happy path and edge cases, run the relevant test file, and fix any failures."

Safe refactor in stages

refactorsafeplanning

Use plan mode first, then implement against the plan so the change stays scoped.

claude --permission-mode plan "Analyze @src/utils and create a safe refactor plan to modernize deprecated API usage without changing behavior."

Continue yesterday's work

resumedailycontext-saving

Resume the last conversation or a named session instead of restating everything.

claude -c

Review PR comments and fix issues

gitprreview

Pull PR review comments directly into the session, then have Claude address them.

claude /pr-comments 123 "Address all unresolved review comments, run tests, and commit the fixes."

Ask a side question without polluting the thread

everydaycontextquick

Use /btw to get a quick answer mid-session without it becoming part of the conversation history.

/btw What's the difference between useEffect and useLayoutEffect here?

Use Claude like a Unix tool

automationclireview

Pipe logs, diffs, or command output straight into headless mode for quick analysis.

git diff main --name-only | claude -p "Review these changed files for security issues and list the top risks first."

⚡ power_moves

Stuff most people don't know about.

Explore -> Plan -> Implement -> Verify

Power users split discovery from coding. First use Plan Mode to understand the codebase and produce a plan, then switch to implementation with explicit verification steps.

claude --permission-mode plan "Read @src/auth and plan an OAuth migration. Identify files, risks, tests, and rollback concerns."

This avoids the biggest beginner mistake: letting Claude start coding before it fully understands the problem.

Make Claude self-check every change

Always specify how Claude should prove success: a test command, linter, screenshot, or exact expected output.

claude "Add retry logic to the payment client, run pnpm test payment-client, and only stop when the tests pass and there are no new lint errors."

Verification is the highest-leverage prompt upgrade because it closes the loop without needing you to babysit every step.

Use `@files` to slash token waste

Instead of saying 'look around the repo', reference the exact files or directory that matter.

claude "Compare @src/db/schema.ts with @src/db/migrations and tell me why signup is failing in production."

Precise file references reduce context bloat and get better answers faster.

Create a project CLAUDE.md that actually helps

Run `/init` (or set CLAUDE_CODE_NEW_INIT=true for an interactive setup that also covers skills, hooks, and personal memory). Keep the file short: build commands, test rules, repo conventions, dangerous areas.

/init

A concise CLAUDE.md compounds over time; a bloated one gets ignored and pollutes every session.

Use subagents for specialist work

Create a debugger, reviewer, or API designer subagent so research and implementation happen in separate context windows. Use `isolation: "worktree"` to give each subagent its own git worktree.

/agents

Subagents preserve main-session context, reduce noise, and can be constrained to the exact tools/models needed.

Use hooks for rules that must happen every time

Wire up shell commands, HTTP endpoints, or LLM prompts to hook events. Key events: PreToolUse (block/modify before a tool runs), PostToolUse (run linters/tests after edits), SubagentStart/Stop (scope or clean up subagents), SessionStart, Stop, PreCompact/PostCompact.

/hooks

CLAUDE.md is advisory; hooks are deterministic. That's the difference between 'usually' and 'always'.

Use worktrees for isolated feature work

Start Claude in an isolated git worktree so main-branch state is never touched during experiments.

claude --worktree "Implement rate limiter on a clean branch without touching main"

Worktrees let you run parallel Claude sessions on the same repo without conflicts. Each subagent can also use worktree isolation.

Compact before the session gets dumb

When context starts getting heavy, compact with an explicit focus so Claude keeps the right thread.

/compact Keep the current debugging state, reproduction steps, and the hypothesis about token refresh failures.

Claude quality drops as context fills. Power users actively manage context instead of hoping it stays sharp forever.

Use headless mode in scripts and CI

For repeatable automation, call Claude with `-p`, structured output, turn limits, and a budget ceiling. Use `--bare` to skip hook/plugin/skill discovery for faster scripted calls.

claude --bare -p --output-format json --max-turns 3 --max-budget-usd 2.00 "Review this diff for security regressions and output JSON with severity, file, and recommendation."

This makes Claude reliable in automation instead of interactive-only. --bare removes startup overhead that only matters for interactive sessions.

Enable remote control to pick up from browser or mobile

Make your local terminal session available for remote control from claude.ai or the Claude app. Or start a standalone remote-control server without a local session.

/remote-control # or from CLI without a local session: claude remote-control --name "My Project"

You don't have to keep a laptop session open for long autonomous tasks. Continue from any device.

Raise effort only when the problem deserves it

Keep everyday coding on default. Use `/effort high` for architecture or stubborn bugs. `/effort max` is session-only and requires Opus 4.6.

/effort high

This matches compute to task complexity instead of paying a speed/cost penalty on every prompt.

🔥 common_gotchas

Save yourself 30 minutes of debugging.

high

Claude starts coding before it fully understands the problem.

Use `/plan` or `--permission-mode plan` for anything multi-file, ambiguous, or architecture-heavy. Switch to implementation only after you like the plan.

high

You get okay-looking code that never got verified.

Always give a success command or artifact: tests, linter, screenshot, exact output, or repro steps. Ask Claude to run it before stopping.

high

Context quality degrades in long sessions and Claude starts forgetting earlier constraints.

Use `/context` to watch usage, `/compact` to trim history, and start a fresh or resumed session when the conversation becomes bloated.

annoying

Claude keeps asking for permission and the session becomes click-heavy.

Use `/permissions` or settings allowlists for safe commands. For read-only work use Plan Mode. Only use `--dangerously-skip-permissions` in a well-contained sandbox.

medium

Your CLAUDE.md is huge, vague, or full of things Claude could infer anyway.

Keep it concise, specific, and focused on repo-specific instructions. If it grows large, split it with `.claude/rules/` or imports.

medium

You describe files in words instead of pointing at them.

Use `@file` and `@directory` references. This is faster, more precise, and reduces wasteful exploration.

medium

Resuming work means re-explaining everything.

Use `-c`, `-r <session>`, or `/pr-comments <PR>` to reopen the existing session context instead of creating a brand-new chat.

high

Beginner prompts ask for 'fix it' with no reproduction steps or constraints.

Include the error, reproduce command, likely area, and what 'done' looks like. Claude performs much better with concrete scope.

annoying

Install works, but `claude` is not found.

Your install directory is probably missing from PATH. Verify `~/.local/bin` is on PATH on macOS/Linux, or `%USERPROFILE%\.local\bin` on Windows.

medium

Hooks block or behave unexpectedly.

Use `claude --debug "hooks"` to trace hook events. Check `/hooks` in the TUI or run `claude doctor` to verify hook config is loading.

📋 cli_flags

----print, --p

Run headless: Claude completes the task and exits instead of opening the interactive TUI.

Use in scripts, CI, one-shot analysis, and quick answers without starting a full session.

claude -p "Explain this function"
----bare

Minimal scripted mode: skips hook discovery, skills, plugins, MCP, auto-memory, and CLAUDE.md loading. Requires ANTHROPIC_API_KEY or apiKeyHelper. Use with -p for fast scripted calls.

CI automation and scripted pipelines where startup time matters and interactive features are not needed. Added v2.1.81.

claude --bare -p "Summarize these logs"
----continue, --c

Resume the most recent conversation in the current directory.

Best for daily work when you want to pick up where you left off without reloading context manually.

claude -c
----resume, --r

Resume a specific session by ID or name.

Use when juggling multiple parallel tasks and you need the exact old thread, not just the latest one.

claude -r "auth-refactor" "Finish the migration and run tests"
----permission-mode

Start a session in a specific permission mode, including Plan Mode for read-only exploration.

Use `plan` for safe research before edits, especially in unfamiliar repos or risky changes.

claude --permission-mode plan
----worktree, --w

Start Claude in an isolated git worktree so all changes happen on a clean branch without touching your working tree.

Safe experimentation and parallel feature work. Subagents can also use `isolation: "worktree"` in their config.

claude --worktree "Implement the feature and open a PR"
----model

Choose the model for the session. Use model names or aliases like `sonnet`, `opus`, `haiku`.

Use stronger models for planning, architecture, or hard bugs; keep everyday work on faster defaults.

claude --model opus
----effort

Adjust adaptive reasoning depth for the session: `low`, `medium`, `high` (persist across sessions), or `max` (current session only, requires Opus 4.6).

Use when the problem is genuinely hard; don't spend extra latency/cost on routine edits.

claude --effort high "Trace the real root cause of this flaky test"
----agent

Use a named preconfigured agent for the current session, overriding the default agent setting.

Activate a project-specific agent persona without having to specify it in settings each time.

claude --agent my-reviewer
----add-dir

Give Claude access to additional directories outside the main working directory.

Useful in monorepos, split repos, or when implementation depends on sibling projects.

claude --add-dir ../shared-lib ../docs
----allowedTools

Allow specific tools or command patterns to run without asking for approval.

Great for reducing permission fatigue while still avoiding full permission bypass.

claude --allowedTools "Bash(git diff *)" "Bash(npm test *)" "Read"
----tools

Restrict which tools are available in the session (different from allowedTools which controls permissions).

Use to create tightly scoped sessions where Claude can only use specific tools.

claude --tools Read Write "Bash(git *)"
----dangerously-skip-permissions

Skip all permission prompts entirely. Use `--allow-dangerously-skip-permissions` to enable it as an option without activating immediately (composable with --permission-mode).

Only for tightly sandboxed or disposable environments where full autonomy is worth the risk.

claude --dangerously-skip-permissions
----append-system-prompt

Append custom text to the end of the default system prompt for the session.

Add per-run rules without modifying CLAUDE.md or creating a new agent config.

claude --append-system-prompt "Always use TypeScript. Prefer functional style."
----agents

Define custom subagents inline as JSON for the current session only.

Handy for temporary specialist agents in automation or experiments without creating files.

claude --agents '{"reviewer":{"description":"Reviews code","prompt":"You are a code reviewer"}}'
----output-format

Set output format for headless (-p) mode: `text`, `json`, or `stream-json`.

Use `json` for machine-readable automation, `stream-json` for real-time processing in pipelines.

claude -p --output-format json "Analyze this diff"
----max-turns

Limit how many agentic turns Claude can take in print mode.

Useful in CI or scripts where you want bounded runtime and predictable behavior.

claude -p --max-turns 3 "Summarize and classify these logs"
----max-budget-usd

Set a cost ceiling for API calls in print mode.

Use in automation to stop costs from drifting upward on open-ended tasks.

claude -p --max-budget-usd 1.50 "Review this patch for security bugs"
----chrome

Enable Chrome browser integration for web automation, screenshots, and UI debugging.

Use for front-end debugging, visual verification, and end-to-end browser tasks.

claude --chrome

/ commands

/init

Generate or improve a project CLAUDE.md based on the current repo. Set CLAUDE_CODE_NEW_INIT=true for an interactive flow that also sets up skills, hooks, and personal memory.

💡 Run this early in a new repo, then trim aggressively so only high-value instructions remain.

/plan

Enter plan mode directly from the prompt for read-only analysis and planning.

💡 Use before migrations, refactors, or any task that spans multiple files or uncertain requirements.

/compact

Compress the conversation to recover context while preserving the important thread.

💡 Give compact instructions; otherwise Claude may preserve the wrong parts of the conversation.

/context

Visualize current context usage as a colored grid. Shows optimization suggestions for context-heavy tools, memory bloat, and capacity warnings.

💡 Check this before long sessions get sloppy; it's an early warning system for degraded performance.

/btw

Ask a quick side question without adding it to the conversation history or affecting the main task.

💡 Use this whenever you have a quick clarifying question mid-session that doesn't belong in the thread.

/hooks

View and manage hook configurations for tool events (PreToolUse, PostToolUse, SubagentStart, Stop, etc.).

💡 Hooks are deterministic guardrails. Wire up formatters, linters, or safety checks here instead of relying on prompts.

/remote-control

Make the current local session available for remote control from claude.ai or the Claude mobile app.

💡 Use this when you start a session locally and want to hand off to mobile, or pick it up from another device.

/permissions

Manage permission rules and allowlists for commands/tools.

💡 Allowlist safe repeat commands like test/lint/git read operations to avoid approval fatigue.

/agents

Create, inspect, and manage custom subagents.

💡 Make a read-only reviewer or debugger first; they pay off quickly and keep your main context clean.

/plugin

Manage Claude Code plugins: install, uninstall, list, and reload.

💡 Plugins can ship hooks, skills, MCP servers, and agents together as a unit.

/pr-comments

Fetch and display comments from a GitHub pull request. Auto-detects the PR for the current branch, or pass a PR URL or number. Requires the `gh` CLI.

💡 Follow up immediately with 'Address all unresolved review comments' to action them in one flow.

/branch

Create a branch (fork) of the current conversation at this point. Alias: /fork.

💡 Use when you want to explore an alternative approach without losing your current thread.

/model

Switch models during a session. For supported models, use left/right arrows to adjust effort level inline.

💡 Switch up only for genuinely hard reasoning tasks; keep default or Sonnet for routine coding.

/effort

Change adaptive reasoning depth. `low`/`medium`/`high` persist across sessions; `max` is current session only (Opus 4.6). `auto` resets to model default.

💡 Often a better move than switching models when the task just needs deeper thought.

/memory

Manage CLAUDE.md memory files and auto-memory behavior. View, edit, or disable auto-memory entries.

💡 If Claude repeats the same mistakes across sessions, fix your memory instead of re-explaining manually every time.

/diff

Open an interactive diff viewer for uncommitted changes and Claude's per-turn edits. Use arrows to browse files and turns.

💡 Use this before commit/PR creation so you catch broad or unintended edits early.

/cost

Show token usage statistics for the session.

💡 If cost spikes, it usually means context sprawl, over-broad exploration, or using a stronger model than the task needs.

/clear

Start fresh and clear conversation history. Aliases: /reset, /new.

💡 For a truly messy session, sometimes a clean restart beats trying to salvage bloated context.

/doctor

Run diagnostics on Claude Code installation and settings.

💡 This is the first thing to try before spelunking through PATH, auth, or config issues by hand.

💡 pro_tips

  • › The single best prompt upgrade is adding a verification target: test command, linter, screenshot, or exact expected output.
  • › Use Plan Mode for uncertainty, not for everything. If you can describe the exact diff in one sentence, just ask Claude to do it directly.
  • › Prefer `@file` references over repo-wide exploration when you already know the area involved.
  • › When a session starts drifting, check `/context` and compact before quality drops noticeably.
  • › A short, repo-specific CLAUDE.md beats a giant handbook. Include only what Claude cannot infer from code.
  • › If you repeat the same instruction every day, move it into CLAUDE.md, a `.claude/rules/` file, a hook, or a subagent.
  • › Use `/diff` before asking for a commit or PR; it's the fastest way to catch accidental broad edits.
  • › `claude -c` is one of the most useful daily commands. Resuming context is often better than starting over.
  • › Headless mode becomes much more powerful when paired with `--output-format json`, `--max-turns`, and `--max-budget-usd`.
  • › Subagents are not just for teams. A personal debugger or code-reviewer agent can keep your main conversation far cleaner.
  • › Use `/btw` for quick side questions mid-session — it answers without adding noise to the main conversation thread.
  • › Hooks fire deterministically at lifecycle points (PreToolUse, PostToolUse, Stop, etc.). Use them for formatters and safety checks instead of relying on prompts.
  • › Use `--bare` with `-p` in scripts and CI — it skips hook/skill/plugin discovery for faster startup when you don't need interactive features.
  • › /remote-control lets you hand off a local session to claude.ai or your phone mid-task without losing context.
  • › If Claude is repeatedly violating a rule, the problem is often instruction quality or context overload, not model capability.
  • › Use stronger models or higher effort selectively. The fastest workflow is usually Sonnet for execution plus better prompts, not always Opus.

⚙️ configuration

model

Default model or alias for Claude Code sessions.

default: default

recommended: Use `sonnet` for daily work, or `opus` if you regularly do heavy planning before coding.

effortLevel

Persistent adaptive reasoning level. `low`/`medium`/`high` persist. `max` is session-only on Opus 4.6.

default: model default

recommended: Set to `medium` for general use; bump to `high` via /effort only when you routinely do complex debugging or architecture.

permissions.defaultMode

Default permission mode for new sessions.

default: default

recommended: Set to `plan` if you want Claude to explore safely by default before making changes.

permissions.allow

Allowlist of safe commands/tools that can run without prompting.

default: []

recommended: Add common read/test/lint/git commands you trust, like `Bash(npm test *)`, `Bash(git diff *)`, and `Read`.

permissions.deny

Denylist of risky paths or commands even if Claude might request them.

default: []

recommended: Block secrets by default, e.g. `.env`, `.env.*`, and sensitive directories.

includeGitInstructions

Whether Claude includes built-in commit/PR workflow instructions.

default: true

recommended: Keep `true` unless your team already has custom git workflow skills or strict alternate conventions.

respectGitignore

Whether `@` file suggestions should respect `.gitignore` patterns.

default: true

recommended: Leave it `true` unless you intentionally need ignored/generated files in the picker.

cleanupPeriodDays

How long inactive sessions persist before cleanup.

default: 30

recommended: Keep default unless you want shorter retention for privacy or disk hygiene.

statusLine

Custom status line configuration for showing context, costs, rate limits, or git state. As of v2.1.80, supports rate_limits field with used_percentage and resets_at.

default: unset

recommended: Set one up if you use Claude heavily; seeing context pressure in real time helps you compact before performance drops.

autoMemoryDirectory

Custom location for auto-memory storage.

default: Claude-managed location

recommended: Only change this if you have a deliberate storage/workstation policy; otherwise leave it alone.

📚 resources