Who this is for
People who already have Claude Code installed and want to start sessions, run one-off prompts from scripts, or control permissions and models from the command line. After reading, you can pick the right flag group for a task and know where to look when a flag is not in --help.
What it is
The command-line entry point is claude. Run with no arguments, it opens an interactive session. Add -p and it sends one query, prints the response and exits, which suits scripts and pipes.[1] Flags fall into groups by purpose: starting and resuming, permissions, models, output, budget and troubleshooting.
Setup
- Install Claude Code and confirm that
clauderuns in your terminal. - Sign in with
claude auth login. Add--consoleto sign in through Anthropic Console for API usage billing instead of a Claude subscription.[1] - Check the login with
claude auth status. It prints JSON by default; add--textfor readable output. It exits with code 0 when you are logged in and 1 when you are not, so a script can branch on the result.[1]
Starting and resuming
claudestarts an interactive session.[1]claude "query"starts one with an initial prompt, for exampleclaude "explain this project".[1]claude -p "query"sends one query and exits.[1]cat logs.txt | claude -p "explain"processes piped content.[1]claude -ccontinues the most recent conversation in the current directory.claude -r "<session>" "query"resumes a session by ID or name.[1]
Permissions and tools
These flags decide what Claude can do without asking, so read them carefully.
--permission-modestarts the session in a chosen mode:default,acceptEdits,plan,auto,dontAsk,bypassPermissionsormanual.[1]--dangerously-skip-permissionsskips permission prompts and is equivalent to--permission-mode bypassPermissions.[1]--allowedToolslists tools that run without a prompt, and accepts rules such as"Bash(git log *)".[1]--disallowedToolstakes deny rules. A bare tool name such asEditremoves that tool from Claude's context. A scoped rule such asBash(rm *)leaves the tool available and denies only the matching calls.[1]--toolsrestricts the built-in tools:""disables all of them,"default"selects the default set, and a list such as"Bash,Edit,Read"enables only the tools named.[1]
Models and effort
--modeltakes an alias such assonnet,opus,haikuorfable, or a full model name. It overrides both themodelsetting and theANTHROPIC_MODELenvironment variable.[1]--efforttakeslow,medium,high,xhigh,maxorultracode. Which levels are available depends on the model.[1]--fallback-modelswitches to the listed models, tried in order, when the primary model is overloaded or unavailable, for example a retired model. It takes a comma-separated list, such asclaude --fallback-model sonnet,haiku.[1]
Output, scripts and system prompts
--output-formatacceptstext,jsonorstream-jsonin print mode.[1]--bareskips auto-discovery of hooks, skills, plugins, MCP servers, auto memory and CLAUDE.md, so scripted calls start faster.[1]--system-promptreplaces the default system prompt, and--append-system-promptadds text to the end of it.[1]--mcp-configloads MCP servers from JSON files or strings.--strict-mcp-configskips servers configured elsewhere, such as.mcp.json, and loads only the ones passed with--mcp-config.[1]- The two append flags can be combined. In the example below, Claude receives the default system prompt, then the contents of
style.md, a blank line, and then the inline instruction.[1]
claude -p --append-system-prompt-file ./style.md --append-system-prompt "Always reply in French" "Summarize README.md"Budget
--max-budget-usd applies in print mode. It stops the run once estimated API spend reaches the amount, and spend from subagents counts toward the cap. The check uses Claude Code's client-side cost estimate, which can differ from your bill.[1]
Subcommands worth knowing
claude agentsopens agent view to watch and dispatch parallel background sessions. It needs an interactive terminal.claude agents --jsonprints the active sessions as a JSON array.[1]claude mcp login <name>runs an MCP server's OAuth flow. Over SSH, add--no-browserto print the authorization URL instead of opening a browser.[1]claude ultrareview [target]runs ultrareview non-interactively and prints findings to stdout.--jsonprints the raw payload, and--timeout <minutes>overrides the 45-minute default.[1]claude purge [path]deletes all local Claude Code state for a project, including transcripts and prompt history.--dry-runpreviews the result.[1]
Troubleshooting
- **A flag is missing from
--help:**claude --helpdoes not list every flag, so a flag that is absent from it may still be available.[1] - A subcommand is mistyped: Claude Code does not run it. It suggests the closest match and exits without starting a session;
claude udpateprintsDid you mean claude update?.[1] - The install or settings look wrong:
claude doctorprints read-only installation and settings diagnostics without starting a session. Inside a session,/doctorcan also apply fixes.[1] - A customization may be breaking things: start with
--safe-mode. CLAUDE.md, skills, plugins, hooks, MCP servers, custom commands and auto memory do not load, which helps isolate the cause.[1]
Next steps
For the full flag table and the Claude Code version each flag requires, use the official CLI reference.[1]
Sources
- 1CLI referenceAnthropic Claude Code docs
Cite this page: Claude Code CLI reference: commands and flags by task. TellWorld, https://www.tellworld.net/practice/practice-claude-code-cli-reference. Updated 2026-11-14