Claude Code CLI Flags Reference
A comprehensive, organized reference of command-line flags, subcommands, in-session
slash commands, and environment variables for Claude Code ,
Anthropic's official CLI for Claude.
Sourced from the official documentation at
code.claude.com/docs .
Note: Claude Code evolves quickly. Flags here reflect the docs as of the last
update to this repo — always cross-check with claude --help or the official docs
for the most current behavior.
Related documents in this repo
PLUGIN-CATALOG.md — top-5-per-category survey of the
Claude plugin marketplace, ranked by uniqueness/usefulness.
system-prompts/ — per-role system prompts (Engineering &
DevOps, Product & Design, Data & Science, Operations/Support/Productivity) compiled
from that catalog, with best practices and effort-level invocation rules for each.
Flag
Short
Type
Description
Example
--continue
-c
flag
Load the most recent conversation and continue it
claude -c
--resume
-r
string (session ID/name)
Resume a specific session by ID or display name; omit value to show a picker
claude -r "auth-refactor"
--fork-session
—
flag
Create a new session ID when resuming (fork instead of continue)
claude --resume abc123 --fork-session
--session-id
—
UUID string
Use a specific session UUID instead of auto-generating one
claude --session-id "550e8400-e29b-41d4-a716-446655440000"
--name
-n
string
Set a human-readable display name for the session
claude -n "my-feature-work"
--no-session-persistence
—
flag
Don't save the session to disk (ephemeral)
claude -p --no-session-persistence "query"
Output & Interactive Mode
Flag
Short
Type
Description
Example
--print
-p
flag
Print the response and exit (non-interactive mode)
claude -p "explain this function"
--output-format
—
string
Output format: text (default), json, stream-json
claude -p "query" --output-format json
--verbose
—
flag
Enable verbose logging to stderr
claude --verbose -p "query"
--ax-screen-reader
—
flag
Render screen-reader-friendly output
claude --ax-screen-reader
Flag
Type
Description
Example
--input-format
string
Input format: text (default), stream-json
claude -p --input-format stream-json
--replay-user-messages
flag
Re-emit user messages for acknowledgment in the stream
claude -p --input-format stream-json --output-format stream-json --replay-user-messages
--include-partial-messages
flag
Include partial streaming events in output
claude -p --output-format stream-json --include-partial-messages "query"
--include-hook-events
flag
Include all hook lifecycle events in the output stream
claude -p --output-format stream-json --include-hook-events "query"
Flag
Type
Description
Example
--model
string
Set model: sonnet, opus, haiku, fable, or a full model ID
claude --model claude-opus-5
--fallback-model
string
Comma-separated fallback models, tried in order if the primary fails
claude --fallback-model sonnet,haiku
--effort
string
Reasoning effort level: low, medium, high, xhigh, max, ultracode
claude --effort high
--betas
string
Enable beta API headers for experimental features
claude --betas interleaved-thinking
Flag
Type
Description
Example
--permission-mode
string
Starting permission mode: default (prompt each time), acceptEdits, plan, auto, dontAsk, bypassPermissions, manual
claude --permission-mode plan
--allow-dangerously-skip-permissions
flag
Make bypassPermissions selectable without starting in it
claude --permission-mode plan --allow-dangerously-skip-permissions
--dangerously-skip-permissions
flag
Skip all permission prompts — disables safety gates. Use with caution, only in trusted/sandboxed environments.
claude --dangerously-skip-permissions
--permission-prompt-tool
string
Delegate permission prompts to an MCP tool
claude -p --permission-prompt-tool mcp_auth_tool "query"
Flag
Type
Description
Example
--allowedTools / --allowed-tools
string array
Tools/patterns that run without prompting
claude --allowed-tools "Bash(git log *)" "Read"
--disallowedTools / --disallowed-tools
string array
Tools/patterns explicitly denied
claude --disallowed-tools "Bash(rm *)" "Edit"
--tools
string
Restrict available tools; empty = none, default = all, or comma-separated list
claude --tools "Bash,Edit,Read"
Flag
Type
Description
Example
--safe-mode
flag
Disable all customizations (hooks, skills, settings) for troubleshooting
claude --safe-mode
System Prompt & Configuration
Flag
Type
Description
Example
--system-prompt
string
Replace the entire default system prompt
claude --system-prompt "You are a security expert"
--system-prompt-file
path
Load system prompt from a file (replaces default)
claude --system-prompt-file ./custom-prompt.txt
--append-system-prompt
string
Append text to the default system prompt
claude --append-system-prompt "Always cite file paths"
--append-system-prompt-file
path
Append system prompt content from a file
claude --append-system-prompt-file ./extra-rules.txt
--append-subagent-system-prompt
string
Append text to every subagent's system prompt
claude -p --append-subagent-system-prompt "Cite file paths" "query"
--exclude-dynamic-system-prompt-sections
flag
Move machine-specific sections (cwd, env, tools) to the first message instead of the system prompt
claude -p --exclude-dynamic-system-prompt-sections "query"
--settings
path or JSON
Override settings for this session
claude --settings ./settings.json
--setting-sources
string
Comma-separated sources to load: user, project, local
claude --setting-sources user,project
Working Directory & File Access
Flag
Short
Type
Description
Example
--add-dir
—
path(s)
Add additional working directories for file access without moving cwd
claude --add-dir ../apps ../lib
--worktree
-w
string
Create or use a git worktree
claude -w feature-auth
MCP (Model Context Protocol)
Flag
Type
Description
Example
--mcp-config
path or JSON
Load MCP servers from a JSON configuration file
claude --mcp-config ./mcp.json
--strict-mcp-config
flag
Only use MCP servers specified in config; ignore defaults
claude --strict-mcp-config --mcp-config ./mcp.json
--channels
string
MCP servers to listen to for notifications
claude --channels plugin:my-notifier@my-marketplace
--dangerously-load-development-channels
string
Enable development/experimental MCP channels (requires confirmation)
claude --dangerously-load-development-channels server:webhook
Flag
Type
Description
Example
--agent
string
Specify a custom agent for the session
claude --agent my-custom-agent
--agents
JSON
Define custom subagents dynamically
claude --agents '{"reviewer":{"description":"Reviews code","prompt":"..."}}'
--teammate-mode
string
Agent team display mode: in-process, auto, tmux, iterm2
claude --teammate-mode auto
Parallel & Background Execution
Flag
Type
Description
Example
--bg / --background
flag
Start as a background agent; return immediately
claude --bg "investigate the flaky test"
--exec
string
Run a shell command as a background job
claude --bg --exec 'pytest -x'
--from-pr
string
Filter sessions by GitHub PR (number or URL)
claude --from-pr 123
Flag
Type
Description
Example
--init
flag
Run Setup hooks with the init matcher
claude -p --init "query"
--init-only
flag
Run Setup hooks and exit (don't start an interactive session)
claude --init-only
--maintenance
flag
Run Setup hooks with the maintenance matcher
claude -p --maintenance "query"
--ide
flag
Auto-connect to IDE on startup if available
claude --ide
--bare
flag
Minimal mode: skip auto-discovery of tools/extensions for faster startup
claude --bare -p "query"
--disable-slash-commands
flag
Disable all skills and / commands
claude --disable-slash-commands
Structured Output & Schema
Flag
Type
Description
Example
--json-schema
JSON
Request JSON output matching a JSON Schema
claude -p --json-schema '{"type":"object","properties":{"name":{"type":"string"}}}'
Browser & IDE Integration
Flag
Type
Description
Example
--chrome
flag
Enable Chrome browser integration for computer use
claude --chrome
--no-chrome
flag
Explicitly disable Chrome integration
claude --no-chrome
--plugin-dir
path
Load a custom plugin from a directory or .zip file
claude --plugin-dir ./my-plugin
--plugin-url
URL
Fetch a plugin from a remote URL
claude --plugin-url https://example.com/plugin.zip
Flag
Type
Description
Example
--cloud
string
Create a web session on claude.ai and run the query there
claude --cloud "Fix the login bug"
--remote
string
Deprecated alias for --cloud
claude --remote "Fix the login bug"
--teleport
flag
Resume a web session (from claude.ai) locally
claude --teleport
--remote-control / --rc
string (optional)
Start with Remote Control enabled for claude.ai/code
claude --remote-control "My Project"
--remote-control-session-name-prefix
string
Prefix for auto-generated Remote Control session names
claude remote-control --remote-control-session-name-prefix dev-box
Flag
Type
Description
Example
--advisor
string
Enable the advisor tool with a specified model: opus or sonnet
claude --advisor opus
Flag
Type
Description
Example
--tmux
string (optional)
Create a tmux session; pass classic for traditional tmux behavior
claude -w feature-auth --tmux
Advanced Output & Streaming
Flag
Type
Description
Example
--prompt-suggestions
flag
Emit predicted next prompts in the output stream
claude -p --prompt-suggestions --output-format stream-json --verbose "query"
--forward-subagent-text
flag
Emit subagent text blocks in the output stream
claude -p --output-format stream-json --forward-subagent-text "query"
Flag
Type
Description
Example
--max-budget-usd
number
Set the maximum spend in USD for this session
claude -p --max-budget-usd 5.00 "query"
Flag
Type
Description
Example
--max-turns
number
Limit agentic turns (number of model invocations)
claude -p --max-turns 3 "query"
Flag
Short
Type
Description
Example
--debug
—
string (optional)
Enable debug logging; optionally filter by component
claude --debug "api,mcp"
--debug-file
—
path
Write debug logs to a specific file
claude --debug-file /tmp/claude-debug.log
--version
-v
flag
Print the Claude Code version and exit
claude --version
claude mcp — MCP server management
Subcommand
Purpose
claude mcp reconnect
Reconnect to all configured MCP servers
claude mcp enable <server-name>
Enable a specific MCP server
claude mcp disable <server-name>
Disable a specific MCP server
claude config — Settings management
Subcommand
Purpose
claude config
Open the settings editor
claude config [key]
Get the value of a specific key
claude config [key=value]
Set a specific key
claude doctor — Diagnostics & health check
Subcommand
Purpose
claude doctor
Run a health check on your Claude Code setup; diagnose & auto-fix issues
claude update — Version management
Subcommand
Purpose
claude update
Check for and install Claude Code updates
claude update [version]
Update to a specific version
claude help — Help & documentation
Subcommand
Purpose
claude help
Show all available commands & flags
claude [command] --help
Show help for a specific command
In-Session Slash Commands
Typed during an interactive session (not CLI flags, but included for a complete reference).
Command
Args
Purpose
/clear
[name]
Start a new conversation; optionally name the old one
/resume
—
Show a picker to resume an earlier conversation
/branch
[name]
Create a new conversation branch from the current point
/fork
[prompt]
Copy the conversation to a new background session
/cd
<path>
Move the session to a new working directory
/add-dir
<path>
Add a directory for file access without moving cwd
/exit
—
Exit the CLI (keeps background sessions running)
Command
Args & flags
Purpose
/code-review
[level] [--fix] [--comment] [target]
Review a diff for bugs & cleanups; levels: low, medium, high, xhigh, max, ultra
/simplify
—
Cleanup-only code review (no bug hunting)
/security-review
—
Security vulnerability check on the diff
/diff
—
Interactive diff viewer for uncommitted changes
Model & performance control
Command
Args
Purpose
/model
[model-name]
Switch AI model (e.g. opus, sonnet, haiku)
/effort
[level|auto]
Set reasoning effort: low, medium, high, xhigh, max, ultracode
/advisor
[model|off]
Enable/disable the advisor tool
/fast
[on|off]
Toggle fast mode for quicker responses
Command
Args
Purpose
/context
[all]
Visualize context usage as a colored grid
/compact
[instructions]
Summarize the conversation to free context space
/btw
<question>
Ask a quick side question without adding it to history
/memory
—
Edit memory files, manage auto-memory
Parallel & background work
Command
Args
Purpose
/batch
<instruction>
Decompose a large change into parallel units
/background
[prompt]
Detach the session as a background agent
/tasks
—
List the current session's background work
/subtask
—
Hand a side task to a subagent
Documentation & reference
Command
Args
Purpose
/init
—
Initialize the project with a CLAUDE.md guide
/claude-api
[migrate|managed-agents-onboard]
Load Claude API reference & docs
/plan
—
Switch to plan mode for large changes
Command
Args
Purpose
/loop
[interval] [prompt]
Run a prompt repeatedly on a schedule (default 10m)
/goal
[condition|clear]
Set a condition for autonomous work
/deep-research
<question>
Fan out web searches with a cited report
Command
Args
Purpose
/debug
[description]
Enable debug logging & troubleshoot
/doctor
—
Run a setup checkup; diagnose & fix issues
/mcp
[reconnect|enable|disable]
Manage MCP server connections
/hooks
—
View hook configurations
Command
Args
Purpose
/copy
[N]
Copy the last response (or Nth-latest) to clipboard
/export
[filename]
Export the conversation as plain text
/config
[key=value]
Open settings or set a specific key
/color
[color|default]
Set the prompt bar color
/permissions
—
Set approval rules
Command
Purpose
/install-github-app
Install the Claude GitHub App
/install-slack-app
Install the Claude Slack app (web sessions only)
/design-sync
Upload a React design system to Claude Design
/autofix-pr
Watch a PR & push fixes when CI fails
Command
Purpose
/login
Sign in to your Anthropic account
/logout
Sign out
/help
Show available commands
/feedback
Send product feedback
/bug
Report a bug with session context
Set in your shell or in ~/.claude/settings.json under the env key.
Variable
Type
Description
ANTHROPIC_API_KEY
string
API key for Anthropic authentication
ANTHROPIC_AUTH_TOKEN
string
Custom Authorization header value
ANTHROPIC_BASE_URL
URL
Override the API endpoint (for proxies)
ANTHROPIC_MODEL
string
Default model to use
Variable
Type
Description
ANTHROPIC_AWS_API_KEY
string
Workspace API key for Claude Platform on AWS
ANTHROPIC_AWS_BASE_URL
URL
Override the AWS endpoint
ANTHROPIC_AWS_WORKSPACE_ID
string
Workspace ID for AWS (required for AWS integration)
ANTHROPIC_BEDROCK_BASE_URL
URL
Override the Amazon Bedrock endpoint
ANTHROPIC_VERTEX_BASE_URL
URL
Override the Google Cloud Agent Platform endpoint
Variable
Type
Default
Description
API_TIMEOUT_MS
number
600000 (10 min)
Request timeout in milliseconds
API_FORCE_IDLE_TIMEOUT
number
—
Override the 5-minute idle timeout for streaming
BASH_DEFAULT_TIMEOUT_MS
number
120000 (2 min)
Default timeout for bash commands
BASH_MAX_TIMEOUT_MS
number
600000 (10 min)
Maximum timeout the model can set for bash
Variable
Type
Description
CLAUDE_CODE_DISABLE_ARTIFACT
flag
Disable artifact publishing
CLAUDE_CODE_DISABLE_AGENT_VIEW
flag
Disable the background agents display
CLAUDE_CODE_DISABLE_AUTO_MEMORY
flag
Disable auto-memory functionality
CLAUDE_CODE_DISABLE_BACKGROUND_TASKS
flag
Disable background task functionality
CLAUDE_CODE_AUTO_CONNECT_IDE
flag
Auto-connect to IDE (override detection)
CLAUDE_CODE_DISABLE_ALTERNATE_SCREEN
flag
Use the classic renderer instead of fullscreen
CLAUDE_CODE_DISABLE_ATTACHMENTS
flag
Disable file attachment processing
Variable
Type
Description
CLAUDE_CODE_DEBUG_LOGS_DIR
path
Override the debug log file directory
CLAUDE_CODE_DEBUG_LOG_LEVEL
string
Minimum log level: verbose, debug, info, warn, error
DEBUG
string
Enable debug mode; use with --debug flag
Shell (macOS/Linux/WSL):
export API_TIMEOUT_MS=" 1200000"
export ANTHROPIC_MODEL=" claude-opus-5"
claude
Shell (Windows PowerShell):
$env: API_TIMEOUT_MS = " 1200000"
$env: ANTHROPIC_MODEL = " claude-opus-5"
claude
Settings file (~/.claude/settings.json):
{
"env" : {
"API_TIMEOUT_MS" : " 1200000" ,
"BASH_DEFAULT_TIMEOUT_MS" : " 300000" ,
"ANTHROPIC_MODEL" : " claude-opus-5"
}
}
Precedence order (highest to lowest):
CLI flags
Environment variables (shell)
Settings file env key
Managed settings (organization-level)
Defaults
Deprecated Flags & Aliases
Deprecated
Replacement
Notes
--remote
--cloud
Renamed for clarity
# Basic interactive session
claude
# Non-interactive query with output
claude -p " explain this function"
# Continue last session
claude -c
# Resume named session
claude -r " session-name"
# Resume and fork (new session ID)
claude -r " session-name" --fork-session
# Set permissions and model
claude --permission-mode plan --model opus
# Custom system prompt (non-interactive)
claude --system-prompt " You are a security expert" -p " audit this code"
# JSON output
claude -p --output-format json " query"
# Structured output with schema
claude -p --json-schema ' {"type":"object","properties":{"code":{"type":"string"}}}' " write hello world"
# Background execution (returns immediately)
claude --bg " run all tests" --effort high
# Debug mode with filtering
claude --debug " api,mcp" -p " query"
# Create a git worktree
claude -w feature-auth
# Add additional directories
claude --add-dir ../apps ../lib -p " analyze the codebase"
# Limit agentic turns
claude -p --max-turns 3 " solve this problem"
# Disable all customizations
claude --safe-mode
# Use a web session
claude --cloud " Fix the login bug"
# Chrome integration for computer use
claude --chrome -p " take a screenshot"
Found a flag that's missing, wrong, or changed? Open a PR or issue. Please verify
against claude --help or the official docs before
submitting.