CLI commands

CommandDescriptionExample
claudeStart interactive REPLclaude
claude "query"Start REPL with initial promptclaude "explain this project"
claude -p "query"Query via SDK, then exitclaude -p "explain this function"
cat file | claude -p "query"Process piped contentcat logs.txt | claude -p "explain"
claude -cContinue most recent conversationclaude -c
claude -c -p "query"Continue via SDKclaude -c -p "Check for type errors"
claude -r "<session-id>" "query"Resume session by IDclaude -r "abc123" "Finish this PR"
claude updateUpdate to latest versionclaude update
claude mcpConfigure Model Context Protocol (MCP) serversSee the Claude Code MCP documentation.

CLI flags

Customize Claude Code’s behavior with these command-line flags:

FlagDescriptionExample
--add-dirAdd additional working directories for Claude to access (validates each path exists as a directory)claude --add-dir ../apps ../lib
--allowedToolsA list of tools that should be allowed without prompting the user for permission, in addition to settings.json files"Bash(git log:*)" "Bash(git diff:*)" "Read"
--disallowedToolsA list of tools that should be disallowed without prompting the user for permission, in addition to settings.json files"Bash(git log:*)" "Bash(git diff:*)" "Edit"
--print, -pPrint response without interactive mode (see SDK documentation for programmatic usage details)claude -p "query"
--output-formatSpecify output format for print mode (options: text, json, stream-json)claude -p "query" --output-format json
--input-formatSpecify input format for print mode (options: text, stream-json)claude -p --output-format json --input-format stream-json
--verboseEnable verbose logging, shows full turn-by-turn output (helpful for debugging in both print and interactive modes)claude --verbose
--max-turnsLimit the number of agentic turns in non-interactive modeclaude -p --max-turns 3 "query"
--modelSets the model for the current session with an alias for the latest model (sonnet or opus) or a model’s full nameclaude --model claude-sonnet-4-20250514
--permission-modeBegin in a specified permission modeclaude --permission-mode plan
--permission-prompt-toolSpecify an MCP tool to handle permission prompts in non-interactive modeclaude -p --permission-prompt-tool mcp_auth_tool "query"
--resumeResume a specific session by ID, or by choosing in interactive modeclaude --resume abc123 "query"
--continueLoad the most recent conversation in the current directoryclaude --continue
--dangerously-skip-permissionsSkip permission prompts (use with caution)claude --dangerously-skip-permissions

The --output-format json flag is particularly useful for scripting and automation, allowing you to parse Claude’s responses programmatically.

For detailed information about print mode (-p) including output formats, streaming, verbose logging, and programmatic usage, see the SDK documentation.

See also