πŸš€ Claude Code 2.1.83

Complete CLI Reference & Environment Variables Cheatsheet

Last Updated: March 25, 2026 | Version 2.1.83

πŸ“– About This Guide

This comprehensive cheatsheet covers every environment variable, CLI flag, slash command, hook event, variable substitution, and setting in Claude Code v2.1.83. Verified against official Anthropic documentation and the anthropics/claude-code CHANGELOG.

Use Ctrl+F (Cmd+F on Mac) to search for any variable, flag, or command.

Quick Start Commands

🎯 Most Used

CommandDescriptionExample
claudeStart interactive REPL sessionclaude
claude "query"Start session with initial promptclaude "explain this function"
claude -p "query"Non-interactive print mode (query and exit)claude -p "review this code"
claude -cContinue most recent conversationclaude -c
claude --continueLong form of -cclaude --continue
claude -r "id" "query"Resume a specific session by IDclaude -r "abc123" "finish the task"
claude --resumeResume last session interactivelyclaude --resume
claude -vShow installed version numberclaude -v
cat file | claude -p "q"Process piped stdincat error.log | claude -p "diagnose"
claude updateUpdate to latest versionclaude update
claude install --forceForce reinstall (bypasses stale locks)claude install --force
claude auth loginAuthenticate with Anthropic accountclaude auth login
claude auth login --consoleAuth via API Console / billing accountclaude auth login --console
claude auth statusCheck current authentication statusclaude auth status
$ claude -p "list all TODO comments in this project" $ cat error.log | claude -p "what caused this?" $ claude --continue "complete the implementation"

πŸ“Ÿ CLI Subcommands

CommandDescriptionExample
claude auth loginAuthenticate via claude.ai subscriptionclaude auth login
claude auth login --consoleAuthenticate via API Console/billing accountclaude auth login --console
claude auth statusCheck current authentication statusclaude auth status
claude auth logoutSign out of current accountclaude auth logout
claude updateUpdate to latest versionclaude update
claude install --forceForce reinstall, bypasses stale lock filesclaude install --force
claude agents NEWList all configured agents for the current projectclaude agents
claude remote-control NEWStart the remote control server as a standalone daemonclaude remote-control
claude mcp NEWMCP management subcommands: add, remove, list, enable, disable, authclaude mcp list
claude mcp add <name> <cmd>Add a new MCP server to config (stdio transport)claude mcp add myserver node server.js
claude mcp add --transport sse <url>Add an SSE-based MCP serverclaude mcp add --transport sse https://mcp.example.com
claude mcp remove <name>Remove a named MCP server from configclaude mcp remove myserver
claude mcp auth <name>Manually trigger OAuth flow for a named MCP serverclaude mcp auth myserver

CLI Flags (Launch-Time)

βš™οΈ Configuration

Passed when launching Claude Code to customize session behavior.

πŸ“‚ Working Directory & Scope

FlagDescriptionExample
--add-dirAdd additional working directories (validates paths exist)claude --add-dir ../apps ../lib
-w, --worktreeLaunch in isolated git worktree (loads skills/hooks from worktree dir)claude --worktree
--fork-sessionCreate new session ID when resuming (parallel work branches)claude --fork-session

πŸ€– Model & Agents

FlagDescriptionExample
--modelSet model (aliases: sonnet, opus, haiku β€” or full model ID)claude --model claude-opus-4-6
--agentSpecify a named agent for the sessionclaude --agent general-purpose
--teammate-modeSet team display: auto | in-process | tmuxclaude --teammate-mode in-process
--agentsDefine custom subagents inline via JSON arrayclaude --agents '[{"name":"explorer"}]'
--effortSet thinking effort: low | medium | high | max | autoclaude --effort high

πŸ” Permissions & Security

FlagDescriptionExample
--permission-modeStart in a specific mode (e.g., plan)claude --permission-mode plan
--enable-auto-mode NEW 2.1.82Enable auto mode (research preview) β€” Claude auto-approves low-risk actions via Sonnet 4.6 classifier. Middle ground between default and --dangerously-skip-permissions. Disable organisation-wide with managed setting disableAutoModeclaude --enable-auto-mode
--dangerously-skip-permissionsSkip all permission prompts ⚠️ β€” use only in devcontainer with firewallclaude --dangerously-skip-permissions
--allow-dangerously-skip-permissionsAllow the skip-permissions option without activating itclaude --permission-mode plan --allow-dangerously-skip-permissions
--toolsRestrict built-in tools (works in interactive AND -p mode)claude --tools "Bash,Edit,Read"
--allowedToolsTools that run without prompting for permissionclaude --allowedTools "Write" "Bash(git *)"
--disallowedToolsTools removed from context entirely; cannot be usedclaude --disallowedTools "Bash(rm *)"
--permission-prompt-toolMCP tool to handle permission prompts in -p (non-interactive) modeclaude -p --permission-prompt-tool mcp_auth_tool "q"

πŸ’Ύ System Prompt Customization

FlagDescriptionExample
--system-promptReplace entire system prompt with custom textclaude --system-prompt "You are a Python expert"
--system-prompt-fileLoad system prompt replacement from file (mutually exclusive with --system-prompt)claude --system-prompt-file ./prompts/custom.txt
--append-system-promptAppend text to the default system prompt (preserves built-in capabilities)claude --append-system-prompt "Always use TypeScript"
--append-system-prompt-fileAppend file contents to the default system promptclaude --append-system-prompt-file ./style-rules.txt
πŸ’‘ Tip: All four system prompt flags work in both interactive and -p modes. Append flags preserve built-in capabilities β€” prefer them over replacement flags unless you need full control.

πŸ“€ Output & Input Formats

FlagDescriptionExample
--output-formattext | json | stream-jsonclaude -p --output-format json "query"
--input-formatSet input format (e.g., stream-json for piped input)claude -p --input-format stream-json
--include-partial-messagesInclude partial streaming events in outputclaude -p --output-format stream-json --include-partial-messages "q"
--json-schemaReturn validated JSON matching a specific schemaclaude -p --json-schema '{"type":"object"}' "query"

πŸ”Œ MCP & Plugins

