Skip to content

Commit 9a909dd

Browse files
committed
refine the code-review-report skill
1 parent 0b626f4 commit 9a909dd

1 file changed

Lines changed: 126 additions & 44 deletions

File tree

  • .github/skills/code-review-report

.github/skills/code-review-report/SKILL.md

Lines changed: 126 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,40 @@
1-
````skill
21
---
32
name: code-review-report
43
description: "Generate structured code review reports in Markdown format suitable for import into GitHub PRs or Azure DevOps pull requests. Produces per-file inline remarks and a summary that renders natively in PR comment threads."
5-
version: 1.0.0
6-
output_format: Markdown
4+
version: 2.0.0
5+
output_format: Markdown + JSON
76
platforms: GitHub, Azure DevOps
87
---
98

109
# Code Review Report Skill
1110

1211
## Purpose
1312

14-
Generates a structured, portable code review report in Markdown that:
15-
1. Renders correctly when pasted as a **GitHub PR comment** or **Azure DevOps PR comment**
16-
2. Can be saved as a persistent artifact in `docs/code-reviews/`
17-
3. Contains per-file remarks with line references that reviewers can act on
18-
4. Provides a machine-parseable remarks table for downstream automation
13+
Generates a structured, portable code review report consisting of **two artifacts**:
14+
15+
1. **Markdown report** — human-readable, renders correctly as a GitHub or Azure DevOps PR comment; can be pasted directly or posted via `gh pr comment`
16+
2. **JSON payload** — machine-ready structured data for programmatic import via `gh api` (GitHub) or `curl` (Azure DevOps REST API)
17+
18+
Both artifacts are saved to `docs/code-reviews/` and referenced in the chat summary.
1919

2020
## When to Use
2121

2222
- After completing a code review with the `code-reviewer` agent
2323
- When the review output must be shared in a pull request on GitHub or Azure DevOps
2424
- When a persistent review artifact is needed for traceability
2525

26-
## Output Locations
26+
## Output Files
2727

28-
| Output | Path |
29-
|--------|------|
30-
| Report file | `docs/code-reviews/{issueId}-review_{timestamp}.md` |
31-
| Chat summary | Displayed inline in the agent conversation |
28+
| File | Path | Purpose |
29+
|------|------|---------|
30+
| Markdown report | `docs/code-reviews/{issueId}-review_{timestamp}.md` | Human-readable, paste into PR comment |
31+
| JSON payload | `docs/code-reviews/{issueId}-review_{timestamp}.json` | Programmatic PR import (GitHub + Azure DevOps) |
3232

3333
**Timestamp format:** `yyyyMMdd-HHmm` (e.g., `20260225-1430`)
3434

35-
## Report Template
35+
> Generate the JSON payload **only** when at least one remark has a resolvable file path. If all remarks are general (no file/line), produce only the Markdown report.
36+
37+
## Artifact 1 — Markdown Report Template
3638

3739
Use the following template **exactly** as the structure for the report file. Replace all `{placeholders}` with actual values. Omit sections that have no content (e.g., if no blockers, omit the blockers subsection) but always keep the top-level sections.
3840

@@ -45,7 +47,7 @@ Use the following template **exactly** as the structure for the report file. Rep
4547
|-------|-------|
4648
| **Issue** | #{issueId} — {issueTitle} |
4749
| **Date** | {date} |
48-
| **Reviewer** | AI Code Reviewer (GitHub Copilot) |
50+
| **Reviewer** | AI Code Reviewer - {Model} |
4951
| **Build** | {✅ Pass \| ❌ Fail} |
5052
| **Tests** | {✅ Pass \| ❌ Fail \| ⚠️ Partial} |
5153

@@ -160,6 +162,115 @@ Use the following template **exactly** as the structure for the report file. Rep
160162

161163
---
162164

