with one click
coderabbit
// Triage CodeRabbit review comments on a PR — vet, apply valid fixes, reply
// Triage CodeRabbit review comments on a PR — vet, apply valid fixes, reply
[HINT] Download the complete skill directory including SKILL.md and all related files
| name | coderabbit |
| description | Triage CodeRabbit review comments on a PR — vet, apply valid fixes, reply |
| argument-hint | [PR number | PR URL | owner/repo#number] [--batch] |
| user-invocable | true |
You are triaging CodeRabbit automated review comments on a GitHub PR. Your job is to be a skeptical, experienced engineer who categorizes each finding, generates fixes for valid ones, and lets the user confirm before anything is applied or replied to.
Most CodeRabbit findings are noise. Apply the same skepticism as vet-review: surface only things that actually matter. For each finding, ask:
CodeRabbit's suggestion blocks are often mechanically correct but
sometimes miss context. Its walkthrough/summary comments are mostly
noise, but occasionally contain substantive findings that don't appear
as inline comments — these should be surfaced and vetted.
Kill the noise. If a finding doesn't survive this filter, drop it.
Parse $ARGUMENTS to extract the PR identifier:
PR URL (e.g., https://github.com/owner/repo/pull/123):
Extract owner, repo, and number from the URL path.
owner/repo#number: Parse directly.
Bare number (e.g., 123, #123): Determine owner/repo from
the current working directory:
gh repo view --json owner,name --jq '"\(.owner.login)/\(.name)"'
No arguments: Detect the PR from the current branch:
gh pr view --json number,url
Store OWNER, REPO, and PR_NUMBER for subsequent steps.
Check whether $ARGUMENTS contains --batch. If present, set
BATCH_MODE = true and remove --batch from the argument string
before parsing the PR identifier. When BATCH_MODE is false (the
default), the full interactive workflow applies.
2a. Summary comment (read for context; extract actionable findings):
gh api "repos/{OWNER}/{REPO}/issues/{PR_NUMBER}/comments" \
--paginate --jq '[.[] | select(.user.login == "coderabbitai[bot]")]'
Read the walkthrough and summary for background understanding.
Then parse for actionable findings. CodeRabbit sometimes posts substantive findings only in the summary — cross-cutting issues, missing artifacts, or whole-PR concerns that don't map to a single diff line. These appear as bulleted or numbered items under headings like "Actionable comments", "Additional comments", or similar sections. Extract each discrete finding that:
Tag each extracted finding with SOURCE: summary. These findings
will not have a COMMENT_ID, path, or line — record the
ISSUE_COMMENT_ID (the id of the issue comment they came from)
for use in the reply step.
Most summary content is walkthrough noise — apply the same skepticism as inline findings. Only surface items that would survive the vet filter in Step 4.
2b. Review body (nitpicks and other non-inline findings):
gh api "repos/{OWNER}/{REPO}/pulls/{PR_NUMBER}/reviews" \
--paginate --jq '[.[] | select(.user.login == "coderabbitai[bot]")] | .[].body'
CodeRabbit nests nitpick findings inside the review body rather than
posting them as standalone inline comments. These appear in
<details> blocks under headings like 🧹 Nitpick comments (N).
Each nitpick typically includes a file path, line number, description,
and sometimes a proposed diff.
Parse the review body for discrete findings:
<summary>🧹 Nitpick comments sectionsTag each extracted finding with SOURCE: review-body. These
findings have file/line context (unlike summary findings) but no
individual COMMENT_ID for inline replies.
2c. Inline review comments (primary line-level actionable items):
gh api "repos/{OWNER}/{REPO}/pulls/{PR_NUMBER}/comments" \
--paginate --jq '[.[] | select(.user.login == "coderabbitai[bot]")]'
Each comment contains: id, path, line, original_line, body,
diff_hunk, in_reply_to_id, commit_id.
2d. Duplicate prevention: For each CodeRabbit comment, check
whether a non-bot reply already exists (a comment whose
in_reply_to_id matches this comment's id). Skip comments that
have already been addressed.
Edge cases:
"No CodeRabbit comments found on PR #{PR_NUMBER}." and stop."No CodeRabbit inline comments found. Triaging N finding(s) from review body/summary.""All CodeRabbit comments on PR #{PR_NUMBER} have already been addressed."
and stop.gh pr diff {PR_NUMBER} --repo {OWNER}/{REPO}
For each unaddressed inline CodeRabbit comment:
path using the Read tool. You need the
surrounding code, not just the diff hunk.For each review-body-sourced finding (SOURCE: review-body):
For each summary-sourced finding (SOURCE: summary):
Identify affected files from the finding's description and the PR diff. Read the relevant files for context. If the finding is about a missing artifact (e.g., missing docs, missing tests), verify it is actually missing.
Parse the comment body:
```suggestion code blocks if present — these are
CodeRabbit's explicit replacement text.Vet the finding:
Categorize into exactly one bucket:
AUTO-APPLY — Unequivocally correct. Very high threshold. Only for:
REVIEW — Valid finding, but involves any of:
DROPPED — Noise:
Generate the fix for AUTO-APPLY and REVIEW items:
suggestion block: use that exact
replacement text.BATCH_MODE = true)When BATCH_MODE is true, skip Steps 5 through 9 entirely. Instead,
output a single JSON object containing all findings:
{
"findings": [
{
"comment_id": "<number|null>",
"category": "auto_apply|review|dropped",
"source": "inline|review-body|summary",
"file": "<string|null>",
"line": "<number|null>",
"description": "<string>",
"fix_diff": "<string|null>",
"reason": "<string>"
}
]
}
Field definitions:
id for inline-sourced findings.
null for review-body and summary-sourced findings (these have no
individual comment ID).auto_apply, review,
or dropped.inline, review-body, or
summary.null for summary findings that are not
file-specific.null for summary findings.null for
dropped findings or findings where no fix was generated.Rules for batch output:
{"findings": []}.(Interactive mode only — skip when BATCH_MODE = true.)
Present ALL findings in a single structured output. Do NOT present findings one-by-one. The user needs to see the full picture before confirming any actions.
Format:
## CodeRabbit Triage — PR #{PR_NUMBER}
**PR**: {title}
**CodeRabbit comments**: N inline (M unaddressed), J review-body, K summary
### Overview
| # | Category | Source | File | Line | Finding |
|---|----------|--------|------|------|---------|
| 1 | AUTO-APPLY | inline | path/file.go | 42 | Missing nil check on foo |
| 2 | REVIEW | inline | pkg/api.go | 15 | Error not propagated from bar() |
| 3 | REVIEW | review-body | cmd/main.go | 88 | Parenthetical contradicts new behavior |
| 4 | REVIEW | summary | — | — | No migration docs for schema change |
| 5 | DROPPED | inline | utils/helper.go | 33 | "Consider extracting to helper" |
---
### Auto-Apply (N)
**1. path/file.go:42 — Missing nil check**
CodeRabbit: `brief quote`
--- a/path/file.go
+++ b/path/file.go
- original code
+ fixed code
### Needs Review (N)
**2. pkg/api.go:15 — Error not propagated**
CodeRabbit: `brief quote`
Assessment: `why this is valid but needs human judgment`
--- a/pkg/api.go
+++ b/pkg/api.go
- original code
+ fixed code
**3. cmd/main.go:88 — Parenthetical contradicts new behavior** (review-body)
CodeRabbit: `brief quote from nitpick`
Assessment: `why this is a genuine inconsistency`
--- a/cmd/main.go
+++ b/cmd/main.go
- old wording
+ fixed wording
**4. (summary) No migration docs for schema change**
CodeRabbit: `brief quote from summary`
Assessment: `why this is valid`
Affected files: db/migrations/0042_add_column.sql
### Dropped (N)
| # | Finding | Reason |
|---|---------|--------|
| 5 | "Consider extracting to helper" | Refactoring advice — not a bug |
---
Actions:
- Confirm auto-apply items? (or reject by number)
- Accept or reject review items? (by number)
- Override dropped items? (by number)
(Interactive mode only — skip when BATCH_MODE = true.)
Wait for the user's response. Parse it to build the final action list. Accept flexible input:
"confirm all" — apply all auto-apply items, skip review items"confirm all, accept 2" — apply auto-apply + item 2"reject 1, accept 2" — reject auto-apply item 1, accept item 2"override 3" — un-drop item 3 and apply itIf the response is ambiguous, ask for clarification.
Hard rule: do NOT apply anything until the user has reviewed the full table and confirmed.
(Interactive mode only — skip when BATCH_MODE = true.)
For all confirmed items:
Apply edits to the codebase using the Edit tool. Within each file, apply changes from bottom to top (highest line number first) to avoid line number drift.
Create a single commit with a message like:
Apply CodeRabbit suggestions from PR #{PR_NUMBER}
Auto-applied:
- {file}:{line}: {brief description}
Accepted after review:
- {file}:{line}: {brief description}
Co-Authored-By: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Record the commit SHA for use in PR replies.
(Interactive mode only — skip when BATCH_MODE = true.)
For inline-sourced findings, post an inline reply:
Applied items:
gh api "repos/{OWNER}/{REPO}/pulls/{PR_NUMBER}/comments/{COMMENT_ID}/replies" \
-f body="Applied — fixed in {SHA_SHORT}."
Declined items (review items the user rejected):
gh api "repos/{OWNER}/{REPO}/pulls/{PR_NUMBER}/comments/{COMMENT_ID}/replies" \
-f body="Won't fix — {one-line reason}."
Dropped items:
gh api "repos/{OWNER}/{REPO}/pulls/{PR_NUMBER}/comments/{COMMENT_ID}/replies" \
-f body="Won't fix — {one-line reason}."
For review-body and summary-sourced findings, post a top-level issue comment (since there is no inline comment to reply to):
gh api "repos/{OWNER}/{REPO}/issues/{PR_NUMBER}/comments" \
-f body="Re: CodeRabbit summary finding — {brief description}
{Applied — fixed in {SHA_SHORT}. | Won't fix — {one-line reason}.}"
If multiple review-body/summary findings were actioned, batch them into a single issue comment to avoid noise:
gh api "repos/{OWNER}/{REPO}/issues/{PR_NUMBER}/comments" \
-f body="Addressed CodeRabbit summary findings:
- {finding 1}: Applied — fixed in {SHA_SHORT}.
- {finding 2}: Won't fix — {one-line reason}."
Verification gate — do not proceed to Step 9 until this passes:
Count the replies you just posted (inline + issue comments). The total must equal the number of unaddressed findings from the overview table (all categories: applied, declined, dropped). If the count doesn't match, identify the missing findings and post the remaining replies.
Checklist:
(Interactive mode only — skip when BATCH_MODE = true.)
## Done
**Commit**: {SHA_SHORT} ({N} files changed)
**PR replies posted**: {M} (applied: X, declined: Y, dropped: Z)
Changes are local. Push when ready.
| Scenario | Action |
|---|---|
| No findings from any source | Report and stop |
| No inline comments but review-body/summary findings exist | Triage non-inline findings only |
| All inline comments replied to, no other findings | Report and stop |
| All inline comments replied to, review-body/summary findings exist | Triage non-inline findings only |
| Suggestion block conflicts with current code | Recategorize to REVIEW |
| Comment on a deleted file | Skip with note |
| Review-body/summary finding duplicates an inline comment | Use inline version, skip duplicate |
| All items dropped | Report: "None survive scrutiny as real issues" |
| User wants to re-process replied comments | Allow if explicitly requested |