[BUG] Bash(git commit:*) in allowedTools during claude -p mode isn't respected.

Status Closed — not planned
Maintainer reply ✓ Yes — rboyce-ant
Activity 12 comments · opened Jun 3, 2025 · closed Jan 8, 2026
💡 Likely answer: A maintainer (rboyce-ant, contributor) responded on this thread — see the highlighted reply below.

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

  1. Have a branch with staged changes
  2. 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"
  3. 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.

View original on GitHub ↗

12 Comments

rboyce-ant contributor · 1 year ago

@lukebergmh Can you share the specific commands that Claude is trying to run but aren't being allowed? If it's running commands with Bash substitution or pipes, for example, you might need a more permissive rule like allowing Bash (or prompting Claude to write a simpler commit command)

lukebergmh · 1 year ago

@rboyce-ant - I'm trying to stop short of giving full Bash privileges to claude -p. What confuses me is that claude -p can run all of the other git commands except git commit. git push, git status (have an example below), git checkout all work. Just git commit doesn't.

The command it specifically is struggling with here is:
git commit -m "[MOSAIC-344] Improve JIRA analysis prompt for maverick-jira
I get this error:
Error: Claude requested permissions to use Bash, but you haven't granted it yet

But I thought that maybe the double quotes was the problem since I don't have a problem with any other git command and the main difference is the message or std in.
I tried this approach below and here's an example where I still have issues, but you can see git status runs fine but now git commit.
I invoked the below example like this:
"Please git commit the changes in the current branch. Run git commit in this way echo \"[{{JIRA_ID}}] <descriptive message>\" | git commit --file - This is because we are in a non-interactive mode." | claude -p --output-format json --allowedTools "Read,Write,Bash(ls),Bash(echo:*),Bash(git:*),Bash(git commit:*),Grep"

`⏺ Bash(git status)…
⎿  On branch ai-MOSAIC-344-maverick-jira-improvements
Your branch is up to date with 'origin/ai-MOSAIC-344-maverick-jira-improvements'.

Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: ai/resources/jira-analysis-prompt.txt

⏺ I see the changes are staged. Let me commit them now:

⏺ Bash(echo "[MOSAIC-344] Update jira analysis prompt formatting" | git commit --file -)…
⎿  Error: Claude requested permissions to use Bash, but you haven't granted it yet.`

lukebergmh · 1 year ago

@rboyce-ant - The other reason I think something is specific with git commit. Most Bash tools, if I accept the permission of Yes and don't ask during interactive and then look at the /permissions. I see something like Bash(find).
But I just did the same interactively for this particular commit and here's what the /permissions lists. It's the full message, not just Bash(git) or Bash(git commit) or something like that.
Bash(git commit -m "$(cat <<'EOF' │
│ [MOSAIC-344] Update JIRA analysis prompt for maverick improvements │
│ │
│ 🤖 Generated with [Claude Code](https://claude.ai/code) │
│ │
│ Co-Authored-By: Claude <noreply@anthropic.com> │
│ EOF │
│ )")

lukebergmh · 1 year ago

Another thing that might help: It's very unclear which Bash permission is missing. I've been focusing on Bash(git:) or Bash(git commit:) but it's possible there's something else.

brendanlong · 1 year ago

I ran into this same problem on a different command, where it works if Claude runs it without quotes but prompts for permission with quotes. This might be intended behavior since technically claude could run something like git commit -m "$(rm -rf)"? The weird thing is that I see this same prompt with single quotes, which I think are safe. If we could make the single-quote version work, you could fix this by prompting Claude to always use single quotes.

In my case I get prompted if Claude runs ./send_command.sh "d" but don't get prompted if Claude runs ./send_command.sh d.

brendanlong · 1 year ago

Nevermind, single quotes aren't allowed either, double quotes do work with echo, and the permission system does detect command substitution.

!Image

amcaplan · 1 year ago

I've found allowedTools to be pretty buggy generally. This is immensely frustrating for me, as I'm passing a list of commands it can run and I find that it can run some but not others. As one easily reproducible example, currently it's working with npm run test but not pnpm test:

$ echo "Run pnpm run test and npm run test and tell me if you encounter permissions issues" | claude -p --allowedTools 'Bash("pnpm run test:*"),Bash("npm run test:*")'
I encountered permissions issues with `pnpm run test` but `npm run test` ran successfully. The npm test command executed all 182 tests across 8 test files and they all passed.

I've tried running in various configurations (changing the order, using pnpm test vs pnpm run test, etc.) and it never works.

brendanlong · 1 year ago

Given how slow it is to execute tools, I'm actually wondering if there's another model checking if the tool use is allowed? I can't think of any other explanation for why there's such a long delay between Claude outputting Bash(some command) and it prompting me for approval.

tiagostutz · 1 year ago

Same thing here... this kinda makes our automation flaky, so a fix or a workaround would be much appreciated.

github-actions[bot] · 8 months ago

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] · 7 months ago

This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.

github-actions[bot] · 7 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.