[BUG] Permission wildcards and "Always allow" not working for Bash commands with environment variables

Resolved 💬 3 comments Opened Oct 1, 2025 by bradmwhite Closed Oct 4, 2025

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?

Wildcard patterns in permissions.allow are not matching Bash commands that include environment variables (e.g., NODE_OPTIONS="..."), and the "Always allow"
button doesn't persist permissions. This makes it impossible to auto-approve common development commands like TypeScript type checks.

Every time I run a command like NODE_OPTIONS="--max-old-space-size=4096" npx tsc --noEmit --skipLibCheck <files>, Claude Code prompts for approval, even when:

  • I click "Always allow"
  • I run the exact same command twice in a row
  • I've added wildcard patterns like Bash(npx tsc:*) to the allow list
  • I've restarted Claude Code

Simple wildcards work fine (Bash(git:), Bash(grep:)), but anything with NODE_OPTIONS= prefix fails to match.

What Should Happen?

With this configuration in .claude/settings.local.json:
{
"permissions": {
"allow": [
"Bash(npx tsc:*)",
"Bash(npx tsx:*)"
]
}
}

Commands like NODE_OPTIONS="--max-old-space-size=4096" npx tsc --noEmit --skipLibCheck server/file.ts should be auto-approved without prompting.

Additionally, when I click "Always allow" on a command, that exact command should never prompt again in future runs.

Error Messages/Logs

Steps to Reproduce

  1. Add "Bash(npx tsc:*)" to permissions.allow in .claude/settings.local.json
  2. Restart Claude Code
  3. Ask Claude to run: NODE_OPTIONS="--max-old-space-size=4096" npx tsc --noEmit --skipLibCheck server/services/SomeFile.ts
  4. Observe: Permission prompt appears
  5. Click "Always allow"
  6. Ask Claude to run the exact same command again
  7. Bug: Permission prompt appears again (should be auto-approved)

Additional patterns tried (none work):

  • Bash(NODE_OPTIONS=:*)
  • Bash(NODE_OPTIONS="--max-old-space-size=4096" npx tsc:*)
  • Bash(npx:*)

Environment:

  • macOS (Darwin 24.6.0)
  • Node.js v22+
  • Multiple Claude Code sessions tested

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.0.1 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Warp

Additional Information

_No response_

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