[BUG] "Yes, and don't ask again" permissions with env var assignments don't persist across sessions
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?
Summary
Commands prefixed with environment variable assignments (e.g., PYTEST_DISABLE_PLUGIN_AUTOLOAD="" uv run --frozen pytest) prompt for approval every new
session despite being approved with "Yes, and don't ask again" in prior sessions.
### Observed behavior
The permission entry is written correctly to .claude/settings.local.json:
"Bash(PYTEST_DISABLE_PLUGIN_AUTOLOAD=\"\" uv run --frozen pytest:*)",
"Bash(PYTEST_DISABLE_PLUGIN_AUTOLOAD=\"\" uv run:*)",
The file persists across sessions (confirmed via stat and the file accumulating entries from many sessions). But commands matching these patterns still
trigger the approval prompt in every new session.
What Should Happen?
### Expected behavior
Commands matching a stored permission pattern should be auto-approved without prompting.
### Suspected cause
The escaped double quotes (\"\") in the JSON-serialized pattern likely don't match correctly against the incoming command's literal ="" when the
permission rules are evaluated at the start of a new session.
### Environment
- macOS (Darwin 24.6.0)
- Claude Code CLI (latest as of 2026-02-26)
Error Messages/Logs
Steps to Reproduce
- Run a command that sets an env var: PYTEST_DISABLE_PLUGIN_AUTOLOAD="" uv run --frozen pytest tests/ -x -v
- When prompted, select "Yes, and don't ask again for: PYTEST_DISABLE_PLUGIN_AUTOLOAD="" uv run:*"
- Verify the permission is written to .claude/settings.local.json
- End the session and start a new one in the same project
- Run the same command again
- You are prompted again despite the permission existing in settings.local.json
Claude Model
Opus
Is this a regression?
Yes, this worked in a previous version
Last Working Version
4.6
Claude Code Version
2.1.59 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
iTerm2
Additional Information
_No response_
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