[BUG] ask permission rule bypassed when git commit is chained with &&
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
The ask permission rule for Bash(git commit:*) was bypassed when the commit command was chained with other commands using &&.
Command that bypassed the rule:
git add migrations/file.sql && git commit --amend --no-edit && git push --force-with-lease
Settings Config
"ask": [
"Bash(git commit:*)",
"Bash(gh pr merge:*)"
]
What Should Happen?
Claude should have prompted for permission before executing the git commit --amend portion of the chained command. Actual behavior: The entire chained command executed without prompting, including the commit. Suggested fix: Pattern matching should parse chained commands (&&, ;, ||) and check each subcommand against permission rules individually.
Error Messages/Logs
Steps to Reproduce
Create a .claude/settings.json with an ask rule for git commit:
{
"permissions": {
"allow": [],
"deny": [],
"ask": [
"Bash(git commit:*)"
]
}
}
Initialize a git repo with a file:
mkdir test-repo && cd test-repo
git init
echo "test" > file.txt
git add file.txt
git commit -m "initial commit"
Ask Claude Code to make a change and commit it using a chained command:
"Edit file.txt to say 'hello', then run: git add file.txt && git commit -m 'update file'"
Expected: Claude prompts for permission before executing the git commit portion Actual: The entire chained command executes without prompting
Claude Model
None
Is this a regression?
Yes, this worked in a previous version
Last Working Version
2.0.55
Claude Code Version
2.0.56
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
VS Code integrated terminal
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