Respond to bot review comments on a PR after evaluation and fixes
Post replies to bot review comments after evaluating feedback and making fixes. Use after `/beagle:fetch-pr-feedback` to address CodeRabbit or other bot comments on your PR.
/plugin marketplace add existential-birds/beagle/plugin install beagle@existential-birdsPost replies to bot review comments after you've evaluated the feedback and made fixes.
/beagle:respond-pr-feedback [--bot <username>] [--pr <number>] [--as <username>]
Flags:
--bot <username> - Bot whose comments to respond to (default: coderabbitai[bot])--pr <number> - PR number to target (default: current branch's PR)--as <username> - Filter already-replied based on this responder (default: current gh user)Run /beagle:fetch-pr-feedback first to evaluate the feedback and make any necessary fixes.
Extract flags from $ARGUMENTS:
--bot <username> or default to coderabbitai[bot]--pr <number> or detect from current branch--as <username> or detect from gh api user# Get repo info
gh repo view --json nameWithOwner --jq '.nameWithOwner'
# Get PR number (if not specified)
gh pr view --json number --jq '.number'
# Get responder username (if --as not specified)
gh api user --jq '.login'
This query filters out already-replied comments and deduplicates (CodeRabbit reposts on each iteration):
gh api --paginate "repos/{owner}/{repo}/pulls/{number}/comments" | jq -s 'add |
# Get root comments from target bot (not replies to itself)
[.[] | select(.user.login == "{bot}" and .in_reply_to_id == null)] as $roots |
# Get IDs that responder has already replied to
[.[] | select(.user.login == "{responder}") | .in_reply_to_id] as $replied |
# Filter to unreplied comments only
$roots | map(select(. as $c | $replied | index($c.id) == null)) |
# Group by file:line and pick newest comment for each (handles duplicates)
group_by({p: .path, l: .line}) |
map(sort_by(.created_at) | last) |
# Output needed fields
map({id, path, line, body})
'
If no unreplied comments found, output: "All {bot} comments have been addressed."
For each unreplied comment, determine the appropriate response based on your evaluation:
| Evaluation Outcome | Response |
|---|---|
| Feedback was incorrect/unfounded | Explain why the current code is correct |
| Feedback lacked context | Explain the design decision |
| Feedback was valid and fixed | "Fixed in {commit}" or brief description of change |
| Feedback was valid but won't fix | Explain the tradeoff/decision |
Post reply to each comment:
gh api "repos/{owner}/{repo}/pulls/{number}/comments/{comment_id}/replies" \
-X POST --raw-field body="@{bot} {response}"
After posting replies, ask the user:
Would you like to resolve these conversation threads?
- Yes, all - Resolve all threads that were just replied to
- Select individually - Choose which threads to resolve
- No - Leave threads open for further discussion
To resolve a thread, use the GraphQL API:
gh api graphql -f query='
mutation {
resolveReviewThread(input: {threadId: "{thread_id}"}) {
thread { isResolved }
}
}
'
Note: To get the thread_id, you need to query review threads:
gh api graphql -f query='
query {
repository(owner: "{owner}", name: "{repo}") {
pullRequest(number: {number}) {
reviewThreads(first: 100) {
nodes {
id
isResolved
comments(first: 1) {
nodes { databaseId }
}
}
}
}
}
}
'
Match databaseId to your comment IDs to find the corresponding thread_id.
Display a summary table:
| File:Line | Response Type | Thread Status |
|---|---|---|
src/foo.ts:42 | Fixed | Resolved |
src/bar.ts:15 | Explained design | Open |
@coderabbitai ...# Respond to CodeRabbit on current PR
/beagle:respond-pr-feedback
# Respond on a specific PR
/beagle:respond-pr-feedback --pr 123
# Use different bot/responder
/beagle:respond-pr-feedback --bot renovate[bot] --as my-bot[bot]