CLI reference
> ## Documentation Index > Fetch the complete documentation index at: https://code.claude.com/docs/llms.txt > Use this file to discover all available pages before exploring further.
Overview
Documentation Index
Fetch the complete documentation index at: https://code.claude.com/docs/llms.txt Use this file to discover all available pages before exploring further.
CLI reference
Complete reference for Claude Code command-line interface, including commands and flags.
CLI commands
You can start sessions, pipe content, resume conversations, and manage updates with these commands:
| Command | Description | Example |
|---|---|---|
claude | Start interactive session | claude |
claude "query" | Start interactive session with initial prompt | claude "explain this project" |
claude -p "query" | Query via SDK, then exit | claude -p "explain this function" |
| `cat file \ | claude -p "query"` | Process piped content |
claude -c | Continue most recent conversation in current directory | claude -c |
claude -c -p "query" | Continue via SDK | claude -c -p "Check for type errors" |
claude -r "<session>" "query" | Resume session by ID or name | claude -r "auth-refactor" "Finish this PR" |
claude update | Update to latest version | claude update |
claude install [version] | Install or reinstall the native binary. Accepts a version like 2.1.118, or stable or latest. See Install a specific version | claude install stable |
claude auth login | Sign in to your Anthropic account. Use --email to pre-fill your email address, --sso to force SSO authentication, and --console to sign in with Anthropic Console for API usage billing instead of a Claude subscription | claude auth login --console |
claude auth logout | Log out from your Anthropic account | claude auth logout |
claude auth status | Show authentication status as JSON. Use --text for human-readable output. Exits with code 0 if logged in, 1 if not | claude auth status |
claude agents | List all configured subagents, grouped by source | claude agents |
claude auto-mode defaults | Print the built-in auto mode classifier rules as JSON. Use claude auto-mode config to see your effective config with settings applied | claude auto-mode defaults > rules.json |
claude mcp | Configure Model Context Protocol (MCP) servers | See the Claude Code MCP documentation. |
claude plugin | Manage Claude Code plugins. Alias: claude plugins. See plugin reference for subcommands | claude plugin install code-review@claude-plugins-official |
claude remote-control | Start a Remote Control server to control Claude Code from Claude.ai or the Claude app. Runs in server mode (no local interactive session). See Server mode flags | claude remote-control --name "My Project" |
claude setup-token | Generate a long-lived OAuth token for CI and scripts. Prints the token to the terminal without saving it. Requires a Claude subscription. See Generate a long-lived token | claude setup-token |
If you mistype a subcommand, Claude Code suggests the closest match and exits without starting a session. For example, claude udpate prints Did you mean claude update?.
CLI flags
Customize Claude Code's behavior with these command-line flags. claude --help does not list every flag, so a flag's absence from --help does not mean it is unavailable.
| Flag | Description | Example |
|---|---|---|
--add-dir | Add additional working directories for Claude to read and edit files. Grants file access; most .claude/ configuration is not discovered from these directories. Validates each path exists as a directory | claude --add-dir ../apps ../lib |
--agent | Specify an agent for the current session (overrides the agent setting) | claude --agent my-custom-agent |
--agents | Define custom subagents dynamically via JSON. Uses the same field names as subagent frontmatter, plus a prompt field for the agent's instructions | claude --agents '{"reviewer":{"description":"Reviews code","prompt":"You are a code reviewer"}}' |
--allow-dangerously-skip-permissions | Add bypassPermissions to the Shift+Tab mode cycle without starting in it. Lets you begin in a different mode like plan and switch to bypassPermissions later. See permission modes | claude --permission-mode plan --allow-dangerously-skip-permissions |
--allowedTools | Tools 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-prompt | Append custom text to the end of the default system prompt | claude --append-system-prompt "Always use TypeScript" |
--append-system-prompt-file | Load additional system prompt text from a file and append to the default prompt | claude --append-system-prompt-file ./extra-rules.txt |
--bare | Minimal mode: skip auto-discovery of hooks, skills, plugins, MCP servers, auto memory, and CLAUDE.md so scripted calls start faster. Claude has access to Bash, file read, and file edit tools. Sets CLAUDE_CODE_SIMPLE. See bare mode | claude --bare -p "query" |
--betas | Beta headers to include in API requests (API key users only) | claude --betas interleaved-thinking |
--channels | (Research preview) MCP servers whose channel notifications Claude should listen for in this session. Space-separated list of plugin:<name>@<marketplace> entries. Requires Claude.ai authentication | claude --channels plugin:my-notifier@my-marketplace |
--chrome | Enable Chrome browser integration for web automation and testing | claude --chrome |
--continue, -c | Load the most recent conversation in the current directory. Includes sessions that added this directory with /add-dir | `claud |