In a CI pipeline nobody is there to answer a permission question. You want the run to refuse anything you didn’t allow up front, and keep going.
claude -p "Check the docs folder for broken internal links and list them" \
--permission-mode dontAsk \
--allowedTools "Read,Grep,Glob"
In dontAsk mode, every call that would normally show a prompt is denied automatically. What still runs: file reads in the working directory, the built-in read-only commands, and whatever your --allowedTools or permissions.allow rules cover. The call is refused and Claude carries on with what it can do.
I think it suits review and report jobs best, where Claude should look and write text but not touch anything. Add exactly the tools the job needs, like Bash(npm test *) for a test run, and nothing more.
A few things are refused even when an allow rule matches, such as AskUserQuestion, because there is no person to ask. With --output-format json, the final result lists refused calls in permission_denials, which is worth checking: a job that “succeeded” may have quietly skipped the one step you cared about. If the run should fail in that case, check the denials in the JSON and set the exit code yourself.
Further reading: Run Claude Code programmatically: auto-approve tools, Permission modes