A practical reference for Claude Code (verified against official docs, July 2026). Official sources: CLI reference · Commands reference · Skills
Tip:
claude --helpdoesn't list every flag, and/helpinside a session shows all slash commands available to you (some depend on plan/platform/version).
Start an interactive session in the current directory.
claudeWhen: Your default way to start working on a project. Run it from the repo root so Claude picks up CLAUDE.md, settings, and skills.
Start an interactive session with an initial prompt.
claude "explain this project's architecture"When: You already know your first question — saves a step.
Run one query, print the result, and exit. No interactive UI, no approval prompts.
claude -p "explain what src/auth/login.ts does"When: Scripting, CI/CD pipelines, quick one-off answers, or composing with other shell tools.
cat error.log | claude -p "explain this error and suggest a fix"
git diff | claude -p "write a commit message for this diff"When: Feed logs, diffs, or any text stream into Claude for analysis.
Continue the most recent conversation in the current directory.
claude -c
claude -c -p "now check for type errors" # continue non-interactivelyWhen: You closed the terminal (or got interrupted) and want to pick up exactly where you left off.
Resume a specific session by ID or name, or open an interactive picker.
claude --resume # pick from a list
claude -r "auth-refactor" "finish this PR"When: Juggling multiple work streams. Pair with --name / /rename so sessions are findable later.
Resume the session(s) linked to a pull request.
claude --from-pr 123When: A reviewer left comments on a PR Claude created; jump straight back into the session that made it.
Update Claude Code to the latest version.
claude updateInstall or reinstall the native binary at a specific version.
claude install stable
claude install 2.1.118When: Pinning a version or recovering from a broken install.
claude auth login # sign in (Claude subscription)
claude auth login --console # sign in with Anthropic Console (API billing)
claude auth status --text # human-readable auth check; exits 0 if logged inWhen: First-time setup, switching between subscription and API billing, or checking auth in scripts (status exit code is script-friendly).
Generate a long-lived OAuth token for CI and scripts (printed, not saved). Requires a Claude subscription.
claude setup-tokenWhen: Setting up GitHub Actions or other automation that needs to authenticate as you.
Configure MCP (Model Context Protocol) servers — external tools like GitHub, Sentry, databases.
claude mcp # interactive configuration
claude mcp login sentry # run a server's OAuth flow from the shell
claude mcp logout sentry # clear stored credentialsWhen: Connecting Claude Code to external services. Use --no-browser with login over SSH.
claude agents # open agent view: monitor/dispatch parallel sessions
claude agents --json # list active sessions for scripting
claude attach 7c5dcf5d # attach to a background session in this terminal
claude logs 7c5dcf5d # print recent output from a background session
claude stop 7c5dcf5d # stop a background session (alias: kill)
claude respawn 7c5dcf5d # restart a session with its conversation intact
claude rm 7c5dcf5d # remove from list (transcript stays resumable)When: Running several Claude sessions in parallel (e.g., one investigating a flaky test while you work on a feature). Start one with claude --bg "task".
Manage plugins (skills, agents, hooks, MCP servers bundled together).
claude plugin install code-review@claude-plugins-officialDelete all local Claude Code state for a project (transcripts, logs, history).
claude project purge ~/work/repo --dry-run # preview firstWhen: Cleaning up before handing off a machine, or reclaiming disk space.
| Flag | What it does | Example |
|---|---|---|
--name, -n |
Name the session (shows in /resume picker) |
claude -n "payment-bugfix" |
--add-dir |
Grant file access to extra directories | claude --add-dir ../shared-lib |
--worktree, -w |
Start in an isolated git worktree; accepts a PR number/URL to branch from it | claude -w feature-auth |
--fork-session |
Resume into a new session ID (keeps the original intact) | claude --resume abc123 --fork-session |
--session-id |
Use a specific UUID for the session | claude --session-id "550e8400-..." |
--bg, --background |
Start as a background agent and return immediately | claude --bg "investigate the flaky test" |
--remote |
Create a session on claude.ai (Claude Code on the web) | claude --remote "Fix the login bug" |
--teleport |
Pull a web session into your local terminal | claude --teleport |
--remote-control, --rc |
Interactive session you can also drive from your phone/claude.ai | claude --rc "My Project" |
Worktree tip: -w is the safest way to run parallel sessions on the same repo — each gets its own branch and working tree, so edits never collide.
| Flag | What it does | Example |
|---|---|---|
--model |
Set the model (sonnet, opus, haiku, fable, or a full model ID) |
claude --model opus |
--effort |
Reasoning effort: low, medium, high, xhigh, max (model-dependent) |
claude --effort high |
--fallback-model |
Auto-fallback chain when the primary model is overloaded | claude --fallback-model sonnet,haiku |
--advisor <model> |
Enable the advisor tool: a second model Claude consults at key moments | claude --advisor opus |
When to change effort: Bump to high/xhigh for gnarly debugging or architecture work; drop to low for mechanical edits to save time and usage.
| Flag | What it does | Example |
|---|---|---|
--permission-mode |
Start in a mode: default, acceptEdits, plan, auto, dontAsk, bypassPermissions |
claude --permission-mode plan |
--allowedTools |
Tools that run without prompting | claude --allowedTools "Bash(git log *)" "Read" |
--disallowedTools |
Deny rules; bare names remove tools entirely | claude --disallowedTools "Bash(rm *)" |
--tools |
Restrict which built-in tools exist at all | claude --tools "Bash,Edit,Read" |
--dangerously-skip-permissions |
Skip all permission prompts | use only in sandboxed/CI environments |
--allow-dangerously-skip-permissions |
Adds bypass mode to the Shift+Tab cycle without starting in it | claude --permission-mode plan --allow-dangerously-skip-permissions |
Rules of thumb:
planmode: Claude researches and proposes before touching files — great for large changes.acceptEdits: auto-approve file edits, still ask for commands — good semi-automation.bypassPermissions: only inside containers/CI where blast radius is contained.
| Flag | What it does | Example |
|---|---|---|
--output-format |
text, json, or stream-json |
claude -p "query" --output-format json |
--input-format |
text or stream-json for piped input |
claude -p --input-format stream-json |
--json-schema |
Validated JSON output matching your schema | claude -p --json-schema '{"type":"object",...}' "query" |
--max-turns |
Cap agentic turns; exits with error at the limit | claude -p --max-turns 3 "query" |
--max-budget-usd |
Spend ceiling for the run | claude -p --max-budget-usd 5.00 "query" |
--bare |
Skip loading hooks/skills/plugins/MCP/CLAUDE.md for fast scripted calls | claude --bare -p "query" |
--no-session-persistence |
Don't save the session to disk | claude -p --no-session-persistence "query" |
--verbose |
Full turn-by-turn output | claude --verbose |
CI example — fail the build on Claude-detected issues:
RESULT=$(claude -p "Review the diff for security issues" --output-format json --max-turns 5)
echo "$RESULT" | jq -r '.result'The JSON output includes cost, duration, and turn count — useful for monitoring pipelines.
| Flag | Behavior | Example |
|---|---|---|
--append-system-prompt |
Adds rules on top of the default prompt | claude --append-system-prompt "Always use TypeScript" |
--append-system-prompt-file |
Same, from a file | claude --append-system-prompt-file ./style-rules.txt |
--system-prompt |
Replaces the entire default prompt | claude --system-prompt "You are a Python expert" |
--system-prompt-file |
Replaces with file contents | claude --system-prompt-file ./prompts/review.txt |
When: Prefer the append flags — they keep Claude Code's default tool guidance and safety instructions and just layer your rules on. Use replacement only when building a non-coding agent in a pipeline, and accept that you now own everything the default prompt provided. For persistent project conventions, use CLAUDE.md instead; for switchable personas, use output styles.
| Flag | What it does | Example |
|---|---|---|
--mcp-config |
Load MCP servers from JSON files/strings | claude --mcp-config ./mcp.json |
--strict-mcp-config |
Use only servers from --mcp-config |
claude --strict-mcp-config --mcp-config ./mcp.json |
--agents |
Define subagents inline as JSON | claude --agents '{"reviewer":{"description":"Reviews code","prompt":"You are a code reviewer"}}' |
--plugin-dir |
Load a plugin from a folder/zip for this session | claude --plugin-dir ./my-plugin |
--chrome / --no-chrome |
Enable/disable Chrome browser integration | claude --chrome |
--ide |
Auto-connect to your IDE on startup | claude --ide |
| Flag | What it does | Example |
|---|---|---|
--safe-mode |
Disable all customizations (CLAUDE.md, hooks, skills, MCP…) to isolate a broken config | claude --safe-mode |
--debug |
Debug logging with category filters | claude --debug "api,mcp" |
--debug-file |
Write debug logs to a path | claude --debug-file /tmp/claude.log |
--version, -v |
Print version | claude -v |
When to reach for --safe-mode: Claude behaves strangely and you suspect a hook, skill, or MCP server. If safe mode fixes it, re-enable customizations one at a time.
Type / in a session to browse everything; type / + letters to filter. A command is only recognized at the start of your message.
| Command | Purpose & when to use |
|---|---|
/help |
List all available commands, including your custom ones. |
/clear [name] |
Start a fresh conversation (empty context). Old one stays in /resume. Use between unrelated tasks. Aliases: /reset, /new. |
/compact [instructions] |
Summarize the conversation to free context while continuing the same task. Pass focus hints: /compact keep the auth module details and failing tests. Use proactively on long sessions. |
/context [all] |
Visualize context-window usage as a grid with optimization suggestions. Run it when things feel sluggish or before a big task. |
/model [model] |
Switch models mid-session (arrow keys also adjust effort). Press s in the picker for session-only switch. |
/effort [level] |
Set reasoning effort (low→max, plus ultracode). Takes effect immediately. |
/usage |
Session cost, plan limits, activity stats, and a per-skill/subagent/MCP breakdown. Aliases: /cost, /stats. |
/copy [N] |
Copy the last (or Nth-latest) response; interactive picker for individual code blocks. |
/exit |
Quit (alias /quit). In an attached background session, this detaches without stopping it. |
| Command | Purpose |
|---|---|
/init |
Generate a starter CLAUDE.md for the project. Run this first in any new repo. |
/memory |
Edit CLAUDE.md files and manage auto-memory. |
/mcp |
Manage MCP server connections and OAuth (/mcp reconnect <server>, enable/disable). |
/agents |
Manage subagent configurations. |
/permissions |
Interactive allow/ask/deny rules editor. Alias: /allowed-tools. |
/fewer-permission-prompts |
Scans your transcripts and proposes a safe allowlist to cut down on prompts. |
/config [key=value] |
Settings UI, or set directly: /config theme=dark, /config model=sonnet. Alias: /settings. |
/hooks |
View hook configurations. |
/statusline |
Configure a custom status bar (context %, cost, git status). |
/theme |
Change color theme (includes colorblind-accessible options). |
| Command | Purpose |
|---|---|
/plan [description] |
Enter plan mode: /plan fix the auth bug. Claude researches and proposes before editing. |
/btw <question> |
Ask a quick side question without adding it to conversation history. Great for "what does this flag mean?" asides. |
/goal [condition] |
Claude keeps working across turns until the condition is met: /goal all tests pass. clear to cancel. |
/diff |
Interactive diff viewer: uncommitted changes and per-turn diffs. |
/rewind |
Roll code and/or conversation back to a checkpoint. Aliases: /undo, /checkpoint. Your safety net. |
/cd <path> |
Move the session to a new working directory (keeps prompt cache). |
/add-dir <path> |
Grant file access to another directory without moving. |
/tasks |
View/manage everything running in the background of this session. Alias: /bashes. |
| Command | Purpose |
|---|---|
/background [prompt] |
Detach this whole session to run as a background agent and free your terminal. Alias: /bg. Monitor with claude agents. |
/fork <directive> |
Spawn a background subagent that inherits the full conversation and works on the directive while you keep going; its result returns to you. |
/branch [name] |
Branch the conversation at this point and switch into the branch yourself — the conversational equivalent of a git branch. Return via /resume. |
/batch <instruction> |
Decompose a large change into 5–30 independent units, each in its own worktree with its own subagent and PR: /batch migrate src/ from Solid to React. |
/fork vs /branch: fork = delegate a copy to a background worker; branch = you personally explore an alternative path.
| Command | Purpose |
|---|---|
/code-review [effort] [--fix] [--comment] [target] |
Review the current diff for bugs and cleanups. --fix applies findings; --comment posts inline GitHub PR comments; ultra runs a deep multi-agent cloud review. |
/review [PR] |
Same engine, aimed at a GitHub PR by number (lists open PRs if omitted). |
/security-review |
Read-only security pass on the branch diff: injection, auth issues, data exposure. |
/simplify [target] |
Cleanup-only review (reuse, simplification, efficiency) that applies fixes — no bug hunting. |
/verify |
Build and run your app to confirm a change actually works, not just that tests pass. |
/run |
Launch and drive your project's app to see a change live. |
| Command | Purpose |
|---|---|
/resume [session] |
Resume by ID/name or open the picker (background sessions show as bg). Alias: /continue. |
/rename [name] |
Name the current session (auto-generates from history if omitted). Do this for anything you'll come back to. |
/export [filename] |
Export the conversation as plain text — postmortems, docs, sharing with teammates. |
/recap |
One-line summary of the current session. |
/teleport |
Pull a Claude Code web session into this terminal. Alias: /tp. |
/remote-control |
Make this session controllable from claude.ai / the mobile app. Alias: /rc. |
/schedule [description] |
Create routines that run on Anthropic cloud infrastructure on a schedule or on GitHub events. Alias: /routines. |
| Command | Purpose |
|---|---|
/doctor |
Verify install and settings; press f to let Claude fix reported issues. |
/debug [description] |
Enable debug logging mid-session and have Claude analyze its own logs. |
/feedback [report] |
Report a bug with session context attached. Aliases: /bug, /share. |
/status |
Version, model, account, connectivity (works even while Claude is responding). |
/release-notes |
Browse the changelog by version. |
/skills |
List skills; press t to sort by token cost, Space to hide one. |
/plugin [subcommand] |
Manage plugins: list, install, enable, disable. |
/reload-skills |
Pick up skills added/changed on disk without restarting. |
/terminal-setup |
Fix Shift+Enter and other keybindings (VS Code, Cursor, Alacritty, Zed terminals). |
/tui [fullscreen|default] |
Switch renderer mid-session; fullscreen = flicker-free mode with mouse support (see Part 6). No argument prints which renderer is active. |
/scroll-speed |
Interactive scroll-speed tuner (← → to adjust, r to reset); persists to settings. |
/login / /logout |
Account sign in/out. |
| Command | Purpose |
|---|---|
/ultraplan <prompt> |
Draft a plan in the cloud, review in browser, execute remotely or locally. |
/deep-research <question> |
Fan out web searches, cross-check sources, synthesize a cited report. |
/autofix-pr [prompt] |
Spawn a cloud session that watches your branch's PR and pushes fixes when CI fails or reviewers comment. |
/loop [interval] [prompt] |
Run a prompt repeatedly: /loop 5m check if the deploy finished. Alias: /proactive. |
/install-github-app |
Set up the Claude GitHub App + Actions workflows for a repo. |
| Plain plan mode | /deep-research <prompt> |
|
|---|---|---|
| What runs | Single agent, foreground, in your session | Background workflow: parallel subagents fan out web searches, fetch and cross-check sources |
| Looks at | Your codebase (read-only) + training knowledge, maybe a few ad-hoc searches | The web — generally doesn't dig through your repo |
| Output | An implementation plan you approve (editable with Ctrl+G), then execute | A cited report; claims that fail cross-checking are filtered out. No execution step |
| Session | Occupied while planning | Stays free; monitor with /workflows |
| Cost/speed | Fast, cheap | Slower, token-heavy (many parallel searches) |
| Plan mode's effect | Core mechanic (blocks edits, forces approval) | Barely any — research is read-only anyway; you just approve the workflow launch |
When to use which: reach for /deep-research when the risk is being wrong about the outside world (API changes, version migrations, best practices, comparisons); use plain plan mode when the risk is misunderstanding your own code.
The chaining pattern (best of both):
1. /deep-research what breaking changes exist between X v2 and v3,
and what are the recommended migration paths?
2. (report lands, verified + cited)
3. [plan mode] using that report, plan the migration for this repo
4. Ctrl+G to trim the plan → approve → execute
Research first when external facts matter, plan second — the plan is then grounded in both accurate outside knowledge and your actual codebase.
You don't have to wait for Claude to finish a turn. You're part of the agentic loop and can step in at any point — from gentlest to most drastic:
While Claude is thinking or running tools, just type your correction or extra context and press Enter. The message is sent without stopping the running tool; Claude reads it as soon as the current action completes and adjusts before deciding its next step.
[Claude is refactoring src/auth/...]
> also, the token refresh logic moved to src/session/ last week — look there
When: Adding a detail you forgot, narrowing scope, correcting an assumption — anything where the current action is still fine. Know this: Your message applies at the next step, not the current one. It won't halt a tool call already in flight, so a long-running command finishes first. You can queue multiple messages; press ↑ (up arrow) to edit a queued message before Claude reads it.
Press Esc to stop Claude on the spot. The running tool call is canceled and Claude waits for your next instruction. Session context and completed work are preserved — you only lose the in-flight action.
When: Claude is clearly heading the wrong way and you don't want it to take even one more step. Redirect with a fresh prompt. Know this: If Esc seems unresponsive (which can happen when messages are queued or during long tool chains), Ctrl+C is the reliable fallback.
Every file edit is snapshotted before Claude makes it. With an empty prompt, pressing Esc twice opens the rewind menu (/rewind) to roll code and/or conversation back to a checkpoint.
When: Something already went wrong — this is "undo," not just "stop." Know this: With text typed in the prompt box, Esc Esc clears your draft instead. Checkpoints only cover local file changes — remote side effects (DB writes, deploys, API calls) can't be rewound.
Answers your question in an overlay while Claude keeps working; nothing is added to the main conversation context.
When: You want information for yourself ("what does that flag mean?"), not to change what Claude is doing.
| You want to… | Do this |
|---|---|
| Add context / nudge direction | Type it + Enter (applies next step) |
| Stop now, keep work, redirect | Esc (fallback: Ctrl+C) |
| Undo changes already made | Esc Esc on empty prompt, or /rewind |
| Ask a side question | /btw <question> |
| Edit a message you queued | ↑ up arrow |
| Edit Claude's proposed plan directly (plan mode) | Ctrl+G — opens it in your editor (see Part 5) |
Shortcuts vary by platform and terminal. macOS: Alt/Option shortcuts (Alt+B/F/Y/M/P) need Option configured as Meta — iTerm2: Settings → Profiles → Keys → set Option key to "Esc+"; Apple Terminal: check "Use Option as Meta Key"; VS Code:
"terminal.integrated.macOptionIsMeta": true. Run/terminal-setupif unsure.
| Shortcut | What it does |
|---|---|
| Esc | Interrupt Claude — stops the current response/tool call so you can redirect; work done so far is kept |
| Esc Esc | With text in the prompt: clears the draft (recall with ↑). With an empty prompt: opens the rewind menu |
| Ctrl+C | Interrupt a running operation; if idle, first press clears input, second press exits |
| Ctrl+D | Exit the session |
| Shift+Tab (or Alt+M) | Cycle permission modes: default → acceptEdits → plan → (auto/bypass if enabled) |
| Ctrl+B | Send a running Bash command/agent to the background and keep working (tmux users: press twice) |
| Ctrl+X Ctrl+K | Stop all background subagents in the session (press twice within 3s to confirm) |
| Ctrl+T | Toggle the task list in the status area |
| Ctrl+O | Toggle the transcript viewer (detailed tool usage; expands collapsed MCP calls) |
| Ctrl+L | Redraw a garbled screen (input and history kept) |
| Shortcut | What it does |
|---|---|
| Ctrl+G (or Ctrl+X Ctrl+E) | Open your current input in your default text editor ($EDITOR). In plan mode, this opens Claude's proposed plan so you can edit it directly — delete steps, adjust the approach, add constraints — far better than describing changes in chat. Also great for long multi-paragraph prompts. Enable "Show last response in external editor" in /config to get Claude's previous reply as commented context above your text |
| Ctrl+A / Ctrl+E | Jump to start / end of the current line |
| Ctrl+K / Ctrl+U / Ctrl+W | Delete to end of line / to line start / previous word (all recoverable) |
| Ctrl+Y | Paste text deleted with the above (Alt+Y after it cycles the paste history) |
| Alt+B / Alt+F | Move back / forward one word |
| ↑ / ↓ (or Ctrl+P/N) | Move cursor in multiline input; at the edge, navigate command history — including editing a queued message |
| Ctrl+R | Reverse-search command history (Ctrl+R again cycles matches; Ctrl+S changes scope: session / project / all) |
| Method | Works in |
|---|---|
\ + Enter |
All terminals |
| Ctrl+J | All terminals, no config |
| Shift+Enter | iTerm2, WezTerm, Ghostty, Kitty, Warp, Apple Terminal, Windows Terminal natively; run /terminal-setup for VS Code, Cursor, Alacritty, Zed |
| Option+Enter | macOS, after Option-as-Meta setup |
| Paste directly | Multi-line clipboard content enters multiline automatically |
| Shortcut | What it does |
|---|---|
| Alt+P / Option+P | Switch model without losing what you've typed |
| Alt+T / Option+T | Toggle extended thinking for deeper reasoning (works on macOS without Meta config since v2.1.132) |
| Alt+O / Option+O | Toggle fast mode |
| Input | What it does |
|---|---|
/ at start |
Command / skill menu (type letters to filter) |
! at start |
Shell mode — run a command directly, output lands in context and Claude responds to it |
@ |
File path autocomplete: @src/components/Header.tsx fix the layout |
| Ctrl+V (Cmd+V in iTerm2, Alt+V on Windows/WSL) | Paste an image from clipboard as an [Image #N] chip |
| Tab or → | Accept the grayed-out prompt suggestion |
| Hold Space | Voice dictation (when enabled via /voice) |
? shows the full shortcut panel (fullscreen mode) · { / } jump between user prompts · Ctrl+E toggles show-all · [ dumps the conversation to native scrollback so Cmd+F works · v opens the transcript in $EDITOR · q/Esc exits.
Enable via /config → Editor mode for full modal editing in the prompt: NORMAL/INSERT/VISUAL modes, motions (w, b, f{char}, gg, G), operators (dd, cw, yy, p), text objects (ciw, di", ya(), undo (u), and repeat (.). See the interactive mode docs for the full table.
- Shift+Tab into plan mode (or
/plan <task>) - Claude researches and proposes a plan
- Ctrl+G — open the plan in your editor, cut/reshape/annotate it directly, save
- Approve; Claude executes exactly what you agreed on
- If anything goes wrong: Esc Esc → rewind
Set env vars in your shell profile (export VAR=1 in ~/.zshrc/~/.bashrc), inline for one run (VAR=1 claude), or under the "env" key in settings.json. Where a behavior has both an env var and a settings field, the env var wins.
Many of these are experimental or version-gated and behavior changes between releases — when something doesn't work, check the official env-vars page and your version first.
| Keyword | What it does |
|---|---|
ultrathink |
Include it anywhere in a prompt to request deeper reasoning on that one turn — Claude Code recognizes the keyword and adds an in-context instruction; your session effort setting and the effort sent to the API are unchanged, and it reverts after that response. Note: other phrases like "think", "think hard" are passed through as ordinary text, not recognized as keywords. Example: ultrathink: why does this deadlock only happen under load? |
ultracode (or "use a workflow") |
Opts a single task into a Dynamic Workflow — Claude writes an orchestration script that fans the task across subagents instead of working turn by turn. Press Option+W (macOS) / Alt+W to dismiss if triggered accidentally. Set it session-wide with /effort ultracode. Token-hungry; reserve for genuinely large tasks. |
ultrathink vs MAX_THINKING_TOKENS: on fixed-thinking-budget models, a set MAX_THINKING_TOKENS takes priority and the keyword is ignored — unset the variable if you want per-turn bursts. On adaptive-reasoning models (Fable 5, Sonnet 5, Opus 4.7+), effort level is the primary control and thinking is always adaptive.
| Variable | What it does |
|---|---|
CLAUDE_CODE_NO_FLICKER=1 |
Enables fullscreen rendering (experimental): draws on the alternate screen buffer like vim/htop, eliminating flicker, keeping memory flat in long conversations, and adding mouse support (click-to-position cursor, click-to-expand tool output, wheel scrolling). Most noticeable in VS Code's terminal, tmux, and iTerm2. On v2.1.89+ you can instead run /tui fullscreen mid-session (/tui default to revert) — the setting and the env var are equivalent |
CLAUDE_CODE_DISABLE_MOUSE=1 |
Keep flicker-free rendering but let your terminal handle the mouse natively (you lose click/scroll inside Claude Code) |
CLAUDE_CODE_DISABLE_MOUSE_CLICKS=1 |
Middle ground: keeps wheel scrolling, disables click/drag/hover handling (v2.1.195+) |
CLAUDE_CODE_SCROLL_SPEED=3 |
Scroll-distance multiplier (1–20, fractions below 1 allowed); adjust interactively with /scroll-speed |
# The popular combo for long sessions
export CLAUDE_CODE_NO_FLICKER=1| Variable | What it does |
|---|---|
ANTHROPIC_MODEL |
Default model for every session (overrides the model setting; --model flag still wins) |
MAX_THINKING_TOKENS |
Fixed thinking budget on models that support it; 0 disables extended thinking. Silently overrides ultrathink (see above) |
CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING=1 |
On Opus 4.6 / Sonnet 4.6, reverts to the fixed thinking budget controlled by MAX_THINKING_TOKENS (no effect on Fable 5 / Sonnet 5 / Opus 4.7+, which are always adaptive) |
CLAUDE_CODE_EFFORT_LEVEL |
Pin effort across sessions — notably the only way to persist max, which settings.json doesn't accept |
CLAUDE_CODE_AUTO_COMPACT_WINDOW |
Change the token threshold where auto-compact kicks in on 1M-context models (default ≈967K) |
CLAUDE_CODE_DISABLE_1M_CONTEXT=1 |
Cap sessions at a 200K window for deployments that need it |
| Variable | What it does |
|---|---|
BASH_DEFAULT_TIMEOUT_MS |
Default timeout for bash commands Claude runs — raise for slow builds/test suites |
BASH_MAX_TIMEOUT_MS |
Ceiling Claude can't exceed even when it requests longer |
BASH_MAX_OUTPUT_LENGTH |
Truncation point for command output, so one cat huge.log can't flood the context |
MCP_TIMEOUT / MCP_TOOL_TIMEOUT |
MCP server startup / tool-call timeouts — raise for heavy servers |
API_TIMEOUT_MS |
API request timeout for very long-running requests |
| Variable | What it does |
|---|---|
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 |
One switch that bundles telemetry off, error reporting off, update checks off — the go-to for air-gapped, privacy-sensitive, or CI environments |
DISABLE_AUTOUPDATER=1 |
Just the auto-update check — always set in CI alongside a pinned version so behavior can't change mid-pipeline |
DISABLE_TELEMETRY=1 / DISABLE_ERROR_REPORTING=1 |
Individual opt-outs (Statsig / Sentry) |
DISABLE_COST_WARNINGS=1 |
Hide cost banners — useful when parsing -p output in scripts |
| Variable | What it does |
|---|---|
ANTHROPIC_API_KEY |
API-billing auth (keep it in CI secrets, never in committed files) |
ANTHROPIC_BASE_URL |
Route API traffic through a gateway/proxy (LiteLLM, internal proxy) |
CLAUDE_CODE_USE_BEDROCK=1 / CLAUDE_CODE_USE_VERTEX=1 |
Use AWS Bedrock / Google Vertex AI as the provider |
HTTP_PROXY / HTTPS_PROXY / NO_PROXY |
Standard corporate proxy configuration for all outbound requests |
# ~/.zshrc / ~/.bashrc
export CLAUDE_CODE_NO_FLICKER=1 # smooth rendering + mouse support
# export MAX_THINKING_TOKENS=... # only if you want a fixed budget — blocks ultrathink
# export BASH_DEFAULT_TIMEOUT_MS=600000 # 10 min, if your builds are slow
# CI job env
# CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
# DISABLE_AUTOUPDATER=1Custom commands are markdown files. The modern format is a skill (.claude/skills/<name>/SKILL.md), which Claude can also invoke automatically; the legacy .claude/commands/<name>.md format still works.
- Project scope:
.claude/skills/(commit to git — your whole team gets them) - Personal scope:
~/.claude/skills/(all your projects)
.claude/commands/optimize.md:
Analyze this code for performance issues and suggest optimizations.Now /optimize works in any session in this project.
.claude/commands/fix-issue.md:
---
argument-hint: [issue-number] [priority]
description: Fix a GitHub issue
---
Fix issue #$0 with priority $1.
Check the issue description and implement the necessary changes.Usage: /fix-issue 123 high → $0 = "123", $1 = "high". Use $ARGUMENTS to capture everything as one string.
.claude/commands/git-commit.md:
---
allowed-tools: Bash(git add *), Bash(git status *), Bash(git commit *)
description: Create a git commit
---
## Context
- Current status: !`git status`
- Current diff: !`git diff HEAD`
## Task
Create a git commit with an appropriate message based on the changes.!`command`runs a shell command and embeds its output in the prompt.@path/to/fileembeds a file's contents (e.g.,@package.json).- Frontmatter can also set
model:to pin a model for that command.
.claude/commands/review-pr.md:
---
allowed-tools: Read, Grep, Glob, Bash(git diff *)
description: Comprehensive code review
---
## Changed Files
!`git diff --name-only HEAD~1`
## Detailed Changes
!`git diff HEAD~1`
Review the above changes for:
1. Code quality and readability
2. Security vulnerabilities
3. Performance implications
4. Test coverage
5. Documentation completeness
Provide specific, actionable feedback organized by priority.Morning triage (headless):
git log --since=yesterday --oneline | claude -p "summarize what changed and flag anything risky"Safe experiment on a shared repo:
claude -w try-new-cache-layer --permission-mode planParallel investigation while you keep coding:
claude --bg "find the root cause of the flaky checkout test and write up findings"
claude agents # check on it laterStructured output for automation:
claude -p "list all TODO comments in src/ as JSON" \
--output-format json --max-turns 3Long session hygiene: watch /context, run /compact with focus instructions before starting the next major task, and /clear (not /compact) when switching to something unrelated.
Availability of some commands depends on your version, plan, and platform. When in doubt: /help in a session, claude --help in the shell, or the official CLI reference.