Skip to content

CLI Reference

A practical reference for Claude Code CLI usage: common commands, key flags, and system-prompt-related advanced switches. For the canonical list, run claude --help on your machine.

Common commands

CommandDescriptionExample
claudeStart an interactive session (REPL)claude
claude "query"Start a session with an initial promptclaude "Explain this repo structure"
claude -p "query"Print/Headless mode: write to stdout then exitclaude -p "Explain this function"
cat file | claude -p "query"Process piped inputcat logs.txt | claude -p "Explain this error"
claude -cContinue the most recent session in current dirclaude -c
claude -r "<session>" "query"Resume by session name/IDclaude -r "auth-refactor" "Continue this PR"
claude updateUpdate to the latest versionclaude update
claude mcpConfigure MCP serversclaude mcp

Common flags (selected)

FlagMeaning
--print, -pPrint/Headless mode (scripting/CI)
--output-formatPrint output format: text / json / stream-json
--input-formatPrint input format: text / stream-json
--continue, -cContinue the latest session
--resume, -rResume a specific session (or open a picker)
--fork-sessionWhen resuming, create a new session (don’t overwrite)
--session-idSet a session ID (UUID)
--no-session-persistencePrint mode: don’t write session state to disk
--modelChoose a model (supports aliases like sonnet / opus)
--agentChoose an agent (override settings agent)
--agentsDefine subagents dynamically via JSON
--permission-modeStart with a permission mode
--allowedTools / --disallowedToolsConfigure tool allow/deny rules
--toolsRestrict which built-in tools are available
--dangerously-skip-permissionsSkip all permission prompts (high risk)
--allow-dangerously-skip-permissionsAllow offering the bypass option (does not enable it)
--append-system-promptAppend to the default system prompt
--append-system-prompt-fileAppend system prompt from a file (Print only)
--system-promptReplace the full system prompt (removes defaults)
--system-prompt-fileReplace system prompt from a file (Print only)
--verboseMore detailed turn-by-turn logs
--version, -vPrint version
--allowedTools uses the same syntax as settings.json permissions. Read the permissions syntax section in the Settings reference—don’t assume Bash(*) means “match all Bash”.

System prompt flags (four variants)

These look similar but mean different things:

FlagBehaviorMode
--system-promptReplace the default system promptInteractive + Print
--system-prompt-fileReplace from a filePrint
--append-system-promptAppend after the default promptInteractive + Print
--append-system-prompt-fileAppend from a filePrint

Prefer the two append variants: they preserve Claude Code default capabilities while layering team rules.

--system-prompt and --system-prompt-file are mutually exclusive; append flags can be combined with replacement flags.

--agents (subagents) format

--agents accepts a JSON object: keys are agent names; values include description, prompt, and optional tools, model, etc.

claude --agents '{
  "code-reviewer": {
    "description": "Code review with focus on quality/security/best practices",
    "prompt": "You are a senior code reviewer. Focus on code quality, security, and best practices.",
    "tools": ["Read", "Grep", "Glob", "Bash"],
    "model": "sonnet"
  }
}'

Next steps