FlagDescriptionExample
--mcp-configLoad MCP server definitions from a JSON fileclaude --mcp-config ./mcp.json
--strict-mcp-configOnly use servers from --mcp-config; ignore all othersclaude --strict-mcp-config --mcp-config ./mcp.json
--plugin-dirLoad plugins from directory for this session (flag is repeatable)claude --plugin-dir ./plugins --plugin-dir ./more

πŸ”— Web, Remote & Browser

FlagDescriptionExample
--remoteCreate a new web session on claude.aiclaude --remote
--remote-controlBridge terminal session to claude.ai for browser/phone controlclaude --remote-control
--rcAlias for --remote-controlclaude --rc
--teleportResume a web/iOS running session in your local terminalclaude --teleport
--chromeEnable Claude in Chrome browser integration (claude.ai/chrome extension)claude --chrome
--no-chromeDisable Chrome integrationclaude --no-chrome
--channels NEWAllow MCP servers to push messages into your active session (research preview β€” server must declare claude/channel capability)claude --channels

πŸŽ›οΈ Debugging & Logging

FlagDescriptionExample
--debugEnable debug mode with optional category filterclaude --debug "api,mcp"
--verboseVerbose logging β€” full turn-by-turn outputclaude --verbose
--mcp-debugDetailed MCP server error informationclaude --mcp-debug

βš™οΈ Session & Configuration

FlagDescriptionExample
-n, --nameSet a display name for the sessionclaude -n "Feature Implementation"
--max-budget-usdSpending cap for API calls (-p mode only)claude -p --max-budget-usd 10 "query"
--max-turnsLimit agentic turns (-p mode only)claude -p --max-turns 3 "query"
--settingsLoad settings from JSON file or inline JSON stringclaude --settings ./settings.json
--setting-sourcesComma-separated sources: user, project, localclaude --setting-sources user,project
--init-onlyRun initialization hooks then exit without a sessionclaude --init-only
--from-pr NEWResume or create a session linked to a GitHub PR URLclaude --from-pr https://github.com/org/repo/pull/42
--maintenance NEWTrigger maintenance/setup hooks and then exit (useful in CI for pre-flight setup)claude --maintenance

πŸ”§ Miscellaneous CLI Flags

FlagDescriptionExample
--betasBeta headers for API requests (API key users only)claude --betas interleaved-thinking
--disable-slash-commandsDisable all slash commands / skills for this sessionclaude --disable-slash-commands
--sandbox NEWLaunch in an isolated sandbox environment with Tab key tab-switchingclaude --sandbox
--bare NEW 2.1.81Scripted -p mode: skips hooks, LSP, plugin sync, and skill directory walks. Requires ANTHROPIC_API_KEY or apiKeyHelper via --settings (OAuth/keychain auth disabled). Auto-memory fully disabled.claude -p --bare "query"

Complete Environment Variables Reference

🌍 All Variables

πŸ”‘ Authentication & API

VariablePurposeExample Value
ANTHROPIC_API_KEYPrimary API key; overrides subscription loginsk-ant-xxx...
ANTHROPIC_AUTH_TOKENCustom Authorization header value (Bearer prefix auto-added)your-token
ANTHROPIC_BETASComma-separated Anthropic beta headers sent with every request (env alternative to --betas flag; applies to all model tiers including Haiku)interleaved-thinking-2025-05-14
ANTHROPIC_BASE_URLRoute requests via proxy or custom gatewayhttps://api.example.com
ANTHROPIC_CUSTOM_HEADERSNewline-separated custom HTTP headers (Name: Value)X-Custom: value
ANTHROPIC_FOUNDRY_API_KEYAPI key for Microsoft Azure Foundryxxx...
ANTHROPIC_FOUNDRY_BASE_URLFull base URL for Azure Foundry resourcehttps://foundry.azure.com
ANTHROPIC_FOUNDRY_RESOURCEAzure Foundry resource namemy-resource
ANTHROPIC_FOUNDRY_DEPLOYMENT NEWAzure Foundry deployment name (separate from resource name)my-deployment
CLAUDE_CODE_CLIENT_CERTPath to client certificate for mTLS/path/to/cert.pem
CLAUDE_CODE_CLIENT_KEYPath to private key for mTLS/path/to/key.pem
CLAUDE_CODE_CLIENT_KEY_PASSPHRASEPassphrase for encrypted mTLS client keyyour-passphrase
AWS_BEARER_TOKEN_BEDROCKBedrock API key / bearer token for authenticationxxx...

☁️ Cloud Provider Configuration

VariablePurposeValue/Notes
CLAUDE_CODE_USE_BEDROCKRoute through AWS Bedrock1 or true
CLAUDE_CODE_USE_VERTEXRoute through Google Vertex AI1 or true
CLAUDE_CODE_USE_FOUNDRYRoute through Microsoft Azure Foundry1 or true
CLAUDE_CODE_SKIP_BEDROCK_AUTHSkip AWS credential check (e.g., when using an LLM gateway)1
CLAUDE_CODE_SKIP_VERTEX_AUTHSkip Google Cloud credential check1
CLAUDE_CODE_SKIP_FOUNDRY_AUTHSkip Azure credential check1
ANTHROPIC_BEDROCK_BASE_URLProxy URL for Bedrock requests (overrides default Bedrock endpoint)https://your-proxy-url
ANTHROPIC_VERTEX_BASE_URLProxy URL for Vertex AI requestshttps://your-proxy-url
CLOUD_ML_REGIONGoogle Cloud region for Vertex AIus-east5
ANTHROPIC_VERTEX_PROJECT_IDGoogle Cloud project ID for Vertex AImy-project-id
ANTHROPIC_SMALL_FAST_MODEL_AWS_REGIONOverride AWS region for Haiku model on Bedrockus-west-2
VERTEX_REGION_CLAUDE_3_5_HAIKUOverride Vertex AI region for Haiku modelus-central1

πŸ€– Model Configuration

