claude-code - 💡(How to fix) Fix [DOCS] Bash permission docs omit env-var prefix matching semantics [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#45469Fetched 2026-04-09 08:04:43
View on GitHub
Comments
0
Participants
1
Timeline
3
Reactions
0
Author
Participants
Timeline (top)
labeled ×3

Root Cause

That omission matters because users rely on these rules to decide which Bash commands should be covered by a given allow or deny pattern. Today the page gives examples only for bare commands, so it is unclear whether leading env-var prefixes are ignored, normalized, or treated as part of the literal command string.

RAW_BUFFERClick to expand / collapse

Documentation Type

Incorrect/outdated documentation

Documentation Location

https://code.claude.com/docs/en/permissions

Section/Topic

Permission rule syntax and Tool-specific permission rulesBash

Current Documentation

The docs currently say:

Bash permission rules support wildcard matching with *. Wildcards can appear at any position in the command, including at the beginning, middle, or end:

  • Bash(npm run build) matches the exact Bash command npm run build
  • Bash(npm run test *) matches Bash commands starting with npm run test
  • Bash(npm *) matches any command starting with npm
  • Bash(* install) matches any command ending with install
  • Bash(git * main) matches commands like git checkout main, git merge main

It also says:

Claude Code is aware of shell operators (like &&) so a prefix match rule like Bash(safe-cmd *) won't give it permission to run the command safe-cmd && other-cmd.

And the same page warns:

Bash permission patterns that try to constrain command arguments are fragile.

  • Redirects: curl -L http://bit.ly/xyz (redirects to github)

What's Wrong or Missing?

Changelog v2.1.97 says Claude Code "Fixed and hardened Bash tool permissions, tightening checks around env-var prefixes and network redirects, and reducing false prompts on common commands."

The permissions page documents wildcard matching, shell-operator handling, and one redirect caveat, but it does not explain the matching semantics for commands that start with environment-variable assignments such as FOO=bar git push.

That omission matters because users rely on these rules to decide which Bash commands should be covered by a given allow or deny pattern. Today the page gives examples only for bare commands, so it is unclear whether leading env-var prefixes are ignored, normalized, or treated as part of the literal command string.

The redirect warning is also underspecified after the v2.1.97 hardening work. The page still lists redirects only as a generic fragility example, without clarifying what is now enforced versus what still requires WebFetch(domain:...), deny rules for network tools, or a PreToolUse hook.

Suggested Improvement

Add a short subsection under Bash permission rules that documents command-normalization behavior before rule matching.

Suggested coverage:

  • State whether leading environment-variable assignments are ignored for matching, with examples such as FOO=bar git push origin main and AWS_PROFILE=prod aws s3 ls.
  • Clarify how Bash permission rules treat leading env-var prefixes before matching.
  • Update the redirect caveat to distinguish current behavior after v2.1.97 from remaining unsupported or unsafe cases.
  • Add one example showing the recommended safe pattern for network access control: deny Bash network tools, use WebFetch(domain:...) for allowed domains, and fall back to hooks for stricter validation.

Impact

Medium - Makes feature difficult to understand

Additional Context

Affected Pages:

PageContext
https://code.claude.com/docs/en/permissionsPrimary Bash permission rule syntax and caveats
https://code.claude.com/docs/en/troubleshooting"Repeated permission prompts" sends users to the permissions page without explaining these matching edge cases

Total scope: 2 pages affected

Source: Changelog v2.1.97

Changelog entry: Fixed and hardened Bash tool permissions, tightening checks around env-var prefixes and network redirects, and reducing false prompts on common commands

extent analysis

TL;DR

Update the Bash permission rules documentation to clarify command-normalization behavior, including how leading environment-variable assignments are handled and the current behavior for redirects after the v2.1.97 hardening work.

Guidance

  • Review the current documentation for Bash permission rules and identify areas where command-normalization behavior is not clearly explained.
  • Add a subsection under Bash permission rules to document how leading environment-variable assignments are handled, including examples such as FOO=bar git push origin main and AWS_PROFILE=prod aws s3 ls.
  • Update the redirect caveat to distinguish current behavior after v2.1.97 from remaining unsupported or unsafe cases, and provide an example of a recommended safe pattern for network access control.
  • Consider adding a note to the troubleshooting page to explain how to handle repeated permission prompts related to these matching edge cases.

Example

No code snippet is provided as the issue is related to documentation and not a specific code problem.

Notes

The suggested improvement is focused on clarifying the documentation, which may not fully address the underlying technical issues. However, it should help users better understand how to use the Bash permission rules and reduce confusion.

Recommendation

Apply workaround: Update the documentation to clarify the command-normalization behavior and provide examples for leading environment-variable assignments and redirects. This will help users understand how to use the Bash permission rules effectively and reduce the difficulty in using the feature.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING