Skip to content

Non-interactive Mode

Use non-interactive mode when you want Claude Code to run from a shell command instead of an interactive session.

Terminal window
claude -p "Explain what this project does"
Terminal window
claude -p "List all API endpoints" --output-format json
Terminal window
claude -p "Analyze this log file" --output-format stream-json --verbose

Add --include-partial-messages to receive tokens as they are generated instead of whole messages.

  • CI checks.
  • Pre-commit hooks.
  • Repo analysis scripts.
  • Batch summarization.
  • Structured extraction into another command.

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.

Terminal window
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.