From c2d46f74143aa9b196bddfed87524f526aaa5eab Mon Sep 17 00:00:00 2001 From: Joseph Mearman Date: Sun, 15 Feb 2026 10:36:21 +0000 Subject: [PATCH 1/4] fix(action): allow gh api graphql commands in review mode The comment hygiene prompt instructs the bot to run gh api graphql for bot identity detection and review thread resolution, but the allowedTools pattern only included Bash(gh api:*) which doesn't match gh api graphql subcommands. --- action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/action.yml b/action.yml index c0fd89f..550905a 100644 --- a/action.yml +++ b/action.yml @@ -181,7 +181,7 @@ runs: echo "$EOF" >> "$GITHUB_OUTPUT" # Determine allowed tools based on mode - COMMON_TOOLS="mcp__github__get_pull_request,mcp__github__get_pull_request_files,mcp__github__get_pull_request_diff,mcp__github__get_pull_request_reviews,mcp__github__list_pull_request_comments,mcp__github__create_pending_pull_request_review,mcp__github__add_comment_to_pending_review,mcp__github__submit_pending_pull_request_review,mcp__github__create_and_submit_pull_request_review,mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr edit:*),Bash(gh label *),Bash(gh api:*)" + COMMON_TOOLS="mcp__github__get_pull_request,mcp__github__get_pull_request_files,mcp__github__get_pull_request_diff,mcp__github__get_pull_request_reviews,mcp__github__list_pull_request_comments,mcp__github__create_pending_pull_request_review,mcp__github__add_comment_to_pending_review,mcp__github__submit_pending_pull_request_review,mcp__github__create_and_submit_pull_request_review,mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr edit:*),Bash(gh label *),Bash(gh api:*),Bash(gh api graphql:*)" if [ "$MODE" = "review" ]; then TOOLS="$COMMON_TOOLS,Read,Grep,Glob,WebFetch,Bash(git diff:*),Bash(git log:*),Bash(git blame:*),Bash(gh issue create:*),Bash(gh pr create:*)" From c3f6cd69360eca077ec40ba934a1a2eef95acc23 Mon Sep 17 00:00:00 2001 From: Joseph Mearman Date: Sun, 15 Feb 2026 10:41:29 +0000 Subject: [PATCH 2/4] fix(prompts): remove label management and add PR title checking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Labels are redundant with review verdicts. Replace label management with PR title validation — the reviewer now checks and fixes vague or inaccurate PR titles after submitting a review. --- .github/prompts/shared/02-guidelines.md | 54 ++++++++++++------------- action.yml | 2 +- 2 files changed, 26 insertions(+), 30 deletions(-) diff --git a/.github/prompts/shared/02-guidelines.md b/.github/prompts/shared/02-guidelines.md index 36d472a..3028f5f 100644 --- a/.github/prompts/shared/02-guidelines.md +++ b/.github/prompts/shared/02-guidelines.md @@ -27,32 +27,28 @@ When the same issue repeats across files, explain the pattern once in the first comment. Still provide a suggestion block on each occurrence so the author can click "Apply" on all of them. Keep subsequent comments brief. -After submitting a review, do both of the following: - -1. **Update the PR description** ONLY if it's missing or incomplete. First check - the existing description with `gh pr view $PR_NUMBER`. If it already has a - clear summary of changes, skip this step entirely. - - When updating, add only what's missing. Use headings only when organizing - multiple distinct sections — a single paragraph needs no `## Summary` heading - since the marker block already provides context. - - ```bash - gh pr edit $PR_NUMBER --body "$(cat <<'EOF' - - - - EOF - )" - ``` - - The markers `` / `` identify your - section. Preserve everything outside the markers. If no marker block exists, - append yours at the end. Do NOT repeat information already in the PR body. - -2. **Update PR labels** to reflect the outcome: - - `gh pr edit {pr} --add-label "needs-changes"` after REQUEST_CHANGES - - `gh pr edit {pr} --remove-label "needs-changes" --add-label "approved"` after APPROVE - - Remove stale labels that no longer apply - - Only manage labels that you have set — do not remove labels added by humans. - - If a label does not exist, skip it — do not attempt to create labels. +After submitting a review, check the PR title and description with +`gh pr view $PR_NUMBER`. Fix what needs fixing: + +- **Title**: If it's vague, generic, or doesn't reflect the actual changes, + update it with `gh pr edit $PR_NUMBER --title "concise title"`. Keep it under + 70 characters. Don't change titles that are already clear and accurate. +- **Description**: Update ONLY if it's missing or incomplete. Skip if it already + has a clear summary of changes. + +When updating, add only what's missing. Use headings only when organizing +multiple distinct sections — a single paragraph needs no `## Summary` heading +since the marker block already provides context. + +```bash +gh pr edit $PR_NUMBER --body "$(cat <<'EOF' + + + +EOF +)" +``` + +The markers `` / `` identify your +section. Preserve everything outside the markers. If no marker block exists, +append yours at the end. Do NOT repeat information already in the PR body. diff --git a/action.yml b/action.yml index 550905a..c21c3a7 100644 --- a/action.yml +++ b/action.yml @@ -181,7 +181,7 @@ runs: echo "$EOF" >> "$GITHUB_OUTPUT" # Determine allowed tools based on mode - COMMON_TOOLS="mcp__github__get_pull_request,mcp__github__get_pull_request_files,mcp__github__get_pull_request_diff,mcp__github__get_pull_request_reviews,mcp__github__list_pull_request_comments,mcp__github__create_pending_pull_request_review,mcp__github__add_comment_to_pending_review,mcp__github__submit_pending_pull_request_review,mcp__github__create_and_submit_pull_request_review,mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr edit:*),Bash(gh label *),Bash(gh api:*),Bash(gh api graphql:*)" + COMMON_TOOLS="mcp__github__get_pull_request,mcp__github__get_pull_request_files,mcp__github__get_pull_request_diff,mcp__github__get_pull_request_reviews,mcp__github__list_pull_request_comments,mcp__github__create_pending_pull_request_review,mcp__github__add_comment_to_pending_review,mcp__github__submit_pending_pull_request_review,mcp__github__create_and_submit_pull_request_review,mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr edit:*),Bash(gh api:*),Bash(gh api graphql:*)" if [ "$MODE" = "review" ]; then TOOLS="$COMMON_TOOLS,Read,Grep,Glob,WebFetch,Bash(git diff:*),Bash(git log:*),Bash(git blame:*),Bash(gh issue create:*),Bash(gh pr create:*)" From 2147ed2357d9c98dd0fc2e8a6062a97af4c571e6 Mon Sep 17 00:00:00 2001 From: Joseph Mearman Date: Sun, 15 Feb 2026 10:54:39 +0000 Subject: [PATCH 3/4] feat(action): pass BOT_NAME to prompt templates via envsubst Add $BOT_NAME (from the bot_name input, default: claude[bot]) to the envsubst variable list so prompts can reference the bot identity directly. Remove the now-redundant Bash(gh api graphql:*) from allowed tools since identity detection no longer requires a GraphQL query. --- action.yml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/action.yml b/action.yml index c21c3a7..a80fcb7 100644 --- a/action.yml +++ b/action.yml @@ -133,6 +133,7 @@ runs: REPO: ${{ github.repository }} REPO_OWNER: ${{ github.repository_owner }} REPO_NAME: ${{ github.event.repository.name }} + BOT_NAME: ${{ inputs.bot_name }} run: | # Determine prompt directory if [ -n "$PROMPT_DIR" ]; then @@ -149,20 +150,20 @@ runs: # Org-wide shared prompts (bundled in action) for f in "${{ github.action_path }}/.github/prompts/shared"/*.md; do [ -f "$f" ] || continue - PROMPT="${PROMPT}$(envsubst '$REPO $REPO_OWNER $REPO_NAME $PR_NUMBER' < "$f")"$'\n' + PROMPT="${PROMPT}$(envsubst '$REPO $REPO_OWNER $REPO_NAME $PR_NUMBER $BOT_NAME' < "$f")"$'\n' done # Org-wide mode-specific prompts (bundled) for f in "${{ github.action_path }}/.github/prompts/$DIR"/*.md; do [ -f "$f" ] || continue - PROMPT="${PROMPT}$(envsubst '$REPO $REPO_OWNER $REPO_NAME $PR_NUMBER' < "$f")"$'\n' + PROMPT="${PROMPT}$(envsubst '$REPO $REPO_OWNER $REPO_NAME $PR_NUMBER $BOT_NAME' < "$f")"$'\n' done # Repo-specific shared prompts (if they exist) if [ -d ".github/prompts/shared" ]; then for f in .github/prompts/shared/*.md; do [ -f "$f" ] || continue - PROMPT="${PROMPT}$(envsubst '$REPO $REPO_OWNER $REPO_NAME $PR_NUMBER' < "$f")"$'\n' + PROMPT="${PROMPT}$(envsubst '$REPO $REPO_OWNER $REPO_NAME $PR_NUMBER $BOT_NAME' < "$f")"$'\n' done fi @@ -170,7 +171,7 @@ runs: if [ -d ".github/prompts/$DIR" ]; then for f in ".github/prompts/$DIR"/*.md; do [ -f "$f" ] || continue - PROMPT="${PROMPT}$(envsubst '$REPO $REPO_OWNER $REPO_NAME $PR_NUMBER' < "$f")"$'\n' + PROMPT="${PROMPT}$(envsubst '$REPO $REPO_OWNER $REPO_NAME $PR_NUMBER $BOT_NAME' < "$f")"$'\n' done fi @@ -181,7 +182,7 @@ runs: echo "$EOF" >> "$GITHUB_OUTPUT" # Determine allowed tools based on mode - COMMON_TOOLS="mcp__github__get_pull_request,mcp__github__get_pull_request_files,mcp__github__get_pull_request_diff,mcp__github__get_pull_request_reviews,mcp__github__list_pull_request_comments,mcp__github__create_pending_pull_request_review,mcp__github__add_comment_to_pending_review,mcp__github__submit_pending_pull_request_review,mcp__github__create_and_submit_pull_request_review,mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr edit:*),Bash(gh api:*),Bash(gh api graphql:*)" + COMMON_TOOLS="mcp__github__get_pull_request,mcp__github__get_pull_request_files,mcp__github__get_pull_request_diff,mcp__github__get_pull_request_reviews,mcp__github__list_pull_request_comments,mcp__github__create_pending_pull_request_review,mcp__github__add_comment_to_pending_review,mcp__github__submit_pending_pull_request_review,mcp__github__create_and_submit_pull_request_review,mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),Bash(gh pr edit:*),Bash(gh api:*)" if [ "$MODE" = "review" ]; then TOOLS="$COMMON_TOOLS,Read,Grep,Glob,WebFetch,Bash(git diff:*),Bash(git log:*),Bash(git blame:*),Bash(gh issue create:*),Bash(gh pr create:*)" From 88ff78572099d08f3e8161f73533da3cfff1d043 Mon Sep 17 00:00:00 2001 From: Joseph Mearman Date: Sun, 15 Feb 2026 10:54:45 +0000 Subject: [PATCH 4/4] fix(prompts): use static BOT_NAME instead of GraphQL identity query Replace the gh api graphql viewer query with the $BOT_NAME variable which is resolved at prompt composition time. This avoids a command that was being denied by allowedTools pattern matching when the bot wrapped it in a variable assignment. --- .github/prompts/shared/03-comment-hygiene.md | 12 ++++-------- README.md | 1 + 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/.github/prompts/shared/03-comment-hygiene.md b/.github/prompts/shared/03-comment-hygiene.md index 9002a86..d1d72e8 100644 --- a/.github/prompts/shared/03-comment-hygiene.md +++ b/.github/prompts/shared/03-comment-hygiene.md @@ -6,11 +6,7 @@ outdated text visible on the PR timeline. ### 0a. List all existing feedback -First, get your own bot identity: - -```sh -BOT_LOGIN=$(gh api graphql -f query='{ viewer { login } }' --jq '.data.viewer.login') -``` +Your bot identity is `$BOT_NAME`. List **all** reviews and comments to understand context and avoid duplicating feedback from others: @@ -24,9 +20,9 @@ gh api repos/${REPO}/issues/${PR_NUMBER}/comments --jq '.[] | {user: .user.login Identify your own previous activity (these are the only items you can modify): ```sh -gh api repos/${REPO}/pulls/${PR_NUMBER}/reviews --jq ".[] | select(.user.login == \"$BOT_LOGIN\") | {id, state, body}" -gh api repos/${REPO}/pulls/${PR_NUMBER}/comments --jq ".[] | select(.user.login == \"$BOT_LOGIN\") | {id, path, body}" -gh api repos/${REPO}/issues/${PR_NUMBER}/comments --jq ".[] | select(.user.login == \"$BOT_LOGIN\") | {id, body}" +gh api repos/${REPO}/pulls/${PR_NUMBER}/reviews --jq '.[] | select(.user.login == "$BOT_NAME") | {id, state, body}' +gh api repos/${REPO}/pulls/${PR_NUMBER}/comments --jq '.[] | select(.user.login == "$BOT_NAME") | {id, path, body}' +gh api repos/${REPO}/issues/${PR_NUMBER}/comments --jq '.[] | select(.user.login == "$BOT_NAME") | {id, body}' ``` Do not modify items you did not author. diff --git a/README.md b/README.md index f71211d..16ba9c0 100644 --- a/README.md +++ b/README.md @@ -275,6 +275,7 @@ Available environment variables in prompts: - `$REPO_OWNER` — Org name (e.g., `YOUR_ORG`) - `$REPO_NAME` — Repo name (e.g., `my-project`) - `$PR_NUMBER` — Pull request number (review mode only) +- `$BOT_NAME` — Bot username for git operations (e.g., `claude[bot]`) ## Secrets Required