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

gh api permission not working despite being in settings.json

Open kaovilai opened this issue 1 year ago • 7 comments

Description

The gh api command is prompting for user approval despite having the permission "Bash(gh api:*)" in ~/.claude/settings.json.

Steps to Reproduce

  1. Add "Bash(gh api:*)" to the approvedTools array in ~/.claude/settings.json
  2. Try to run any gh api command, for example:
    gh api /user
    
    or
    gh api -X GET /repos/owner/repo/issues
    
  3. Claude Code still prompts for approval despite the permission being set

Expected Behavior

Commands matching gh api:* should execute without prompting, similar to how other gh permissions work (e.g., gh pr view:*)

Actual Behavior

The user is prompted to approve the command execution

Environment

  • Platform: darwin
  • OS Version: Darwin 24.5.0

Additional Context

Other similar permissions in the same settings.json file work correctly:

  • "Bash(gh pr checkout:*)"
  • "Bash(gh pr checks:*)"
  • "Bash(gh pr diff:*)"
  • "Bash(gh pr view:*)"

The permission format appears correct and consistent with working permissions.

kaovilai avatar Aug 04 '25 21:08 kaovilai

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/1453
  2. https://github.com/anthropics/claude-code/issues/1520
  3. https://github.com/anthropics/claude-code/issues/2983

If your issue is a duplicate, please close it and 👍 the existing issue instead.

🤖 Generated with Claude Code

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

I have this same issue with gh issue commands. I have to approve gh issue create every single time.

I have Bash(gh issue:*) in the project's allow array in settings.local.json and I have tried to add the same to the allowedTools array in ~/claude.json but the array gets emptied every time I open Claude CLI.

tulensrma avatar Aug 10 '25 13:08 tulensrma

Same problem here. I eventually found out that the issue is with the backtick "`" character. Creating an issue without having the backtick (either single or triple) worked for me.

payam-pawapay avatar Aug 17 '25 11:08 payam-pawapay

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] avatar Dec 05 '25 10:12 github-actions[bot]

I think I'm experiencing a slightly different variation of this issue - gh api commands are not auto-authorized when allowed via a slash-command's allowed-tools section.

ed-irl avatar Dec 13 '25 13:12 ed-irl

This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.

github-actions[bot] avatar Jan 13 '26 10:01 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 Jan 20 '26 14:01 github-actions[bot]