VariablePurposeValues/Examples
ANTHROPIC_MODELOverride default model for all requestsclaude-opus-4-6, claude-sonnet-4-6
ANTHROPIC_DEFAULT_SONNET_MODELFull model ID the sonnet alias resolves toclaude-sonnet-4-6
ANTHROPIC_DEFAULT_HAIKU_MODELFull model ID the haiku alias resolves toclaude-haiku-4-5-20251001
ANTHROPIC_DEFAULT_OPUS_MODELFull model ID the opus alias resolves toclaude-opus-4-6
ANTHROPIC_SMALL_FAST_MODELDEPRECATED Haiku-class model for background tasks β€” use specific varsUse ANTHROPIC_DEFAULT_HAIKU_MODEL
CLAUDE_CODE_SUBAGENT_MODELModel used specifically for subagentsclaude-sonnet-4-6
CLAUDE_CODE_EFFORT_LEVELDefault thinking effort (Opus 4.6 and Sonnet 4.6 only). Default for Max/Team is now medium as of March 2026low | medium | high | max | auto
CLAUDE_CODE_DISABLE_ADAPTIVE_THINKINGDisable adaptive reasoning; revert to fixed MAX_THINKING_TOKENS budget1
MAX_THINKING_TOKENSOverride extended thinking token budget; 0 disables thinking10000 or 0
CLAUDE_CODE_MAX_OUTPUT_TOKENSOverride max output tokens per request (Opus 4.6 default is 64K, upper bound 128K)4096
CLAUDE_CODE_DISABLE_1M_CONTEXTDisable 1M context window; removes 1M variants from /model picker1
ANTHROPIC_CUSTOM_MODEL_OPTIONAdds custom entry at bottom of /model picker (skips ID validation)my-gateway/claude-opus-4-6
ANTHROPIC_CUSTOM_MODEL_OPTION_NAMEDisplay name for the custom model picker entry (optional)Opus via Gateway
ANTHROPIC_CUSTOM_MODEL_OPTION_DESCRIPTIONDisplay description for the custom model picker entry (optional)Custom optimized model

πŸ§‘β€πŸ€β€πŸ§‘ Agent Teams (Experimental)

πŸ§ͺ Experimental Features

Enables parallel AI agent workflows. Disabled by default.

VariablePurposeValue/Notes
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMSEnable agent teams feature1 or true
CLAUDE_CODE_TEAM_NAMEName of the agent team β€” auto-set by Claude Code for teammatesmy-team
CLAUDE_CODE_PLAN_MODE_REQUIREDAuto-set on teammates requiring plan approval (read-only)true (auto-managed)
πŸ“Œ Enable Teams:
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 claude --teammate-mode in-process

πŸ”§ Bash & Shell Behavior

VariablePurposeDefault / Examples
BASH_DEFAULT_TIMEOUT_MSDefault timeout for long-running bash commands30000 ms
BASH_MAX_TIMEOUT_MSMax timeout the model can request for a bash command300000 ms
BASH_MAX_OUTPUT_LENGTHMax characters in bash output before middle-truncation500000
CLAUDE_BASH_MAINTAIN_PROJECT_WORKING_DIRReturn to original working dir after each Bash command1
CLAUDE_CODE_SHELLOverride automatic shell detectionbash | zsh | sh
CLAUDE_CODE_SHELL_PREFIXCommand prefix wrapping all bash commands (logging / auditing)time or strace
CLAUDE_ENV_FILEShell script sourced before each Bash command (activate virtualenv, load .env, etc.)venv/bin/activate
CLAUDECODEAuto-set to 1 inside Claude Code-spawned shells β€” use to detect context in scripts1 (auto-set)

🧠 Memory, Context & Compaction

VariablePurposeValues / Defaults
CLAUDE_CODE_DISABLE_AUTO_MEMORYDisable automatic memory creation and loading1
CLAUDE_AUTOCOMPACT_PCT_OVERRIDEContext fill % at which auto-compaction triggers95 (default)
CLAUDE_CODE_AUTO_COMPACT_WINDOWToken capacity used for auto-compaction calculationsAuto-calculated
CLAUDE_CODE_ADDITIONAL_DIRECTORIES_CLAUDE_MDAlso load CLAUDE.md from --add-dir directories1
CLAUDE_CODE_FILE_READ_MAX_OUTPUT_TOKENSOverride default token limit for file read operationsModel default

πŸ”Œ MCP (Model Context Protocol)

VariablePurposeValues / Examples
MCP_TIMEOUTTimeout (ms) for MCP server startup30000 ms
MCP_TOOL_TIMEOUTTimeout (ms) for individual MCP tool call execution60000 ms
MAX_MCP_OUTPUT_TOKENSMax tokens in MCP tool responses (warning shown above 10K by default)50000
ENABLE_CLAUDEAI_MCP_SERVERSControl claude.ai-managed MCP servers; set false to disablefalse to disable
ENABLE_TOOL_SEARCHMCP tool search mode. Auto-mode is now the default since v2.1.80; defers tools that exceed 10% of contexttrue | auto | auto:N | false
MCP_CLIENT_SECRETOAuth 2.0 client secret for MCP server auth (stored in keychain, not config file)your-secret
MCP_OAUTH_CALLBACK_PORTFixed port for OAuth callback URI (use when server has pre-registered redirect URIs)8888

πŸ“‹ Tasks, Sessions & Scheduling

VariablePurposeValues
CLAUDE_CODE_ENABLE_TASKSEnable task tracking in non-interactive (-p) modetrue
CLAUDE_CODE_TASK_LIST_IDShare a task list across multiple Claude Code instancestask-id-123
CLAUDE_CODE_DISABLE_CRONDisable scheduled cron jobs and /loop immediately1
CLAUDE_CODE_DISABLE_BACKGROUND_TASKSDisable background task execution and Ctrl+B shortcut1
CLAUDE_CODE_EXIT_AFTER_STOP_DELAYAuto-exit after N ms of idle in SDK/print mode5000 ms
CLAUDE_CODE_SESSIONEND_HOOKS_TIMEOUT_MSMax time (ms) for SessionEnd hooks to complete1500 ms

πŸ“¦ Plugins & Updates

VariablePurposeValues
DISABLE_AUTOUPDATERDisable automatic background updates1
FORCE_AUTOUPDATE_PLUGINSForce plugin auto-updates even when autoupdater is disabled1
CLAUDE_CODE_PLUGIN_GIT_TIMEOUT_MSTimeout (ms) for git ops during plugin install/update120000 (default)
CLAUDE_CODE_PLUGIN_SEED_DIRRead-only plugin seed directory paths for container images (: on Unix, ; on Windows)/path/to/plugins

