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/.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 diff --git a/action.yml b/action.yml index c0fd89f..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 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:*)"