Skip to content

Claude How ToClaude How To

CLI Reference ​

Overview ​

The Claude Code CLI (Command Line Interface) is the primary way to interact with Claude Code. It provides powerful options for running queries, managing sessions, configuring models, and integrating Claude into your development workflows.

Architecture ​

Runtime & Packaging ​

Since v2.1.113, the Claude Code CLI launches a native per-platform binary (macOS, Linux, Windows) via optional npm dependencies. The binary is matched to your OS and architecture at install time — the older bundled-JavaScript runtime is no longer the default on macOS or Linux.

The recommended install is the native installer (curl -fsSL https://claude.ai/install.sh | bash; on Windows irm https://claude.ai/install.ps1 | iex). npm installation is deprecated in the official README; prefer the native installer, Homebrew (brew install --cask claude-code) or WinGet (winget install Anthropic.ClaudeCode). For reference, npm install -g @anthropic-ai/claude-code (Node.js 22+) installs the same native binary through a per-platform optional dependency. On npm 12, which skips Claude Code's postinstall step by default, that install ends with Error: claude native binary not installed. — switch to the native installer or follow Fix an npm 12 install.

Download host (v2.1.116+): native-binary artifacts are served from https://downloads.claude.ai/claude-code-releases.

Corporate / proxy users: If your network requires an explicit allowlist, add downloads.claude.ai (and https://downloads.claude.ai/claude-code-releases) to your proxy egress rules. Environments that previously allowlisted only storage.googleapis.com or the npm registry will need to be updated or claude update and the initial install will fail. On Bedrock, Mantle, Vertex, and Foundry, Claude Code also loads model settings from a signed file on downloads.claude.ai (v2.1.311); set CLAUDE_CODE_MODEL_CATALOG=off to turn that off.

The older JavaScript bundle is still produced for Windows and for environments that pin to it; those installs continue to ship Glob and Grep as first-class tools (see the Glob/Grep footnote under Tools).

CLI Commands ​

CommandDescriptionExample
claudeStart interactive REPLclaude
claude "query"Start REPL with initial promptclaude "explain this project"
claude -p "query"Print mode - query then exitclaude -p "explain this function"
cat file | claude -p "query"Process piped contentcat logs.txt | claude -p "explain"
claude -cContinue most recent conversationclaude -c
claude -c -p "query"Continue in print modeclaude -c -p "check for type errors"
claude -r "<session>" "query"Resume session by ID or nameclaude -r "auth-refactor" "finish this PR"
claude updateUpdate to latest versionclaude update
/restart (slash command, alias /update)Restart Claude Code and resume this session to apply an installed update. Pro, Max, and Ultra plans; native install on macOS or Linux, not WSL (v2.1.288+)/restart
/doctor (slash command)Diagnose installation, config, and plugin health. Since v2.1.116 it can be opened while Claude is responding, shows status icons inline, and accepts the f keypress to auto-fix detected issues. v2.1.178 refreshed the layout to a flat tree with clearer status icons and highlighted commandsrun /doctor inside the REPL
claude mcpConfigure MCP servers (incl. login/logout for auth, v2.1.186+)See MCP documentation
claude mcp serveRun Claude Code as an MCP serverclaude mcp serve
claude agentsOpen the Agent View (Research Preview, v2.1.139+) — multi-session manager listing every Claude Code session with its status. See Agent View below.claude agents
claude auto-mode defaultsPrint auto mode default rules as JSONclaude auto-mode defaults
claude auto-mode resetRestore default auto-mode configuration, with a confirmation prompt (--yes to skip) (v2.1.212)claude auto-mode reset --yes
claude remote-controlStart a Remote Control server (server mode, no local interactive session; serves several sessions, --capacity default 32)claude remote-control --name "My Project"
claude --remote-control [name]Start an interactive session with Remote Control enabled (alias --rc)claude --rc
claude pluginManage plugins (install, enable, disable)claude plugin install my-plugin
claude plugin init <name>Scaffold a new plugin at ~/.claude/skills/<name>/ (user-global) — auto-loads in the next session as <name>@skills-dir, no marketplace required (v2.1.157+)claude plugin init my-plugin
claude plugin tag [path]Create a {name}--v{version} release git tag for the plugin at [path], validating that plugin.json and any enclosing marketplace entry agree (v2.1.118+)claude plugin tag ./my-plugin
claude install [version]Install a specific native-binary version. Accepts stable, latest, or an explicit version stringclaude install 2.1.131
claude purge [path]Delete all local Claude Code state for a project (transcripts, tasks, debug logs, file-edit history, prompt history, and ~/.claude.json entry). Omit [path] for an interactive picker. Flags: --dry-run to preview, -y/--yes to skip confirmation, -i/--interactive to confirm each item, --all for every project (v2.1.126+) — renamed from claude project purge in v2.1.288; the old name still works and prints a noticeclaude purge ~/work/repo --dry-run
claude plugin pruneRemove orphaned auto-installed plugin dependencies (parent plugin gone). plugin uninstall --prune does the same cascade after uninstalling a target (v2.1.121+)claude plugin prune
claude ultrareview [target]Run /ultrareview non-interactively. Prints findings to stdout, exits 0 on success / 1 on failure / 130 if interrupted with Ctrl-C. Use --json for raw payload, --timeout <minutes> to override the 45-minute default (since v2.1.260), and --post / --no-post to control whether findings are posted back to the PR. In a folder you haven't trusted it asks on a terminal and otherwise exits 1; in scripts and CI, append --trust-workspace after the target (v2.1.309+). Requires Claude Code v2.1.227 or laterclaude ultrareview 1234 --json --no-post
claude self-hosted-runner [setup|doctor|orchestrator]Start a runner that hosts Claude Code cloud sessions on your own machine or container. setup is a guided operator walkthrough, doctor diagnoses a deployed runner, orchestrator spawns on-demand runners (its --shutdown-drain-sec, v2.1.299, lets the in-flight poll and spawn hooks finish on SIGTERM). Team and Enterprise plans; requires Claude Code v2.1.224 or later. On Windows, startup requires an explicit --base-dir (v2.1.229). Since v2.1.307 checkout hooks are stopped after 30 minutes by default, which fails the session's setup; raise --checkout-hook-timeout-min or set it to 0. Since v2.1.311, --hold-idle-file <path> and --max-hold-min <n> (default 1440, 0 turns it off) keep an idle session while your host reports processes it left runningclaude self-hosted-runner setup
claude auth loginLog in (supports --email, --sso). Since v2.1.126, accepts the OAuth code pasted into the terminal as a fallback when the browser callback can't reach localhost (WSL2, SSH, containers)claude auth login --email user@example.com
claude auth logoutLog out of current accountclaude auth logout
claude auth statusCheck auth status (exit 0 if logged in, 1 if not); since v2.1.318 its output includes loginExpiresAt, the date a stored claude.ai sign-in endsclaude auth status

Core Flags ​

FlagDescriptionExample
-p, --printPrint response without interactive modeclaude -p "query"
-c, --continueLoad most recent conversationclaude --continue
-r, --resumeResume specific session by ID or nameclaude --resume auth-refactor
-v, --versionOutput version numberclaude -v
--system-prompt-snapshot offRender the system prompt fresh on every request instead of reusing the prompt recorded with the conversation. Useful while iterating on prompt text (v2.1.257+)claude --system-prompt-snapshot off
-w, --worktreeStart in isolated git worktree. Accepts a GitLab merge-request URL as well as a GitHub PR URL since v2.1.233claude -w
-n, --nameSession display nameclaude -n "auth-refactor"
--from-pr <url-or-number>Resume sessions linked to a pull/merge request. Accepts GitHub (cloud + Enterprise), GitLab MR, and Bitbucket PR URLs since v2.1.119; previously GitHub.com onlyclaude --from-pr 42 or claude --from-pr https://gitlab.example.com/org/repo/-/merge_requests/17
--cloud [description|session_id|url]Create a cloud session on claude.ai with the given description, or attach to an existing one by session ID or claude.ai/code URLclaude --cloud "implement API"
--remote "task"Deprecated alias for --cloud, including the existing-session form. Use --cloud insteadclaude --remote "implement API"
--remote-control, --rcInteractive session with Remote Controlclaude --rc
--teleport [session]Resume a web session locally. Bare form opens a picker of your web sessions; pass a session ID to resume that session directly. Requires a claude.ai subscriptionclaude --teleport
--teammate-modeAgent team display modeclaude --teammate-mode tmux
--bareMinimal mode (skip hooks, skills, plugins, MCP, auto memory, CLAUDE.md)claude --bare
--safe-modeStart with all customizations disabled (CLAUDE.md, plugins, skills, hooks, MCP) to isolate config problems; also CLAUDE_CODE_SAFE_MODE=1 (v2.1.169)claude --safe-mode
--restrictedLock the session down for untrusted or shared use: removes the built-in command- and code-running tools and WebFetch, ignores user/project/local settings, confines file tools to the working directories, and refuses bypassPermissions and cloud sessions. Also CLAUDE_CODE_RESTRICTED=1 (v2.1.248+)claude --restricted -p "summarize this repo"
--permission-mode autoStart in auto permission mode (replaces the removed --enable-auto-mode flag, gone since v2.1.111)claude --permission-mode auto
--channelsSubscribe to MCP channel plugins. Entries must be tagged plugin:<name>@<marketplace>; bare names are rejectedclaude --channels plugin:discord@my-marketplace
--chrome / --no-chromeEnable/disable Chrome browser integrationclaude --chrome
--effortSet thinking effort levelclaude --effort high
--desktopOpen the session in the Claude desktop app on the current directory; add --continue or --resume <id> to pick the session (v2.1.285)claude --desktop --continue
--init / --init-only--init runs initialization (Setup) hooks before the session, print mode only; --init-only runs Setup and SessionStart hooks, then exitsclaude -p --init "query"
--maintenanceRun maintenance (Setup) hooks before the session (print mode only)claude -p --maintenance "query"
--disable-slash-commandsDisable all skills and slash commandsclaude --disable-slash-commands
--no-session-persistenceDisable session saving (print mode)claude -p --no-session-persistence "query"
--exclude-dynamic-system-prompt-sectionsExclude dynamic sections from the system prompt for better prompt cache hit ratesclaude -p --exclude-dynamic-system-prompt-sections "query"

Restricted Mode (--restricted, v2.1.248+) ​

--restricted (or CLAUDE_CODE_RESTRICTED=1) is for running claude on behalf of someone whose input you do not control — an evaluation harness on a shared machine, a CI job triggered by an outside contributor, a demo box. It applies all of the following:

  • Removes the tools that run commands or code — Bash, PowerShell, and the REPL — plus WebFetch, unless --tools explicitly names them.
  • Ignores user, project, and local settings files. Managed settings and an explicit --settings file still apply, so an administrator keeps control while a checked-in .claude/settings.json cannot widen the sandbox.
  • Confines the file tools to the working directories, so reads and writes cannot escape the paths you started in.
  • Refuses bypassPermissions, whichever way it is requested.
  • Refuses to create cloud sessions, so a restricted run cannot push work off the machine.
bash
# Evaluation harness: no shell, no network fetches, no settings inheritance
claude --restricted -p "summarize the architecture of this repo"

# Same lockdown, but deliberately re-enable one tool
claude --restricted --tools WebFetch -p "check the linked RFC"

Note: --restricted is a coarser lock than --permission-mode. It removes tools outright rather than prompting for them, so a restricted session cannot be widened from inside the session.

Interactive vs Print Mode ​

Interactive Mode (default):

bash
# Start interactive session
claude

# Start with initial prompt
claude "explain the authentication flow"

Print Mode (non-interactive):

bash
# Single query, then exit
claude -p "what does this function do?"

# Process file content
cat error.log | claude -p "explain this error"

# Chain with other tools
claude -p "list todos" | grep "URGENT"

Model & Configuration ​

FlagDescriptionExample
--modelSet model (sonnet, opus, haiku, or full name)claude --model opus
--fallback-modelAutomatic model fallback when the primary is overloaded/unavailable; configure up to three via the fallbackModel setting. Applies to interactive sessions too since v2.1.166 (previously print mode only)claude -p --fallback-model sonnet "query"
--agentSpecify agent for sessionclaude --agent my-custom-agent
--agentsDefine custom subagents via JSONSee Agents Configuration
--effortSet effort level (low, medium, high, xhigh, max)claude --effort xhigh

Model Selection Examples ​

bash
# Use Opus 5.5 for complex tasks
claude --model opus "design a caching strategy"

# Use Haiku for quick tasks (Haiku 5.5 on the Anthropic API since v2.1.293; Haiku 4.5 on Bedrock, Vertex, and Foundry)
claude --model haiku -p "format this JSON"

# Full model name
claude --model claude-sonnet-4-6 "review this code"

# With fallback for reliability
claude -p --model opus --fallback-model sonnet "analyze architecture"

# Use opusplan (Opus plans, Sonnet executes)
claude --model opusplan "design and implement the caching layer"

Gateway model discovery (v2.1.129+, opt-in): When ANTHROPIC_BASE_URL points at an Anthropic-compatible gateway, set CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERY=1 to populate /model from the gateway's /v1/models endpoint. Without the env var, /model falls back to the built-in static list. The flag is opt-in (changed in v2.1.129) because the discovery call can surface models a user may not be entitled to use; v2.1.126 made it implicit and that behavior was reverted.

1M context behind a custom base URL (v2.1.285): Sessions whose ANTHROPIC_BASE_URL points at a custom endpoint now use the 1M context window of models that have one (Opus 4.7+, Sonnet 5+, Fable). If your gateway stops at 200K, run /autocompact 200k.

1M context by default on third-party providers (v2.1.287): Opus 4.7+ and Fable now use the 1M context window by default on Amazon Bedrock, Google Vertex AI, Microsoft Foundry, and the Claude apps gateway, with no [1m] suffix. Set CLAUDE_CODE_DISABLE_1M_CONTEXT=1 to keep them at 200K.

Org default model (v2.1.196): When an org admin sets a default model, /model labels it as "Org default" (or "Role default").

System Prompt Customization ​

FlagDescriptionExample
--system-promptReplace entire default promptclaude --system-prompt "You are a Python expert"
--system-prompt-fileLoad prompt from file, replacing the default promptclaude -p --system-prompt-file ./prompt.txt "query"
--append-system-promptAppend to default promptclaude --append-system-prompt "Always use TypeScript"
--append-subagent-system-promptAppend text to every subagent's system prompt (non-interactive)claude -p --append-subagent-system-prompt "Cite sources" "query"
--append-subagent-system-prompt-file(v2.1.261) Load that appended text from a file instead, for prompts too long to pass on the command line. Non-interactive only, and cannot be combined with --append-subagent-system-promptclaude -p --append-subagent-system-prompt-file ./subagent-rules.txt "query"

System Prompt Examples ​

bash
# Complete custom persona
claude --system-prompt "You are a senior security engineer. Focus on vulnerabilities."

# Append specific instructions
claude --append-system-prompt "Always include unit tests with code examples"

# Load complex prompt from file
claude -p --system-prompt-file ./prompts/code-reviewer.txt "review main.py"

System Prompt Flags Comparison ​

FlagBehaviorInteractivePrint
--system-promptReplaces entire default system prompt✅✅
--system-prompt-fileReplaces with prompt from file✅✅
--append-system-promptAppends to default system prompt✅✅

All system prompt flags work in both interactive and print mode (the file forms since v2.1.69). --system-prompt and --system-prompt-file replace the default prompt; the append flags add to it.

Tool & Permission Management ​

FlagDescriptionExample
--toolsRestrict available built-in toolsclaude -p --tools "Bash,Edit,Read" "query"
--allowedToolsTools that execute without prompting"Bash(git log:*)" "Read"
--disallowedToolsTools removed from context"Bash(rm:*)" "Edit"
--dangerously-skip-permissionsSkip all permission promptsclaude --dangerously-skip-permissions
--permission-modeBegin in specified permission modeclaude --permission-mode auto
--permission-prompt-toolMCP tool that answers permission prompts in print mode; pass its full mcp__<server>__<tool> name, from a server the run loadsclaude -p --mcp-config ./mcp.json --permission-prompt-tool mcp__permissions__approve "query"
--permission-prompts(v2.1.259) Who answers permission prompts in print mode. Default host sends them to the Agent SDK host or the --permission-prompt-tool tool; pass none when nobody can answer and Claude Code denies them insteadclaude -p --permission-prompts none "query"

v2.1.111 update: --enable-auto-mode was removed; auto mode is now in the Shift+Tab cycle by default — use --permission-mode auto to start in it directly.

Glob / Grep footnote (v2.1.113+): On native macOS/Linux builds, Glob and Grep are provided as the embedded bfs and ugrep binaries invoked through the Bash tool rather than as separate first-class tools. Windows and npm-bundled (JS) installs still expose them as standalone tools. For subagent allowedTools / disallowedTools lists the backend substitution is transparent — you can keep referring to Glob / Grep in your configuration on every platform.

PowerShell auto-approve (v2.1.119): PowerShell tool commands can be auto-approved in permission mode exactly the same way Bash commands are. Use the same matcher syntax you already use for Bash(...) rules to scope PowerShell permissions — for example, PowerShell(Get-ChildItem:*).

--permission-mode honored on resume (v2.1.132+): claude -p --continue --permission-mode plan (and --resume) now respects the flag. Earlier versions silently dropped --permission-mode when resuming a session, so a plan-mode session resumed without re-passing the flag would silently downgrade — that's fixed.

Permission hardening (v2.1.214): Docker/Podman commands using daemon-redirect flags (e.g. --url, --connection, --identity) now require a permission prompt instead of running automatically. file commands using -m/--magic-file or -f/--files-from also now require permission. Bash commands over 10,000 characters always prompt for permission, regardless of allow rules.

Permission hardening (v2.1.319–v2.1.321): the Bash tool now asks before running which with flags outside a lookup/display set; read-only commands wrapped in a plain timeout DURATION (such as timeout 30 rg foo) no longer prompt; a session's exact Bash or PowerShell ask rule is refused, not asked about, when a broader deny rule covers the command (v2.1.319). cp and mv spelled by a path, such as /bin/cp, get the same path checks as cp and mv, and deny rules and protected-file prompts now apply to the file that a cp or mv into a directory writes (v2.1.321).

Permission hardening (v2.1.323): Claude Code warns at start-up about a Bash allow rule with a * in a variable's value, such as Bash(PORT=* npm run dev). It fixes allow rules with an attached wildcard, such as Bash(ls*), that skipped the permission prompt in some cases; a rule that names a variable, such as Bash(NODE_ENV*), now asks. Bash deny and ask rules no longer miss some commands run through sudo, env and similar wrappers, and a case where the Write and Edit tools could write to a path a Read deny rule covers is fixed. With plansDirectory set, a plan-file write that can't be shown to stay inside the project is refused. Bash prompts no longer offer "don't ask again" for commands that write to sensitive paths such as .git or .claude, where the saved rule didn't stop the next prompt, and "don't ask again" on an allow rule that looks like it holds a secret, or that would be saved to a settings.local.json that git tracks, lasts for the session only and isn't saved.

Permission hardening (v2.1.325): read-only git commands now ask first in a repository that isn't the project's or one you trusted; to run them there without prompts, name that repository with --add-dir, not the additionalDirectories setting. Relative deny and ask rules such as Read(./.env) keep covering the project after a cd, and now also apply in added directories. Some compound Bash commands that could run without asking now ask, a Bash allow rule can no longer run a different program than the one it names, and some deny and ask rules that didn't apply to certain Bash commands now do. With plansDirectory set, an approved plan edit that the folder can't take is saved in the default plans folder, and a warning says where and why. These come from the changelog; the permissions docs don't list the git and added-directory changes yet.

Permission Examples ​

bash
# Read-only mode for code review
claude --permission-mode plan "review this codebase"

# Restrict to safe tools only
claude --tools "Read,Grep,Glob" -p "find all TODO comments"

# Allow specific git commands without prompts
claude --allowedTools "Bash(git status:*)" "Bash(git log:*)"

# Block dangerous operations
claude --disallowedTools "Bash(rm -rf:*)" "Bash(git push --force:*)"

Parameter matching Tool(param:value) (v2.1.178): Permission rules follow the format Tool (every use) or Tool(specifier). As of v2.1.178, a specifier can match a tool's input parameters, not just command or path patterns — using the Tool(param:value) form with wildcard support. This generalizes the matching you already use for Bash(...) command prefixes (e.g. Bash(npm run test *)) and Read(...) path globs (e.g. Read(./.env.*)) so other tools can be scoped by their arguments. Check the permissions reference for the current per-tool example strings before writing a rule, since the exact parameter names differ by tool.

Output & Format ​

FlagDescriptionOptionsExample
--output-formatSpecify output format (print mode)text, json, stream-jsonclaude -p --output-format json "query"
--input-formatSpecify input format (print mode)text, stream-jsonclaude -p --input-format stream-json
--verboseEnable verbose loggingclaude --verbose
--include-partial-messagesInclude streaming eventsRequires stream-jsonclaude -p --output-format stream-json --include-partial-messages "query"
--forward-subagent-textForward subagent text output into the stream. As of v2.1.219, subagents spawned at depth 2 or deeper are forwarded too, keyed by their spawning Agent tool_use id (this is how you observe the nesting enabled by default via CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTH)Requires stream-jsonclaude -p --output-format stream-json --forward-subagent-text "query"
--json-schemaGet validated JSON matching schemaclaude -p --json-schema '{"type":"object"}' "query"
--max-budget-usdMaximum spend for print mode. Since v2.1.217, hitting the cap also halts running background subagents and denies new spawns (previously background agents kept running past the cap)claude -p --max-budget-usd 5.00 "query"

Output Format Examples ​

bash
# Plain text (default)
claude -p "explain this code"

# JSON for programmatic use
claude -p --output-format json "list all functions in main.py"

# Streaming JSON for real-time processing
claude -p --output-format stream-json "generate a long report"

# Structured output with schema validation
claude -p --json-schema '{"type":"object","properties":{"bugs":{"type":"array"}}}' \
  "find bugs in this code and return as JSON"

Workspace & Directory ​

FlagDescriptionExample
--add-dirAdd additional working directoriesclaude --add-dir ../apps ../lib
--setting-sourcesComma-separated setting sourcesclaude --setting-sources user,project

/config persistence (v2.1.119): Changes made interactively via the /config command are now written to ~/.claude/settings.json and participate in the normal precedence chain (policy → local → project → user). Before v2.1.119, some /config changes were session-only. See Memory & Settings for the full precedence order. | --settings | Load settings from file or JSON. File must be no larger than 2 MiB (v2.1.214) | claude --settings ./settings.json | | --plugin-dir | Load plugins from directory (repeatable). Since v2.1.265 it also accepts a folder of plugins — every child folder with a manifest loads, and children added or removed while the session runs are picked up | claude --plugin-dir ./my-plugin |

Multi-Directory Example ​

bash
# Work across multiple project directories
claude --add-dir ../frontend ../backend ../shared "find all API endpoints"

# Load custom settings
claude --settings '{"model":"opus","verbose":true}' "complex task"

MCP Configuration ​

FlagDescriptionExample
--mcp-configLoad MCP servers from JSONclaude --mcp-config ./mcp.json
--strict-mcp-configOnly use specified MCP configclaude --strict-mcp-config --mcp-config ./mcp.json
--channelsSubscribe to MCP channel plugins. Entries must be tagged plugin:<name>@<marketplace>; bare names are rejectedclaude --channels plugin:discord@my-marketplace

MCP Examples ​

bash
# Load GitHub MCP server
claude --mcp-config ./github-mcp.json "list open PRs"

# Strict mode - only specified servers
claude --strict-mcp-config --mcp-config ./production-mcp.json "deploy to staging"

Session Management ​

FlagDescriptionExample
--session-idUse specific session ID (UUID)claude --session-id "550e8400-..."
--fork-sessionCreate new session when resumingclaude --resume abc123 --fork-session

Session Examples ​

bash
# Continue last conversation
claude -c

# Resume named session
claude -r "feature-auth" "continue implementing login"

# Fork session for experimentation
claude --resume feature-auth --fork-session "try alternative approach"

# Use specific session ID
claude --session-id "550e8400-e29b-41d4-a716-446655440000" "continue"

v2.1.299: The resume command printed at exit names the session by its ID. Since v2.1.317 it also repeats the flags you launched with (for example --chrome --debug) ahead of --resume.

Session Fork ​

Create a branch from an existing session for experimentation:

bash
# Fork a session to try a different approach
claude --resume abc123 --fork-session "try alternative implementation"

# Fork with a custom message
claude -r "feature-auth" --fork-session "test with different architecture"

Use Cases:

  • Try alternative implementations without losing the original session
  • Experiment with different approaches in parallel
  • Create branches from successful work for variations
  • Test breaking changes without affecting the main session

The original session remains unchanged, and the fork becomes a new independent session.

Project State Cleanup (v2.1.126+) ​

claude purge deletes all local Claude Code state for a project — transcripts, task lists, debug logs, file-edit history, prompt history lines, and the project's ~/.claude.json entry. It was called claude project purge before v2.1.288; that name still works and prints a notice. Use --dry-run first to preview the deletion; --all walks every project on the machine.

bash
# Preview what would be deleted (safe)
claude purge ~/work/repo --dry-run

# Delete state for a specific project, no prompts
claude purge ~/work/repo --yes

# Walk every project interactively
claude purge --all --interactive

Advanced Features ​

FlagDescriptionExample
--chromeEnable Chrome browser integrationclaude --chrome
--no-chromeDisable Chrome browser integrationclaude --no-chrome
--ideAuto-connect to IDE if availableclaude --ide
--max-turnsLimit agentic turns (non-interactive)claude -p --max-turns 3 "query"
--debugEnable debug mode with filtering (the filter applies only in the = form)claude --debug=api,mcp
--enable-lsp-loggingEnable verbose LSP loggingclaude --enable-lsp-logging
--betasBeta headers for API requestsclaude --betas interleaved-thinking
--plugin-dirLoad plugins from directory (repeatable). Since v2.1.265 it also accepts a folder of plugins — every child folder with a manifest loads, and children added or removed while the session runs are picked upclaude --plugin-dir ./my-plugin
--effortSet thinking effort levelclaude --effort high
--bareMinimal mode (skip hooks, skills, plugins, MCP, auto memory, CLAUDE.md)claude --bare
--channelsSubscribe to MCP channel plugins (tagged plugin:<name>@<marketplace>)claude --channels plugin:discord@my-marketplace
--tmuxCreate tmux session for worktree (requires --worktree)claude --worktree feature-x --tmux
--fork-sessionCreate new session ID when resumingclaude --resume abc --fork-session
--max-budget-usdMaximum spend (print mode); also halts background subagents when hit (v2.1.217)claude -p --max-budget-usd 5.00 "query"
--json-schemaValidated JSON outputclaude -p --json-schema '{"type":"object"}' "q"
--ax-screen-readerPlain-text rendering mode for screen readers (v2.1.208)claude --ax-screen-reader

Platform & Theme Notes (v2.1.111) ​

  • PowerShell tool on Windows: A dedicated PowerShell tool is rolling out on Windows and is controllable via environment variable.
  • Auto (match terminal) theme: The new "Auto (match terminal)" theme syncs Claude Code's light/dark appearance with your terminal.
  • Quieter permission prompts: Read-only Bash commands with glob patterns, such as ls *.ts, and commands starting with cd <project-dir> && no longer trigger a permission prompt.

Advanced Examples ​

bash
# Limit autonomous actions
claude -p --max-turns 5 "refactor this module"

# Debug API calls
claude --debug=api "test query"

# Enable IDE integration
claude --ide "help me with this file"

Agents Configuration ​

The --agents flag accepts a JSON object defining custom subagents for a session.

As of v2.1.243, --agents no longer silently ignores invalid JSON or an invalid agent definition — it exits with a clear error, matching how --mcp-config already behaved.

Agents JSON Format ​

json
{
  "agent-name": {
    "description": "Required: when to invoke this agent",
    "prompt": "Required: system prompt for the agent",
    "tools": ["Optional", "array", "of", "tools"],
    "model": "optional: sonnet|opus|haiku"
  }
}

Required Fields:

  • description - Natural language description of when to use this agent
  • prompt - System prompt that defines the agent's role and behavior

Optional Fields:

  • tools - Array of available tools (inherits all if omitted)
    • Format: ["Read", "Grep", "Glob", "Bash"]
  • model - Model to use: sonnet, opus, or haiku

Complete Agents Example ​

json
{
  "code-reviewer": {
    "description": "Expert code reviewer. Use proactively after code changes.",
    "prompt": "You are a senior code reviewer. Focus on code quality, security, and best practices.",
    "tools": ["Read", "Grep", "Glob", "Bash"],
    "model": "sonnet"
  },
  "debugger": {
    "description": "Debugging specialist for errors and test failures.",
    "prompt": "You are an expert debugger. Analyze errors, identify root causes, and provide fixes.",
    "tools": ["Read", "Edit", "Bash", "Grep"],
    "model": "opus"
  },
  "documenter": {
    "description": "Documentation specialist for generating guides.",
    "prompt": "You are a technical writer. Create clear, comprehensive documentation.",
    "tools": ["Read", "Write"],
    "model": "haiku"
  }
}

Agents Command Examples ​

bash
# Define custom agents inline
claude --agents '{
  "security-auditor": {
    "description": "Security specialist for vulnerability analysis",
    "prompt": "You are a security expert. Find vulnerabilities and suggest fixes.",
    "tools": ["Read", "Grep", "Glob"],
    "model": "opus"
  }
}' "audit this codebase for security issues"

# Load agents from file
claude --agents "$(cat ~/.claude/agents.json)" "review the auth module"

# Combine with other flags
claude -p --agents "$(cat agents.json)" --model sonnet "analyze performance"

Agent Priority ​

When multiple agent definitions exist, they are loaded in this priority order:

  1. CLI-defined (--agents flag) - Session-specific
  2. Project-level (.claude/agents/) - Current project
  3. User-level (~/.claude/agents/) - All projects

CLI-defined agents override both project and user agents for the session. Project-level agents override user-level agents when their names collide. See Lesson 04 — Subagents for the full priority table including plugin-level agents.

Agent View (claude agents, v2.1.139+) ​

Research Preview — feature is stable enough for daily use but may change.

claude agents opens the Agent View — a single list of every Claude Code session on the machine with its current status (running, blocked on you, done). It is the replacement for juggling multiple terminal tabs when you run background agents, scheduled tasks, or --bg-launched sessions.

bash
# Open the Agent View
claude agents

When you dispatch a session from the view (or via claude --bg <prompt>), you can pass the same configuration flags you would pass to claude itself. Flags introduced for the Agent View dispatch path:

FlagSinceDescription
--cwd <path>v2.1.141Scope the session list (or new session) to a specific working directory
--add-dir <path>v2.1.142Add directories to the dispatched session's workspace
--settings <path>v2.1.142Use a specific settings.json for the dispatched session
--mcp-config <path>v2.1.142Use a specific MCP config for the dispatched session
--plugin-dir <path>v2.1.142Use a specific plugin directory for the dispatched session
--permission-mode <mode>v2.1.142Set permission mode (plan, acceptEdits, auto, etc.) for the dispatched session
--model <model>v2.1.142Pin a model for the dispatched session
--effort <level>v2.1.142Set the dispatched session's starting effort level (low/medium/high/xhigh/max) — a level picked in the session or CLAUDE_CODE_EFFORT_LEVEL outranks it
--dangerously-skip-permissionsv2.1.142Run the dispatched session without permission prompts (use only in sandboxes)
--agent <name>—Subagent used when a dispatch prompt doesn't name one (with @name or as the first word); defaults to the agent setting, otherwise the built-in claude agent
--jsonv2.1.145Print the agent list as machine-readable JSON for scripting (status bars, session pickers, tmux-resurrect integrations)

Before v2.1.321, --permission-mode, --dangerously-skip-permissions, --model, --effort and --agent were ignored when typed before agents together with a flag such as --verbose.

Sessions that finish their work but leave a background shell open move from "Working" to "Completed" (v2.1.141 fix). Within an attached agent session, Shift+Tab cycles through permission modes including auto mode (v2.1.143).

GitLab merge requests (v2.1.233) — the Agent View recognizes GitLab MR URLs alongside GitHub PR URLs, and displays merge requests as !N (GitHub pull requests stay #N). The same release taught --worktree to accept a GitLab MR URL.

Pin a session — press Ctrl+T on a session in claude agents to pin it (v2.1.147). Pinned background sessions stay alive when idle, are restarted in place to apply Claude Code updates, and are shed under memory pressure only after non-pinned sessions. (This Ctrl+T is scoped to the Agent View; in the main session it toggles the task list view.)

Defaults for new sessions (v2.1.299) — in agent view, /effort and /fast set what new sessions start with; a bare /model, /effort or /fast opens a picker.


High-Value Use Cases ​

1. CI/CD Integration ​

Use Claude Code in your CI/CD pipelines for automated code review, testing, and documentation.

GitHub Actions Example:

yaml
name: AI Code Review

on: [pull_request]

jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Install Claude Code
        run: npm install -g @anthropic-ai/claude-code

      - name: Run Code Review
        env:
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}
        run: |
          claude -p --output-format json \
            --max-turns 5 \
            "Review the changes in this PR for:
            - Security vulnerabilities
            - Performance issues
            - Code quality
            Output as JSON with 'issues' array" > review.json

      - name: Post Review Comment
        uses: actions/github-script@v7
        with:
          script: |
            const fs = require('fs');
            const review = JSON.parse(fs.readFileSync('review.json', 'utf8'));
            // Process and post review comments

Jenkins Pipeline:

groovy
pipeline {
    agent any
    stages {
        stage('AI Review') {
            steps {
                sh '''
                    claude -p --output-format json \
                      --max-turns 3 \
                      "Analyze test coverage and suggest missing tests" \
                      > coverage-analysis.json
                '''
            }
        }
    }
}

Headless ultrareview (requires v2.1.227+; --trust-workspace requires v2.1.309+):

yaml
# .github/workflows/ultrareview.yml
# Check out a branch you trust, e.g. actions/checkout with `ref: ${{ github.base_ref }}`;
# ultrareview clones the pull request itself in the cloud.
- name: Claude ultrareview
  run: claude ultrareview ${{ github.event.pull_request.number }} --trust-workspace --json --no-post > review.json

claude ultrareview exits 0 when the review completes, with or without findings, 1 when it fails to launch, errors, times out, or the folder isn't trusted, and 130 when you press Ctrl-C while it's launching the review, waiting for findings, or posting the --post comment, so gate a PR on the findings in review.json, not on the exit code. In CI the run can't ask whether you trust the checkout, so since v2.1.309 it exits 1 with Error: Workspace not trusted unless you pass --trust-workspace after the PR number or base branch (it takes no value) or set CLAUDE_CODE_DISABLE_ULTRAREVIEW_TRUST_CHECK=1 in the job's environment. Use either only on a checkout you trust. Use --timeout <minutes> to override the 45-minute default (since v2.1.260). --post posts the finished findings to the pull request; --no-post keeps them in stdout only, which is what you want when a later CI step formats the report itself.

2. Script Piping ​

Process files, logs, and data through Claude for analysis.

Log Analysis:

bash
# Analyze error logs
tail -1000 /var/log/app/error.log | claude -p "summarize these errors and suggest fixes"

# Find patterns in access logs
cat access.log | claude -p "identify suspicious access patterns"

# Analyze git history
git log --oneline -50 | claude -p "summarize recent development activity"

Code Processing:

bash
# Review a specific file
cat src/auth.ts | claude -p "review this authentication code for security issues"

# Generate documentation
cat src/api/*.ts | claude -p "generate API documentation in markdown"

# Find TODOs and prioritize
grep -r "TODO" src/ | claude -p "prioritize these TODOs by importance"

3. Multi-Session Workflows ​

Manage complex projects with multiple conversation threads.

bash
# Start a feature branch session
claude -r "feature-auth" "let's implement user authentication"

# Later, continue the session
claude -r "feature-auth" "add password reset functionality"

# Fork to try an alternative approach
claude --resume feature-auth --fork-session "try OAuth instead"

# Switch between different feature sessions
claude -r "feature-payments" "continue with Stripe integration"

4. Custom Agent Configuration ​

Define specialized agents for your team's workflows.

bash
# Save agents config to file
cat > ~/.claude/agents.json << 'EOF'
{
  "reviewer": {
    "description": "Code reviewer for PR reviews",
    "prompt": "Review code for quality, security, and maintainability.",
    "model": "opus"
  },
  "documenter": {
    "description": "Documentation specialist",
    "prompt": "Generate clear, comprehensive documentation.",
    "model": "sonnet"
  },
  "refactorer": {
    "description": "Code refactoring expert",
    "prompt": "Suggest and implement clean code refactoring.",
    "tools": ["Read", "Edit", "Glob"]
  }
}
EOF

# Use agents in session
claude --agents "$(cat ~/.claude/agents.json)" "review the auth module"

5. Batch Processing ​

Process multiple queries with consistent settings.

bash
# Process multiple files
for file in src/*.ts; do
  echo "Processing $file..."
  claude -p --model haiku "summarize this file: $(cat $file)" >> summaries.md
done

# Batch code review
find src -name "*.py" -exec sh -c '
  echo "## $1" >> review.md
  cat "$1" | claude -p "brief code review" >> review.md
' _ {} \;

# Generate tests for all modules
for module in $(ls src/modules/); do
  claude -p "generate unit tests for src/modules/$module" > "tests/$module.test.ts"
done

6. Security-Conscious Development ​

Use permission controls for safe operation.

bash
# Read-only security audit
claude --permission-mode plan \
  --tools "Read,Grep,Glob" \
  "audit this codebase for security vulnerabilities"

# Block dangerous commands
claude --disallowedTools "Bash(rm:*)" "Bash(curl:*)" "Bash(wget:*)" \
  "help me clean up this project"

# Restricted automation
claude -p --max-turns 2 \
  --allowedTools "Read" "Glob" \
  "find all hardcoded credentials"

7. JSON API Integration ​

Use Claude as a programmable API for your tools with jq parsing.

bash
# Get structured analysis
claude -p --output-format json \
  --json-schema '{"type":"object","properties":{"functions":{"type":"array"},"complexity":{"type":"string"}}}' \
  "analyze main.py and return function list with complexity rating"

# Integrate with jq for processing (schema output lands in .structured_output)
claude -p --output-format json \
  --json-schema '{"type":"object","properties":{"endpoints":{"type":"array"}}}' \
  "list all API endpoints" | jq '.structured_output.endpoints[]'

# Use in scripts
RESULT=$(claude -p --output-format json \
  --json-schema '{"type":"object","properties":{"secure":{"type":"boolean"},"issues":{"type":"array"}},"required":["secure","issues"]}' \
  "is this code secure?" < code.py)
if echo "$RESULT" | jq -e '.structured_output.secure == false' > /dev/null; then
  echo "Security issues found!"
  echo "$RESULT" | jq '.structured_output.issues[]'
fi

jq Parsing Examples ​

Parse and process Claude's JSON output using jq. The response text is in .result; with --json-schema, the validated object is in .structured_output ($SCHEMA below stands for a schema that defines the fields each filter reads):

bash
# Extract the response text
claude -p --output-format json "analyze this code" | jq -r '.result'

# Filter array elements
claude -p --output-format json --json-schema "$SCHEMA" "list issues" | jq -r '.structured_output.issues[] | select(.severity=="high")'

# Extract multiple fields
claude -p --output-format json --json-schema "$SCHEMA" "describe the project" | jq -r '.structured_output | {name, version, description}'

# Convert to CSV
claude -p --output-format json --json-schema "$SCHEMA" "list functions" | jq -r '.structured_output.functions[] | [.name, .lineCount] | @csv'

# Conditional processing
claude -p --output-format json --json-schema "$SCHEMA" "check security" | jq 'if (.structured_output.vulnerabilities | length) > 0 then "UNSAFE" else "SAFE" end'

# Extract nested values
claude -p --output-format json --json-schema "$SCHEMA" "analyze performance" | jq '.structured_output.metrics.cpu.usage'

# Process entire array
claude -p --output-format json --json-schema "$SCHEMA" "find todos" | jq '.structured_output.todos | length'

# Transform output
claude -p --output-format json --json-schema "$SCHEMA" "list improvements" | jq '.structured_output.improvements | map({title: .title, priority: .priority})'

With a stored claude.ai sign-in, JSON results also carry credential_expires_at, and text output prints a one-line stderr warning starting 10 days before that sign-in ends (v2.1.318).


Models ​

Claude Code supports multiple models with different capabilities:

ModelIDContext WindowNotes
Opus 5.5claude-opus-5-51M tokensDefault model and default Opus model since v2.1.280 on Pro, Max, Ultra, Team, Enterprise, the Anthropic API, Claude Platform on AWS, Amazon Bedrock, and Google Cloud's Agent Platform (Pro and Team Standard previously defaulted to Sonnet 5); Microsoft Foundry still resolves opus to Opus 4.6 and default to Sonnet 4.5. Adaptive effort levels low → max, default effort medium; thinking can't be turned off. Requires v2.1.280+
Sonnet 5.5claude-sonnet-5-51M tokensDefault Sonnet model on the Anthropic API since v2.1.284 (the sonnet alias resolves to it there); adaptive effort levels low → max, default effort medium; thinking can't be turned off; not available in fast mode. Requires v2.1.284+
Haiku 5.5claude-haiku-5-51M tokensDefault Haiku model on the Anthropic API since v2.1.293 (the haiku alias resolves to it there; Bedrock, Vertex, Foundry, and Claude Platform on AWS still resolve haiku to Haiku 4.5); adaptive effort levels low → max, default effort medium; thinking can't be turned off. Requires v2.1.293+
Sonnet 5claude-sonnet-51M tokensDefault on Pro / Team Standard seats from v2.1.197 until v2.1.280, when those plans moved to Opus 5.5; native 1M-token context window
Opus 5claude-opus-51M tokensDefault Opus model from v2.1.219 until v2.1.280 (now Opus 5.5); still selectable; adaptive effort levels low → max, default effort high
Opus 4.8claude-opus-4-81M tokensPrevious flagship Opus, still selectable; adaptive effort levels low → max; default effort high (v2.1.154)
Sonnet 4.6claude-sonnet-4-61M tokensBalanced speed and capability; default effort for Pro/Max subscribers raised from medium to high in v2.1.117
Haiku 4.5claude-haiku-4-5200K tokensPrevious Haiku, still the haiku alias on Bedrock, Vertex, Foundry, and Claude Platform on AWS; no effort levels
Fable 5.2claude-fable-5-21M tokensCurrent Fable model since v2.1.321; the fable alias resolves to it except in Claude apps gateway sessions (Fable 5 there); default effort medium; supports fast mode. Requires v2.1.321+
Fable 5.1claude-fable-5-1—Previous Fable model (the fable alias pointed to it from v2.1.257 until v2.1.321); select it with /model claude-fable-5-1. Requires v2.1.257+
Fable 5claude-fable-5—Mythos-class model, made safe for general use (v2.1.170)

Note: Sonnet 4.5 retires on November 30, 2026 on the Claude API, Claude Platform on AWS, Claude Models on Google Cloud (Anthropic managed) and Microsoft Foundry; Amazon Bedrock and Google Cloud's Agent Platform set their own dates. On Foundry, where default and sonnet still resolve to Sonnet 4.5, set a newer model explicitly.

Model Selection ​

bash
# Use short names
claude --model opus "complex architectural review"
claude --model sonnet "implement this feature"
claude --model haiku -p "format this JSON"

# Use opusplan alias (Opus plans, Sonnet executes)
claude --model opusplan "design and implement the API"

# Toggle fast mode during session
/fast

Fable 5.2 and the fable alias (v2.1.321): Fable 5.2 (claude-fable-5-2) ships in v2.1.321, and fable now resolves to it, except in Claude apps gateway sessions, where fable still resolves to Fable 5 (run /model claude-fable-5-2 there if your gateway serves it). Fable 5.2 has a 1M context window and costs $8/$40 per Mtok, with $0.20/Mtok cache reads. The best alias now resolves to the same model as opus; before v2.1.321 it used the model fable resolved to, where Fable is available. Fable 5.1 (claude-fable-5-1, v2.1.257+) and Fable 5 stay selectable by model ID. On Pro, Max, and Ultra plans, a claude-fable-5-1 model saved in your user settings moves to fable the first time you run v2.1.321 or later; on Team and Enterprise plans the move waits for your organization's settings. Console accounts, third-party providers, and project, local, or managed settings keep claude-fable-5-1; run /model claude-fable-5-1 to switch back. If the newest Fable model isn't available to your organization, fable retries once on the previous Fable model (v2.1.301).

Fast Mode runs on Fable 5.2, Opus 5.5, Opus 5, and Opus 4.8 (v2.1.321): As of v2.1.219, /fast applies to Opus 5 and Opus 4.8 — Opus 4.7 was removed from fast mode. Opus 5's fast mode is billed at $10/$50 per Mtok. Fast mode first moved to Opus 4.8 in v2.1.154 (about 2× the standard rate for ~2.5× the output speed), having flipped from Opus 4.6 to Opus 4.7 in v2.1.142. The CLAUDE_CODE_OPUS_4_6_FAST_MODE_OVERRIDE env var was deprecated in v2.1.154 and removed on 2026-06-01; fast mode is no longer available on Opus 4.6 — select Opus 5 or Opus 4.8 instead. Since v2.1.280, fast mode defaults to Opus 5.5 ($8/$40 per Mtok); Opus 5 and Opus 4.8 remain supported at $10/$50 as a research preview (fast mode on Opus 5.5 is generally available). Since v2.1.321, fast mode also runs on Fable 5.2 at $16/$80 per Mtok; on Fable 5.2 it stays on across sessions only if you turned it on with /fast while using Fable 5.2, and a "fastMode": true setting alone has no effect there. Fast mode on Opus 4.8 is deprecated as of October 30, 2026 and will be removed on November 30, 2026 (v2.1.316); after that, fast mode requests on Opus 4.8 return an error instead of falling back to standard speed, so move to Opus 5.5 to keep the speedup. Fast mode and standard speed keep separate prompt caches: the first switch to fast mode re-reads the conversation uncached at fast-mode rates, and each later toggle, including the automatic fallback after a rate limit, re-reads what that speed hasn't cached, so turn it on at the start of a session.

Fast mode on Google Cloud's Agent Platform (Vertex AI, v2.1.322): there fast mode works for Fable 5.2 only, in the global, us, or eu region (for example export VERTEX_REGION_CLAUDE_FABLE_5_2=global). /fast switches the session to Fable 5.2 without saving fast mode as your default, and "fastMode": true in settings has no effect; in a -p run pass --model claude-fable-5-2 --settings '{"fastMode": true}'. If Agent Platform refuses fast mode, Claude Code falls back to standard speed.

Effort Levels (Opus 5 / Sonnet 5 / Opus 4.8 / Opus 4.7) ​

The Fable models, Opus 5, Sonnet 5, Opus 4.8, and Opus 4.7 support adaptive reasoning with effort levels, ordered from lightest to heaviest: low (○), medium (◐), high (●), xhigh, and max. Opus 5.5, Sonnet 5.5, and Haiku 5.5 support all five levels too. The default is medium on Fable 5.2, Opus 5.5 (the default model since v2.1.280), Sonnet 5.5, and Haiku 5.5, high on Fable 5.1, Fable 5, Opus 5, Sonnet 5, Opus 4.8 (since v2.1.154), Opus 4.6, and Sonnet 4.6, and xhigh on Opus 4.7. xhigh is available on the Fable models, Opus 5.5, Sonnet 5.5, Haiku 5.5, Opus 5, Sonnet 5, Opus 4.8, and Opus 4.7; max works on the Fable models, Opus 5.5, Sonnet 5.5, Haiku 5.5, Opus 5, Sonnet 5, Opus 4.8/4.7/4.6 and Sonnet 4.6 (session-only). Haiku 4.5 has no effort levels. On Opus 4.6 / Sonnet 4.6, the default effort for Pro/Max subscribers was raised from medium to high in v2.1.117.

bash
# Set effort level via CLI flag
claude --effort high "complex review"

# Set effort level via slash command
/effort high

# Set effort level via environment variable
export CLAUDE_CODE_EFFORT_LEVEL=high   # low, medium, high, xhigh (Fable models, Opus 5.5, Sonnet 5.5, Haiku 5.5, Opus 5, Sonnet 5, Opus 4.8/4.7), or max — default is high on Opus 5

The "ultrathink" keyword in prompts activates deep reasoning; since v2.1.311, typed in the interactive terminal it also runs that turn at xhigh on Opus 5.5, Sonnet 5.5, Haiku 5.5, Fable 5.2 (v2.1.321+), and Fable 5.1 through Anthropic's API (rainbow-colored when it can; VS Code since v2.1.316), and CLAUDE_CODE_DISABLE_ULTRATHINK=1 (v2.1.316) turns it off. The /effort slider also has an Ultracode toggle (Tab, or /effort ultracode [on|off]), which is not a model effort level — it has Claude orchestrate dynamic workflows at whichever effort level the session runs at. Since v2.1.284 it no longer forces xhigh and stays on when you change the level; --effort ultracode and the Agent SDK's effortLevel: "ultracode" still set xhigh.


Key Environment Variables ​

VariableDescription
ANTHROPIC_API_KEYAPI key for authentication
ANTHROPIC_MODELOverride default model
ANTHROPIC_DEFAULT_MODEL(v2.1.236) Sets the model new sessions start on. Unlike ANTHROPIC_MODEL, which pins the model, a /model pick still overrides this value and persists across restarts — that contrast is the point of the variable.
ANTHROPIC_CUSTOM_MODEL_OPTIONCustom model option for API
ANTHROPIC_DEFAULT_OPUS_MODELOverride default Opus model ID
ANTHROPIC_DEFAULT_SONNET_MODELOverride default Sonnet model ID
ANTHROPIC_DEFAULT_HAIKU_MODELOverride default Haiku model ID
MAX_THINKING_TOKENSSet extended thinking token budget
CLAUDE_CODE_EFFORT_LEVELSet effort level (low/medium/high/xhigh/max) — default is medium on Fable 5.2, Opus 5.5, Sonnet 5.5, and Haiku 5.5, high on Fable 5.1, Fable 5, Opus 5, Sonnet 5, and Opus 4.8 (xhigh on Opus 4.7); xhigh needs a Fable model, Opus 5.5, Sonnet 5.5, Haiku 5.5, Opus 5, Sonnet 5, or Opus 4.8/4.7; max works on Fable models, Opus 5.5, Sonnet 5.5, Haiku 5.5, Opus 5, Sonnet 5, Opus 4.8/4.7/4.6 and Sonnet 4.6; set auto or unset to send no effort level so the API's default applies. It outranks --effort and /effort
CLAUDE_CODE_SIMPLEMinimal mode, set by --bare flag
CLAUDE_CODE_SAFE_MODESet to 1 to start with all customizations disabled (CLAUDE.md, plugins, skills, hooks, MCP) — env-var form of --safe-mode, for isolating config problems (v2.1.169)
CLAUDE_CODE_DISABLE_BUNDLED_SKILLSSet to 1 to hide the bundled skills, workflows, and commands from the model (v2.1.169)
CLAUDE_CODE_DISABLE_AUTO_MEMORYSet to 1 to disable auto memory (no auto memory files are created or loaded)
CLAUDE_CODE_DISABLE_BACKGROUND_TASKSDisable background task execution
CLAUDE_CODE_DISABLE_CRONDisable session-scoped scheduled tasks (/loop, cron tools); cloud scheduled tasks are unaffected
CLAUDE_CODE_DISABLE_FEATURE_FLAGSSet to 1 to stop feature-flag fetching without turning off telemetry; every flag then uses its built-in default. With it set, Remote Control and the other features that need feature-flag fetching are unavailable. The older name DISABLE_GROWTHBOOK still works (v2.1.319)
CLAUDE_CODE_DISABLE_GIT_INSTRUCTIONSDisable git-related instructions
CLAUDE_CODE_DISABLE_TERMINAL_TITLEDisable terminal title updates
CLAUDE_CODE_DISABLE_1M_CONTEXTDisable 1M token context window
CLAUDE_CODE_DISABLE_MOUSE_CLICKSDisable mouse click/drag/hover in fullscreen mode; wheel scroll still works (v2.1.195+)
CLAUDE_CODE_DISABLE_NESTED_SESSION_IDSet to 1 on a self-hosted runner so a claude -p run inside a session uses that session's ID and transcript, as before v2.1.317
CLAUDE_CODE_DISABLE_NONSTREAMING_FALLBACKDisable non-streaming fallback
CLAUDE_CODE_ENABLE_TASKSTask tools are the default; set to 0 to revert to the legacy TodoWrite tool
CLAUDE_CODE_TASK_LIST_IDNamed task directory shared across sessions
CLAUDE_CODE_ENABLE_PROMPT_SUGGESTIONToggle prompt suggestions (true/false)
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMSEnable experimental agent teams
CLAUDE_CODE_NEW_INITUse new initialization flow
CLAUDE_CODE_SUBAGENT_MODELModel for subagent execution
CLAUDE_CODE_PLUGIN_SEED_DIRDirectory for plugin seed files
CLAUDE_CODE_SUBPROCESS_ENV_SCRUBEnv vars to scrub from subprocesses
CLAUDE_AUTOCOMPACT_PCT_OVERRIDEOverride auto-compaction percentage
CLAUDE_CODE_AUTO_COMPACT_WINDOWAuto-compact window, from 100000 to 1000000 tokens. Accepts k/M suffixes such as 200k since v2.1.304 (earlier versions read 200k as 200 and clamped to 100K) and warns on out-of-range values
CLAUDE_STREAM_IDLE_TIMEOUT_MSStream idle timeout in milliseconds
API_TIMEOUT_MSTime each API request attempt has to receive its response headers (default 600000). 0 removes the limit since v2.1.305; a non-streaming attempt still stops after 300 s locally
CLAUDE_CODE_WARN_DISK_FREE_GIB / CLAUDE_CODE_WARN_MEMORY_FREE_GIBWhole GiB thresholds below which Claude is warned about free disk space on the working directory's filesystem / available memory (memory: Linux and WSL); launch environment only (v2.1.304)
SLASH_COMMAND_TOOL_CHAR_BUDGETCharacter budget for slash command tools
ENABLE_TOOL_SEARCHEnable tool search capability
MAX_MCP_OUTPUT_TOKENSMaximum tokens for MCP tool output
CLAUDE_CODE_PERFORCE_MODESet to 1 to enable Perforce-aware write protection: Edit, Write, and NotebookEdit fail with a p4 edit <file> hint when the target file lacks the owner-write bit, which Perforce clears on synced files until p4 edit opens them (added v2.1.98). Since v2.1.323, a one-time start-up notice names this variable when Perforce settings are found and the mode is off
DISABLE_UPDATESBlocks all update paths including manual claude update. Stricter than DISABLE_AUTOUPDATER, which only blocks the background autoupdater (v2.1.118+)
CLAUDE_CODE_HIDE_CWDWhen set to 1, hides the current working directory in the startup logo (privacy / screen-share use) (v2.1.119+)
CLAUDE_CODE_FORK_SUBAGENTSet to 0 to turn fork subagents off. Since v2.1.302 they are on by default in the terminal, claude -p, the Agent SDK, the desktop app and VS Code; before v2.1.302, set 1 to turn them on in claude -p and the Agent SDK.
CLAUDE_CODE_DISABLE_ALTERNATE_SCREENSet to 1 to opt out of the fullscreen alternate-screen renderer; the session stays in normal terminal scrollback. Useful when piping transcripts to logs or pairing with script(1) (v2.1.132+).
CLAUDE_CODE_SESSION_IDSet in every Bash tool subprocess launched by Claude Code; equals the session_id in hook input JSON. Use to correlate bash logs with hook telemetry (v2.1.132+).
CLAUDE_CODE_ENABLE_FEEDBACK_SURVEY_FOR_OTELSet to 1 to re-enable Anthropic's session-quality survey for organizations capturing OpenTelemetry data. Off by default in OTEL deployments (v2.1.136+).
OTEL_LOG_TOOL_DETAILSSet to 1 to unredact custom and MCP command names in OpenTelemetry events (v2.1.117+). Redaction remains the default. Also adds classifier_category to tool_decision events (v2.1.301).
CLAUDE_CODE_OTEL_CONTENT_MAX_LENGTHConfigures the truncation limit (default 60 KB) applied to OpenTelemetry content attributes (v2.1.214)
FORCE_HYPERLINKSet to 0 to opt out of clickable PR-badge hyperlinks in the footer, which now render even when terminal support can't be auto-detected (v2.1.217)
ANTHROPIC_BEDROCK_SERVICE_TIERSelects the Bedrock service tier: default, flex, or priority (v2.1.122+)
AI_AGENTSet automatically on subprocesses so external CLIs (e.g., gh) can attribute traffic to Claude Code (v2.1.120+)
CLAUDE_CODE_FORCE_SYNC_OUTPUTSet to 1 to force synchronous output for terminals where auto-detection misses (e.g., Emacs eat) (v2.1.129+)
CLAUDE_CODE_PACKAGE_MANAGER_AUTO_UPDATESet to 1 to enable background upgrades for Homebrew/WinGet installs (which normally do not auto-update) (v2.1.129+)
CLAUDE_CODE_ENABLE_GATEWAY_MODEL_DISCOVERYSet to 1 to opt in to gateway /v1/models discovery when ANTHROPIC_BASE_URL is set. Without it, /model shows the built-in static list (v2.1.129+)
CLAUDE_CODE_DISABLE_STRUCTURED_OUTPUTSSet to 1 to stop sending the structured-output output_config.format field and its paired anthropic-beta value, for an LLM gateway whose upstream rejects them. Leaves on the other pre-release capabilities that CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS turns off (v2.1.288)
CLAUDE_CODE_ENABLE_AUTO_MODELegacy opt-in for auto mode on Bedrock, Vertex, and Foundry (v2.1.158–v2.1.206). As of v2.1.207, auto mode is available by default on those providers for Sonnet 5, Opus 4.7/4.8, and Fable 5 (Opus 5 added in v2.1.219) — this variable is accepted for compatibility but has no effect
CLAUDE_CODE_MAX_WEB_SEARCHES_PER_SESSIONCap on WebSearch tool calls per session, to stop runaway search loops. Default 200 (v2.1.212). Since v2.1.290 the budget refills over time in interactive sessions — see CLAUDE_CODE_WEB_SEARCH_REFILLS_PER_HOUR
CLAUDE_CODE_WEB_SEARCH_REFILLS_PER_HOURRate at which a session's WebSearch budget refills, in calls per hour. Default 100 in an interactive session; 0 (no refill) in a non-interactive (-p) session. Plain digits only (v2.1.290)
CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTSCap on subagents running concurrently. Default 20 (v2.1.217)
CLAUDE_CODE_MAX_SUBAGENT_SPAWN_DEPTHControls how deep nested subagent spawns can go. Since v2.1.219 the default is 3 layers (was 1); set to 1 to disable nesting entirely
CLAUDE_CODE_MCP_AUTO_BACKGROUND_MSThreshold, in milliseconds, before a long-running MCP tool call auto-backgrounds. Default 120000 (2 minutes) (v2.1.212)
CLAUDE_CODE_DISABLE_MCP_TASK_BACKGROUNDSet to 1 so Claude waits for an MCP task's result in an interactive session; automatic backgrounding still applies after two minutes (v2.1.304)
CLAUDE_AX_SCREEN_READERSet to 1 to enable plain-text screen reader rendering mode, or 0 to force it off. Same effect as --ax-screen-reader or "axScreenReader": true in user or managed settings (v2.1.208). Since v2.1.305 the key, and this variable in a settings env block, are ignored in project and local settings
CLAUDE_CLIENT_PRESENCE_FILEPoint at a marker file to suppress mobile push notifications while you're at the machine (v2.1.181+). Note: the name is CLAUDE_CLIENT_PRESENCE_FILE, not CLAUDE_CODE_CLIENT_PRESENCE_FILE.
CLAUDE_CODE_MAX_RETRIESMaximum number of API retry attempts. Capped at 15 as of v2.1.186.
CLAUDE_CODE_RETRY_WATCHDOGRetry control recommended for unattended sessions, as an alternative to raising CLAUDE_CODE_MAX_RETRIES (v2.1.186+).
CLAUDE_CODE_RETRY_WATCHDOG_MAX_WAIT_MSMaximum time in milliseconds that each API request spends waiting out 429 and 529 errors when CLAUDE_CODE_RETRY_WATCHDOG is set; once it's spent, the next such error ends the request. Positive whole number in plain digits (e.g. 1800000 for 30 minutes); unset means no limit (v2.1.295)
CLAUDE_CODE_RETRY_WATCHDOG_MAX_USAGE_LIMIT_WAIT_MSLongest usage-limit reset that unattended retry mode (CLAUDE_CODE_RETRY_WATCHDOG) waits for; a request at a limit that resets later ends instead of waiting (v2.1.301)
CLAUDE_CODE_RETRY_WATCHDOG_USAGE_LIMIT_RECHECK_MSMinimum interval between checks of whether a claude.ai usage limit was lifted early while CLAUDE_CODE_RETRY_WATCHDOG waits for its reset; plain digits from 60000 to 10800000. Unset means no checks (v2.1.305)
CLAUDE_CODE_OVERLOADED_RETRY_BASE_DELAY_MSStarting delay in milliseconds, in place of the default 500, of the exponential backoff between automatic retries of a request rejected with a 529 overloaded error. Whole milliseconds from 500 to 32000 in plain digits; no effect when CLAUDE_CODE_RETRY_WATCHDOG=1 or in fast mode (v2.1.292)
CLAUDE_ENABLE_STREAM_WATCHDOGStreaming idle watchdog (aborts/retries after 5 min with no stream events) is on by default for all providers; set to 0 to disable (v2.1.196).
CLAUDE_CODE_MCP_TOOL_IDLE_TIMEOUTOverride the 5-minute idle abort for remote MCP tool calls that hang with no response (v2.1.187+).
CLAUDE_CODE_OPUS_4_6_FAST_MODE_OVERRIDERemoved (no-op as of v2.1.160). Previously pinned Fast Mode (/fast) to Opus 4.6. /fast applies to Fable 5.2 (v2.1.321+), Opus 5.5 (default since v2.1.280), Opus 5, and Opus 4.8 only (Opus 4.8 fast mode is deprecated and removed on November 30, 2026, v2.1.316) — Opus 4.6 and Opus 4.7 are no longer fast-mode targets.
CLAUDE_CODE_MCP_STARTUP_WAIT_MSBounds how long the first non-interactive turn waits for MCP servers that are still connecting. Set 0 to not wait (v2.1.274), except that since v2.1.284 the first turn still waits up to 2 s for servers named by --allowedTools or an mcp_tool hook
MCP_PROTOCOL_NEGOTIATIONOn the v2 MCP client runtime only, whether Claude Code probes servers for MCP protocol revision 2026-07-28: auto probes HTTP, claude.ai connector, and stdio servers; legacy probes none. Any other value is ignored with a warning in the debug log (v2.1.221). With it unset, Claude Code can skip asking a stdio server for 7 days, for example after the server exits when asked (v2.1.318); set auto to have an upgraded server asked sooner.
CLAUDE_CODE_DISABLE_WEB_FETCHTurns off the WebFetch tool (v2.1.285)
CLAUDE_CODE_NONSTREAMING_TIMEOUT_RETRIESCaps how many times a timed-out non-streaming fallback request is re-sent (v2.1.285)
CLAUDE_CODE_WEBFETCH_DEADLINE_MSOverrides WebFetch's 300-second deadline, introduced in v2.1.268. Set 0 to disable the deadline (v2.1.268)
CLAUDE_CODE_WORKFLOW_MAX_CONCURRENT_AGENTSRaises the Workflow tool's per-run concurrent agent limit. Accepts 1–256 (v2.1.269)
CLAUDE_CODE_AUTO_MODE_SERVERSet to 0 to use Claude Code's own auto-mode classifier requests instead of server-side review — on Bedrock, Vertex, Foundry, and gateways since v2.1.278, and on a direct Anthropic API connection since v2.1.281 (there the local classifier then counts toward usage, and 1 opts in)
CLAUDE_CODE_AUTO_MODE_MODELFull model ID, such as claude-sonnet-4-6, for the client-side auto mode classifier, which otherwise uses Sonnet 5; does not change server-side auto mode's model. Ignored for Opus 5, Sonnet 5.5, Opus 5.5 or a model your organization's policy excludes (v2.1.302). Since v2.1.323 it also works in managed settings for Claude Desktop sessions on third-party providers, taking effect once Claude Desktop includes that version
CLAUDE_CODE_DISABLE_DANGEROUS_RM_TIMEOUTSet to 1 in the launching environment to change the critical-path rm prompt: in --dangerously-skip-permissions (bypassPermissions) mode the terminal prompt has no time limit and the VS Code chat panel asks you; in auto mode the classifier decides instead, in the terminal, the VS Code panel, -p runs and Agent SDK sessions. Without it, the terminal prompt denies the command after 2 minutes with a rewrite hint so unattended sessions keep going (v2.1.281)
CLAUDE_CODE_DISABLE_MOUNTED_DRIVE_RM_PROMPTSet to 1 in the launching environment (ignored in a settings env block) to turn off the prompt for a recursive rm of a mounted drive path such as /Volumes/USB or WSL's /mnt/c (v2.1.304)
CLAUDE_CODE_DISABLE_ULTRAREVIEW_TRUST_CHECKSet to 1 in the launching environment so claude ultrareview doesn't exit with Error: Workspace not trusted in a folder it can't ask about, such as in CI; use only where every run starts in a folder you trust (v2.1.309)
CLAUDE_CODE_DISABLE_FILE_MENTIONSSet to 1 to stop expanding @ mentions of files and directories; Claude gets the mentioned paths with a note to read them with its file tools. Ignored in project and local settings (v2.1.299)
CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENSContext size, in tokens, at which idle compaction applies (default 200000; values below 100000 are raised to 100000). Turn idle compaction off with "idleCompaction": false, or turn it off from the Idle compaction row in /config (v2.1.302). Added in v2.1.299; requires v2.1.290+
CLAUDE_CODE_GZIP_REQUEST_BODIESSet to 0 to turn off gzip compression of large API, telemetry, and artifact-publish request bodies sent to api.anthropic.com. Compression is skipped automatically behind a proxy, with a client certificate, or with NODE_EXTRA_CA_CERTS; use 0 if a TLS-inspecting proxy Claude Code can't detect mishandles compressed requests. Since v2.1.300 compression applies even when telemetry is disabled (v2.1.300)
CLAUDE_CODE_ARTIFACT_PUBLISH_EDITSSet to 0 to stop Claude from applying small changes to an artifact's file as part of publishing it; Claude then edits the file with its file tools and publishes as a separate step (v2.1.300)
CLAUDE_CODE_EVEN_MORE_DANGEROUSLY_SKIP_PERMISSIONSSet to 1 in the launching environment (ignored in a settings env block) to let critical-path rm/rmdir commands run with no prompt in bypassPermissions mode; no effect in plan mode, the VS Code panel, Desktop, or while a PermissionRequest hook or a Bash/Edit/Read ask or deny rule applies (v2.1.311)
CLAUDE_CODE_MODEL_CATALOGSet to off to stop Claude Code on Bedrock, Mantle, Vertex, and Foundry from loading model settings from a signed file on downloads.claude.ai (v2.1.311)
CLAUDE_CODE_DISABLE_ULTRATHINKSet to 1 to turn the ultrathink keyword off (v2.1.316)
CLAUDE_CODE_SUBAGENT_EFFORTEffort level subagents run at when nothing else names one, instead of inheriting the session's (v2.1.316). Since v2.1.317, a subagent on a different model from the main conversation uses that model's saved effort level or its default, instead of the session's effort level
CLAUDE_CODE_DISABLE_AGENT_PROGRESS_SUMMARIESSet to 1 to turn off subagent progress summaries and the requests that write them. Available since v2.1.318 and announced in the v2.1.323 changelog; the env-vars docs page doesn't list it yet
CLAUDE_CODE_RESUME_HINT_COMMANDA program that starts Claude Code can set it so the exit hint names that program's own resume command (v2.1.323; changelog-sourced, the env-vars docs page doesn't list it yet)
CLAUDE_CODE_ENABLE_TODO_TOOLSSet to 1 to restore the todo/task-tracking tools (TaskCreate/Get/Update/List, TodoWrite), which are available by default only on Claude 3.x models, Opus 4 through 4.7, Sonnet 4 through 4.6, and Haiku 4.5 (v2.1.268)
CLAUDE_CODE_WEBFETCH_CACHE_TTL_MSHow long WebFetch caches a fetched URL. Default 15 minutes (v2.1.233)
CLAUDE_CODE_TOOL_MEMORY_LIMITLinux only: opt in to a memory cgroup applied to Bash commands (v2.1.233)
ANTHROPIC_BEDROCK_REGION_PREFIXPrefer a specific Bedrock cross-region inference profile (v2.1.224)
CLAUDE_CODE_DISABLE_UNKNOWN_MODEL_WINDOW_ENFORCEMENTSet to 1 to restore pre-v2.1.223 auto-compact behavior on unrecognized model IDs (v2.1.223)
CLAUDE_CODE_MAX_CONTEXT_TOKENSOverride the context window size, in tokens, that Claude Code assumes for the active model, such as 400000 for a gateway or custom model ID. For an ID it doesn't recognize and that has no [1m], the value applies on its own; that includes IDs starting with claude-, such as a gateway's claude-sonnet-latest, since v2.1.324 per the model configuration docs (the changelog lists it in v2.1.325). For an unrecognized ID with [1m], a value under 1M also needs CLAUDE_CODE_DISABLE_1M_CONTEXT=1; for an ID it recognizes, the value applies only with DISABLE_COMPACT, which turns off all compaction
CLAUDE_CODE_WORKFLOW_PREFIX_STAGGER_MSSet to 0 to disable prefix staggering on dynamic-workflow fan-out (v2.1.229)
CLAUDE_CODE_USER_DIALOG_TIMEOUT_MSOverrides the dialogExpiry setting (v2.1.224)
CLAUDE_CODE_PROJECT_DIR_NAMEOverrides the per-project transcript directory name Claude Code derives from the project path (v2.1.234)

These eight rows are changelog-sourced. The CLI reference page has no dedicated environment-variable section, so they are documented from the v2.1.221–v2.1.234 changelog entries rather than a reference page.

CLAUDE_CODE_DISABLE_1M_CONTEXT widened in v2.1.223: it now holds every Claude model with a native 1M-token window to 200K via auto-compaction, not just a fixed list of model IDs.

ENABLE_TOOL_SEARCH on Agent Platform (Vertex AI) and gateways: Before v2.1.221, tool search was off on Google Cloud's Agent Platform unless you set ENABLE_TOOL_SEARCH=true; it is now on there for Claude Opus 4.5, Sonnet 4.5, Haiku 4.5 and later models (earlier models load all MCP tools upfront, and true doesn't change that). Tool search is on by default, including behind a custom ANTHROPIC_BASE_URL gateway since v2.1.304 (since v2.1.305 a gateway that rejects it with a 400 or 422 is retried without it); set ENABLE_TOOL_SEARCH=false to load every tool upfront.

OpenTelemetry variables in project settings (v2.1.282): project and local settings ignore OpenTelemetry variables that turn on export, set its endpoint, or capture content, such as CLAUDE_CODE_ENABLE_TELEMETRY and OTEL_LOG_*.


Settings.json Keys ​

These keys live in a settings.json file (~/.claude/settings.json for user scope, .claude/settings.json for project scope) rather than being passed as flags or env vars. The table below covers a few recently added UI/UX keys; for the managed enforceAvailableModels key, see Advanced Features → Managed Settings.

KeyDescription
respondToBashCommands(v2.1.186) Auto-respond to the output of ! bash commands. Default true. Set false for context-only (pre-v2.1.186) behavior. See Advanced Features → Bash Mode.
wheelScrollAccelerationEnabled(v2.1.174) Set to false to disable mouse-wheel scroll acceleration in the fullscreen renderer. Useful when fast wheel flicks overshoot.
footerLinksRegexes(v2.1.176) Array of regexes that render matched links as badges in the footer row. Configurable in user or managed settings.
languageSets Claude's preferred response language and voice-dictation language (e.g. "french", "japanese"). As of v2.1.176 it also pins the language used for auto-generated session titles.
sandbox.filesystem.disabled(v2.1.216) Skips filesystem sandboxing while keeping network egress control enforced. For workflows where file sandboxing breaks tooling but network policy must stay enforced.
emojiCompletionEnabled(v2.1.217) Enables emoji shortcode autocomplete in the prompt input (e.g. typing :heart: inserts ❤️). Set false to disable.
workflowSizeGuideline(v2.1.219) Sets the advisory Dynamic workflow size guideline from any settings file. The guideline is guidance Claude aims for, not a hard cap — the default is medium (aim for fewer than 10 agents), or small when signed in on a Pro plan (v2.1.271+), and other sizes or unrestricted can be selected. While this key is set, the "Dynamic workflow size" row is hidden in /config. Distinct from CLAUDE_CODE_MAX_CONCURRENT_SUBAGENTS, which is an enforced concurrency limit.
spellcheck(v2.1.235) Underlines misspelled words in the prompt input using whichever of aspell, hunspell, or ispell is on your PATH, tried in that order. Object-valued — {"enabled": true, "language": "en_GB"} — and off by default. Read from user settings, the --settings flag, and managed settings only: a spellcheck block in a project .claude/settings.json or .claude/settings.local.json is ignored. See also Advanced Features → Additional Per-User Settings.
modelPicker(v2.1.243) Choose which models the /model picker lists, in your own order and with your own labels. One of the few settings that replaces rather than merges across settings layers.
promptCacheTtl(v2.1.243) Choose the prompt cache lifetime for the main conversation.
subagentPromptCacheTtl(v2.1.243) The same choice for subagents and other requests outside the main conversation.
modelPricing(v2.1.243) Managed setting. Supplies your organization's contracted rates so /cost, the status line, and telemetry report those instead of list price.
availableModelsMatch(v2.1.283) Managed setting. With "exact", an availableModels entry allows only the model version it names, so new releases stay blocked until listed.
deniedModels(v2.1.283) Managed setting. Blocks specific models, even when availableModels allows them.
keybindingFlavorDeprecated since v2.1.261 and has no effect. The prompt's word-editing keys always follow readline conventions, as Bash does: Ctrl+W deletes back to whitespace, Alt+F and Alt+D stop at word end, and punctuation separates words. Claude Code still accepts the key, so a settings file that sets it stays valid. (In v2.1.238–v2.1.260 it chose between "classic" and "readline".)
bashOutputMaxChars(v2.1.261) How many characters of a successful Bash or PowerShell command's output Claude receives inline, up to 128K. Past the limit Claude Code saves the output to a file and Claude gets a short preview plus the path. Setting it makes Claude Code ignore BASH_MAX_OUTPUT_LENGTH.
taskOutputMaxChars(v2.1.261) Superseded in v2.1.278 and has no effect. It used to cap how many characters of a background task's output Claude received inline when reading it with the TaskOutput tool. v2.1.278 removed the TaskOutput tool — Claude now reads a background task's output file with Read — so this key and TASK_MAX_OUTPUT_LENGTH are both inert. Claude Code still accepts the key, so a settings file that sets it stays valid.
maxEffortLevel(v2.1.267) Caps the effort level Claude Code may use, on every provider including Bedrock, Vertex, and Foundry. Set it top-level or per-model under modelSettings. Users can still pick a lower level.
bashEditDiffEnabled(v2.1.269) Bash tool results include a diff of the files the command changed.
syncClaudeAiSkills / syncClaudeAiPlugins(v2.1.275) Set either to false to opt out of syncing the skills or plugins you have enabled on your claude.ai account into terminal sessions.
attribution(v2.1.281) Set "attribution": false to hide all commit and PR attribution. Older CLI versions skip a settings file that holds it, so keep the object form in files shared across versions.
maxProseWidth(v2.1.282) Caps the width of Claude's prose in wide terminals; tables and code blocks keep the full width.
idleCompaction(v2.1.290) Compacts a long conversation you've stepped away from shortly before its prompt cache expires, so your next message sends a summary instead of the whole conversation. On by default in interactive terminal sessions on the one-hour cache TTL once context reaches 200K tokens (CLAUDE_CODE_IDLE_COMPACT_MIN_TOKENS) and about an hour has passed. Since v2.1.314 it also runs in the VS Code chat panel and the Desktop app's Code tab (local or SSH sessions), for subscribers with telemetry off, and on Bedrock, Vertex, Foundry, and LLM gateways once the one-hour prompt cache is on. Set false to turn it off, or turn it off from the Idle compaction row in /config (v2.1.302); DISABLE_AUTO_COMPACT also turns it off.
permissions.denyInsteadOfPrompting(v2.1.319) true denies a tool call that would otherwise wait on a permission prompt, and the turn continues; calls an allow rule, your permission mode or auto mode approves still run. User or managed settings, or --settings — a repository can't set it
json
{
  "wheelScrollAccelerationEnabled": false,
  "language": "french",
  "footerLinksRegexes": ["https://jira\\.example\\.com/.*"]
}

Quick Reference ​

Most Common Commands ​

bash
# Interactive session
claude

# Quick question
claude -p "how do I..."

# Continue conversation
claude -c

# Process a file
cat file.py | claude -p "review this"

# JSON output for scripts
claude -p --output-format json "query"

Flag Combinations ​

Use CaseCommand
Quick code reviewcat file | claude -p "review"
Structured outputclaude -p --output-format json "query"
Safe explorationclaude --permission-mode plan
Autonomous with safetyclaude --permission-mode auto
CI/CD integrationclaude -p --max-turns 3 --output-format json
Resume workclaude -r "session-name"
Custom modelclaude --model opus "complex task"
Minimal modeclaude --bare "quick query"
Budget-capped runclaude -p --max-budget-usd 2.00 "analyze code"

Troubleshooting ​

Command Not Found ​

Problem: claude: command not found

Solutions:

  • Install Claude Code: curl -fsSL https://claude.ai/install.sh | bash (native, recommended) or npm install -g @anthropic-ai/claude-code
  • Check PATH includes ~/.local/bin (native install) or npm's global bin directory
  • Run claude doctor

API Key Issues ​

Problem: Authentication failed

Solutions:

  • Set API key: export ANTHROPIC_API_KEY=your-key
  • Check key is valid and has sufficient credits
  • Verify key permissions for the model requested

Session Not Found ​

Problem: Cannot resume session

Solutions:

  • List available sessions to find correct name/ID
  • Sessions may expire after period of inactivity
  • Use -c to continue most recent session

Output Format Issues ​

Problem: JSON output is malformed

Solutions:

  • Use --json-schema to enforce structure
  • Add explicit JSON instructions in prompt
  • Use --output-format json (not just asking for JSON in prompt)

Permission Denied ​

Problem: Tool execution blocked

Solutions:

  • Check --permission-mode setting
  • Since v2.1.302, a claude -p or Agent SDK run with no permission mode set starts in Manual mode (config value default) and denies tool calls that need approval; pass --permission-mode (for example auto or acceptEdits) or --allowedTools.
  • Review --allowedTools and --disallowedTools flags
  • Use --dangerously-skip-permissions for automation (with caution)

Additional Resources ​


Part of the Claude How To guide series


Last Updated: November 14, 2026 Claude Code Version: 2.1.325 Sources: