PRODUCTION SCENARIO
A CI job runs claude -p to draft a commit message from staged changes. The pipeline may run git diff, git status, and git commit, and nothing else in Bash.
Which allowedTools value is correct?
Answering here is anonymous. Nothing is saved unless you sign in.
Show answer and explanation
Answer: --allowedTools "Bash(git diff *),Bash(git status *),Bash(git commit *)"
A trailing asterisk preceded by a space enables prefix matching for exactly those subcommands. Without the space, git diff followed directly by an asterisk also matches git diff-index, and with no wildcard at all the pattern matches only the bare command with no arguments. Allowing all of git and denying one push pattern still grants every other git subcommand.
Official Source: https://code.claude.com/docs/en/headless ↗