Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 25 additions & 29 deletions .github/prompts/shared/02-guidelines.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
<!-- claude:start -->
<only add information not already present in the description>
<!-- claude:end -->
EOF
)"
```

The markers `<!-- claude:start -->` / `<!-- claude:end -->` 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'
<!-- claude:start -->
<only add information not already present in the description>
<!-- claude:end -->
EOF
)"
```

The markers `<!-- claude:start -->` / `<!-- claude:end -->` 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.
12 changes: 4 additions & 8 deletions .github/prompts/shared/03-comment-hygiene.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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.
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 6 additions & 5 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -149,28 +150,28 @@ 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

# Repo-specific mode-specific prompts (if they exist)
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

Expand All @@ -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 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 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:*)"
Expand Down