Skip to main content

CLI commands

You can start sessions, pipe content, resume conversations, and manage updates with these commands:
CommandDescriptionExample
claudeStart interactive sessionclaude
claude "query"Start interactive session with initial promptclaude "explain this project"
claude -p "query"Query via SDK, then exitclaude -p "explain this function"
cat file | claude -p "query"Process piped contentcat logs.txt | claude -p "explain"
claude -cContinue most recent conversation in current directoryclaude -c
claude -c -p "query"Continue via SDKclaude -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
claude auth loginSign in to your Anthropic account. Use --email to pre-fill your email address and --sso to force SSO authenticationclaude auth login --email [email protected] --sso
claude auth logoutLog out from your Anthropic accountclaude auth logout
claude auth statusShow authentication status as JSON. Use --text for human-readable output. Exits with code 0 if logged in, 1 if notclaude auth status
claude agentsList all configured subagents, grouped by sourceclaude agents
claude mcpConfigure Model Context Protocol (MCP) serversSee the Claude Code MCP documentation.
claude remote-controlStart a Remote Control session to control Claude Code from Claude.ai or the Claude app while running locally. See Remote Control for flagsclaude remote-control

CLI flags

Customize Claude Code’s behavior with these command-line flags:
FlagDescriptionExample
--add-dirAdd additional working directories for Claude to access (validates each path exists as a directory)claude --add-dir ../apps ../lib
--agentSpecify an agent for the current session (overrides the agent setting)claude --agent my-custom-agent
--agentsDefine custom subagents dynamically via JSON (see below for format)claude --agents '{"reviewer":{"description":"Reviews code","prompt":"You are a code reviewer"}}'
--allow-dangerously-skip-permissionsEnable permission bypassing as an option without immediately activating it. Allows composing with --permission-mode (use with caution)claude --permission-mode plan --allow-dangerously-skip-permissions
--allowedToolsTools that execute without prompting for permission. See permission rule syntax for pattern matching. To restrict which tools are available, use --tools instead"Bash(git log *)" "Bash(git diff *)" "Read"
--append-system-promptAppend custom text to the end of the default system promptclaude --append-system-prompt "Always use TypeScript"
--append-system-prompt-fileLoad additional system prompt text from a file and append to the default promptclaude --append-system-prompt-file ./extra-rules.txt
--betasBeta headers to include in API requests (API key users only)claude --betas interleaved-thinking
--chromeEnable Chrome browser integration for web automation and testingclaude --chrome
--continue, -cLoad the most recent conversation in the current directoryclaude --continue
--dangerously-skip-permissionsSkip all permission prompts (use with caution)claude --dangerously-skip-permissions
--debugEnable debug mode with optional category filtering (for example, "api,hooks" or "!statsig,!file")claude --debug "api,mcp"
--disable-slash-commandsDisable all skills and commands for this sessionclaude --disable-slash-commands
--disallowedToolsTools that are removed from the model’s context and cannot be used"Bash(git log *)" "Bash(git diff *)" "Edit"
--fallback-modelEnable automatic fallback to specified model when default model is overloaded (print mode only)claude -p --fallback-model sonnet "query"
--fork-sessionWhen resuming, create a new session ID instead of reusing the original (use with --resume or --continue)claude --resume abc123 --fork-session
--from-prResume sessions linked to a specific GitHub PR. Accepts a PR number or URL. Sessions are automatically linked when created via gh pr createclaude --from-pr 123
--ideAutomatically connect to IDE on startup if exactly one valid IDE is availableclaude --ide
--initRun initialization hooks and start interactive modeclaude --init
--init-onlyRun initialization hooks and exit (no interactive session)claude --init-only
--include-partial-messagesInclude partial streaming events in output (requires --print and --output-format=stream-json)claude -p --output-format stream-json --include-partial-messages "query"
--input-formatSpecify input format for print mode (options: text, stream-json)claude -p --output-format json --input-format stream-json
--json-schemaGet validated JSON output matching a JSON Schema after agent completes its workflow (print mode only, see structured outputs)claude -p --json-schema '{"type":"object","properties":{...}}' "query"
--maintenanceRun maintenance hooks and exitclaude --maintenance
--max-budget-usdMaximum dollar amount to spend on API calls before stopping (print mode only)claude -p --max-budget-usd 5.00 "query"
--max-turnsLimit the number of agentic turns (print mode only). Exits with an error when the limit is reached. No limit by defaultclaude -p --max-turns 3 "query"
--mcp-configLoad MCP servers from JSON files or strings (space-separated)claude --mcp-config ./mcp.json
--modelSets the model for the current session with an alias for the latest model (sonnet or opus) or a model’s full nameclaude --model claude-sonnet-4-6
--no-chromeDisable Chrome browser integration for this sessionclaude --no-chrome
--no-session-persistenceDisable session persistence so sessions are not saved to disk and cannot be resumed (print mode only)claude -p --no-session-persistence "query"
--output-formatSpecify output format for print mode (options: text, json, stream-json)claude -p "query" --output-format json
--permission-modeBegin in a specified permission modeclaude --permission-mode plan
--permission-prompt-toolSpecify an MCP tool to handle permission prompts in non-interactive modeclaude -p --permission-prompt-tool mcp_auth_tool "query"
--plugin-dirLoad plugins from directories for this session only (repeatable)claude --plugin-dir ./my-plugins
--print, -pPrint response without interactive mode (see Agent SDK documentation for programmatic usage details)claude -p "query"
--remoteCreate a new web session on claude.ai with the provided task descriptionclaude --remote "Fix the login bug"
--resume, -rResume a specific session by ID or name, or show an interactive picker to choose a sessionclaude --resume auth-refactor
--session-idUse a specific session ID for the conversation (must be a valid UUID)claude --session-id "550e8400-e29b-41d4-a716-446655440000"
--setting-sourcesComma-separated list of setting sources to load (user, project, local)claude --setting-sources user,project
--settingsPath to a settings JSON file or a JSON string to load additional settings fromclaude --settings ./settings.json
--strict-mcp-configOnly use MCP servers from --mcp-config, ignoring all other MCP configurationsclaude --strict-mcp-config --mcp-config ./mcp.json
--system-promptReplace the entire system prompt with custom textclaude --system-prompt "You are a Python expert"
--system-prompt-fileLoad system prompt from a file, replacing the default promptclaude --system-prompt-file ./custom-prompt.txt
--teleportResume a web session in your local terminalclaude --teleport
--teammate-modeSet how agent team teammates display: auto (default), in-process, or tmux. See set up agent teamsclaude --teammate-mode in-process
--toolsRestrict which built-in tools Claude can use. Use "" to disable all, "default" for all, or tool names like "Bash,Edit,Read"claude --tools "Bash,Edit,Read"
--verboseEnable verbose logging, shows full turn-by-turn outputclaude --verbose
--version, -vOutput the version numberclaude -v
--worktree, -wStart Claude in an isolated git worktree at <repo>/.claude/worktrees/<name>. If no name is given, one is auto-generatedclaude -w feature-auth
The --output-format json flag is particularly useful for scripting and automation, allowing you to parse Claude’s responses programmatically.

