Skip to main content

CLI Overview

claude is the command that starts Claude Code. Alone, it opens a chat in your terminal. With -p, it answers once and exits, which is how scripts and CI jobs use it. Flags change one run. Subcommands do separate jobs, such as sign-in, plugins, and background sessions.

At a Glance​

QuestionAnswer
Can you use it?✅ Yes. Run claude in a project folder.
Can you change it?✅ Yes. Add flags for one run, or set the same choice in a settings file or an environment variable.
Can you turn it on or off?Each flag is its own switch. A flag is on when you pass it, and some have a --no- twin, such as --no-chrome. Flags win over settings for that run. A subcommand runs only when you call it.
Where does it live?The claude program on your PATH. Run claude --help for the list.
StatusDocumented Undocumented

Example​

claude # chat
claude "explain this project" # chat with a first prompt
claude -p "list the TODOs" > todos.txt # one answer, then exit
git diff | claude -p "review this diff" # pipe in text

Ways to Start​

Source: the official CLI Reference and Run Claude Code Programmatically pages.

CommandStatusWhat it does
claudeDocumentedStarts an interactive session.
claude "query"DocumentedStarts an interactive session with a first prompt.
claude -p "query"DocumentedPrints one answer and exits, and it skips the trust dialog, so use it only in folders you trust.
cmd | claude -p "query"DocumentedPrints one answer for the text that you pipe in.
claude -c, claude -r "<session>"DocumentedContinues or resumes a session (see Sessions and Storage).
claude --bg "query"DocumentedStarts a background session, and claude agents lists the sessions.
claude --bareDocumentedStarts with no hooks, plugins, MCP servers, auto memory, or CLAUDE.md discovery, and sets CLAUDE_CODE_SIMPLE=1.
claude --safe-modeDocumentedStarts with all customizations off to debug a broken setup, and sets CLAUDE_CODE_SAFE_MODE=1.
claude --restrictedDocumentedRemoves the tools that run code, and ignores user, project, and local settings.
claude --cloud, --environment, --teleportDocumentedWork with cloud sessions.
warning

Print mode (-p) skips the trust dialog for the folder. Use it only in folders you trust. It also ignores settings files that fail validation, without any error.

Print mode runs once and prints the result. These flags shape its input and output. Some of them work only together, for example --include-partial-messages needs --output-format stream-json.

FlagStatusWhat it does
--output-format text|json|stream-jsonDocumentedjson gives one result object, and stream-json gives one JSON line for each event (see Stream JSON).
--input-format text|stream-jsonDocumentedstream-json reads JSON lines from stdin.
--include-partial-messages, --include-hook-events, --forward-subagent-text, --replay-user-messagesDocumentedAdd events to the stream, with stream-json only.
--json-schema <schema>DocumentedChecks the final answer against a JSON Schema.
--max-budget-usd <amount>DocumentedStops at a spend limit.
--max-turns <n>DocumentedStops after n agent turns, and the flag is hidden in --help.
--permission-prompts host|noneDocumentednone denies everything that would ask.
--permission-prompt-tool <tool>DocumentedLets an MCP tool answer permission prompts, and the flag is hidden in --help.
--no-session-persistenceDocumentedWrites no transcript.
--init, --init-only, --maintenanceDocumentedRun Setup hooks, and the flags are hidden in --help.

The result of --output-format json has a usage field. Its cache_creation part is split into ephemeral_1h_input_tokens and ephemeral_5m_input_tokens. Source: the official How Claude Code Uses Prompt Caching page.

How It Works​

Claude Code reads your flags first. A flag then wins over the same choice in an environment variable or a settings file, with a few exceptions that Environment Variables lists.

Source: the program (claude --help, 2.1.304).