claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

[BUG] Bash Permissions Not Working in Slash Command

Open JamesonNyp opened this issue 1 year ago • 6 comments

Environment

  • Platform (select one):
    • [X] Anthropic API
    • [ ] AWS Bedrock
    • [ ] Google Vertex AI
    • [ ] Other:
  • Claude CLI version: 1.0.57
  • Operating System: Ubuntu 24.04 LTS
  • Terminal: Terminal

Bug Description

When running slash commands in v1.0.57, any slash command that has bash commands listed within it, errors out before reading all of the logic. The yaml frontmatter doesn't seem to effect it, and even giving full bash permissions in the settings.json doesn't allow it to move forward. Also it doesn't prompt the user to allow bash access permissions.

Steps to Reproduce

  1. Run claude code
  2. Run any slash command that uses bash in the process

Expected Behavior

Claude reads the slash command and runs the bash command and then continues with the command logic.

Actual Behavior

Get the following error even if all bash permissions are allowed.

Error: Bash command permission check failed for pattern "!`git status --short | grep -E "^M|^MM|\?\?" | head -10`": Claude requested permissions to use Bash, but you haven't granted it yet.

Additional Context

Confirmed it worked as intended on v1.0.54.

JamesonNyp avatar Jul 22 '25 17:07 JamesonNyp

Related to #3662 perhaps too?

Taytay avatar Jul 22 '25 18:07 Taytay

It may be, but it looks like in that issue the slash command is actually running at least partially. This one just errors out immediately. But if I run the exact same command in v1.0.54 in the same codebase it works no problem. Seems to be tied to some new additional permission validation in v1.0.57.

> /git:commit 
  ⎿ Error: Bash command permission check failed for pattern "!`git status --short | grep -E "^ 
    M|^MM|\?\?" | head -10`": Claude requested permissions to use Bash, but you haven't granted
     it yet.

And I tried both capital and lowercase on bash in the frontmatter.

---
allowed-tools: Bash(*), Git(*)
description: V2 Create conventional format commits with automatic scope detection and validation
argument-hint: <type> [scope] "message"
---

I also removed the $ARGUMENT from the body of the command to ensure that it wasn't causing issues, but it doesn't seem to have any effect. I also have Bash(git *) and Bash(git status *) in my settings.local.json in the .claude directory.

JamesonNyp avatar Jul 22 '25 20:07 JamesonNyp

I have further isolated the issue in the simplest cases.

Grep with Regex

What doesn't work:

git status --short | grep -E "^ M|^MM|\?\?" | head -10

What does works:

git status --short | grep -F -e " M" -e "MM" -e "??" | head -10

Commands using $ARGUMENTS

What doesn't work

cat .working/issues/issue-$ARGUMENTS/plan.md | head -50 || echo "Plan not found"
git branch -a | awk "/$ARGUMENTS/ {print}"`
git branch -a | grep -i "$ARGUMENTS"

What does work

cat .working/issues/issue-57/plan.md | head -50 || echo "Plan not found"

Bash command with $ARGUMENTS in the same command that do work

ls -la .working/issues/issue-$ARGUMENTS/ 2>/dev/null || echo "No active work for issue $ARGUMENTS"
git branch --list "*$ARGUMENTS*"

There seem to be multiple inconsistencies in what commands can be run within a slash command. Is there a set of unwritten rules about how $ARGUMENTS can be used? Or is there a limit of what commands can be run in a slash command? Maybe a documentation clarification would be helpful if this is an expected behavior.

JamesonNyp avatar Jul 23 '25 15:07 JamesonNyp

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/3662
  2. https://github.com/anthropics/claude-code/issues/5598
  3. https://github.com/anthropics/claude-code/issues/2983

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

github-actions[bot] avatar Aug 15 '25 21:08 github-actions[bot]

This issue has been automatically closed as a duplicate of #3662.

If this is incorrect, please re-open this issue or create a new one.

🤖 Generated with Claude Code

github-actions[bot] avatar Aug 19 '25 09:08 github-actions[bot]

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.

github-actions[bot] avatar Aug 27 '25 14:08 github-actions[bot]