claude "explain this project"
claude -p "explain this function"
cat logs.txt | claude -p "explain"
claude -c -p "Check for type errors"
claude -r "auth-refactor" "Finish this PR"
--config pointing at a gateway.yaml.claude gateway --config gateway.yaml
2.1.118, or stable or latest. See Install a specific versionclaude install stable
--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 subscriptionclaude auth login --console
--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--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 terminalclaude agents --json
claude attach 7c5dcf5d
claude auto-mode config to see your effective config with settings applied. --label <prefix> prints only the rules whose label starts with that prefix, matched case-insensitively. Requires Claude Code v2.1.208 or laterclaude auto-mode defaults --label 'Git Destructive'
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 configclaude auto-mode reset --yes
~/.claude/daemon.log, printing new lines as they arrive until you press Ctrl+C--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 supervisorclaude daemon stop --any --keep-workers
/doctor/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 laterclaude import codex --dry-run
claude logs 7c5dcf5d
See the [Claude Code MCP documentation](https://code.claude.com/docs/en/mcp).
/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 lineclaude mcp login sentry
claude mcp logout sentry
claude plugins. See plugin reference for subcommandsclaude plugin install code-review@claude-plugins-official
~/.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 dataclaude purge ~/work/repo --dry-run
claude remote-control --name "My Project"
--all to restart every running session, e.g. to pick up an updated Claude Code binaryclaude respawn 7c5dcf5d
claude rm can resolve it, the refusal prints the exact flag and value to pass: --discard-unpushed <commit>@<worktree-id> discards a worktree that has unpushed commits along with those commits, and --force-remove-worktree <worktree-id> deletes a worktree directory that git or the WorktreeRemove hook couldn't remove. --discard-unpushed requires Claude Code v2.1.260 or later, and --force-remove-worktree requires v2.1.268 or later. The conversation transcript stays on your local machine, available through claude --resumeclaude rm 7c5dcf5d
claude self-hosted-runner setup for a guided operator walkthrough, claude self-hosted-runner doctor to diagnose a deployed runner, and claude self-hosted-runner orchestrator to spawn on-demand runners. Requires Claude Code v2.1.224 or laterclaude self-hosted-runner setup
claude killclaude stop 7c5dcf5d
--json for the raw payload and --timeout <minutes> to override the 45-minute default. Use --post on a github.com pull request target to post the finished findings to the PR as one plain comment from your GitHub account. --no-post is the default. --post and --no-post require Claude Code v2.1.227 or later. See Post findings to the pull requestclaude ultrareview 1234 --json
.claude/ configuration from these directories. Validates that each path exists as a directory. You can't add most network paths, such as \\server\share. To persist these directories across sessions, set permissions.additionalDirectories in settingsclaude --add-dir ../apps ../lib
fable, opus, or sonnet, or a full model ID. Takes precedence over the advisorModel setting for the session. fable requires Fable accessclaude --advisor opus
agent setting)claude --agent my-custom-agent
--print, the value can instead be the path to a JSON file holding the object; the file form requires Claude Code v2.1.281 or later. Claude Code validates the value at startup and exits on an invalid one; see Invalid --agents configuration for the message and for the flags and environment variable that skip the validation. Validation requires Claude Code v2.1.242 or laterclaude --agents '{"reviewer":{"description":"Reviews code","prompt":"You are a code reviewer"}}'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 modesclaude --permission-mode plan --allow-dangerously-skip-permissions
--tools instead. If you name one of the task-tracking tools here, Claude Code also opts the session in"Bash(git log *)" "Bash(git diff *)" "Read"
-p. Requires Claude Code v2.1.205 or laterclaude -p --append-subagent-system-prompt "Cite file paths in every answer" "query"
--append-subagent-system-prompt for text too long to pass on the command line. The two flags can't be combined. Only applies in non-interactive mode with -p. Requires Claude Code v2.1.261 or laterclaude -p --append-subagent-system-prompt-file ./subagent-rules.txt "query"
claude --append-system-prompt "Always use TypeScript"
claude --append-system-prompt-file ./extra-rules.txt
/autocompact; that section covers the value forms and what overrides the flag. Requires Claude Code v2.1.221 or laterclaude --autocompact 500k
tui setting has no effect; attached background sessions still render fullscreen. Takes precedence over CLAUDE_AX_SCREEN_READER and the axScreenReader setting. Requires Claude Code v2.1.181 or laterclaude --ax-screen-reader
--add-dir still load. Claude has access to Bash, file read, and file edit tools. Sets CLAUDE_CODE_SIMPLE. See bare modeclaude --bare -p "query"
claude --betas interleaved-thinking
--exec to run a shell command as a background job instead of a Claude session, or with --agent to run a specific subagent. Checks workspace trust for the directory before it starts. Can't be combined with -p/--print; see the error referenceclaude --bg "investigate the flaky test"
plugin:<name>@<marketplace> entries. Requires Anthropic authentication through claude.ai or a Console API keyclaude --channels plugin:my-notifier@my-marketplace
claude --chrome
session_... or cse_...) or a claude.ai/code URL, queue a message into that existing session instead, with -p. See send a follow-up message.claude --cloud "Fix the login bug"
claude -p or the Agent SDK, and sessions whose first prompt was /loop. claude -p --continue includes -p, SDK, and /loop sessions. Includes sessions that added this directory with /add-dirclaude --continue
plugin:<name>@<marketplace> and server:<name> entries. Prompts for confirmation, so it takes effect in interactive sessions. With -p, Claude Code ignores the flagclaude --dangerously-load-development-channels server:webhook
--permission-mode bypassPermissions. See permission modes for what this does and does not skip. For sessions started with --bg, the mode persists when the supervisor restarts the sessionclaude --dangerously-skip-permissions
--debug='mcp,startup' or --debug='!mcp'. The filter binds only in the = form; a space-separated filter enables debug mode without filteringclaude --debug='mcp,startup'
CLAUDE_CODE_DEBUG_LOGS_DIRclaude --debug-file /tmp/claude-debug.log
--continue, or --resume with a session ID, to open that session in Desktop instead. --resume here takes only a session ID, not a name or transcript path. Takes no prompt and no other flags except --verbose and the --debug flags, since the app starts the session itself. Available on macOS and x64 Windows when you're signed in with a Claude subscription. Requires Claude Code v2.1.285 or laterclaude --desktop
claude --disable-slash-commands
"Edit" removes Edit, "*" removes every tool, and "mcp__*" removes every MCP tool. A scoped rule such as Bash(rm *) leaves the tool available and denies only calls that match as written. A rule naming EndConversation can't remove it while any other tool remains"Bash(git log *)" "Bash(git diff *)" "Edit"
low, medium, high, xhigh, max, or ultracode. Available levels depend on the model. ultracode requests xhigh effort with ultracode turned on, and requires Claude Code v2.1.203 or later. On the main conversation's model, overrides the modelSettings and effortLevel settings for this session and doesn't persistclaude --effort high
Shift+Tab cycle by default; use --permission-mode auto to start in itclaude --permission-mode auto
ccpool_. See --environment dispatch behavior for dispatch behavior and the flag combinations it rejects. Requires Claude Code v2.1.224 or laterclaude -p "Fix the login bug" --environment ccpool_abc123
--system-prompt or --system-prompt-file is set. Use with -p for scripted, multi-user workloadsclaude -p --exclude-dynamic-system-prompt-sections "query"
--bg to launch from the shellclaude --bg --exec 'pytest -x'
fallbackModel setting, which this flag overridesclaude --fallback-model sonnet,haiku
--resume or --continue)claude --resume abc123 --fork-session
assistant and user messages with parent_tool_use_id set, so you can reconstruct each subagent's transcript. Without this flag, Claude Code omits the text and thinking blocks of a subagent that runs in the foreground. Requires --print and --output-format stream-json. For nested subagents, forked skills, and the version each needs, see Follow subagent messages. The CLAUDE_CODE_FORWARD_SUBAGENT_TEXT environment variable enables the same behavior. Requires Claude Code v2.1.211 or laterclaude -p --output-format stream-json --verbose --forward-subagent-text "query"
claude --from-pr 123
claude --ide
init matcher before the session (print mode only)claude -p --init "query"
SessionStart hooks, then exit without starting a conversationclaude --init-only
SessionStart and Setup hook events are always included and don't need this flag. Some hook events, such as Notification, SessionEnd, PreCompact, and PostCompact, never produce a hook_started event, even with this flag. For those events, Claude Code still emits hook_progress while a command hook that runs for more than a second produces output, and emits hook_response only when a hook that runs in the background finishes. Requires --output-format stream-jsonclaude -p --output-format stream-json --verbose --include-hook-events "query"
--print and --output-format stream-jsonclaude -p --output-format stream-json --verbose --include-partial-messages "query"
text, stream-json)claude -p --input-format stream-json --output-format stream-json --verbose
format keyword as an annotation without client-side validationclaude -p --json-schema '{"type":"object","properties":{...}}' "query"maintenance matcher before the session (print mode only)claude -p --maintenance "query"
--continue or --resume, totals restored from earlier runs don't count toward it. Once spend reaches the cap, spawning another subagent fails with Budget limit reached, and Claude Code stops background subagents that are still running; the cap-enforcement behaviors require Claude Code v2.1.217 or laterclaude -p --max-budget-usd 5.00 "query"
--input-format stream-json, a message still queued when the limit ends a turn stays queued and starts a new turn with its own limitclaude -p --max-turns 3 "query"
-p, Claude Code waits for still-pending servers to connect before running the first turn, up to the MCP_TIMEOUT startup timeout, 30 seconds by default; a server with a cached tool list skips the wait and connects on first use. In a self-hosted environment, a shorter wait applies instead. The wait requires Claude Code v2.1.221 or laterclaude --mcp-config ./mcp.json
sonnet, opus, haiku, or fable, or a model's full name. Overrides the model setting and ANTHROPIC_MODELclaude --model claude-sonnet-5
/resume and the terminal title. You can resume a named session with claude --resume <name>. /rename changes the name mid-session and also shows it on the prompt barclaude -n "my-feature-work"
claude --no-chrome
CLAUDE_CODE_SKIP_PROMPT_HISTORY environment variable does the same in any modeclaude -p --no-session-persistence "query"
text, json, stream-json)claude -p "query" --output-format json
default, acceptEdits, plan, auto, dontAsk, bypassPermissions, or manual as an alias for default. The manual alias selects the permission mode the UI labels Manual and requires Claude Code v2.1.200 or later; claude --help lists it in place of default, and both values work. Overrides defaultMode from settings files. Without this flag or --dangerously-skip-permissions, a new session starts in the permission mode described in which permission mode a session starts in, which also covers what a -p run starts inclaude --permission-mode plan
mcp__<server>__<tool>, of a tool on an MCP server that the run loads. Claude Code waits for that tool's MCP server to connect before running the first turn, up to the MCP_TIMEOUT startup timeout, 30 seconds by default. The prompt tool can't approve an MCP tool marked as requiring user interaction: Claude Code converts an allow result for one to a deny. This restriction requires Claude Code v2.1.199 or laterclaude -p --mcp-config ./mcp.json --permission-prompt-tool mcp__permissions__approve "query"
host, Claude Code sends them to the Agent SDK host or the --permission-prompt-tool tool. Pass none when nobody can answer, and Claude Code denies them instead. See Turn off permission prompts in unattended runs. Requires Claude Code v2.1.259 or laterclaude -p --permission-prompts none "query"
.zip archive, or several from a folder of plugins, for this session only. Each flag takes one path. Repeat the flag for more paths: --plugin-dir A --plugin-dir B.zip. Passing a folder of plugins requires Claude Code v2.1.265 or laterclaude --plugin-dir ./my-plugin
.zip archive from a URL for this session only. Repeat the flag for multiple plugins, or pass space-separated URLs in a single quoted valueclaude --plugin-url https://example.com/plugin.zip
--resume on a background session that is still running, see Resume a running background sessionclaude -p "query"
prompt_suggestion message with a predicted next user prompt after each turn that generates one; very short conversations can produce none. Requires --print, --output-format stream-json, and --verbose. See Prompt suggestionsclaude -p --prompt-suggestions --output-format stream-json --verbose "query"
--environment, base the new session's checkout on a named ref instead of local HEADclaude -p "Run the smoke test" --environment ccpool_abc123 --ref main
--cloud, including the existing-session formclaude --remote "Fix the login bug"
claude --remote-control "My Project"
myhost-graceful-unicorn. Set CLAUDE_REMOTE_CONTROL_SESSION_NAME_PREFIX for the same effectclaude remote-control --remote-control-session-name-prefix dev-box
--input-format stream-json and --output-format stream-jsonclaude -p --input-format stream-json --output-format stream-json --verbose --replay-user-messages
claude on a shared machine and Claude Code must not run commands or read that machine's user and project settings. Claude Code removes the built-in tools that run commands or code, and WebFetch, unless you name them individually in --tools, not through the default preset. It also confines the built-in file tools to the working directories, loads only managed settings and --settings, refuses bypassPermissions, and refuses to create cloud sessions. Requires Claude Code v2.1.248 or laterclaude --restricted -p "query"
.jsonl transcript file. The picker and name search include sessions that added this directory with /add-dir. When you pass a session ID, Claude Code searches the current project directory and its git worktrees, then every other project on this machine. Before v2.1.223, the ID search covered only the current project directory and its git worktrees. Background sessions appear in the picker marked with bg. Resuming one that is still running opens that session in this terminal through claude attach, and a prompt you pass on the command line goes to it as its next turn. Before v2.1.285, Claude Code refused and printed the claude attach command to run insteadclaude --resume auth-refactor
--bare. Managed settings policy still applies, including policy-configured hooks, status line, and file-suggestion commands; managed plugins, managed skills, managed CLAUDE.md, and policy-configured MCP servers do not. Useful for checking whether a customization is what triggers automatic model fallback. Sets CLAUDE_CODE_SAFE_MODEclaude --safe-mode
claude --session-id "550e8400-e29b-41d4-a716-446655440000"
user, project, local). See agent view and agent teams for the sessions you start from this one that inherit the listclaude --setting-sources user,project
settings.json files for this session. Keys you omit keep their file-based values. The file must be a regular file no larger than 2 MiB. See settings precedenceclaude --settings ./settings.json
--mcp-config, ignoring all other MCP configurations. See Exclusive control with managed-mcp.json for what the flag does under a managed MCP fileclaude --strict-mcp-config --mcp-config ./mcp.json
claude --system-prompt "You are a Python expert"
claude --system-prompt-file ./custom-prompt.txt
off to rebuild the system prompt on every request instead of reusing the prompt recorded on the conversation's first request, for example while you iterate on --append-system-prompt text across --continue runs. Requires Claude Code v2.1.257 or laterclaude --system-prompt-snapshot off
claude --teleport
in-process (default), auto, tmux, or iterm2. Overrides the teammateMode setting for this session. See Choose a display modeclaude --teammate-mode auto
--worktree. Uses iTerm2 native panes when available; pass --tmux=classic for traditional tmuxclaude -w feature-auth --tmux
"" to disable all, "default" for the default set, or tool names like "Bash,Edit,Read". On macOS, Linux, and WSL, the default set leaves out Glob and Grep, as described under Glob tool behavior. If you name one of the task-tracking tools here, Claude Code also opts the session in. The flag doesn't affect MCP tools; to deny those too, use --disallowedTools "mcp__*". A list that omits EndConversation doesn't remove it; "" removes it only when no MCP tools remainclaude --tools "Bash,Edit,Read"
viewMode setting for this sessionclaude --verbose
claude -v
<repo>/.claude/worktrees/<name>. If you don't give a name, Claude Code generates one. Pass #<number>, a GitHub pull request URL, or a GitLab merge request URL to fetch that PR or MR from origin and branch the worktree from it. Branching from a GitLab merge request requires Claude Code v2.1.233 or laterclaude -w feature-auth
claude --system-prompt "You are a Python expert"
claude --system-prompt-file ./prompts/review.txt
claude --append-system-prompt "Always use TypeScript"
claude --append-system-prompt-file ./style-rules.txt
off, rebuilds the prompt on every request. With on, the default, reuses a recorded prompt where recording appliesclaude --append-system-prompt "Draft rules" --system-prompt-snapshot off
Most-used flags
-p/--print: run once and print the answer. The basis of every script and CI job.-c/--continueand-r/--resume: pick up where you left off.--model: choose the model for this session.--permission-mode,--allowedTools,--disallowedTools: control what runs without asking. Test rules with the permission rule tester.--append-system-prompt: add instructions without replacing Claude Code's own system prompt.
Frequently asked questions
How do I run Claude Code non-interactively?
Use print mode: claude -p "your prompt". It runs the task, prints the result and exits, which suits scripts and CI. Add --output-format json or stream-json for machine-readable output, and --allowedTools to pre-approve the tools it needs.
How do I resume a previous Claude Code session?
claude -c (or --continue) reopens the most recent conversation in the current directory. claude -r (or --resume) opens a picker, or takes a session ID or name to resume a specific one.
What does --dangerously-skip-permissions do?
It starts Claude Code in bypassPermissions mode, which skips permission prompts except for a few protected actions. Only use it in an isolated container or VM, never on a machine with credentials or data you care about.
How do I pick a model from the command line?
Pass --model with an alias (opus, sonnet, haiku, fable) or a full model ID such as claude-opus-5-5. You can also set ANTHROPIC_MODEL or the model key in settings.json.
Sources: Claude Code CLI reference. Claude Code Agents is an independent site, not affiliated with Anthropic.