AgentSkillsCN

fix-pr-comments

回复 GitHub PR 中的评论。在可能的情况下,直接在评论线程中进行回复。该技能会获取所有评论,规划修改方案,完成代码变更并提交,随后逐一回复各条评论线程。

SKILL.md
--- frontmatter
name: fix-pr-comments
description: Address comments on a GitHub PR. Reply directly to comment threads where possible. Fetches all comments, plans changes, makes code changes, commits, and replies to each thread.

Fix PR Comments

Address GitHub PR comments by assessing each one, making valid changes, and replying with rationale.

Workflow

  1. Fetch PR info and ALL comments (use --paginate for all pages):

    bash
    gh pr view --json number,headRepositoryOwner,headRepository
    gh api repos/{owner}/{repo}/pulls/{pr}/comments --paginate
    gh api repos/{owner}/{repo}/issues/{pr}/comments --paginate
    
  2. Assess each comment using this framework:

    AssessmentActionReply
    Valid & clearMake the changeBrief summary of change
    Valid but disagreeNo changeTechnical rationale for current approach
    Invalid/incorrectNo changeExplain why suggestion doesn't apply
    UnclearNo changeAsk clarifying question
  3. For comments with line numbers: Fetch file at the referenced commit (line numbers are commit-specific):

    bash
    git show {commit_id}:{file_path}
    
  4. Plan ALL changes before editing — line numbers shift once you start editing.

  5. Make changes and commit:

    bash
    git add <specific-files>
    git commit -m "Address PR review comments"
    
  6. If changes were made: Update PR description, then push:

    bash
    # Append summary to PR body (review agents read this on push)
    gh pr edit --body "$(gh pr view --json body -q .body)
    
    ---
    ## Comments Addressed
    - [Brief summary of each change made]
    "
    git push
    
  7. Reply to EACH comment thread using the correct endpoint:

    bash
    # For review comments (have pull_request_review_id):
    gh api repos/{owner}/{repo}/pulls/{pr}/comments -X POST \
      --field body="[🤖 YourName]: Your reply" \
      --field in_reply_to={comment_id}
    
    # For issue comments (general PR comments):
    gh api repos/{owner}/{repo}/issues/{pr}/comments -X POST \
      -f body="[🤖 YourName]: Your reply"
    

Reply Templates

Use [🤖 YourName]: prefix where "YourName" is your AI model name (e.g., Claude, GPT, Gemini).

Change made:

code
[🤖 YourName]: Done — updated X to use Y as suggested.

Valid but disagree:

code
[🤖 YourName]: Keeping the current approach because [technical reason].
The suggestion would [tradeoff/issue]. Happy to discuss further.

Invalid/doesn't apply:

code
[🤖 YourName]: No change made — [explain why suggestion doesn't apply,
e.g., "this code path only handles X case" or "Y is already handled at line Z"].

Need clarification:

code
[🤖 YourName]: Could you clarify [specific question]?
I want to make sure I address this correctly.

Critical Rules

  • [🤖 YourName]: prefix on EVERY reply — substitute your AI name (Claude, GPT, etc.)
  • Reply to ALL comments — each gets its own API call
  • Update PR description, then push, then reply — in that order
  • Use --field in_reply_to for review comments (not /replies endpoint)