🚫 Disabling Features

VariablePurposeValue
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFICDisables autoupdater, feedback, error reporting, and telemetry β€” all at once1
DISABLE_TELEMETRYOpt out of Statsig analytics/telemetry1
DISABLE_ERROR_REPORTINGOpt out of Sentry crash/error reporting1
DISABLE_FEEDBACK_COMMANDDisable the /feedback slash command1
DISABLE_BUG_COMMANDAlias for DISABLE_FEEDBACK_COMMAND1
DISABLE_COST_WARNINGSDisable cost warning messages during sessions1
DISABLE_INSTALLATION_CHECKSSuppress installation health warnings at startup1
DISABLE_PROMPT_CACHINGDisable prompt caching globally across all model tiers1
DISABLE_PROMPT_CACHING_HAIKUDisable prompt caching for Haiku tier only1
DISABLE_PROMPT_CACHING_SONNETDisable prompt caching for Sonnet tier only1
DISABLE_PROMPT_CACHING_OPUSDisable prompt caching for Opus tier only1
CLAUDE_CODE_DISABLE_FAST_MODEDisable fast mode globally1
CLAUDE_CODE_DISABLE_TERMINAL_TITLEDisable automatic terminal title/tab updates1
CLAUDE_CODE_DISABLE_GIT_INSTRUCTIONSRemove built-in git/commit instructions from system prompt1
CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETASStrip anthropic-beta headers (for proxies that reject unknown headers)1
CLAUDE_CODE_DISABLE_FEEDBACK_SURVEYDisable "How is Claude doing?" end-of-session surveys1
CLAUDE_CODE_SUBPROCESS_ENV_SCRUB NEW 2.1.83Strip all Anthropic and cloud-provider credentials from subprocess/child-process environments (prevents credential leakage into spawned shells)1

🌐 Network & Proxy

VariablePurposeExample Value
HTTP_PROXYHTTP proxy server URLhttp://proxy.example.com:8080
HTTPS_PROXYHTTPS proxy server URLhttps://proxy.example.com:8080
NO_PROXYComma-separated domains/IPs to bypass proxylocalhost,127.0.0.1,.internal.com
CLAUDE_CODE_PROXY_RESOLVES_HOSTSLet the proxy handle DNS resolution instead of the client1
CLAUDE_CODE_SKIP_FAST_MODE_NETWORK_ERRORSAllow fast mode even when org status check fails due to network error1

βš™οΈ Miscellaneous / Advanced

VariablePurposeExample Value
CLAUDE_CONFIG_DIROverride default config/data directory (default: ~/.claude)~/.my-claude-config
CLAUDE_CODE_TMPDIROverride internal temp directory (Claude Code appends /claude/ to the path)/tmp/my-claude
CLAUDE_CODE_SIMPLEMinimal mode: Bash + file tools only, no MCP/hooks/CLAUDE.md loading1
CLAUDE_CODE_NEW_INITEnable interactive /init onboarding flowtrue
CLAUDE_CODE_ENABLE_PROMPT_SUGGESTIONShow/hide grayed-out prompt suggestions; set false to hidefalse
CLAUDE_CODE_ENABLE_TELEMETRYEnable OpenTelemetry data collection for enterprise monitoring1
CLAUDE_CODE_OTEL_HEADERS_HELPER_DEBOUNCE_MSInterval (ms) for refreshing dynamic OTel authentication headers1740000 (29 min)
CLAUDE_CODE_API_KEY_HELPER_TTL_MSCredentials refresh interval for apiKeyHelper scriptsAuto-managed
SLASH_COMMAND_TOOL_CHAR_BUDGETOverride character budget for slash command / skill metadata loading5000
USE_BUILTIN_RIPGREPBundled ripgrep is used by default; set 0 to use system ripgrep instead0 to use system
IS_DEMODemo mode: hides email/org, skips onboarding1
CLAUDE_CODE_HIDE_ACCOUNT_INFO NEWHide email and organization from the UI (useful for streaming/recording sessions)1
CLAUDE_CODE_ACCOUNT_UUIDSDK callers provide account UUID synchronously at startupUUID format
CLAUDE_CODE_USER_EMAILUser email for SDK / headless modeuser@example.com
CLAUDE_CODE_ORGANIZATION_UUIDOrganization UUID for SDK / headless modeUUID format
CLAUDE_CODE_ENABLE_REMOTE_CONTROL_SERVER NEWEnable remote control server for IDE/web session bridging1

⚑ Slash Commands (In-Session)

πŸ’¬ Interactive Mode Only

Type / anywhere in the prompt β€” not just at the start β€” to trigger autocomplete. Custom commands in .claude/commands/ appear namespaced by subdirectory (e.g. /frontend:component).

/help

Show all commands including custom skills and MCP server commands

/clear

Clear conversation history and free context. Aliases: /reset, /new

/exit

Exit Claude Code. Alias: /quit

/rename [name]

Rename the current session title

/status

Show version, model, account, and connectivity status

/release-notes

View the latest release notes at any time

/model [model]

Select or change AI model. Use arrow keys to adjust effort when a supported model is active

/effort [level]

Set effort: low | medium | high | max | auto. Shows what auto currently resolves to

/fast [on|off]

Toggle fast mode (speed-optimized Opus 4.6). Note: prior context is re-billed at fast rates when toggled mid-session

/context

Visualize context usage with optimization suggestions. Skills shown as a separate category

/compact [focus]

Compact conversation, optionally retaining focus (e.g., /compact retain the error handling patterns). Use when context > ~80%

/memory

Edit CLAUDE.md, manage auto-memory, view and edit all imported memory files

/init

Initialize project with an interactive CLAUDE.md guide

/add-dir <path>

Add a new working directory to the current session

/config

Open the tabbed Settings interface. Alias: /settings

/permissions

View/update tool permissions. Press / inside to filter. Alias: /allowed-tools

/keybindings

Create or edit ~/.claude/keybindings.json. Changes take effect immediately

/vim

