[BUG] Auto-generated Bash permission uses invalid syntax for prefix matching
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?
When approving a Bash command that starts with an environment variable (e.g., DEBUG=1 npm run dev), Claude Code auto-adds the permission to settings.local.json with invalid syntax:
"Bash(DEBUG=*)"
On the next startup, Claude Code shows a settings validation error:
Settings Error
/Users/username/project/.claude/settings.local.json
└ permissions
└ allow
└ "Bash(DEBUG=*)": Use ":*" for prefix matching, not just "*". Change to "Bash(DEBUG=:*)" for prefix matching. Examples: Bash(npm run:*), Bash(git:*)
Files with errors are skipped entirely, not just the invalid settings.
What Should Happen?
When auto-generating a permission entry for prefix matching, Claude Code should use the correct syntax with :* instead of just *:
"Bash(DEBUG=:*)"
Error Messages/Logs
Settings Error
/Users/ptn677/personal/.claude/settings.local.json
└ permissions
└ allow
└ "Bash(DEBUG=*)": Use ":*" for prefix matching, not just "*". Change to "Bash(DEBUG=:*)" for prefix matching. Examples: Bash(npm run:*), Bash(git:*)
Files with errors are skipped entirely, not just the invalid settings.
Steps to Reproduce
- Start Claude Code in any project
- Ask Claude to run a command with an environment variable prefix, e.g.,
DEBUG=1 npm run dev - When prompted, click "Allow" to permit the command
- Close Claude Code
- Reopen Claude Code
- Settings error appears about invalid permission syntax
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.0.76 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
The permission validator correctly enforces the :* syntax for prefix matching, but the auto-generation logic that runs when users approve commands doesn't follow the same rule. This creates a mismatch where:
- Validator expects:
Bash(DEBUG=:*) - Auto-generator produces:
Bash(DEBUG=*)
This affects any command approval where the command starts with ENV_VAR=value pattern.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