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. Scripts and CI jobs use it this way.
Flags change one run. Subcommands do separate jobs, such as sign-in, plugins, and background sessions.
The claude program is on your PATH. Run it in a project folder. Run claude --help for the list.
Each flag is its own switch. A flag is on when you pass it. Some flags have a --no- twin, such as --no-chrome.
You can also set the same choice in a settings file or an environment variable. A subcommand runs only when you call it.
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.
| Command | Status | What it does |
|---|---|---|
claude | Documented: An official docs page names this item. | Starts an interactive session. |
claude "query" | Documented: An official docs page names this item. | Starts an interactive session with a first prompt. |
claude - | Documented: An official docs page names this item. | Prints one answer and exits. It skips the trust dialog. Use it only in folders you trust. |
cmd | claude - | Documented: An official docs page names this item. | Prints one answer for the text that you pipe in. |
claude -, claude - | Documented: An official docs page names this item. | Continues or resumes a session (see Sessions and Storage). |
claude -- | Documented: An official docs page names this item. | Starts a background session. claude agents lists the sessions. |
claude -- | Documented: An official docs page names this item. | Starts with no hooks, plugins, MCP servers, auto memory, or CLAUDE. discovery. It sets CLAUDE_. |
claude -- | Documented: An official docs page names this item. | Starts with all customizations off to debug a broken setup. It sets CLAUDE_. |
claude -- | Documented: An official docs page names this item. | Removes the tools that run code. It also ignores user, project, and local settings. |
claude --, --, -- | Documented: An official docs page names this item. | Work with cloud sessions. |
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 Flags
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.
| Flag | Status | What it does |
|---|---|---|
-- | Documented: An official docs page names this item. | json gives one result object. stream- gives one JSON line for each event (see Stream JSON). |
-- | Documented: An official docs page names this item. | stream- reads JSON lines from stdin. |
--, --, --, -- | Documented: An official docs page names this item. | Add events to the stream, with stream- only. |
-- | Documented: An official docs page names this item. | Checks the final answer against a JSON Schema. |
-- | Documented: An official docs page names this item. | Stops at a spend limit. |
-- | Documented: An official docs page names this item. | Stops after n agent turns. -- hides the flag. |
-- | Documented: An official docs page names this item. | none denies everything that would ask. |
-- | Documented: An official docs page names this item. | Lets an MCP tool answer permission prompts. -- hides the flag. |
-- | Documented: An official docs page names this item. | Writes no transcript. |
--, --, -- | Documented: An official docs page names this item. | Run Setup hooks. -- hides the flags. |
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, There are a few exceptions. Environment Variables lists them.
Source: the program (claude --help, 2.1.312).
Related Pages
- All Flags lists every flag, including the hidden ones.
- Subcommands lists every
claude <command>. - Environment Variables holds the variables that match many flags.
- Permissions explains
--permission-modeand the tool allow lists. - Sessions and Storage explains
-cand-r. - The Agent Loop shows what runs after startup.