Agents flag format

The --agents flag accepts a JSON object that defines one or more custom subagents. Each subagent requires a unique name (as the key) and a definition object with the following fields:
FieldRequiredDescription
descriptionYesNatural language description of when the subagent should be invoked
promptYesThe system prompt that guides the subagent’s behavior
toolsNoArray of specific tools the subagent can use, for example ["Read", "Edit", "Bash"]. If omitted, inherits all tools. Supports Agent(agent_type) syntax
disallowedToolsNoArray of tool names to explicitly deny for this subagent
modelNoModel alias to use: sonnet, opus, haiku, or inherit. If omitted, defaults to inherit
skillsNoArray of skill names to preload into the subagent’s context
mcpServersNoArray of MCP servers for this subagent. Each entry is a server name string or a {name: config} object
maxTurnsNoMaximum number of agentic turns before the subagent stops
Example:
claude --agents '{
  "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."
  }
}'
For more details on creating and using subagents, see the subagents documentation.

System prompt flags

Claude Code provides four flags for customizing the system prompt. All four work in both interactive and non-interactive modes.
FlagBehaviorUse case
--system-promptReplaces entire default promptComplete control over Claude’s behavior and instructions
--system-prompt-fileReplaces with file contentsLoad prompts from files for reproducibility and version control
--append-system-promptAppends to default promptAdd specific instructions while keeping default Claude Code behavior
--append-system-prompt-fileAppends file contents to default promptLoad additional instructions from files while keeping defaults
When to use each:
  • --system-prompt: use when you need complete control over Claude’s system prompt. This removes all default Claude Code instructions, giving you a blank slate.
    claude --system-prompt "You are a Python expert who only writes type-annotated code"
    
  • --system-prompt-file: use when you want to load a custom prompt from a file, useful for team consistency or version-controlled prompt templates.
    claude --system-prompt-file ./prompts/code-review.txt
    
  • --append-system-prompt: use when you want to add specific instructions while keeping Claude Code’s default capabilities intact. This is the safest option for most use cases.
    claude --append-system-prompt "Always use TypeScript and include JSDoc comments"
    
  • --append-system-prompt-file: use when you want to append instructions from a file while keeping Claude Code’s defaults. Useful for version-controlled additions.
    claude --append-system-prompt-file ./prompts/style-rules.txt
    
--system-prompt and --system-prompt-file are mutually exclusive. The append flags can be used together with either replacement flag. For most use cases, --append-system-prompt or --append-system-prompt-file is recommended as they preserve Claude Code’s built-in capabilities while adding your custom requirements. Use --system-prompt or --system-prompt-file only when you need complete control over the system prompt.

See also