A water utility runs a nightly Claude Code job in its CI pipeline that reads SCADA export files and writes a summary of anomalous pump-pressure readings. The job runs headless with no operator at a terminal, so any permission prompt would hang the build until it times out. The platform team wants the run to be able to read files and run git diff, and nothing else, without weakening the checked-in settings for engineers who use Claude Code interactively on the same repository. Which approach fits this requirement?
Select an answer to reveal the explanation.
Short Explanation
Think of --allowedTools as a visitor badge good for one shift. You list exactly what the headless run may touch on that invocation, and the checked-in settings your interactive engineers rely on never change.
Full Explanation
Headless automation has to resolve permissions before the process starts, because there is no operator to answer a prompt and an unanswered prompt in CI is just a timeout. The architectural question is therefore not whether to grant capability but where to express the grant, and a good answer keeps the automation's needs separate from the humans' needs.
The --allowedTools flag pre-authorizes a named set of tools for a single invocation. It accepts the same rule syntax as the settings files, so a tool can be narrowed to a specific command rather than granted wholesale, and because the grant lives on the command line it leaves the repository's persisted configuration untouched. The nightly SCADA job gets file reads and git diff; interactive sessions on the same repository keep the prompts they had.
Skipping permissions wholesale removes every guardrail instead of granting the two capabilities actually needed, and it applies to every run reading that settings file; adding the tools to the project allow array does persist them but grants them to every interactive session too, which is precisely the weakening the team wanted to avoid, and the premise that settings files are the only place permissions can be expressed is false; piping keystrokes approves whatever happens to be asked, including a request nobody intended to allow.
Exam caveat: pre-authorization decides what will not prompt, not what a granted tool can reach, so a broadly written rule is still a broad grant. Operational check: run the job with the flag while deliberately exercising an unlisted tool, and confirm the run fails rather than silently proceeding.