From coderabbit-pack
Apply production-ready CodeRabbit automation patterns using GitHub API and PR comments. Use when building automation around CodeRabbit reviews, processing review feedback programmatically, or integrating CodeRabbit into custom workflows. Trigger with phrases like "coderabbit automation", "coderabbit API patterns", "automate coderabbit", "coderabbit github api", "process coderabbit reviews".
npx claudepluginhub flight505/skill-forge --plugin coderabbit-packThis skill is limited to using the following tools:
CodeRabbit does not have a traditional SDK. You interact with it through `.coderabbit.yaml` configuration, PR comment commands (`@coderabbitai`), and the GitHub/GitLab API to process its review output. These patterns show how to automate around CodeRabbit reviews programmatically.
Guides Next.js Cache Components and Partial Prerendering (PPR): 'use cache' directives, cacheLife(), cacheTag(), revalidateTag() for caching, invalidation, static/dynamic optimization. Auto-activates on cacheComponents: true.
Guides building MCP servers enabling LLMs to interact with external services via tools. Covers best practices, TypeScript/Node (MCP SDK), Python (FastMCP).
Share bugs, ideas, or general feedback.
CodeRabbit does not have a traditional SDK. You interact with it through .coderabbit.yaml configuration, PR comment commands (@coderabbitai), and the GitHub/GitLab API to process its review output. These patterns show how to automate around CodeRabbit reviews programmatically.
coderabbit-install-auth)gh) or GitHub API access via personal access token// scripts/fetch-coderabbit-reviews.ts
import { Octokit } from "@octokit/rest";
const octokit = new Octokit({ auth: process.env.GITHUB_TOKEN });
async function getCodeRabbitReview(owner: string, repo: string, prNumber: number) {
const reviews = await octokit.pulls.listReviews({ owner, repo, pull_number: prNumber });
const coderabbitReview = reviews.data.find(
(r) => r.user?.login === "coderabbitai[bot]"
);
if (!coderabbitReview) {
console.log("No CodeRabbit review found yet. Review typically takes 2-5 minutes.");
return null;
}
return {
state: coderabbitReview.state, // "APPROVED" | "CHANGES_REQUESTED" | "COMMENTED"
body: coderabbitReview.body, // Walkthrough summary
submittedAt: coderabbitReview.submitted_at,
};
}
async function getCodeRabbitComments(owner: string, repo: string, prNumber: number) {
const comments = await octokit.pulls.listReviewComments({
owner, repo, pull_number: prNumber,
});
const coderabbitComments = comments.data
.filter((c) => c.user?.login === "coderabbitai[bot]")
.map((c) => ({
file: c.path,
line: c.line || c.original_line,
body: c.body,
severity: categorizeSeverity(c.body),
url: c.html_url,
}));
return coderabbitComments;
}
function categorizeSeverity(body: string): "critical" | "warning" | "suggestion" {
const lower = body.toLowerCase();
if (lower.includes("security") || lower.includes("vulnerability") || lower.includes("injection")) {
return "critical";
}
if (lower.includes("bug") || lower.includes("error") || lower.includes("issue")) {
return "warning";
}
return "suggestion";
}
// Programmatically trigger CodeRabbit actions
async function sendCodeRabbitCommand(
owner: string, repo: string, prNumber: number, command: string
) {
await octokit.issues.createComment({
owner, repo, issue_number: prNumber,
body: `@coderabbitai ${command}`,
});
}
// Available commands:
// "full review" - Complete review from scratch
// "summary" - Generate walkthrough summary
// "resolve" - Mark all comments resolved
// "generate-docstrings" - Generate docstrings for functions
// "configuration" - Show current config as YAML
// "run <recipe>" - Run a finishing touch recipe
#!/bin/bash
# scripts/coderabbit-dashboard.sh - Review metrics for last 50 PRs
set -euo pipefail
ORG="${1:?Usage: $0 <org> <repo>}"
REPO="${2:?Usage: $0 <org> <repo>}"
echo "=== CodeRabbit Review Dashboard ==="
echo "Repository: $ORG/$REPO"
echo ""
# Count PRs with CodeRabbit reviews
TOTAL=$(gh api "repos/$ORG/$REPO/pulls?state=closed&per_page=50" --jq 'length')
REVIEWED=0
for PR_NUM in $(gh api "repos/$ORG/$REPO/pulls?state=closed&per_page=50" --jq '.[].number'); do
HAS_CR=$(gh api "repos/$ORG/$REPO/pulls/$PR_NUM/reviews" \
--jq '[.[] | select(.user.login=="coderabbitai[bot]")] | length' 2>/dev/null || echo "0")
[ "$HAS_CR" -gt 0 ] && REVIEWED=$((REVIEWED + 1))
done
echo "Review Coverage: $REVIEWED/$TOTAL PRs reviewed ($(( REVIEWED * 100 / TOTAL ))%)"
# .github/workflows/coderabbit-gate.yml
# Block merge until CodeRabbit has reviewed
name: CodeRabbit Review Gate
on:
pull_request_review:
types: [submitted]
jobs:
check-coderabbit:
if: github.event.review.user.login == 'coderabbitai[bot]'
runs-on: ubuntu-latest
steps:
- name: Check review state
uses: actions/github-script@v7
with:
script: |
const { data: reviews } = await github.rest.pulls.listReviews({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
});
const crReview = reviews.find(r => r.user.login === 'coderabbitai[bot]');
if (crReview?.state === 'CHANGES_REQUESTED') {
core.setFailed('CodeRabbit requested changes. Address feedback before merging.');
} else {
core.info(`CodeRabbit review state: ${crReview?.state || 'pending'}`);
}
| Issue | Cause | Solution |
|---|---|---|
| Review not found | PR too new | Wait 2-5 minutes for review to complete |
| 403 from GitHub API | Token missing scopes | Ensure repo scope on personal access token |
| Bot login doesn't match | Different app slug | Check with coderabbitai[bot] (includes [bot] suffix) |
| Rate limited by GitHub | Too many API calls | Use pagination and caching for bulk queries |
Apply patterns in coderabbit-core-workflow-a for real-world review workflows.