@routerhub/agent-rules 1.5.87 → 1.5.89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AGENTS.base.md +9 -1
- package/package.json +1 -1
- package/rules/devops.md +6 -0
- package/rules/global.md +3 -1
- package/skills/create-doc/SKILL.md +2 -0
- package/skills/create-pr/SKILL.md +2 -0
- package/skills/deploy-test/SKILL.md +8 -0
- package/skills/figma-to-code/SKILL.md +2 -0
- package/skills/github-pr-review/SKILL.md +233 -0
- package/skills/github-pr-review/references/coderabbit_parsing.md +206 -0
- package/skills/github-pr-review/references/severity_guide.md +222 -0
- package/skills/tdd-workflow/SKILL.md +2 -0
package/AGENTS.base.md
CHANGED
|
@@ -56,7 +56,9 @@
|
|
|
56
56
|
|
|
57
57
|
## 部署规则
|
|
58
58
|
|
|
59
|
-
- 发版统一执行 `./release.sh
|
|
59
|
+
- 发版统一执行 `./release.sh`。
|
|
60
|
+
- ⚠️ 部署测试环境必须使用 `/deploy-test` skill。任何包含「部署测试」「发布测试」「上线测试」「部署test」「推到test」「部署到测试环境」等表述的需求,必须先调用 `Skill` 工具加载 `deploy-test`,严禁跳过 skill 直接执行部署操作。
|
|
61
|
+
- ⚠️ 部署测试环境的正确流程是:当前分支 → 合并到 test 分支 → 推送 test → 触发部署 → 切回原分支。禁止直接在 test 分支上提交代码,禁止跳过合并步骤直接部署功能分支。
|
|
60
62
|
|
|
61
63
|
## 文档规则
|
|
62
64
|
|
|
@@ -94,3 +96,9 @@
|
|
|
94
96
|
## 部署规则
|
|
95
97
|
|
|
96
98
|
<!-- 部署特有规则在此添加 -->
|
|
99
|
+
|
|
100
|
+
### 🚨 测试环境部署铁律(不可跳过)
|
|
101
|
+
|
|
102
|
+
- ⚠️ **部署到测试环境唯一入口:`/deploy-test` skill。** 不论用户怎么表述(「部署测试」「帮我部署」「推到test」「发布测试环境」等),必须通过 `Skill` 工具调用 `deploy-test`,禁止凭记忆手动执行 git 命令。
|
|
103
|
+
- ⚠️ **必须先合并再部署**:流程必须是 `当前功能分支 → merge 到 test → push test → 触发部署 → 切回原分支`。严禁跳过 merge 步骤直接部署功能分支。
|
|
104
|
+
- ⚠️ **部署完成后必须切回原分支**,不得停留在 test 分支。
|
package/package.json
CHANGED
package/rules/devops.md
CHANGED
|
@@ -7,3 +7,9 @@ outputName: "devops"
|
|
|
7
7
|
## 部署规则
|
|
8
8
|
|
|
9
9
|
<!-- 部署特有规则在此添加 -->
|
|
10
|
+
|
|
11
|
+
### 🚨 测试环境部署铁律(不可跳过)
|
|
12
|
+
|
|
13
|
+
- ⚠️ **部署到测试环境唯一入口:`/deploy-test` skill。** 不论用户怎么表述(「部署测试」「帮我部署」「推到test」「发布测试环境」等),必须通过 `Skill` 工具调用 `deploy-test`,禁止凭记忆手动执行 git 命令。
|
|
14
|
+
- ⚠️ **必须先合并再部署**:流程必须是 `当前功能分支 → merge 到 test → push test → 触发部署 → 切回原分支`。严禁跳过 merge 步骤直接部署功能分支。
|
|
15
|
+
- ⚠️ **部署完成后必须切回原分支**,不得停留在 test 分支。
|
package/rules/global.md
CHANGED
|
@@ -56,7 +56,9 @@ name: "通用规则"
|
|
|
56
56
|
|
|
57
57
|
## 部署规则
|
|
58
58
|
|
|
59
|
-
- 发版统一执行 `./release.sh
|
|
59
|
+
- 发版统一执行 `./release.sh`。
|
|
60
|
+
- ⚠️ 部署测试环境必须使用 `/deploy-test` skill。任何包含「部署测试」「发布测试」「上线测试」「部署test」「推到test」「部署到测试环境」等表述的需求,必须先调用 `Skill` 工具加载 `deploy-test`,严禁跳过 skill 直接执行部署操作。
|
|
61
|
+
- ⚠️ 部署测试环境的正确流程是:当前分支 → 合并到 test 分支 → 推送 test → 触发部署 → 切回原分支。禁止直接在 test 分支上提交代码,禁止跳过合并步骤直接部署功能分支。
|
|
60
62
|
|
|
61
63
|
## 文档规则
|
|
62
64
|
|
|
@@ -11,8 +11,16 @@ description: >-
|
|
|
11
11
|
|
|
12
12
|
# 部署测试环境
|
|
13
13
|
|
|
14
|
+
⚠️ **本 Skill 已触发。第一句话必须输出:「🔧 已触发 `deploy-test`,按流程部署测试环境...」然后严格按照以下步骤执行,不得跳过。**
|
|
15
|
+
|
|
14
16
|
将当前功能分支部署到测试环境,完成后自动切回原分支。
|
|
15
17
|
|
|
18
|
+
## 🚨 铁律(违反即错误)
|
|
19
|
+
|
|
20
|
+
- ⚠️ 部署测试环境**唯一正确流程**:当前功能分支 → 合并到 test → 推送 test → 触发部署 → 切回原分支。
|
|
21
|
+
- ⚠️ **绝对禁止**跳过合并步骤、直接在功能分支上部署、或往 test 分支直接提交代码。
|
|
22
|
+
- ⚠️ 每一步必须执行完毕并确认成功后才能进入下一步,不可并行或跳过。
|
|
23
|
+
|
|
16
24
|
## 核心流程
|
|
17
25
|
|
|
18
26
|
### 1. 记录当前分支
|
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: github-pr-review
|
|
3
|
+
description: >-
|
|
4
|
+
PR Code Review 评论处理 / 解决 Review 反馈 / 处理 Reviewer 意见。触发场景包括但不限于:
|
|
5
|
+
「处理review」「处理review评论」「处理review意见」「处理review反馈」「处理PR评论」「处理PR review」。
|
|
6
|
+
「解决review」「解决PR评论」「解决PR review」「解决review评论」「解决review意见」「解决review反馈」。
|
|
7
|
+
「修复review」「修复PR评论」「修复review评论」「修复review意见」「修复review反馈」「修复review问题」。
|
|
8
|
+
「回复review」「回复review评论」「回复review意见」「回复PR评论」「回复reviewer」「回复审阅」「回复审阅意见」。
|
|
9
|
+
「看review」「看下review」「看一下review」「看看review」「查看review」「查看review评论」「查看PR review」「查看PR评论」。
|
|
10
|
+
「review一下」「review下」「看一下PR」「看看PR」「审阅一下」「审一下」「Code Review」「code review」。
|
|
11
|
+
「处理审查」「解决审查」「修复审查」「回复审查」「查看审查」「审查一下」。
|
|
12
|
+
「评审」「评审一下」「处理评审」「看一下评审」「看看评审」「回复评审」。
|
|
13
|
+
「有人review了」「有人审阅了」「有人评论了」「有review了」「有review评论」「有新的review」「有新review」「来review了」。
|
|
14
|
+
「review怎么改」「review要我改」「review让我改」「review说了」「review提到」「review指出的」「review提到的问题」。
|
|
15
|
+
「reviwer说了」「reviwer让我改」「reviwer要我改」「reviwer提到」。
|
|
16
|
+
「re-request」「重新请求review」「重新请求审阅」「发起re-review」。
|
|
17
|
+
「PR反馈」「PR审阅」「PR审查」「PR评审」。
|
|
18
|
+
通过 GitHub CLI 拉取评论 → 按严重程度分类 → 逐条提出修复 → 用户确认后提交 → 回复对应 thread。
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
# GitHub PR review
|
|
22
|
+
|
|
23
|
+
⚠️ **本 Skill 已触发。第一句话必须输出:「🔧 已触发 `github-pr-review`,按流程拉取 Review 评论并逐条处理...」然后严格按照以下步骤执行,不得跳过。**
|
|
24
|
+
|
|
25
|
+
Resolves Pull Request review comments with severity-based prioritization, fix application, and thread replies.
|
|
26
|
+
|
|
27
|
+
## Current PR
|
|
28
|
+
|
|
29
|
+
!`gh pr view --json number,title,state,milestone -q '"PR #\(.number): \(.title) (\(.state)) | Milestone: \(.milestone.title // "none")"' 2>/dev/null`
|
|
30
|
+
|
|
31
|
+
## Core workflow
|
|
32
|
+
|
|
33
|
+
### 1. Fetch, filter, and classify comments
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
REPO=$(gh repo view --json nameWithOwner -q '.nameWithOwner')
|
|
37
|
+
PR=$(gh pr view --json number -q '.number')
|
|
38
|
+
LAST_PUSH=$(git log -1 --format=%cI HEAD)
|
|
39
|
+
|
|
40
|
+
# Inline review comments - filter out replies (keep only originals)
|
|
41
|
+
gh api repos/$REPO/pulls/$PR/comments?per_page=100 --jq '
|
|
42
|
+
[.[] | select(.in_reply_to_id == null) |
|
|
43
|
+
{id, path, user: .user.login, created_at, body: .body[0:200]}]
|
|
44
|
+
'
|
|
45
|
+
|
|
46
|
+
# PR-level reviews with non-empty body (CodeRabbit sections, Gemini, etc.)
|
|
47
|
+
gh api repos/$REPO/pulls/$PR/reviews?per_page=100 --jq '
|
|
48
|
+
[.[] | select(.body | length > 0) |
|
|
49
|
+
{id, user: .user.login, state, submitted_at, body: .body[0:500]}]
|
|
50
|
+
'
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
**Cross-check review-attached comments**: CodeRabbit's review body states "Actionable comments posted: N". If the general `pulls/$PR/comments` endpoint returns fewer than N new originals from that reviewer, some comments are only available via the review-specific endpoint. Fetch them and merge by comment ID:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
# $REVIEW_ID from the reviews fetch above; $EXPECTED from parsing "Actionable comments posted: N"
|
|
57
|
+
gh api repos/$REPO/pulls/$PR/reviews/$REVIEW_ID/comments?per_page=100 --jq '
|
|
58
|
+
[.[] | select(.in_reply_to_id == null) |
|
|
59
|
+
{id, path, user: .user.login, created_at, body: .body[0:200]}]
|
|
60
|
+
'
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Deduplicate by `id` before continuing. Comments found only via the review-specific endpoint are valid inline comments and should be treated identically (same classification, same `in_reply_to` reply mechanism).
|
|
64
|
+
|
|
65
|
+
**Filter new vs already-seen**: compare `created_at`/`submitted_at` with `$LAST_PUSH`. Comments posted after the last push are new. Mark older comments as "previous round" in the summary table.
|
|
66
|
+
|
|
67
|
+
**Parse CodeRabbit review bodies**: the initial fetch truncates bodies for classification. For reviews from CodeRabbit (`user.login` starts with `coderabbitai`), fetch the full body separately:
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
gh api repos/$REPO/pulls/$PR/reviews?per_page=100 --jq '
|
|
71
|
+
[.[] | select(.user.login | startswith("coderabbitai")) |
|
|
72
|
+
{id, submitted_at, body}]
|
|
73
|
+
'
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
CodeRabbit posts structured `<details>` blocks containing outside-diff, duplicate, and nitpick comments. Each block includes file path, line range, severity, and optionally a "Prompt for AI Agents" with pre-built context. See `references/coderabbit_parsing.md` for full parsing guide.
|
|
77
|
+
|
|
78
|
+
**Use CodeRabbit AI prompts when available**: if a comment (or the review body) contains a "Prompt for AI Agents" `<details>` block, use it to understand the issue and suggested approach. Always read the actual code before proposing a fix. If the review body contains a "Prompt for all review comments with AI agents" block, read it first for cross-comment context before processing individual comments.
|
|
79
|
+
|
|
80
|
+
Classify all comments by severity and process in order: CRITICAL > HIGH > MEDIUM > LOW.
|
|
81
|
+
|
|
82
|
+
| Severity | Indicators | Action |
|
|
83
|
+
|----------|------------|--------|
|
|
84
|
+
| CRITICAL | `critical.svg`, `_🔒 Security_`, `_🚨 Critical_`, `_🔴 Critical_`, "security", "vulnerability" | Must fix |
|
|
85
|
+
| HIGH | `high-priority.svg`, `_⚠️ Potential issue_`, `_🐛 Bug_`, `_⚡ Performance_`, `_🟠 Major_`, "High Severity" | Should fix |
|
|
86
|
+
| MEDIUM | `medium-priority.svg`, `_🛠️ Refactor suggestion_`, `_💡 Suggestion_`, "Medium Severity" | Recommended |
|
|
87
|
+
| LOW | `low-priority.svg`, `_🧹 Nitpick_`, `_🔧 Optional_`, `_🟡 Minor_`, `_🔵 Trivial_`, `_⚪ Info_`, "style", "nit" | Optional |
|
|
88
|
+
|
|
89
|
+
When a comment has both a type label and a secondary color badge (e.g., `_💡 Suggestion_ | _🟠 Major_`), the color badge is the **binding** severity and overrides the type-based default.
|
|
90
|
+
|
|
91
|
+
See `references/severity_guide.md` for full detection patterns (Gemini badges, CodeRabbit emoji, Cursor comments, keyword fallback, related comments heuristics).
|
|
92
|
+
|
|
93
|
+
### 2. Show review summary table
|
|
94
|
+
|
|
95
|
+
Before processing, display a structured overview of all comments:
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
| # | ID | Severity | File:Line | Type | Status | Summary |
|
|
99
|
+
|---|------------|----------|--------------------|----------|----------|--------------------|
|
|
100
|
+
| 1 | 123456789 | CRITICAL | src/auth.py:45 | inline | new | SQL injection risk |
|
|
101
|
+
| 2 | 987654321 | HIGH | src/db.py:346-350 | outside | new | Missing join cond |
|
|
102
|
+
| 3 | 555555555 | HIGH | src/chunk.py:188 | duplicate| previous | Stale metadata |
|
|
103
|
+
| 4 | 444444444 | LOW | tests/test_q.py:12 | nitpick | previous | Naming convention |
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
- **Type**: `inline`, `outside` (outside diff), `duplicate`, `minor`, `nitpick` (from CodeRabbit sections), or `review` (generic PR-level)
|
|
107
|
+
- **Status**: `new` (posted after last push) or `previous` (from earlier rounds)
|
|
108
|
+
- Group related comments (same file, same root cause, "also applies to" ranges) and note clusters
|
|
109
|
+
- Deduplicate: if the same issue appears both as an inline comment and in a CodeRabbit review body section (e.g., duplicate), keep one entry and note both sources
|
|
110
|
+
|
|
111
|
+
If there are **more than 10 comments**, suggest saving a review summary to Claude's memory for tracking across sessions. The summary should include: PR number, comment IDs, severity, status (new/addressed/deferred/won't fix), and brief description. This helps maintain continuity when new comments arrive after subsequent pushes.
|
|
112
|
+
|
|
113
|
+
### 3. Process each comment
|
|
114
|
+
|
|
115
|
+
For each comment, in severity order:
|
|
116
|
+
|
|
117
|
+
1. **Show context**: comment ID, severity, file:line, quote
|
|
118
|
+
2. **Check for AI prompt**: if CodeRabbit "Prompt for AI Agents" is available for this comment, use it to understand the issue and suggested approach
|
|
119
|
+
3. **Check for proposed fix**: if CodeRabbit includes a "Proposed fix" or "Suggested fix" code block, use it as a starting point (but verify correctness)
|
|
120
|
+
4. **Read affected code** and propose fix (always read the actual code, even when an AI prompt or proposed fix provides context)
|
|
121
|
+
5. **Handle "also applies to"**: if the comment references additional line ranges, include all locations in the fix
|
|
122
|
+
6. **Confirm with user** before applying
|
|
123
|
+
7. **Apply fix** if approved
|
|
124
|
+
8. **Verify ALL issues** in the comment are addressed (multi-issue comments are common)
|
|
125
|
+
|
|
126
|
+
### 4. Commit changes
|
|
127
|
+
|
|
128
|
+
Use git-commit skill format. Functional fixes get separate commits, cosmetic fixes are batched:
|
|
129
|
+
|
|
130
|
+
| Change type | Strategy |
|
|
131
|
+
|-------------|----------|
|
|
132
|
+
| Functional (CRITICAL/HIGH) | Separate commit per fix |
|
|
133
|
+
| Cosmetic (MEDIUM/LOW) | Single batch `style:` commit |
|
|
134
|
+
|
|
135
|
+
Reference the comment ID in the commit body.
|
|
136
|
+
|
|
137
|
+
### 5. Reply to threads
|
|
138
|
+
|
|
139
|
+
#### Inline comments
|
|
140
|
+
|
|
141
|
+
**Important**: use `--input -` with JSON. The `-f in_reply_to=...` syntax does NOT work.
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
COMMIT=$(git rev-parse --short HEAD)
|
|
145
|
+
gh api repos/$REPO/pulls/$PR/comments \
|
|
146
|
+
--input - <<< '{"body": "Fixed in '"$COMMIT"'. Brief explanation.", "in_reply_to": 123456789}'
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
#### Non-inline comments (CodeRabbit review body)
|
|
150
|
+
|
|
151
|
+
Comments embedded in the review body (outside diff, duplicate, nitpick) do not have inline threads. The GitHub API does not support replying to a review body directly. Post a general PR comment referencing the specific issue:
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
gh pr comment $PR --body "Fixed in $COMMIT. Addresses outside-diff comment on file/path.py:346-350."
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**Reply templates** (no emojis, minimal and professional):
|
|
158
|
+
|
|
159
|
+
| Situation | Template |
|
|
160
|
+
|-----------|----------|
|
|
161
|
+
| Fixed | `Fixed in [hash]. [brief description of fix]` |
|
|
162
|
+
| Won't fix | `Won't fix: [reason]` |
|
|
163
|
+
| By design | `By design: [explanation]` |
|
|
164
|
+
| Deferred | `Deferred to [issue/task]. Will address in future iteration.` |
|
|
165
|
+
| Acknowledged | `Acknowledged. [brief note]` |
|
|
166
|
+
|
|
167
|
+
### 6. Run tests and push
|
|
168
|
+
|
|
169
|
+
Run the project test suite. All tests must pass before pushing. Push all fixes together to minimize review loops.
|
|
170
|
+
|
|
171
|
+
### 7. Submit review (optional)
|
|
172
|
+
|
|
173
|
+
After addressing all comments, formally submit a review:
|
|
174
|
+
|
|
175
|
+
- `gh pr review $PR --approve --body "..."` - all comments addressed, PR is ready
|
|
176
|
+
- `gh pr review $PR --request-changes --body "..."` - critical issues remain
|
|
177
|
+
- `gh pr review $PR --comment --body "..."` - progress update, no decision yet
|
|
178
|
+
|
|
179
|
+
### 8. Verify milestone
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
gh pr view $PR --json milestone -q '.milestone.title // "none"'
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
If the PR has no milestone, check for open milestones:
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
REPO=$(gh repo view --json nameWithOwner -q '.nameWithOwner')
|
|
189
|
+
gh api repos/$REPO/milestones --jq '[.[] | select(.state=="open")] | .[] | "\(.number): \(.title)"'
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
If open milestones exist, inform the user and suggest assigning:
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
gh pr edit $PR --milestone "[milestone-title]"
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
Do **not** assign automatically. This is a reminder only.
|
|
199
|
+
|
|
200
|
+
## Avoiding review loops
|
|
201
|
+
|
|
202
|
+
When bots (Gemini, Codex, etc.) review every push:
|
|
203
|
+
|
|
204
|
+
1. **Batch fixes**: accumulate all fixes, push once
|
|
205
|
+
2. **Draft PR**: convert to draft during fixes
|
|
206
|
+
3. **Commit keywords**: some bots respect `[skip ci]` or `[skip review]`
|
|
207
|
+
|
|
208
|
+
## Important rules
|
|
209
|
+
|
|
210
|
+
- **ALWAYS** fetch both inline comments (`pulls/$PR/comments`) and review bodies (`pulls/$PR/reviews`)
|
|
211
|
+
- **ALWAYS** cross-check "Actionable comments posted: N" against found originals; fetch `pulls/$PR/reviews/$REVIEW_ID/comments` when count mismatches
|
|
212
|
+
- **ALWAYS** parse CodeRabbit review bodies for all section types (outside diff, duplicate, minor, nitpick)
|
|
213
|
+
- **ALWAYS** use CodeRabbit "Prompt for AI Agents" as primary context when available
|
|
214
|
+
- **ALWAYS** show the review summary table before processing
|
|
215
|
+
- **ALWAYS** confirm before modifying files
|
|
216
|
+
- **ALWAYS** verify ALL issues in multi-issue comments are fixed, including "also applies to" ranges
|
|
217
|
+
- **ALWAYS** run tests before pushing
|
|
218
|
+
- **ALWAYS** reply to resolved threads using standard templates
|
|
219
|
+
- **ALWAYS** submit formal review (`gh pr review`) after addressing all comments
|
|
220
|
+
- **ALWAYS** check milestone at the end and remind if missing
|
|
221
|
+
- **ALWAYS** suggest saving a review summary to memory when there are more than 10 comments
|
|
222
|
+
- **NEVER** use emojis in commit messages or thread replies
|
|
223
|
+
- **NEVER** skip HIGH/CRITICAL comments without explicit user approval
|
|
224
|
+
- **NEVER** assign milestone automatically - suggest only
|
|
225
|
+
- **Functional fixes** -> separate commits (one per fix)
|
|
226
|
+
- **Cosmetic fixes** -> batch into single `style:` commit
|
|
227
|
+
- **Duplicate comments** -> treat as higher priority than their label (issue was already flagged before)
|
|
228
|
+
- **Related comments** -> group and fix together when they share root cause or file context
|
|
229
|
+
|
|
230
|
+
## References
|
|
231
|
+
|
|
232
|
+
- `references/severity_guide.md` - Severity detection patterns (Gemini badges, CodeRabbit emoji, Cursor comments, keyword fallback, related comments heuristics)
|
|
233
|
+
- `references/coderabbit_parsing.md` - CodeRabbit review body structure, section parsing, "Prompt for AI Agents" usage, duplicate and "also applies to" handling
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
# CodeRabbit review parsing
|
|
2
|
+
|
|
3
|
+
Guide for extracting and processing all comment types from CodeRabbit PR reviews.
|
|
4
|
+
|
|
5
|
+
## Review body structure
|
|
6
|
+
|
|
7
|
+
CodeRabbit posts a single PR-level review (via `pulls/$PR/reviews` API) containing multiple sections as collapsible `<details>` blocks. The body follows this structure:
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
Actionable comments posted: N
|
|
11
|
+
|
|
12
|
+
> [!CAUTION]
|
|
13
|
+
> Some comments are outside the diff and can't be posted inline...
|
|
14
|
+
|
|
15
|
+
<details>
|
|
16
|
+
<summary>⚠️ Outside diff range comments (N)</summary>
|
|
17
|
+
(actionable comments on code outside the PR diff)
|
|
18
|
+
</details>
|
|
19
|
+
|
|
20
|
+
<details>
|
|
21
|
+
<summary>♻️ Duplicate comments (N)</summary>
|
|
22
|
+
(issues already flagged in a previous review)
|
|
23
|
+
</details>
|
|
24
|
+
|
|
25
|
+
<details>
|
|
26
|
+
<summary>🟡 Minor comments (N)</summary>
|
|
27
|
+
(lower severity comments grouped to reduce inline noise)
|
|
28
|
+
</details>
|
|
29
|
+
|
|
30
|
+
<details>
|
|
31
|
+
<summary>🧹 Nitpick comments (N)</summary>
|
|
32
|
+
(style/convention issues, lowest priority)
|
|
33
|
+
</details>
|
|
34
|
+
|
|
35
|
+
<details>
|
|
36
|
+
<summary>🤖 Prompt for all review comments with AI agents</summary>
|
|
37
|
+
(global prompt covering all comments in this review)
|
|
38
|
+
</details>
|
|
39
|
+
|
|
40
|
+
<!-- Informational sections (not actionable, ignore): -->
|
|
41
|
+
<details><summary>ℹ️ Review info</summary></details>
|
|
42
|
+
<details><summary>⚙️ Run configuration</summary></details>
|
|
43
|
+
<details><summary>📥 Commits</summary></details>
|
|
44
|
+
<details><summary>⛔ Files ignored due to path filters (N)</summary></details>
|
|
45
|
+
<details><summary>📒 Files selected for processing (N)</summary></details>
|
|
46
|
+
<details><summary>🚧 Files skipped from review as they are similar to previous changes (N)</summary></details>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Not all sections are always present. CodeRabbit only includes sections that have comments. Other severity-based sections (e.g., "🔴 Critical comments", "🟠 Major comments") may also appear.
|
|
50
|
+
|
|
51
|
+
## Fetching CodeRabbit reviews
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
REPO=$(gh repo view --json nameWithOwner -q '.nameWithOwner')
|
|
55
|
+
PR=$(gh pr view --json number -q '.number')
|
|
56
|
+
|
|
57
|
+
# Get all CodeRabbit review bodies (may be multiple reviews across pushes)
|
|
58
|
+
gh api repos/$REPO/pulls/$PR/reviews?per_page=100 --jq '
|
|
59
|
+
[.[] | select(.user.login | startswith("coderabbitai")) |
|
|
60
|
+
{id, submitted_at, body}]
|
|
61
|
+
'
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The `id` field is the review ID (visible in the GitHub URL as `#pullrequestreview-<id>`). Use this as the stable identifier for tracking.
|
|
65
|
+
|
|
66
|
+
## Parsing sections from the body
|
|
67
|
+
|
|
68
|
+
Each section is a `<details>` block. Extract them by matching the summary text:
|
|
69
|
+
|
|
70
|
+
| Summary pattern | Comment type | Default severity |
|
|
71
|
+
|----------------|--------------|-----------------|
|
|
72
|
+
| `⚠️ Outside diff range comments` | Code outside the PR diff | Use per-comment severity |
|
|
73
|
+
| `♻️ Duplicate comments` | Already flagged in previous reviews | Use per-comment severity |
|
|
74
|
+
| `🟡 Minor comments` | Lower severity, grouped to reduce noise | MEDIUM/LOW (use per-comment) |
|
|
75
|
+
| `🧹 Nitpick comments` | Style/convention issues | LOW |
|
|
76
|
+
| `🤖 Prompt for all review comments with AI agents` | Global AI context prompt | N/A (not a comment) |
|
|
77
|
+
|
|
78
|
+
Other severity-based sections like "🔴 Critical comments" or "🟠 Major comments" may appear. Treat any unrecognized `<details>` section with comments as actionable and classify by per-comment severity.
|
|
79
|
+
|
|
80
|
+
Informational sections (`ℹ️ Review info`, `⚙️ Run configuration`, `📥 Commits`, `⛔ Files ignored due to path filters`, `📒 Files selected for processing`, `🚧 Files skipped from review as they are similar to previous changes`) are not actionable. Ignore them.
|
|
81
|
+
|
|
82
|
+
### Per-comment structure inside sections
|
|
83
|
+
|
|
84
|
+
Each file group is wrapped in a `<details>` block. The summary format varies:
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
<!-- Outside diff / Duplicate sections: file path + count -->
|
|
88
|
+
<details>
|
|
89
|
+
<summary>file/path.ext (N)</summary>
|
|
90
|
+
|
|
91
|
+
<!-- Minor / Nitpick sections: file path + line range + count -->
|
|
92
|
+
<details>
|
|
93
|
+
<summary>file/path.ext-X-Y (N)</summary>
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
Inside each file group, individual comments follow this pattern:
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
`X-Y`: _<emoji> <type>_ | _<color> <severity>_
|
|
100
|
+
|
|
101
|
+
**Title text**
|
|
102
|
+
|
|
103
|
+
Description paragraph(s)...
|
|
104
|
+
|
|
105
|
+
As per coding guidelines, `path/**`: "quote..." (optional, references project rules)
|
|
106
|
+
|
|
107
|
+
Also applies to: X-Y, X-Y (optional, other line ranges with same issue)
|
|
108
|
+
|
|
109
|
+
<details><summary>Proposed fix</summary>
|
|
110
|
+
```lang
|
|
111
|
+
code suggestion
|
|
112
|
+
```
|
|
113
|
+
</details>
|
|
114
|
+
|
|
115
|
+
<details><summary>Prompt for AI Agents</summary>
|
|
116
|
+
prompt text...
|
|
117
|
+
</details>
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Key fields to extract:
|
|
121
|
+
- **File path**: from the `<details><summary>` wrapping the file group
|
|
122
|
+
- **Line range**: backtick-formatted `` `X-Y` `` at the start of each comment (may also appear in the file summary as `path.ext-X-Y`)
|
|
123
|
+
- **Severity**: emoji + type label and optional color severity (see severity_guide.md)
|
|
124
|
+
- **Title**: bold text after the severity line
|
|
125
|
+
- **"Also applies to"**: additional line ranges in the same file with the same issue
|
|
126
|
+
- **Proposed fix / Suggested fix**: code suggestion inside `<details>`. Summary text varies widely, with optional emoji prefix and description. Examples: `Proposed fix`, `Suggested fix`, `🔧 Proposed fix (...)`, `💡 Proposed fix`, `🔒 Suggested direction`, `✨ Optional: ...`, `♻️ Suggested cleanup`, `🔎 Suggested assertion hardening`, `♻️ Suggested diff`. Match any `<details>` block whose summary contains "fix", "suggest", "proposed", or "optional"
|
|
127
|
+
- **Prompt for AI Agents**: per-comment context prompt inside `<details>`
|
|
128
|
+
|
|
129
|
+
## Using the "Prompt for AI Agents"
|
|
130
|
+
|
|
131
|
+
CodeRabbit provides two levels of AI prompts:
|
|
132
|
+
|
|
133
|
+
### Per-comment prompt
|
|
134
|
+
Inside each comment's `<details><summary>Prompt for AI Agents</summary>` block. Contains:
|
|
135
|
+
- The specific file and line range
|
|
136
|
+
- The issue description with context
|
|
137
|
+
- References to coding guidelines or project conventions
|
|
138
|
+
- The suggested fix approach
|
|
139
|
+
|
|
140
|
+
### Global prompt
|
|
141
|
+
At the bottom of the review body, inside `<details><summary>Prompt for all review comments with AI agents</summary>`. Contains:
|
|
142
|
+
- Aggregated context for all comments in the review
|
|
143
|
+
- File paths, line ranges, and descriptions for every comment
|
|
144
|
+
- Useful for batch processing multiple comments at once
|
|
145
|
+
|
|
146
|
+
**How to use these prompts**:
|
|
147
|
+
1. When processing a comment, check if it has a per-comment prompt
|
|
148
|
+
2. If present, use it to understand the issue and suggested approach
|
|
149
|
+
3. Always read the actual code before proposing a fix, even when the prompt provides context
|
|
150
|
+
4. For batch processing, use the global prompt to understand all issues at once before diving into individual fixes
|
|
151
|
+
|
|
152
|
+
## Inline comments vs review body comments
|
|
153
|
+
|
|
154
|
+
CodeRabbit posts comments in two ways:
|
|
155
|
+
|
|
156
|
+
| Type | API endpoint | When used |
|
|
157
|
+
|------|-------------|-----------|
|
|
158
|
+
| Inline review comments | `pulls/$PR/comments` | Comments on lines within the PR diff |
|
|
159
|
+
| Review body sections | `pulls/$PR/reviews` | Outside diff, duplicate, nitpick comments |
|
|
160
|
+
| Review-attached inline comments | `pulls/$PR/reviews/$REVIEW_ID/comments` | Fallback for inline comments not yet surfaced by the general endpoint |
|
|
161
|
+
|
|
162
|
+
**ALWAYS** fetch both endpoints to get the complete picture. Inline comments may reference issues also mentioned in the review body (especially duplicates).
|
|
163
|
+
|
|
164
|
+
### Review-attached comment gap
|
|
165
|
+
|
|
166
|
+
CodeRabbit's "actionable comments" are posted as part of a review object. The general `pulls/$PR/comments` endpoint may not surface these comments, or may surface them with a delay. When the review body states "Actionable comments posted: N" but the general endpoint returns fewer than N new originals from CodeRabbit, fetch the missing comments via the review-specific endpoint:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
gh api repos/$REPO/pulls/$PR/reviews/$REVIEW_ID/comments?per_page=100 --jq '
|
|
170
|
+
[.[] | select(.in_reply_to_id == null) |
|
|
171
|
+
{id, path, user: .user.login, created_at, body: .body[0:200]}]
|
|
172
|
+
'
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
Deduplicate by `id` against the general endpoint results. Comments found only via this endpoint are standard inline comments and support the same `in_reply_to` reply mechanism.
|
|
176
|
+
|
|
177
|
+
## "Also applies to" handling
|
|
178
|
+
|
|
179
|
+
Some comments include `Also applies to: 258-266, 291-296`. These indicate the same issue exists at multiple locations in the same file. When fixing:
|
|
180
|
+
|
|
181
|
+
1. Fix the primary location (the one with the full description)
|
|
182
|
+
2. Apply the same fix pattern to all "also applies to" ranges
|
|
183
|
+
3. Verify each location, as the exact code may differ slightly
|
|
184
|
+
|
|
185
|
+
## Duplicate comments
|
|
186
|
+
|
|
187
|
+
Comments in the "Duplicate comments" section were already flagged in a previous review. They reappear because the underlying issue was not fixed. Treat them as:
|
|
188
|
+
|
|
189
|
+
- Same severity as indicated in their label
|
|
190
|
+
- Higher actual priority than their label suggests (reviewer is repeating themselves)
|
|
191
|
+
- Check if they were previously deferred or missed
|
|
192
|
+
|
|
193
|
+
## Configuration reference
|
|
194
|
+
|
|
195
|
+
CodeRabbit behavior is controlled via `.coderabbit.yaml` in the repo root:
|
|
196
|
+
|
|
197
|
+
```yaml
|
|
198
|
+
reviews:
|
|
199
|
+
profile: "chill" # chill (default) or assertive (includes nitpicks)
|
|
200
|
+
enable_prompt_for_ai_agents: true # includes "Prompt for AI Agents" in comments
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
- `chill`: lighter feedback, nitpick sections are hidden
|
|
204
|
+
- `assertive`: full feedback, includes nitpick and minor comments
|
|
205
|
+
|
|
206
|
+
Official docs: https://docs.coderabbit.ai/guides/code-review-overview
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
# Severity guide
|
|
2
|
+
|
|
3
|
+
Reference guide for interpreting severity levels from automated review comments (Gemini, CodeRabbit, Cursor, and others).
|
|
4
|
+
|
|
5
|
+
## Severity Badges
|
|
6
|
+
|
|
7
|
+
Gemini uses visual badges in review comments to indicate severity:
|
|
8
|
+
|
|
9
|
+
### CRITICAL
|
|
10
|
+
**Badge**: ``
|
|
11
|
+
|
|
12
|
+
**Visual**: Red badge with "critical" text
|
|
13
|
+
|
|
14
|
+
**Meaning**: Must be fixed before merge. Indicates:
|
|
15
|
+
- Security vulnerabilities
|
|
16
|
+
- Data loss risks
|
|
17
|
+
- Logic errors causing incorrect behavior
|
|
18
|
+
- Infinite loops or deadlocks
|
|
19
|
+
- Memory leaks or resource exhaustion
|
|
20
|
+
|
|
21
|
+
**Action**: Stop and fix immediately. These block merge.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
### HIGH
|
|
26
|
+
**Badge**: ``
|
|
27
|
+
|
|
28
|
+
**Visual**: Orange badge
|
|
29
|
+
|
|
30
|
+
**Meaning**: Should be fixed. Indicates:
|
|
31
|
+
- Performance issues
|
|
32
|
+
- Error handling gaps
|
|
33
|
+
- Potential race conditions
|
|
34
|
+
- Missing validation on important paths
|
|
35
|
+
|
|
36
|
+
**Action**: Address before merge unless there's a strong reason not to.
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
### MEDIUM
|
|
41
|
+
**Badge**: ``
|
|
42
|
+
|
|
43
|
+
**Visual**: Yellow badge
|
|
44
|
+
|
|
45
|
+
**Meaning**: Recommended fix. Indicates:
|
|
46
|
+
- Code style issues
|
|
47
|
+
- Minor refactoring opportunities
|
|
48
|
+
- Unreachable code (dead code)
|
|
49
|
+
- Duplicate logic
|
|
50
|
+
- Missing edge case handling
|
|
51
|
+
|
|
52
|
+
**Action**: Address if time permits, or create follow-up issue.
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
### LOW
|
|
57
|
+
**Badge**: ``
|
|
58
|
+
|
|
59
|
+
**Visual**: Blue/gray badge
|
|
60
|
+
|
|
61
|
+
**Meaning**: Optional improvement. Indicates:
|
|
62
|
+
- Import ordering
|
|
63
|
+
- Naming conventions
|
|
64
|
+
- Documentation suggestions
|
|
65
|
+
- Minor style preferences
|
|
66
|
+
|
|
67
|
+
**Action**: Optional. Can be skipped with justification.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## Detection Patterns
|
|
72
|
+
|
|
73
|
+
### Gemini Badge Detection (Primary for Gemini)
|
|
74
|
+
```python
|
|
75
|
+
# In comment body, look for:
|
|
76
|
+
"critical.svg" → CRITICAL
|
|
77
|
+
"high-priority.svg" → HIGH
|
|
78
|
+
"medium-priority.svg" → MEDIUM
|
|
79
|
+
"low-priority.svg" → LOW
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### CodeRabbit Detection
|
|
83
|
+
|
|
84
|
+
CodeRabbit does **not** use SVG badges. It uses emoji + italic text in the comment body.
|
|
85
|
+
The pattern is: `_<emoji> <label>_` or `_<emoji> <label>_ | _<color> <severity>_`
|
|
86
|
+
|
|
87
|
+
CodeRabbit classifies comments along two axes: **type** (what kind of issue) and **severity** (how impactful).
|
|
88
|
+
|
|
89
|
+
#### Comment types (primary label)
|
|
90
|
+
|
|
91
|
+
| Comment pattern | Severity |
|
|
92
|
+
|----------------|----------|
|
|
93
|
+
| `_🔒 Security_` or `_🚨 Critical_` | CRITICAL |
|
|
94
|
+
| `_⚠️ Potential issue_` | HIGH |
|
|
95
|
+
| `_🐛 Bug_` | HIGH |
|
|
96
|
+
| `_⚡ Performance_` | HIGH |
|
|
97
|
+
| `_🛠️ Refactor suggestion_` | MEDIUM |
|
|
98
|
+
| `_💡 Suggestion_` | MEDIUM |
|
|
99
|
+
| `_🧹 Nitpick_` | LOW (only in assertive mode) |
|
|
100
|
+
| `_🔧 Optional_` | LOW (skip by default) |
|
|
101
|
+
|
|
102
|
+
#### Severity levels (secondary color badge)
|
|
103
|
+
|
|
104
|
+
When a secondary color badge is present, use it as the **binding** severity indicator
|
|
105
|
+
(it overrides the type-based default above):
|
|
106
|
+
|
|
107
|
+
| Secondary badge | Official name | Maps to |
|
|
108
|
+
|----------------|---------------|---------|
|
|
109
|
+
| `_🔴 Critical_` | Critical | CRITICAL |
|
|
110
|
+
| `_🟠 Major_` | Major | HIGH |
|
|
111
|
+
| `_🟡 Minor_` | Minor | LOW |
|
|
112
|
+
| `_🔵 Trivial_` | Trivial | LOW (skip by default) |
|
|
113
|
+
| `_⚪ Info_` | Info | LOW (informational, no action needed) |
|
|
114
|
+
|
|
115
|
+
Note: some older reviews may use `_🔵 Info_` instead of `_🔵 Trivial_`. Treat both as LOW.
|
|
116
|
+
|
|
117
|
+
#### Assertive vs chill mode
|
|
118
|
+
|
|
119
|
+
CodeRabbit has two profiles configured via `.coderabbit.yaml`:
|
|
120
|
+
- `profile: chill` (default) - lighter feedback, nitpicks are hidden
|
|
121
|
+
- `profile: assertive` - full feedback, includes nitpick comments
|
|
122
|
+
|
|
123
|
+
When reviewing a repo in `chill` mode, nitpick sections will not appear in the review body.
|
|
124
|
+
|
|
125
|
+
**CodeRabbit non-inline comments** (outside diff, duplicate, nitpick) are not posted
|
|
126
|
+
as inline review comments. They are embedded in the PR-level review body
|
|
127
|
+
(`pulls/$PR/reviews`) inside structured `<details>` blocks. Each section type
|
|
128
|
+
has its own block with file paths, line ranges, severity, and optional AI prompts.
|
|
129
|
+
|
|
130
|
+
See `coderabbit_parsing.md` for the full body structure and parsing guide.
|
|
131
|
+
|
|
132
|
+
**Duplicate comments** from CodeRabbit indicate an issue was already flagged in a
|
|
133
|
+
previous review and not fixed. Treat these as higher actual priority than their
|
|
134
|
+
severity label suggests.
|
|
135
|
+
|
|
136
|
+
### Cursor Comments
|
|
137
|
+
```
|
|
138
|
+
<!-- **High Severity** --> → HIGH
|
|
139
|
+
<!-- **Medium Severity** --> → MEDIUM
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Keyword Detection (Fallback)
|
|
143
|
+
When badges or HTML comments aren't present, infer from keywords:
|
|
144
|
+
|
|
145
|
+
| Keywords | Severity |
|
|
146
|
+
|----------|----------|
|
|
147
|
+
| security, vulnerability, injection, XSS, SQL | CRITICAL/HIGH |
|
|
148
|
+
| dangerous, unsafe, exploit | CRITICAL |
|
|
149
|
+
| performance, slow, O(n²) | HIGH |
|
|
150
|
+
| error handling, exception, catch | HIGH |
|
|
151
|
+
| unreachable, dead code, unused | MEDIUM |
|
|
152
|
+
| refactor, simplify, consolidate | MEDIUM |
|
|
153
|
+
| style, formatting, PEP, naming | LOW |
|
|
154
|
+
| import order, whitespace | LOW |
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Related Comments Detection
|
|
159
|
+
|
|
160
|
+
Comments are often related when:
|
|
161
|
+
|
|
162
|
+
1. **Consequence relationship**: Comment B is a consequence of fixing Comment A
|
|
163
|
+
- Keywords: "consequence", "result of", "as mentioned above"
|
|
164
|
+
|
|
165
|
+
2. **Same root cause**: Multiple comments about the same underlying issue
|
|
166
|
+
- Keywords: "root cause", "same issue", "related to"
|
|
167
|
+
|
|
168
|
+
3. **Unreachable code**: After an exception handling fix, related `except` blocks may become unreachable
|
|
169
|
+
- Pattern: CRITICAL exception handling → MEDIUM unreachable code
|
|
170
|
+
|
|
171
|
+
4. **Same function/method**: Comments within ~100 lines in the same file, where one is CRITICAL and others are MEDIUM/LOW
|
|
172
|
+
|
|
173
|
+
---
|
|
174
|
+
|
|
175
|
+
## Example: Exception Handling Pattern
|
|
176
|
+
|
|
177
|
+
Common scenario from Gemini reviews:
|
|
178
|
+
|
|
179
|
+
**Comment 1 (CRITICAL)**: Exception handling in `method_x()` needs refactoring:
|
|
180
|
+
- FileNotFoundError should fail-fast, not retry
|
|
181
|
+
- Generic exceptions need sleep to avoid busy-loop
|
|
182
|
+
|
|
183
|
+
**Comment 2 (MEDIUM)**: `except FileNotFoundError` block at line 186 is unreachable
|
|
184
|
+
→ This is a CONSEQUENCE of fixing Comment 1
|
|
185
|
+
|
|
186
|
+
**Comment 3 (MEDIUM)**: `except FileNotFoundError` block at line 473 is unreachable
|
|
187
|
+
→ Also a CONSEQUENCE of fixing Comment 1
|
|
188
|
+
|
|
189
|
+
**Resolution**: Fix Comment 1 first. Comments 2 and 3 will be automatically resolved.
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## Gemini Config Reference
|
|
194
|
+
|
|
195
|
+
Gemini behavior is controlled by `.gemini/config.yaml`:
|
|
196
|
+
|
|
197
|
+
```yaml
|
|
198
|
+
code_review:
|
|
199
|
+
threshold: LOW # Minimum severity to report
|
|
200
|
+
auto_fix: false # Whether to suggest auto-fixes
|
|
201
|
+
blocking: false # Whether reviews block merge
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
When `threshold: LOW`, all severities are reported.
|
|
205
|
+
When `blocking: false`, reviews are advisory only.
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## Workflow Integration
|
|
210
|
+
|
|
211
|
+
1. **Fetch comments**: Parse severity from badge URLs in comment body
|
|
212
|
+
2. **Sort by severity**: CRITICAL → HIGH → MEDIUM → LOW
|
|
213
|
+
3. **Group related**: Use heuristics above
|
|
214
|
+
4. **Process CRITICAL first**: These often resolve MEDIUM/LOW comments
|
|
215
|
+
5. **Skip LOW if needed**: They're optional by definition
|
|
216
|
+
|
|
217
|
+
---
|
|
218
|
+
|
|
219
|
+
## References
|
|
220
|
+
|
|
221
|
+
- [Gemini Code Assist Documentation](https://cloud.google.com/gemini/docs/discover/code-assist)
|
|
222
|
+
- [GitHub PR Review API](https://docs.github.com/en/rest/pulls/comments)
|