Claude Code CLI Flags Reference
Every claude CLI flag, searchable, with examples.
- $19 Free
- 30 sec
- No signup
Search the flag you need
See what it does + an example
Copy the assembled command
You get: A searchable CLI flag reference plus a copyable command.
Find a flag
Showing 21 of 21 flags. Always confirm against `claude --help` for your installed version.
claudeCoreStart an interactive Claude Code session in the current directory.
claude[prompt]CorePass an initial prompt as an argument to start the session with that instruction.
claude "explain this repo"-p, --printOutputPrint mode. Runs the prompt non-interactively, prints the response, and exits. Ideal for scripts and pipes.
claude -p "summarize README.md"--output-formatOutputSet the output format for print mode. Accepts text, json, or stream-json.
claude -p "list files" --output-format json--input-formatOutputSet the input format for print mode. Accepts text or stream-json for piping structured input.
cat data.json | claude -p --input-format stream-json-c, --continueSessionContinue the most recent conversation in the current directory.
claude -c-r, --resumeSessionResume a specific past session by picking it from a list (or by session id).
claude -r--modelCoreChoose the model for the session, such as a Sonnet, Opus, or Haiku alias.
claude --model sonnet--add-dirConfigAdd one or more extra working directories Claude Code is allowed to read and edit.
claude --add-dir ../shared-lib--permission-modePermissionsStart the session in a specific permission mode, such as plan mode for read-only planning.
claude --permission-mode plan--dangerously-skip-permissionsPermissionsSkip all permission prompts. High risk - only use in a sandboxed or throwaway environment you fully trust.
claude --dangerously-skip-permissions--allowedToolsPermissionsPre-approve a specific set of tools so the session does not prompt for them.
claude --allowedTools "Bash(git*)" "Edit"--disallowedToolsPermissionsBlock a specific set of tools for the session so they can never run.
claude --disallowedTools "Bash(rm*)"--mcp-configMCPLoad MCP servers from a specific JSON config file for this session.
claude --mcp-config ./mcp.jsonclaude mcpMCPManage MCP servers. Use subcommands like add, list, and remove to wire up integrations.
claude mcp listclaude configConfigRead and write Claude Code configuration values from the command line.
claude config listclaude updateCoreUpdate Claude Code to the latest available version.
claude updateclaude doctorCoreDiagnose your Claude Code installation and report common setup problems.
claude doctor--verboseOutputEnable verbose logging for the session, useful when debugging tool calls or MCP behavior.
claude --verbose--helpCoreShow the built-in help with the authoritative, up-to-date list of flags for your installed version.
claude --help--versionCorePrint the installed Claude Code version and exit.
claude --versionStop digging through --help every time
The Claude Code CLI is small on purpose, but the handful of flags it does expose change how a whole session behaves - which model you get, whether it asks permission, whether it runs once and exits or opens an interactive loop. Most people learn three flags and never discover the ones that would save them the most time. This reference puts the real, established flags in one searchable place with a working example for each, so you can build the exact command you need without leaving the page.
Every flag listed here is a stable, documented option. Where a detail is version-specific or could drift, this page deliberately points you back to `claude --help`, which is always the authoritative source for your installed version. The goal is a fast, accurate cheat sheet - not a guess.
The flags you will actually reach for
- -p / --print - run a prompt once, print the answer, and exit. This is the single most useful flag for scripting and CI, because it turns Claude Code into a normal command-line program you can pipe into and out of.
- -c / --continue and -r / --resume - pick up where you left off. --continue grabs the latest session in the current directory; --resume lets you choose from your history.
- --model - switch between Opus, Sonnet, and Haiku without leaving the terminal. Default to Sonnet, escalate to Opus for hard reasoning, drop to Haiku for cheap bulk work.
- --permission-mode - start in a specific safety posture, such as plan mode when you only want Claude to read and think before touching anything.
- --add-dir - grant access to sibling directories so Claude can work across a monorepo or a shared library without you copying files around.
Print mode is the power user's secret
The interactive session gets all the attention, but `claude -p` is where serious automation lives. Because it reads from stdin and writes to stdout, you can chain it into any pipeline: generate a commit message from a diff, summarize a log file, transform a data blob, or answer a question inside a shell script. Pair it with --output-format json when you need structured output that another program will parse, and --input-format stream-json when you are feeding structured input in.
One command, endless scripts
git diff | claude -p 'write a one-line commit message for this diff' turns Claude Code into a Unix citizen. Anything you can pipe, you can run through print mode.
Permission flags: convenience versus safety
The permission flags are the ones to understand before you use them. --allowedTools pre-approves a specific set of tools so a session runs without stopping to ask - great for trusted, repetitive work. --disallowedTools does the opposite, hard-blocking tools you never want to fire. And --dangerously-skip-permissions removes the safety net entirely. That last one is named the way it is for a reason: only use it inside a sandbox or a throwaway container where a mistaken command cannot hurt anything real.
- Prefer --permission-mode plan when you want Claude to investigate and propose without editing.
- Use --allowedTools to scope trust narrowly, like allowing only git commands.
- Reserve --dangerously-skip-permissions for disposable, isolated environments.
- Layer --disallowedTools on top to explicitly forbid destructive operations.
MCP and configuration from the command line
The `claude mcp` subcommands let you add, list, and remove MCP servers so Claude Code can talk to your databases, browsers, and internal tools. If you keep a per-project MCP setup, --mcp-config points the session at a specific JSON file. On the config side, `claude config` reads and writes settings without hand-editing files, and `claude doctor` diagnoses a broken install faster than trial and error. Every MCP server you load costs tokens on each turn, so keep the set lean.
How to keep this reference honest
Command-line tools evolve, and Claude Code ships often. Treat this page as a fast lookup, then trust `claude --help` and `claude --version` as the final word for whatever build you have installed. If a flag here behaves differently than described, your installed version is the source of truth - update with `claude update` and re-check the help output. That habit keeps you accurate and never caught out by a rename.
Frequently asked questions
Where does this flag list come from?
It is a conservative, hand-checked list of established Claude Code CLI options and subcommands. Uncertain or version-specific details are deliberately left out. The authoritative source for your build is always `claude --help`.
What is the difference between --continue and --resume?
--continue picks up the most recent conversation in the current directory automatically. --resume lets you choose which past session to reopen, which is handy when you juggle several threads in one project.
Is --dangerously-skip-permissions safe to use?
Only inside a sandbox or throwaway environment you fully trust. It removes every permission prompt, so a single wrong command can run unchecked. For normal work, use --permission-mode and --allowedTools instead.
How do I use Claude Code in a shell script?
Use print mode: claude -p 'your prompt'. It runs once, prints the answer, and exits, so it composes with pipes like any other CLI tool. Add --output-format json when another program needs to parse the result.
Can I switch models without restarting?
You can launch a session on a specific model with --model, and inside an interactive session you can change models with the /model command. Default to Sonnet and escalate to Opus only for genuinely hard reasoning.
Why does the page keep telling me to run claude --help?
Because it is the one source that is always correct for your exact installed version. This reference is a fast cheat sheet; --help is the ground truth. If anything conflicts, believe --help.
Liked this tool? The club is the next step.
Join Claude Code Club for $9/month. 650+ lessons, weekly updates, and the workflows behind every tool on this site.
- No experience needed
- Cancel anytime
- Updated weekly