165+
## Artifact 2 — JSON Payload Template
166+
167+
The JSON payload serves a dual purpose: it is the body for the **GitHub PR Review API** and contains all data needed to reconstruct **Azure DevOps PR threads**. The agent fills this structure from the collected remarks.
168+
169+
```json
170+
{
171+
"_meta": {
172+
"issueId": "{issueId}",
173+
"issueTitle": "{issueTitle}",
174+
"date": "{date}",
175+
"timestamp": "{timestamp}",
176+
"markdownReport": "docs/code-reviews/{issueId}-review_{timestamp}.md"
177+
},
178+
"verdict": "{APPROVE|REQUEST_CHANGES|COMMENT}",
179+
"summary": "{2-4 sentence overview}",
180+
"body": "{full markdown summary block — same as the Markdown report's Summary + Metrics + Verdict sections}",
181+
"event": "{APPROVE|REQUEST_CHANGES|COMMENT}",
182+
"metrics": {
183+
"blockers": 0,
184+
"warnings": 0,
185+
"suggestions": 0,
186+
"notes": 0
187+
},
188+
"remarks": [
189+
{
190+
"id": "R1",
191+
"severity": "blocker",
192+
"dimension": "Architecture Compliance",
193+
"file": "Modules/Sales/Sales.Services/OrderingService.cs",
194+
"line": 42,
195+
"lineEnd": 42,
196+
"title": "{short title}",
197+
"description": "{full description}",
198+
"suggestedFix": "{direction — no full code}"
199+
}
200+
]
201+
}
202+
```
203+
204+
### JSON Field Rules
205+
206+
| Field | Values | Notes |
207+
|-------|--------|-------|
208+
| `verdict` / `event` | `APPROVE`, `REQUEST_CHANGES`, `COMMENT` | `APPROVE WITH SUGGESTIONS` → use `COMMENT` |
209+
| `severity` | `blocker`, `warning`, `suggestion`, `note` | Lowercase |
210+
| `file` | Repo-root relative, forward slashes | e.g. `Modules/Sales/Sales.Services/Foo.cs` |
211+
| `line` / `lineEnd` | Integer (1-based), or `null` if unknown | Set both to same value for single-line remarks |
212+
| `suggestedFix` | Omit the field if remark is a `note` | |
213+
| `body` | GFM Markdown string | Used as the top-level PR review body |
214+
215+
---
216+
217+
## CLI Import Commands
218+
219+
After the agent saves both files, output a **ready-to-run commands block** in the chat so the user can import the review into their PR immediately.
220+
221+
### GitHub — `gh` CLI
222+
223+
```bash
224+
# Option A: Post the full Markdown report as a single PR comment
225+
gh pr comment {PR_NUMBER} --body-file docs/code-reviews/{issueId}-review_{timestamp}.md
226+
227+
# Option B: Post as a formal PR review with inline file comments (uses GitHub Review API)
228+
# Requires: GH_TOKEN with repo scope, jq installed
229+
gh api repos/{OWNER}/{REPO}/pulls/{PR_NUMBER}/reviews \
230+
--method POST \
231+
--input docs/code-reviews/{issueId}-review_{timestamp}.json
232+
```
233+
234+
> **Note for Option B:** The JSON payload's top-level structure matches the GitHub PR Review API.
235+
> GitHub inline comments (`remarks[]`) require `path` (= `file`), `line`, and `body`.
236+
> The `gh api --input` flag reads JSON directly from the file — no shell escaping needed.
237+
238+
### Azure DevOps — REST API via `curl`
239+
240+
```bash
241+
# Post the full Markdown report as a PR thread (top-level comment)
242+
curl -s -X POST \
243+
"https://dev.azure.com/{ORG}/{PROJECT}/_apis/git/repositories/{REPO}/pullRequests/{PR_ID}/threads?api-version=7.1" \
244+
-H "Content-Type: application/json" \
245+
-H "Authorization: Bearer $AZURE_DEVOPS_TOKEN" \
246+
--data-binary @- <<EOF
247+
{
248+
"comments": [{"content": $(jq -Rs . < docs/code-reviews/{issueId}-review_{timestamp}.md), "commentType": 1}],
249+
"status": 1
250+
}
251+
EOF
252+
253+
# Post individual inline remarks from the JSON payload
254+
# (run once per remark that has a non-null 'file' and 'line')
255+
curl -s -X POST \
256+
"https://dev.azure.com/{ORG}/{PROJECT}/_apis/git/repositories/{REPO}/pullRequests/{PR_ID}/threads?api-version=7.1" \
257+
-H "Content-Type: application/json" \
258+
-H "Authorization: Bearer $AZURE_DEVOPS_TOKEN" \
259+
-d '{
260+
"comments": [{"content": "{R1 body}", "commentType": 1}],
261+
"threadContext": {
262+
"filePath": "/{file}",
263+
"rightFileStart": {"line": {line}, "offset": 1},
264+
"rightFileEnd": {"line": {lineEnd}, "offset": 1}
265+
},
266+
"status": 1
267+
}'
268+
```
269+
270+
> The agent outputs **placeholder-filled** commands (with actual values substituted) so the user only needs to set environment variables (`OWNER`, `REPO`, `PR_NUMBER`, `AZURE_DEVOPS_TOKEN`) and run.
271+
272+
---
273+
163274
## Formatting Rules
164275

165276
### General
@@ -195,34 +306,6 @@ The report is designed to render correctly when pasted as a GitHub PR comment:
195306
- Same Markdown renders correctly in both platforms
196307
- Avoid Mermaid diagrams in the report (not supported in Azure DevOps PR comments)
197308

198-
## Chat Summary Format
199-
200-
In addition to saving the report file, output a **condensed summary** in the chat conversation. This is what the agent displays inline:
201-
202-
```
203-
# Code Review: Issue #{id} — {title}
204-
205-
**Design Documents:**
206-
- High-Level: docs/workitems/{id}-design.md — {found|MISSING}
207-
- Detailed: docs/workitems/{id}-detailed-design.md — {found|MISSING}
208-
209-
**Build:** {✅|❌} | **Tests:** {✅|❌}
210-
**Blockers:** {count} | **Warnings:** {count} | **Suggestions:** {count} | **Notes:** {count}
211-
212-
## Verdict
213-
{APPROVE | REQUEST CHANGES | APPROVE WITH SUGGESTIONS}
214-
215-
## Summary
216-
{2-4 sentence overview}
217-
218-
## Top Remarks
219-
{List only 🔴 blockers and 🟡 warnings here, as bullet points:}
220-
- **R1** 🔴 `path/File.cs` — {title}
221-
- **R2** 🟡 `path/File.cs` — {title}
222-
223-
📄 Full report saved to: `docs/code-reviews/{issueId}-review_{timestamp}.md`
224-
```
225-
226309
## Edge Cases
227310

228311
### No Remarks Found
@@ -247,4 +330,3 @@ If the agent was asked to review only specific dimensions (e.g., "Review only ar
247330
### Large File Lists (>20 files)
248331
- Group the Files Reviewed table by module/folder
249332
- Add a sub-header per module for readability
250-
````

0 commit comments

Comments
 (0)