Get a one-shot answer and exit

cli flags & headless

// what it does

claude -p "query" (or --print) runs the agent non-interactively, prints the final result, and exits — the entry point for scripts and CI. Every CLI flag works with -p. Add --bare to skip auto-discovery of hooks, skills, plugins, MCP, auto memory, and CLAUDE.md for a fast, reproducible run that only uses the flags you pass.

// shell

$ claude -p "what does the auth module do?"
$ claude --bare -p "summarize this file" --allowedTools "Read"

// gotcha

Without --bare, a headless run still loads whatever is configured locally (a teammate's hook, a project .mcp.json), so results differ per machine. Use --bare in CI to get the same behavior everywhere; it is the recommended mode for scripted calls.

// resources