[BUG] Bash comments break permissions
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?
Since a few days ago Claude Code sometimes adds comments to tool executions, like this:
# Check the diff
git diff ....
Even if the allowlist contains Bash(git:*), I need to manually approve.
The same happens if the comment is after the command, or if the command itself uses the # sign for whatever reason.
What Should Happen?
If Claude Code runs a command, it should not add comments around it, so that tools from the allowlist execute without manual approval.
Error Messages/Logs
Steps to Reproduce
This mostly happens when I try to let it do a large task autonomously, which involves lots of external tool calls, for example reworking a coding task from one approach to another, which involves heavy git work.
Claude Model
Not sure / Multiple models
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.34 (Claude Code)
Platform
Anthropic API
Operating System
Ubuntu/Debian Linux
Terminal/Shell
VS Code integrated terminal
Additional Information
_No response_
9 Comments
Found 3 possible duplicate issues:
This issue will be automatically closed as a duplicate in 3 days.
🤖 Generated with Claude Code
The referenced issues look similar, but I don't think they are duplicates.
Same here. I had a very well polished allow list where for the most part I never had permissions prompted on commands I allowed in the past. Now I have a lot of isntances where I need to approve command that are arealdy whitelisted because of messages like: "Command contains a backslash before a shell operator (;, |, &, <, >) which can hide command structure"
It's very common for claude to run such commands, specially on explore agents, and it makes the process spammy. Would be great to maybe have a flag that allows to run such commands as long it matches with the criteria of the allowlist? Or maybe cleverly allow certain combination of commands, or whitelist read command that can be run after a pipe operator?
Just run
/code-review:code-reviewwithout fullBashpermission (Bash(*)) or--dangerously-skip-permissionsand be prepared to hit enter repeatedly every 5 seconds.Workaround: a PreToolUse hook can strip the comment lines before permission matching sees them.
The hook reads the command, removes leading
#lines, and returns the clean command viaupdatedInput. YourBash(git:*)allowlist then matches correctly.Implementation: comment-strip.sh
Or install it with all safety hooks:
npx cc-safe-setupIs auto mode meant to prevent this issue? Can we have it on the MAX plan? I see it's only for the Teams plan? Honestly CC has become almost unusable, I'm sitting right now hiting yes on 4 parallel sub agents it's the worst experience.
Thanks for the report. This is fixed — the reporter was on v2.1.34, which predates both fixes.
# ...lines never reach rule matching.#inside a quoted argument was tripping the compound-command check.Verified on current main:
# Check the diff\ngit diff HEAD→ matches asgit diff HEADgit diff HEAD # check→ matches asgit diff HEADecho "hello#world"→ matches asecho "hello#world"Please upgrade to v2.1.76+ and reopen if you still see it.
(The "backslash before a shell operator" complaint further down the thread is a separate intentional security check, not this bug.)
This issue was fixed as of version 2.1.76.
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.