Permission matching fails when bash command has leading comment
Resolved 💬 3 comments Opened Feb 18, 2026 by dmnd Closed Feb 22, 2026
Bug
When a Bash tool call includes a leading # comment line before the actual command, the permission matcher fails to match against allowed patterns, causing an unnecessary permission prompt.
Reproduction
With this permission configured in settings:
"Bash(grep:*)"
No prompt (works correctly):
grep -rl '^\s*on:[a-zA-Z]' /path/to/src --include="*.svelte" | wc -l
Triggers permission prompt (bug):
# Count files with bare event forwarding
grep -rl '^\s*on:[a-zA-Z]' /path/to/src --include="*.svelte" | wc -l
Both commands are identical except for the leading comment line. The first auto-approves; the second prompts.
Expected behavior
The permission matcher should strip leading comment lines (lines starting with #) before matching, since bash comments don't affect what the command actually does.
Environment
- macOS (Darwin 25.2.0)
- Claude Code CLI
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