[BUG] Bash permission matcher fails when command arguments contain literal parentheses (e.g. Next.js route groups)
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?
Bash permission rules with * wildcards fail to auto-approve commands when file path arguments contain literal ( and ) characters. The command prompts for permission every time despite matching the rule pattern.
This likely affects many Next.js projects — route groups like (dashboard), (auth), (marketing) are a core routing convention and appear a large number of file paths.
What Should Happen?
Commands with parentheses in file path arguments should be auto-approved when they match a Bash(command:*) permission rule. The * wildcard should match the full argument text including literal parentheses.
Error Messages/Logs
(No error message — the command silently falls through to prompting the user for permission, as if the allow rule doesn't exist.)
Steps to Reproduce
- Have a permission rule in
.claude/settings.local.json:
``json``
{ "permissions": { "allow": ["Bash(git -C /path/to/repo add:*)"] } }
- In the repo, have any file under a directory with parens (e.g. Next.js route group):
````
/path/to/repo/web-console/src/app/(dashboard)/inbox/_components/MyComponent.tsx
- Ask Claude Code to run:
````
git -C /path/to/repo add web-console/src/app/(dashboard)/inbox/_components/MyComponent.tsx
- Result: Claude prompts for permission despite the rule matching.
- All escaping variants also fail:
- Quoted:
git -C /path/to/repo add "web-console/src/app/(dashboard)/..." - Backslash-escaped:
git -C /path/to/repo add web-console/src/app/\(dashboard\)/...
- For comparison, these are auto-approved as expected:
git -C /path/to/repo add .git -C /path/to/repo add web-console/src/lib/utils.ts(no parens in path)
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.74
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
VS Code integrated terminal
Additional Information
Seen before? Similar issue reported as #14522 (closed by stale bot). Reported similar issues with parentheses in PowerShell commands; this issue is about Next.js route groups in filenames affecting the permissions structure.
Potential root cause (from analysis of minified source): The rule format \Bash(command:args) uses ( and ) as structural delimiters. The parser appears to find the first unescaped ( and last unescaped ) to split toolName from ruleContent. When the actual command contains literal parens in file paths like (dashboard), this likely corrupts the structural parsing. This is consistent with the observed behavior: every variant with parens in the argument fails, while identical commands without parens succeed.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