Enable Vim key bindings for prompt input (also configurable in /config)

/plan [description]

Enter plan mode. Pass a description to start immediately (e.g., /plan fix the auth bug)

/output-style [style] DEPRECATED

Deprecated in v2.1.81 β€” use /config instead. Output style is now fixed at session start for better prompt caching.

/loop [interval] [prompt]

Run a prompt or command on a recurring interval (e.g., /loop 5m check deploy status)

/branch [name]

Fork the current conversation to explore a different path. Alias: /fork

/export [filename]

Export the full conversation as plain text

/copy [N]

Copy last assistant response to clipboard. Press w to write to file instead (useful over SSH)

/btw <question>

Ask a side question without adding it to the main conversation context

/diff

Open the interactive diff viewer for uncommitted changes

/mcp

Manage MCP server connections and OAuth authentication

/plugin

Install, update, and remove Claude Code plugins

/doctor

Diagnose Claude Code installation; validates permission rule syntax and suggests fixes

/debug

Ask Claude to help troubleshoot the current session directly

/stats

Visualize daily usage, session history, and model preferences

/login

Sign in to your Anthropic account (subscription or API Console)

/logout

Sign out from your current account

/feedback

Submit feedback about Claude Code. Alias: /bug

/tasks

List and manage foreground and background tasks. Alias: /bashes

/hooks

View hook configurations for PreToolUse, PostToolUse, and Stop events

/ide

Manage VS Code / JetBrains integrations and show connection status

/color [color]

Set prompt bar color: red, blue, green, yellow, purple, orange, pink, cyan, default

/theme

Open theme selector to change Claude Code's terminal color theme

/remote-control NEW

Bridge terminal session to claude.ai/code β€” control from any browser or phone

/teleport NEW

Pull a running web/iOS session into your local terminal

/remote-env NEW

Configure environment for remote sessions (claude.ai subscribers)

/desktop NEW

Hand off terminal session to the Desktop app for visual diff review

/sandbox NEW

Launch isolated sandbox environment. Tab / arrow keys switch between tabs

/voice NEW

Toggle voice mode on or off

/terminal NEW

Open an integrated terminal pane within the session

/simplify NEW

Ask Claude to simplify or shorten its last response (built-in bundled command)

/batch <commands> NEW

Run multiple slash commands in a single turn (bundled command)

/reload-plugins NEW

Hot-reload all plugins without restarting Claude Code

/usage NEW

Show token and cost usage summary for the current session

/extra-usage NEW

Detailed breakdown of fast-mode vs normal-mode usage and costs

/resume [id] NEW

Resume a previous session from within an active session (in-session resume)

/security-review NEW

Run a focused security review of the current codebase or recent changes

/tag <name> NEW

Save a named snapshot/tag of the current conversation for later reference

/claude-api NEW

Explore and call Anthropic API endpoints directly from within a session

πŸͺ Hook Events

⚑ Automation Triggers

Hooks run shell commands or HTTP endpoints at key lifecycle points. Configure in ~/.claude/settings.json under the hooks key. Hooks can be "type": "command" (default) or "type": "http" (POST to a URL). PreToolUse hooks can block tool use by exiting non-zero; PostToolUse hooks receive the result.

Standard Hook Events

EventWhen it firesNotes
PreToolUseBefore any tool call executesExit non-zero to block the tool. Receives tool name + input JSON on stdin. Filter by matcher field to target specific tools.
PostToolUseAfter a tool call completesReceives tool name, input, and output on stdin. Use for logging, linting, or side effects.
StopWhen the model stops generating (turn ends)Runs after each complete assistant turn.
StopFailureWhen a turn ends in an error/failure stateUse for alerting or rollback automation.
PostCompactAfter context compaction completesUseful for reloading context-sensitive state after a /compact.
InstructionsLoadedAfter all CLAUDE.md files and memory are loadedGood for injecting dynamic system prompt additions.
SessionStartAt the start of a new sessionRuns once when Claude Code starts.
SessionEndWhen the session ends (exit or /clear)Timeout controlled by CLAUDE_CODE_SESSIONEND_HOOKS_TIMEOUT_MS.
CwdChanged NEW 2.1.83Whenever the working directory changesIdeal for direnv-style automatic environment loading on cd.
FileChanged NEW 2.1.83When a file is written by a toolReceives the changed file path. Use for auto-formatting, linting, or reloading.
ConfigChangeWhen settings/config files are reloadedFires after dynamic config updates.
TeammateIdleWhen a teammate agent becomes idleAvailable when agent teams are enabled.
TaskCompletedWhen a background task finishesFires on both success and failure of background tasks.
ElicitationWhen an MCP server sends an elicitation request (needs user input)Allows custom handling of MCP server prompts.
ElicitationResultAfter user responds to an MCP elicitationReceives the user's response for logging or processing.

Hook Configuration Examples

# ~/.claude/settings.json β€” command hook (auto-format on file write) { "hooks": { "FileChanged": [ { "matcher": ".*\\.py$", "hooks": [{ "type": "command", "command": "black $CLAUDE_FILE_PATHS" }] } ], "PreToolUse": [ { "matcher": "Bash", "hooks": [{ "type": "command", "command": "echo \"Running: $TOOL_INPUT_COMMAND\" >> ~/audit.log" }] } ], "PostToolUse": [ { "matcher": "Write", "hooks": [{ "type": "command", "command": "eslint --fix $CLAUDE_FILE_PATHS" }] } ], "CwdChanged": [ { "hooks": [{ "type": "command", "command": "direnv allow && direnv export bash" }] } ] } }
# HTTP hook β€” send POST to a webhook on every stop { "hooks": { "Stop": [ { "hooks": [{ "type": "http", "url": "https://my-server.example.com/claude-webhook", "headers": { "Authorization": "Bearer my-token" } }] } ] } }

Hook Environment Variables (available inside hook commands)

VariableAvailable inDescription
TOOL_NAMEPreToolUse, PostToolUseName of the tool being called (e.g., Bash, Write)
TOOL_INPUT_COMMANDPreToolUse (Bash)The exact command string being run
CLAUDE_FILE_PATHSFileChanged, PostToolUse (file tools)Space-separated list of affected file paths
CLAUDE_SESSION_IDAll hooksUnique ID for the current session
CLAUDECODEAll hooks & subshellsAlways 1 β€” use to detect you're inside Claude Code

