[BUG] Permission pattern matching fails when command contains # character
Description
Permission patterns with the :* wildcard do not match commands that contain the # character. This affects Nix flake commands specifically.
Steps to Reproduce
- Add permission pattern to
settings.json:
``json``
"permissions": {
"allow": ["Bash(nix build:*)"]
}
- Run command containing
#:
``bash``
nix build .#darwinConfigurations.default.system
- Expected: Command auto-approves (matches
Bash(nix build:*)) - Actual: Claude prompts for permission
Working vs Non-Working
| Command | Pattern | Works? |
|---------|---------|--------|
| nix build /path/to/flake | Bash(nix build:*) | ✅ Yes |
| nix build .#target | Bash(nix build:*) | ❌ No |
| nix flake check /path | Bash(nix flake check:*) | ✅ Yes |
| nix flake show .#foo | Bash(nix flake show:*) | ❌ No |
Workaround
Use command variants that don't require #:
nix flake check /absolute/pathinstead ofnix build .#target- Specify full path without
#fragment
Environment
- Claude Code version: 2.0.56
- OS: macOS (Darwin 25.1.0)
- Shell: zsh
Impact
This affects all Nix/flake users who want to auto-approve common build commands. The # character is fundamental to Nix flake syntax for specifying outputs.
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