CLI reference - Claude Code Docs
Documentation Index Fetch the complete documentation index at: /docs/llms.txt Use this file to discover all available pages before exploring further. Skip to main content Assistant Responses are generated using AI and may contain mistakes. 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 cat logs.txt | claude -p "explain" 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 gateway Start the self-hosted Claude apps gateway server, for administrators deploying SSO and policy in front of Claude Code on Amazon Bedrock, Google Cloud’s Agent Platform, or Microsoft Foundry.
Requires --config pointing at a gateway.yaml . claude gateway --config gateway.yaml 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.
If managed settings require a Claude apps gateway sign-in, run the command with no flags in a terminal, on v2.1.316 or later. If the command points you to /login , run that inside claude 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.
The JSON includes a configDirectory field naming the configuration directory the CLI uses. The field requires Claude Code v2.1.268 or later. The JSON’s authMethod field is one of none , claude.ai , oauth_token , api_key , api_key_helper , or third_party claude auth status claude agents Open agent view to monitor and dispatch parallel background sessions. Use --cwd <path> to show only sessions started under that directory, or --json to print active sessions as a JSON array for scripting ( --json --all also includes completed background sessions).
Pass --permission-mode , --model , --effort , or --agent to set defaults for dispatched sessions . Accepts --settings , --add-dir , --plugin-dir , and --mcp-config like the top-level claude command. Opening agent view requires an interactive terminal claude agents --json claude attach <id|name> Attach to a background session in this terminal. Passing part of a running session’s name in place of the ID requires Claude Code v2.1.290 or later claude attach 7c5dcf5d claude auto-mode defaults Print the auto mode classifier rules built into Claude Code as JSON.
Use claude auto-mode config to see those rules with your settings applied. --label <prefix> prints only the rules whose label starts with that prefix, matched case-insensitively. Requires Claude Code v2.1.208 or later claude auto-mode defaults --label 'Git Destructive' claude auto-mode reset Restore the default auto mode configuration by removing the autoMode section from your user settings file. Prompts for confirmation before writing; pass -y / --yes to skip the prompt.
Rules from managed settings or the --settings flag still apply. Requires Claude Code v2.1.212 or later. See Inspect the defaults and your effective config claude auto-mode reset --yes claude daemon logs Follow the background-session supervisor’s log file, ~/.claude/daemon.log , printing new lines as they arrive until you press Ctrl+C claude daemon logs claude daemon run Run the background-session supervisor in the foreground of this terminal, printing its log claude daemon run claude daemon status Print the background-session supervisor’s state, version, socket directory, and worker count for diagnostics.
Exits 1 if the supervisor isn’t running claude daemon status claude daemon stop --any Stop the background-session supervisor and the sessions it hosts. Pass --keep-workers to leave background sessions running for the next supervisor to reconnect to. --any confirms stopping an on-demand supervisor, which is the default. Use this to recover from an unresponsive supervisor claude daemon stop --any --keep-workers claude doctor Print read-only installation and settings diagnostics from the terminal without starting a session, including install health, settings-file validation errors, and Remote Control eligibility.
For the in-session setup checkup that can also apply fixes, run /doctor claude doctor claude import [source] Start an interactive session that runs /import to bring configuration from other coding agents into Claude Code. Accepts the same --dry-run and --yes options as the command. Not available on Amazon Bedrock, Google Cloud’s Agent Platform, Microsoft Foundry, or Claude Platform on AWS. Also unavailable when you turn off feature-flag fetching .
Requires Claude Code v2.1.213 or later claude import codex --dry-run claude logs <id|name> Print recent output from a background session . Passing part of a session’s name in place of the ID requires Claude Code v2.1.290 or later claude logs 7c5dcf5d claude mcp Configure Model Context Protocol (MCP) servers See the Claude Code MCP documentation . claude mcp login <name> Run a configured MCP server’s OAuth flow without opening the interactive /mcp panel.
Works for HTTP, SSE, and claude.ai connector servers. Add --no-browser over SSH to print the authorization URL instead of opening a browser. For an HTTP or SSE server, paste the redirect URL back at the prompt. For a claude.ai connector, see Authorize a connector again from your shell . See Authenticate from the command line claude mcp login sentry claude mcp logout <name> Clear stored OAuth credentials for an MCP server claude mcp logout sentry claude plugin Manage Claude Code plugins .
Alias: claude plugins . See plugin reference for subcommands claude plugin install code-review@claude-plugins-official claude purge [path] Delete all local Claude Code state for a project: transcripts, task lists, debug logs, file-edit history, prompt history lines, and the project’s entry in ~/.claude.json . Omit [path] to pick from an interactive list. Flags: --dry-run to preview, -y / --yes to skip confirmation, -i / --interactive to confirm each item, --all for every project.
See Clear local data claude purge ~/work/repo --dry-run claude remote-control Start a Remote Control server to control Claude Code from claude.ai or the Claude app. Alias: claude rc . Runs in server mode (no local interactive session). See Server mode flags . After you stop the server, you can bring back the sessions it was serving. See Resume sessions after stopping the server claude remote-control --name "My Project" claude respawn <id> Restart a background session , running or stopped, with its conversation intact.
Use --all to restart every running session, e.g. to pick up an updated Claude Code binary claude respawn 7c5dcf5d claude rm <id> Remove a background session from the list. If Claude Code refuses to delete the session because of its worktree, see Delete a session after Claude Code refuses . The conversation transcript stays on your local machine, available through claude --resume claude rm 7c5dcf5d claude self-hosted-runner Start a runner process that registers this machine or container with a self-hosted environment and hosts Claude Code cloud sessions on your infrastructure.
Run claude self-hosted-runner setup for a guided operator wal
The rest of this page is on the live site.