A script that works on my laptop and breaks in CI usually has a hidden difference. With Claude Code, the hidden difference is often my own setup.
Normally claude -p loads hooks, skills, subagents, plugins, MCP servers, auto memory and CLAUDE.md, just like an interactive session. --bare skips all of that.
claude --bare -p "Summarize README.md" --allowedTools "Read"
Claude still has Bash, file read and file edit. If you need anything else, you hand it over with a flag: --append-system-prompt, --settings, --mcp-config, --agents or --plugin-dir. The docs call --bare the recommended mode for scripted calls and say it will become the default for -p in a future release.
The part that catches people: bare mode never reads your OAuth login or the keychain. You need ANTHROPIC_API_KEY in the environment, or an apiKeyHelper in the --settings JSON.
Think of it as the difference between running a script in a clean container and running it in your own shell with all your aliases. The clean one is boring, and boring is what you want from automation. If a bare run misbehaves, you know the cause is in the command line you wrote, because there is nothing else it could have loaded.
So a teammate's hook or a project MCP server cannot sneak into a pipeline run.
Further reading: Run Claude Code programmatically – Claude Code docs, CLI reference – Claude Code docs, On this site: claude -p lets you pipe text into Claude Code from a script, On this site: pipe a log straight into claude -p instead of pasting it