fix(code-review): reduced permission prompts, prevented unnecessary cd calls#33397
fix(code-review): reduced permission prompts, prevented unnecessary cd calls#33397sunnypatell wants to merge 1 commit intoanthropics:mainfrom
Conversation
…y cd calls - expanded allowed-tools to include git commands (diff, log, blame, show, rev-parse), Read, Grep, Glob that review agents actually need - simplified gh tool patterns from per-subcommand to Bash(gh:*) to cover all gh operations without over-specifying - added explicit "never use cd" instruction in agent assumptions, which gets relayed to all subagents, preventing the cd + command chaining that triggers the compound command security check - added instruction to use Read/Grep instead of cat/grep bash commands fixes anthropics#33357, related to anthropics#28240, anthropics#30832, anthropics#30213
There was a problem hiding this comment.
Pull request overview
This PR updates the /code-review plugin command prompt to reduce repetitive permission prompts during PR reviews by broadening pre-approved read-only tools and steering agents away from cd && ... compound bash commands.
Changes:
- Expands
allowed-toolsto include broaderghaccess plus common read-onlygitsubcommands, and addsRead/Grep/Glob. - Strengthens and clarifies “agent assumptions” to explicitly prohibit
cd-prefixed bash commands. - Adds guidance to prefer
Read/Greptools overcat/grepvia Bash.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
|
addressing copilot's 2 inline comments:
|
the code-review plugin generates hundreds of permission prompts per review because sub-agents prefix every command with
cd /path && ..., which triggers the compound command security check. this makes the plugin essentially unusable without constant babysitting.fixes #33357, related to #28240, #30832, #30213
changes
expanded
allowed-toolsto match what review agents actually need:the old list only covered specific
ghsubcommands. agents that neededgit blame,git log,git show, or file reads (Read,Grep,Glob) would trigger permission prompts on every call. theghpatterns were also unnecessarily granular since all subcommands are safe in a review context.added explicit no-cd instruction to agent assumptions:
this is relayed to every sub-agent and directly prevents the
cd && commandchaining that triggers the runtime's "compound commands with cd and git require approval" security check. users in #28240 confirmed that explicit instructions in CLAUDE.md reduce the behavior, but putting it in the plugin's command prompt is more reliable than relying on per-repo CLAUDE.md files.added Read/Grep preference over cat/grep bash commands, which avoids unnecessary Bash tool calls entirely.
why this works
the permission explosion has two causes:
cd /cwd && gh pr diff ...even though the cwd is already correct. the runtime flags this as a security concern (bare repo attack prevention). the no-cd instruction stops this at the sourcegit blame,git log, etc. for context analysis but these weren't inallowed-tools, forcing approval on every call. expanding the list pre-approves these safe read-only operationsthe runtime's
cddetection is being addressed separately (#28240), but this plugin-level fix provides immediate relief.