Non-interactive Mode
Use non-interactive mode when you want Claude Code to run from a shell command instead of an interactive session.
One-off prompt
Section titled “One-off prompt”claude -p "Explain what this project does"JSON output
Section titled “JSON output”claude -p "List all API endpoints" --output-format jsonStreaming JSON
Section titled “Streaming JSON”claude -p "Analyze this log file" --output-format stream-json --verboseAdd --include-partial-messages to receive tokens as they are generated instead of whole messages.
Good use cases
Section titled “Good use cases”- CI checks.
- Pre-commit hooks.
- Repo analysis scripts.
- Batch summarization.
- Structured extraction into another command.
Production guidance
Section titled “Production guidance”For CI and scripts, add --bare. It skips auto-discovery of hooks, skills, custom commands, subagents, plugins, MCP servers, auto memory, and CLAUDE.md, so the run starts faster and behaves the same on every machine. The docs call it the recommended mode for scripted calls and say it will become the default for -p in a future release.
claude --bare -p "Summarize README.md" --allowedTools "Read"Bare mode does not use your subscription login, so set ANTHROPIC_API_KEY first.
Without --bare, a -p session runs the hooks in a project’s .claude/settings.json and connects the servers in its .mcp.json, even in a folder you have never trusted. Do not run plain claude -p inside a repository you have not reviewed.
A -p run starts in Manual permission mode on every plan. Pass --allowedTools or --permission-mode for what the job needs. See Auto mode.
Keep --verbose on stream-json commands, as the official examples do. For text and json output, use it while developing the automation and drop it once the workflow is stable.