πŸ”£ Variable Substitutions

πŸ“ Custom Commands & Prompts

These placeholders are expanded when Claude Code executes custom slash commands (files in .claude/commands/) and in system prompt templates. Arguments passed to a command are available as $ARGUMENTS or individual positional vars.

VariableExpands toExample Use
$ARGUMENTSFull argument string passed to the custom command/mycommand fix the auth flow β†’ $ARGUMENTS = fix the auth flow
$1, $2, ...Positional arguments (word-split)/mycommand foo bar β†’ $1=foo, $2=bar
${CLAUDE_SKILL_DIR}Absolute path to the directory containing the current skill/command fileUseful for loading sibling files relative to the command
${CLAUDE_SESSION_ID}Unique session identifier (UUID)Use in logs or filenames to correlate with hook output
${CLAUDE_CWD}Current working directory when the command was invokedUseful for path-relative operations in commands
!`shell command`Output of a shell command, injected into the prompt!`cat README.md` β€” injects file contents at invocation time

Custom Command Frontmatter

Custom commands (Markdown files in .claude/commands/) support YAML frontmatter to control behavior:

--- description: "Generate a component with tests" effort: high # low | medium | high | max | auto model: opus # override model for this command disableMemory: true # skip loading CLAUDE.md memory for this command allowedTools: # restrict tools available during this command - Read - Write - Bash --- Create a $ARGUMENTS component with unit tests. Use $1 as the component name.

Custom Command Namespacing

Files in subdirectories of .claude/commands/ are namespaced by folder:

.claude/commands/ β”œβ”€β”€ deploy.md β†’ /deploy β”œβ”€β”€ frontend/ β”‚ β”œβ”€β”€ component.md β†’ /frontend:component β”‚ └── test.md β†’ /frontend:test └── backend/ └── migrate.md β†’ /backend:migrate

βš™οΈ Settings.json Reference

πŸ—‚οΈ Configuration Files

Settings are layered in this priority order (highest wins): local (.claude/settings.local.json) β†’ project (.claude/settings.json) β†’ user (~/.claude/settings.json) β†’ managed (/etc/claude-code/managed-settings.json or managed-settings.d/). Use --setting-sources to control which layers are loaded.

Model & Behavior Settings

KeyPurposeValues
modelDefault model for the session"claude-opus-4-6", "sonnet", "haiku"
modelOverridesPer-tier model overrides (e.g., override just the haiku alias){"haiku": "claude-haiku-4-5-20251001"}
effortLevelDefault effort level"low" | "medium" | "high" | "max" | "auto"
includeGitInstructionsInclude built-in git/commit instructions in system prompt (default: true)false to disable
outputStyleResponse output style β€” set at session start for stable prompt caching"auto" | "concise" | "verbose"
showTurnDurationShow elapsed time for each assistant turn in the UItrue | false
feedbackSurveyRateFrequency of end-of-session feedback surveys (0 = never, 1 = always)0–1 (float)
reducedMotionReduce or disable animations in the UItrue

Memory & Context Settings

KeyPurposeValues
autoMemoryDirectoryOverride where auto-generated memory files are stored"~/.claude/memory" (path string)
clearContextOnStartStart each new session with a fresh context (no continuation)true | false
plansDirectoryCustom directory for plan mode output files".claude/plans"

Sandbox & Security Settings

KeyPurposeValues
sandboxEnable or configure sandbox for all sessionstrue | false | object
sandbox.failIfUnavailable NEW 2.1.83Exit with error if sandbox is enabled but cannot start (instead of silently falling back)true
sandbox.enableWeakerNetworkIsolationAllow limited outbound network access inside sandbox (weaker isolation)true
sandbox.allowReadAdditional paths sandbox is allowed to read from (array of glob strings)["/home/user/data/**"]
disableDeepLinkRegistration NEW 2.1.83Prevent Claude Code from registering the claude-cli:// protocol handler on the systemtrue

LSP & IDE Settings

KeyPurposeValues
lspStartupTimeoutMilliseconds to wait for LSP server startup before giving up10000 (default)
preferredNotificationsFormatNotification format for IDE plugin events"json" | "text"

Plugin & Skill Settings

KeyPurposeValues
pluginMarketplaceSourceURL of the plugin marketplace index (for custom/enterprise marketplaces)"https://my-registry.example.com/index.json"
spinnerCustomize the loading spinner style in the terminal UI"dots" | "line" | "minimal"
chat:newlineKeybinding action to insert a newline in multi-line input mode"shift+enter" (configurable via /keybindings)

Voice Settings

KeyPurposeValues
voice.enabledEnable voice mode in the sessiontrue | false
voice.languageLanguage/locale for voice recognition"en-US", "ja-JP", etc.
voice.autoSubmitAuto-submit prompt after silence is detectedtrue | false

Worktree Settings

KeyPurposeValues
worktree.sparsePathsLimit git worktree sparse checkout to specific paths (array)["src/", "tests/"]

Settings.json Full Example

// ~/.claude/settings.json { "model": "claude-opus-4-6", "effortLevel": "medium", "includeGitInstructions": true, "autoMemoryDirectory": "~/.claude/memory", "sandbox": { "failIfUnavailable": true, "enableWeakerNetworkIsolation": false, "allowRead": ["/home/user/datasets/**"] }, "disableDeepLinkRegistration": false, "voice": { "enabled": false }, "lspStartupTimeout": 10000, "showTurnDuration": true, "feedbackSurveyRate": 0, "reducedMotion": false, "env": { "ANTHROPIC_API_KEY": "sk-ant-xxx...", "CLAUDE_CODE_SHELL": "zsh" }, "permissions": { "allow": ["Bash(git *)", "Read(**)", "Write(src/**)"], "deny": ["Bash(rm -rf *)"] }, "hooks": { "FileChanged": [ { "hooks": [{ "type": "command", "command": "prettier --write $CLAUDE_FILE_PATHS" }] } ] } }

🏒 Managed Settings (Enterprise)

πŸ”’ Admin / Fleet Deployment

