[Feature Request] Tool allow patterns should support wildcard matching for command arguments

Status Fixed / completed
Reported on v2.1.80
Maintainer reply None cached
Activity 4 comments · opened Mar 21, 2026 · closed Mar 23, 2026

Bug Description
currently the way claude uses some tools clashes with the way the allows work making them redundant. For example i have "Bash(git status:*)" in my allows, but cluade always calls uses git with the -C --> git -C path/to/the/thing status, which doesn't hit on the allow i've put in. the only way arround this currently is for me to tell claude to not use the -C (which to be honest i don't mind better to be precise). I'm unsure if this is a bug or feature request, guess that depends on how you solve it.

ethier:

  • fix claude not to use the -C so the allows work (there are other tools where this is an issue too so not real fix)
  • leave how it uses git but allow for argument wild carding before the :, ie, Bash(git -C %s status:)
  • allow for a variables in the allow, so we can vairable it out, ie, Bash(git -C $PROJECT_PATH status:*)
  • something else cooler :)

Environment Info

  • Platform: linux
  • Terminal: vscode
  • Version: 2.1.80
  • Feedback ID: 718f29cf-fb0f-4347-ad30-b78ba42f13e6

View original on GitHub ↗

4 Comments

yurukusa · 6 months ago

This is a common friction point — Claude Code adds flags like -C that change how the command looks to the permission matcher.

Workaround with a PreToolUse hook:

#!/bin/bash
INPUT=$(cat)
COMMAND=$(echo "$INPUT" | jq -r '.tool_input.command // empty')

# Auto-approve any git read-only command regardless of flags
if echo "$COMMAND" | grep -qE '^\s*git\s+(-C\s+\S+\s+)?(status|log|diff|branch|show|rev-parse)'; then
    jq -n '{
      hookSpecificOutput: {
        hookEventName: "PreToolUse",
        permissionDecision: "allow",
        permissionDecisionReason: "git read-only auto-approved"
      }
    }'
    exit 0
fi

exit 0

This matches git status, git -C /path status, git -C /path log --oneline, etc. The regex handles the optional -C <path> that Claude inserts.

See also #36873 for a related trailing-wildcard matching issue.

github-actions[bot] · 6 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/27803
  2. https://github.com/anthropics/claude-code/issues/26546
  3. https://github.com/anthropics/claude-code/issues/13371

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

happyclap · 6 months ago
github-actions[bot] · 6 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.