Allowing plain Bash to a headless run is a big yes. Allowing four specific git commands is a small one.
--allowedTools lists tools that run without a permission prompt, and it accepts the same rule syntax as your settings. A Bash(...) rule can be narrow.
claude -p "Look at my staged changes and create an appropriate commit" \
--allowedTools "Bash(git diff *),Bash(git log *),Bash(git status *),Bash(git commit *)"
That commit job can read the diff and commit, and nothing else in the shell. The trailing * matches the command with or without arguments.
My rule of thumb: the more unattended the job, the narrower the list. A prompt that nobody sees cannot be answered, so the list is the whole safety net. Four read and commit commands is a list I can reason about; a bare Bash is a shrug.
The caveat is the space. Bash(git diff *) with a space matches git diff, while Bash(git diff*) without one would also match git diff-index. Also note that this flag only approves tools; to remove tools from Claude’s reach entirely, use --tools or --disallowedTools.
Further reading: Run Claude Code programmatically – Claude Code docs, CLI reference – Claude Code docs, On this site: deny Read(./.env) so Claude never opens your secrets, On this site: scope instructions with paths in .claude/rules