Managed settings are applied system-wide and cannot be overridden by users or project settings. They are read from /etc/claude-code/managed-settings.json (Linux/macOS) or the equivalent Windows path. New in v2.1.83: place fragment files in /etc/claude-code/managed-settings.d/ β€” files are merged alphabetically, allowing independent teams to deploy separate policy fragments.

Key Managed Settings

KeyPurposeValues
disableAutoMode NEW 2.1.82Prevent users from enabling auto mode (research preview) organisation-widetrue
apiKeyHelperShell command that outputs a fresh API key (used for token rotation)"python3 /opt/get-key.py"
disableTelemetryDisable all telemetry and analytics organisation-widetrue
disableErrorReportingDisable Sentry crash reporting organisation-widetrue
disableAutoUpdaterPrevent automatic background updatestrue
disableFeedbackCommandRemove /feedback command for all userstrue
disableDeepLinkRegistrationPrevent claude-cli:// protocol handler registrationtrue
permissions.allowOrg-wide allowed tool patterns (merged with user/project allows)["Bash(git *)", "Read(**)"]
permissions.denyOrg-wide denied tool patterns β€” cannot be overridden by users["Bash(curl *)", "Bash(wget *)"]
envEnvironment variables applied to all sessions fleet-wide{"HTTPS_PROXY": "http://corp-proxy:8080"}

managed-settings.d/ Drop-in Fragments NEW 2.1.83

# Deploy individual policy fragments β€” merged alphabetically /etc/claude-code/managed-settings.d/ β”œβ”€β”€ 00-base.json # base org policy β”œβ”€β”€ 10-security-team.json # security team overrides └── 20-ml-platform.json # ML platform team additions # Example fragment: /etc/claude-code/managed-settings.d/10-security-team.json { "permissions": { "deny": ["Bash(curl *)", "Bash(wget *)"] }, "disableTelemetry": true }

🎯 Quick Reference Matrix

πŸ“Š Common Patterns

TaskCommand / Flag / Variable
Start interactive sessionclaude
Continue previous conversationclaude -c or claude --continue
Quick non-interactive queryclaude -p "query"
Change model to Opusclaude --model claude-opus-4-6
Set effort levelclaude --effort high or CLAUDE_CODE_EFFORT_LEVEL=high
Enable experimental agent teamsCLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1
Use AWS BedrockCLAUDE_CODE_USE_BEDROCK=1 + AWS_REGION=us-east-1
Use Google Vertex AICLAUDE_CODE_USE_VERTEX=1 + CLOUD_ML_REGION=us-east5 + ANTHROPIC_VERTEX_PROJECT_ID=my-proj
Skip permission prompts (devcontainer only)claude --dangerously-skip-permissions
Enter plan mode at launchclaude --permission-mode plan
Add multiple directoriesclaude --add-dir ../apps ../lib
Append to system promptclaude --append-system-prompt "Always use TypeScript"
JSON output in -p modeclaude -p --output-format json "query"
Restrict tools to safe setclaude --tools "Bash,Read,Grep,Edit"
Disable all non-essential trafficCLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
Load MCP serversclaude --mcp-config ./mcp.json
Enable MCP push channelsclaude --channels
Corporate HTTPS proxyHTTPS_PROXY=http://proxy:8080 claude
Custom shellCLAUDE_CODE_SHELL=zsh claude
Auto-activate virtualenvCLAUDE_ENV_FILE=.venv/bin/activate claude
Fork session for parallel workclaude --fork-session
Isolated git worktreeclaude --worktree
Disable extended thinkingMAX_THINKING_TOKENS=0
Disable 1M context windowCLAUDE_CODE_DISABLE_1M_CONTEXT=1
Bridge session to browser/phoneclaude --remote-control or in-session /remote-control
Pull web session to terminalIn-session: /teleport
Launch sandbox environmentclaude --sandbox
Run recurring check every 5 minIn-session: /loop 5m check deploy status
Hide account info from UICLAUDE_CODE_HIDE_ACCOUNT_INFO=1
Use system ripgrepUSE_BUILTIN_RIPGREP=0
Debug MCP issuesclaude --mcp-debug --verbose
Fast scripted automation (no hooks/LSP/plugins)claude -p --bare "query"
Enable auto mode (research preview)claude --enable-auto-mode
Strip credentials from subprocessesCLAUDE_CODE_SUBPROCESS_ENV_SCRUB=1
Resume from GitHub PRclaude --from-pr https://github.com/org/repo/pull/42
List configured agentsclaude agents
Manage MCP serversclaude mcp list / claude mcp add
Transcript search (in-session)Press / then n/N to navigate

πŸ“₯ Installation & Setup

πŸš€ Getting Started

⚠️ npm install is deprecated. npm install -g @anthropic-ai/claude-code is no longer the recommended method. Use native installers below. Native installs auto-update in the background.

macOS & Linux β€” Install Script (Recommended)

# Latest version curl -fsSL https://claude.ai/install.sh | bash # Specific version curl -fsSL https://claude.ai/install.sh | bash -s 2.1.83

macOS β€” Homebrew

brew install --cask claude-code # Note: Homebrew does NOT auto-update. Run periodically: brew upgrade claude-code

Windows β€” WinGet (Recommended for Windows)

# Requires Git for Windows installed first winget install Anthropic.ClaudeCode # Note: WinGet does NOT auto-update. Run periodically: winget upgrade Anthropic.ClaudeCode

Windows β€” PowerShell Script

# Latest irm https://claude.ai/install.ps1 | iex # Specific version & ([scriptblock]::Create((irm https://claude.ai/install.ps1))) 2.1.83

Authentication

# Login with claude.ai subscription claude auth login # Login via Anthropic Console / API billing account claude auth login --console # Or set API key directly export ANTHROPIC_API_KEY=sk-ant-xxx... # Check auth status claude auth status # Logout claude auth logout

Update

# Manual update (native installs also update automatically) claude update # Force reinstall (bypasses stale lock files) claude install --force

npm β€” Legacy / CI Fallback

# ⚠️ DEPRECATED β€” use native installers above npm install -g @anthropic-ai/claude-code@2.1.83

πŸ’‘ Tips & Best Practices

