AgentSkillsCN

Reply

当用户提出“回复 PR 评论”、“回应评审评论”、“回复 PR”时,应使用此技能。

SKILL.md
--- frontmatter
description: This skill should be used when the user asks to "reply to PR comments", "respond to review comments", "reply to PR #123", "answer PR feedback", or wants to respond to unresolved review threads or comments from other users on a pull request.
argument-hint: "<pr-number>"
disable-model-invocation: true
allowed-tools: Bash, Read, Grep, Glob

GitHub PR Comment Replier

Reply to comments on a GitHub pull request by finding threads that need responses, generating thoughtful replies based on codebase context, and posting them directly.

Filter criteria for actionable threads:

  • Thread is not resolved
  • Latest comment was not generated by Claude Code (detected by "Claude Code" signature in comment body)

Helper Scripts

This skill provides two helper scripts in scripts/:

ScriptPurpose
fetch-review-threads.shFetch review threads from a PR with optional filtering
post-reply.shPost a reply to a review thread

Workflow

Step 1: Fetch Actionable Threads

Use the helper script to fetch review threads that need replies:

bash
PR_NUMBER=$ARGUMENTS
bash ${CLAUDE_PLUGIN_ROOT}/skills/reply/scripts/fetch-review-threads.sh $PR_NUMBER --filter-actionable

This returns JSON with:

  • owner, repo, prNumber: Repository context
  • threads: Array of threads requiring action
  • totalCount: Number of actionable threads

Each thread contains:

  • id: Thread ID for posting replies (e.g., PRRT_xxx)
  • isResolved: Always false (filtered)
  • path: File path in the repository
  • line: Line number in the file
  • comments.nodes: Array of all comments in the thread (latest comment is last)

If no actionable threads are found (totalCount: 0), report that no replies are needed.

Step 2: Analyze and Generate Replies

For each actionable thread:

  1. Read all comments: Parse the entire comments.nodes array to understand the full conversation context
  2. Examine the code context: Read the file at path around line
  3. Analyze the codebase: Use Grep and Glob to understand related code and patterns
  4. Generate a thoughtful reply: Address the reviewer's concern with specifics

When generating replies:

  • Be concise but thorough
  • Reference specific code when relevant
  • Acknowledge valid points
  • Suggest changes or improvements (but do NOT modify any files)
  • If suggesting a fix, explain what should be changed and why

Step 3: Post Replies

Post each reply using the helper script:

bash
bash ${CLAUDE_PLUGIN_ROOT}/skills/reply/scripts/post-reply.sh "<thread-id>" "<reply-body>"

Or for longer replies, write to a file first:

bash
bash ${CLAUDE_PLUGIN_ROOT}/skills/reply/scripts/post-reply.sh --file "<thread-id>" /tmp/reply.md

The script returns JSON with:

  • success: Boolean indicating success
  • comment.id: The created comment's ID
  • comment.url: URL to the comment

Step 4: Report Summary

After processing all threads, provide a summary:

  • Number of threads processed
  • Number of replies posted
  • Any errors encountered

Important Guidelines

No Code Changes

This skill must NOT modify any files. Only suggest changes in replies:

  • Do NOT use Write or Edit tools
  • Do NOT create or modify any files
  • Only read files for context and analysis
  • Suggest code changes in the reply text, not by editing files

Reply Quality

  • Address the specific concern raised in the comment
  • Provide context from the codebase when relevant
  • Be professional and collaborative
  • Keep replies focused and actionable

Codebase Analysis

  • Read the file mentioned in the thread's path field
  • Look at surrounding code for context
  • Check for related patterns elsewhere in the codebase
  • Consider the reviewer's perspective

Error Handling

  • If gh CLI is not authenticated, inform the user to run gh auth login
  • If the PR number is invalid, report the error clearly
  • If no actionable threads are found, report that no replies are needed
  • If posting a reply fails, report the error and continue with remaining threads

Script Reference

fetch-review-threads.sh

code
Usage: fetch-review-threads.sh <pr-number> [--filter-actionable]

Options:
  --filter-actionable  Filter to show only threads requiring a reply:
                       - Thread is not resolved
                       - Latest comment was NOT generated by Claude Code

Output: JSON with repository info and thread array

post-reply.sh

code
Usage: post-reply.sh <thread-id> <body>
       post-reply.sh --file <thread-id> <body-file>

Arguments:
  thread-id   The GraphQL ID of the review thread (e.g., PRRT_xxx)
  body        The reply message text
  body-file   Path to a file containing the reply message

Note: Automatically appends a "Claude Code" signature to identify
      AI-generated replies for filtering in subsequent runs.

Output: JSON with success status and comment details