[BUG] Bash(git commit:*) in allowedTools during claude -p mode isn't respected.
Environment
- Platform (select one):
- [ ] Anthropic API
- [ ] AWS Bedrock
- [x] Google Vertex AI
- [ ] Other: <!-- specify -->
- Claude CLI version: <!-- output of
claude --version-->claude --version
1.0.9 (Claude Code)
- Operating System: <!-- e.g. macOS 14.3, Windows 11, Ubuntu 22.04 --> macOS 15.5
- Terminal: <!-- e.g. iTerm2, Terminal App --> iterm2
Bug Description
Reading the claude documentation here: https://www.anthropic.com/engineering/claude-code-best-practices
It says:
"Bash(git commit:*) to allow git commits" but that isn't respected in claude -p mode.
I'm on a git branch with some staged changes (which Claude was able to do), but when trying to get claude -p to commit the changes to the branch I get an error.
My command line:
echo "Please git commit the changes in the current branch" | claude -p --output-format json --allowedTools "Read,Write,Bash(ls),Bash(git:),Bash(git commit:),Grep"
If I run claude --resume <session-id> to see the session I see the following error:
⏺ Bash(git commit -m "<commit message"
⎿ Error: Claude requested permissions to use Bash, but you haven't granted it yet.
Steps to Reproduce
- Have a branch with staged changes
- echo "Please git commit the changes in the current branch" | claude -p --output-format json --allowedTools "Read,Write,Bash(ls),Bash(git:),Bash(git commit:),Grep"
- Check the branch and the resumed session to see the error message
Expected Behavior
Bash permissions should be accepted for git commit from either git: or git commit:.
Actual Behavior
Claude refuses to run git commit due to permissions.
Additional Context
It does manage to run git push, git pull, git branch, etc, but not git commit for some reason.
I have a similar problem with "gh pr create" but this is the most obvious issue and the documentation says it should work explicitly.
This issue has 12 comments on GitHub. Read the full discussion on GitHub ↗