✨ Pro Tips

πŸ” Search: Ctrl+F (Cmd+F on Mac) to find any variable, flag, or command on this page.
βš™οΈ Environment Variables: Set temporarily by prefixing your command, or permanently in your shell profile. Can also be set under env in ~/.claude/settings.json for team-wide rollout.
πŸ§ͺ Experimental Features: Agent teams and some v2.1.80 features are experimental β€” avoid in production without testing.
πŸ“ Context Management: Use /compact when context > ~80% (instant since v2.0.64). Use /clear when switching to an unrelated task entirely.
πŸ” Security: --dangerously-skip-permissions bypasses all safety checks. Use only in a devcontainer with a firewall configured β€” never on your main machine.
πŸ’° Cost: Enabling fast mode mid-session re-bills the entire prior context at fast rates. Use --max-budget-usd to cap spending in -p mode.
🎯 Model Choice: Opus 4.6 (1M context, 64K output) for complex reasoning; Sonnet 4.6 for daily work; Haiku for subagents and cheap searches. Default effort for Max/Team Opus subscribers changed to medium in March 2026.
πŸ†• v2.1.81 Highlights: --bare flag for fast deterministic scripted -p automation (skips hooks/LSP/plugins/skills), --channels permission relay (channel servers can forward tool approval prompts to phone), default Opus model on Bedrock/Vertex/Foundry changed to Opus 4.6 (was 4.1), /output-style deprecated (use /config), ANTHROPIC_BETAS env var now correctly applied to all model tiers including Haiku, VS Code spark icon + native MCP management dialog, Remote Control poll rate cut ~300Γ—.
πŸ†• v2.1.82 Highlights: --enable-auto-mode (research preview) β€” Claude auto-approves low-risk actions via Sonnet 4.6 classifier, safer middle ground between default and --dangerously-skip-permissions. Configurable multi-line input keybinding (chat:newline). Managed setting disableAutoMode to block auto mode org-wide.
πŸ†• v2.1.83 Highlights: managed-settings.d/ drop-in directory for enterprise policy fragments, CLAUDE_CODE_SUBPROCESS_ENV_SCRUB to strip credentials from subprocesses, CwdChanged / FileChanged hook events for reactive environment management, sandbox.failIfUnavailable setting, transcript search with / key (n/N to navigate matches).

πŸŽ“ Real-World Examples

Example 1: Agent Teams (Experimental)

export CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 claude --teammate-mode in-process --permission-mode plan

Example 2: High-Effort Analysis on Opus

claude --model claude-opus-4-6 --effort high \ --append-system-prompt "Focus on security and performance implications"

Example 3: Privacy / Air-Gap Setup

export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 export ANTHROPIC_API_KEY=sk-ant-xxx... claude

Example 4: Enterprise Bedrock with Proxy & Pinned Models

export HTTPS_PROXY=http://corporate-proxy:8080 export CLAUDE_CODE_USE_BEDROCK=1 export AWS_REGION=us-east-1 # Pin exact model versions to prevent breakage on Anthropic updates export ANTHROPIC_DEFAULT_OPUS_MODEL='us.anthropic.claude-opus-4-6-v1' export ANTHROPIC_DEFAULT_SONNET_MODEL='us.anthropic.claude-sonnet-4-6' export ANTHROPIC_DEFAULT_HAIKU_MODEL='us.anthropic.claude-haiku-4-5-20251001-v1:0' export CLAUDE_CODE_SHELL_PREFIX="time" # Audit command timings claude

Example 5: CI/CD Integration (Fully Automated)

# Best run inside a devcontainer with firewall claude -p \ --output-format json \ --max-turns 10 \ --max-budget-usd 5 \ --dangerously-skip-permissions \ --tools "Bash,Read,Grep,Edit,Write" \ "Analyze this PR for security vulnerabilities and output findings" \ > analysis.json

Example 6: Strict MCP-Only Environment

claude \ --mcp-config ./mcp-servers.json \ --strict-mcp-config \ --plugin-dir ./plugins \ --append-system-prompt "Use MCP tools for all external data"

Example 7: Python Virtual Environment Auto-Activation

export CLAUDE_ENV_FILE=.venv/bin/activate export CLAUDE_CODE_SHELL=bash claude --add-dir ./backend ./frontend

Example 8: Debug MCP & API Issues

claude --verbose --mcp-debug --debug "api,mcp,hooks" \ --append-system-prompt "Include diagnostic details in responses"

Example 9: Remote Control & MCP Channels (v2.1.80)

# Bridge terminal to browser or phone claude --remote-control # Or enable MCP push channels (server must declare claude/channel capability) claude --channels --mcp-config ./mcp-servers.json # Or start a session then bridge mid-session claude # then type: /remote-control

Example 10: Recurring Monitor with /loop

claude # then type: /loop 10m check test suite status and summarize any failures

Example 11: Cross-Surface Workflow

# Start long-running task on claude.ai web # Later, pull it into your terminal: claude # then type: /teleport # Or hand a terminal session off to the Desktop app for visual diff: # type: /desktop

Example 12: Bare Scripted Automation (v2.1.81)

# --bare skips hooks, LSP, plugin sync, skill walks β€” fastest deterministic -p calls # Requires ANTHROPIC_API_KEY (OAuth/keychain disabled in bare mode) export ANTHROPIC_API_KEY=sk-ant-xxx... claude -p --bare \ --output-format json \ --max-turns 5 \ "Summarize all TODO comments in this repo" \ > todos.json

Example 13: Auto Mode (v2.1.82)

# Auto mode β€” Claude auto-approves low-risk actions (research preview) # Safer than --dangerously-skip-permissions, more autonomous than default claude --enable-auto-mode "implement the feature described in TASK.md" # Disable auto mode org-wide via managed settings: # /etc/claude-code/managed-settings.json β†’ { "disableAutoMode": true }

Example 14: Managed Settings Drop-in (v2.1.83)

# Deploy policy fragments independently per team # /etc/claude-code/managed-settings.d/10-security.json { "permissions": { "deny": ["Bash(curl *)", "Bash(wget *)"] }, "env": { "CLAUDE_CODE_SUBPROCESS_ENV_SCRUB": "1" } }