Pipe character in regex patterns incorrectly triggers bash permission check
Environment
- Platform (select one):
- [x] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other: <!-- specify -->
- Claude CLI version: v1.0.92
- Operating System: macOS (Darwin 24.6.0)
- Terminal: iTerm
Bug Description
Slash commands that use bash patterns containing the pipe character | inside regex or glob patterns (e.g., grep -E '(\.idea|\.claude|bruno)') are incorrectly flagged by the security permission system. The system interprets the | inside the pattern string as a bash pipe operator requiring separate permissions, when it's actually part of a regex alternation pattern.
Steps to Reproduce
- Create a slash command with a bash command like:
git ls-files --cached --others --exclude-standard '*.md' | grep -v -E '(\.idea|\.claude|bruno|\.yarn|CLAUDE\.md)' - Add appropriate permissions in the command's frontmatter:
allowed-tools: Bash(git:*), Bash(grep:*) - Execute the slash command
- Command fails with error: "Bash command permission check failed for pattern... This Bash command contains multiple operations. The following part requires approval: grep -v -E '(\.idea|\.claude|bruno|\.yarn|CLAUDE\.md)'"
Expected Behavior
The command should execute successfully since:
- The
|betweengit ls-filesandgrepis correctly recognized as a bash pipe - The
|characters inside the grep regex pattern'(\.idea|\.claude|bruno)'should be recognized as part of the regex pattern, not as bash pipes - The
Bash(grep:*)permission should cover the entire grep command including its regex pattern
Actual Behavior
The security system incorrectly interprets the | characters inside the regex pattern as bash pipe operators, causing the permission check to fail even with appropriate Bash(grep:*) permissions.
Additional Context
Workaround: Replace regex patterns containing | with multiple chained commands:
- Instead of:
grep -v -E '(\.idea|\.claude|bruno)' - Use:
grep -v '\.idea' | grep -v '\.claude' | grep -v 'bruno'
This issue affects any slash command that needs to use regex alternation patterns with tools like grep, sed, or awk.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