@nano-step/skill-manager 5.6.0 → 5.6.2

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.
Files changed (44) hide show
  1. package/dist/utils.d.ts +1 -1
  2. package/dist/utils.js +1 -1
  3. package/package.json +1 -1
  4. package/private-catalog.json +5 -0
  5. package/skills/deep-design/SKILL.md +402 -0
  6. package/skills/deep-design/evals/evals.json +23 -0
  7. package/skills/deep-design/skill.json +7 -0
  8. package/skills/feature-analysis/SKILL.md +290 -0
  9. package/skills/feature-analysis/skill.json +15 -0
  10. package/skills/nano-brain/AGENTS_SNIPPET.md +0 -9
  11. package/skills/nano-brain/skill.json +7 -0
  12. package/skills/pr-code-reviewer/CHANGELOG.md +287 -0
  13. package/skills/pr-code-reviewer/RESEARCH.md +60 -0
  14. package/skills/pr-code-reviewer/SKILL.md +530 -0
  15. package/skills/pr-code-reviewer/assets/config.json +47 -0
  16. package/skills/pr-code-reviewer/checklists/backend-express.md +357 -0
  17. package/skills/pr-code-reviewer/checklists/ci-cd.md +428 -0
  18. package/skills/pr-code-reviewer/checklists/consumer-search-matrix.md +339 -0
  19. package/skills/pr-code-reviewer/checklists/database.md +382 -0
  20. package/skills/pr-code-reviewer/checklists/frontend-vue-nuxt.md +426 -0
  21. package/skills/pr-code-reviewer/checklists/review-checklist.md +116 -0
  22. package/skills/pr-code-reviewer/references/framework-rules/express.md +39 -0
  23. package/skills/pr-code-reviewer/references/framework-rules/nestjs.md +41 -0
  24. package/skills/pr-code-reviewer/references/framework-rules/typeorm.md +52 -0
  25. package/skills/pr-code-reviewer/references/framework-rules/typescript.md +50 -0
  26. package/skills/pr-code-reviewer/references/framework-rules/vue-nuxt.md +53 -0
  27. package/skills/pr-code-reviewer/references/nano-brain-integration.md +61 -0
  28. package/skills/pr-code-reviewer/references/performance-patterns.md +26 -0
  29. package/skills/pr-code-reviewer/references/quality-patterns.md +25 -0
  30. package/skills/pr-code-reviewer/references/report-template.md +167 -0
  31. package/skills/pr-code-reviewer/references/security-patterns.md +31 -0
  32. package/skills/pr-code-reviewer/references/subagent-prompts.md +323 -0
  33. package/skills/pr-code-reviewer/skill.json +15 -0
  34. package/skills/rri-t-testing/SKILL.md +224 -0
  35. package/skills/rri-t-testing/assets/rri-t-coverage-dashboard.md +138 -0
  36. package/skills/rri-t-testing/assets/rri-t-memory-protocol.md +271 -0
  37. package/skills/rri-t-testing/assets/rri-t-persona-interview.md +249 -0
  38. package/skills/rri-t-testing/assets/rri-t-quality-scorecard.md +122 -0
  39. package/skills/rri-t-testing/assets/rri-t-risk-matrix.md +87 -0
  40. package/skills/rri-t-testing/assets/rri-t-stress-matrix.md +100 -0
  41. package/skills/rri-t-testing/assets/rri-t-test-case.md +181 -0
  42. package/skills/rri-t-testing/assets/rri-t-testability-gate.md +131 -0
  43. package/skills/rri-t-testing/assets/rri-t-traceability-matrix.md +105 -0
  44. package/skills/rri-t-testing/skill.json +9 -0
@@ -0,0 +1,530 @@
1
+ ---
2
+ name: pr-code-reviewer
3
+ description: "Comprehensive code review with 4 parallel subagents, smart tracing, iterative refinement, workspace-aware configuration, and GitHub Copilot-style PR summaries."
4
+ compatibility: "OpenCode with nano-brain"
5
+ metadata:
6
+ author: Sisyphus
7
+ version: "3.1.0"
8
+ severity-levels: ["critical", "warning", "improvement", "suggestion"]
9
+ ---
10
+
11
+ # PR Code Reviewer
12
+
13
+ **Version**: 3.1.0 | **Architecture**: 4 Parallel Subagents + Verification Pipeline | **Memory**: nano-brain
14
+
15
+ ## Overview
16
+
17
+ Comprehensive PR reviewer: gathers full context, applies smart tracing by change type, runs four specialized subagents in parallel, iteratively refines findings, and produces a **short, actionable report** — only what matters. Also suggests code improvements when opportunities exist.
18
+
19
+ ### NO PHASE SKIPPING (ABSOLUTE RULE)
20
+
21
+ **Every phase MUST be executed for every review, regardless of PR size.** A 1-line deletion can hide a critical logic bug. A "trivial" change can break cross-repo contracts. The phases exist because each one catches different classes of issues.
22
+
23
+ - **1-line change?** → Run all phases.
24
+ - **Deletion-only PR?** → Run all phases. Deletions are MORE dangerous, not less.
25
+ - **"Obviously safe"?** → Run all phases. Your confidence is the risk.
26
+ - **Only STYLE changes?** → Run all phases. Verify no hidden logic changes.
27
+
28
+ **The ONLY exception**: Phase 0 (clone) is skipped for `--staged` local reviews. Every other phase runs unconditionally.
29
+
30
+ ## Report Philosophy
31
+
32
+ **People don't read long reports.** Every section must earn its place.
33
+
34
+ - **Critical + Warning = expanded** — full detail with file, line, impact, fix
35
+ - **Improvements = brief** — one-liner with code suggestion, only when there's a clear win
36
+ - **Suggestions = count only** — mentioned as a number, details in collapsible section or skipped
37
+ - **Praise = one line max** — or skip entirely if nothing stands out
38
+ - **No filler sections** — omit Traced Dependencies, Memory Context, Test Coverage unless they contain actionable findings
39
+ - **TL;DR at the top** — verdict + issue counts in 3 lines, reader decides whether to scroll
40
+
41
+ **Filtering rule**: If a finding wouldn't make a senior engineer stop and think, drop it.
42
+
43
+ ## Prerequisites
44
+
45
+ ### GitHub MCP Server (Required for PR Reviews)
46
+
47
+ ```bash
48
+ npx create-code-reviewer # Auto-detects git remote, configures everything
49
+ ```
50
+
51
+ **Manual setup**: Add GitHub MCP to `opencode.json` — see [GitHub MCP Server](https://github.com/github/github-mcp-server). Needs `repo` scope token from https://github.com/settings/tokens.
52
+
53
+ **After setup**: Restart OpenCode. Verify with `/review PR#1`.
54
+
55
+ ### Available GitHub MCP Tools
56
+
57
+ | Tool | Purpose |
58
+ |------|---------|
59
+ | `get_pull_request` | PR metadata (title, author, base) |
60
+ | `get_pull_request_files` | Changed files with diff |
61
+ | `get_pull_request_reviews` | Existing reviews |
62
+ | `get_pull_request_status` | CI/check status |
63
+ | `get_file_contents` | File content at ref |
64
+
65
+ ### Local Reviews (No MCP Required)
66
+
67
+ For `--staged` or local reviews, uses git commands directly (`git diff --staged`, `git diff`, `git log`).
68
+
69
+ ### nano-brain (Recommended)
70
+
71
+ Persistent memory for historical context — past reviews, architectural decisions, known issues.
72
+
73
+ **Full tool reference + query patterns**: [nano-brain-integration.md](references/nano-brain-integration.md)
74
+
75
+ ### Linear MCP (Optional — Enriches Review Context)
76
+
77
+ When a Linear ticket is linked to the PR (via branch name or PR description), the reviewer fetches ticket context automatically.
78
+
79
+ **Available Linear MCP Tools:**
80
+
81
+ | Tool | Purpose |
82
+ |------|---------|
83
+ | `linear_get_issue` | Ticket title, description, acceptance criteria, status, priority, labels |
84
+ | `linear_list_comments` | Discussion thread on the ticket |
85
+ | `linear_get_attachment` | Attached specs, screenshots, designs |
86
+ | `linear_extract_images` | Extract images embedded in ticket description/comments |
87
+
88
+ **Ticket ID extraction** (checked in order):
89
+ 1. PR branch name pattern: `feature/DEV-1234-...` or `fix/DEV-1234-...` → extracts `DEV-1234`
90
+ 2. PR description: looks for `Linear: DEV-1234`, `Ticket: DEV-1234`, or Linear URL `linear.app/.../DEV-1234`
91
+ 3. PR title: looks for `[DEV-1234]` or `DEV-1234:` prefix
92
+
93
+ If no ticket ID found → skip Linear context silently (no error, no warning).
94
+
95
+ ## Configuration
96
+
97
+ Check for config at `.opencode/code-reviewer.json`. **Full example**: [config.json](assets/config.json)
98
+
99
+ ## Checkpoint System
100
+
101
+ Reviews are resumable via checkpoints saved at each phase. If the agent crashes mid-review, you can resume from the last completed phase instead of starting over.
102
+
103
+ ### Checkpoint Directory
104
+
105
+ **For PR Reviews:** `$REVIEW_DIR/.checkpoints/` (inside the temp clone directory)
106
+ **For Local Reviews (`--staged`):** `{current_working_directory}/.checkpoints/`
107
+
108
+ Checkpoints are automatically removed when the clone directory is deleted (Phase 6 cleanup).
109
+
110
+ ### Checkpoint Files
111
+
112
+ | File | Content | Updated When |
113
+ |------|---------|--------------|
114
+ | `manifest.json` | Master state tracker | After every phase |
115
+ | `phase-0-clone.json` | Clone metadata (clone_dir, branches, head_sha, files_changed) | Phase 0 |
116
+ | `phase-1-context.json` | PR metadata, file classifications | Phase 1 |
117
+ | `phase-1.5-linear.json` | Linear ticket context, acceptance criteria | Phase 1.5 |
118
+ | `phase-2-tracing.json` | Smart tracing results per file | Phase 2 |
119
+ | `phase-2.5-summary.json` | PR summary text | Phase 2.5 |
120
+ | `phase-3-subagents.json` | Subagent findings (updated after EACH subagent completes) | Phase 3 |
121
+ | `phase-4-refined.json` | Deduplicated/filtered findings | Phase 4 |
122
+ | `phase-4.5-verification.json` | Verification results (verified/false/unverifiable counts, dropped/downgraded findings) | Phase 4.5 |
123
+ | `phase-5-report.md` | Copy of final report | Phase 5 |
124
+
125
+ ### Manifest Schema
126
+
127
+ ```json
128
+ {
129
+ "version": "1.0",
130
+ "pr": { "repo": "owner/repo", "number": 123, "url": "..." },
131
+ "clone_dir": "/tmp/pr-review-...",
132
+ "started_at": "ISO-8601",
133
+ "last_updated": "ISO-8601",
134
+ "completed_phase": 2,
135
+ "next_phase": 2.5,
136
+ "phase_status": {
137
+ "0": "complete", "1": "complete", "1.5": "complete",
138
+ "2": "complete", "2.5": "pending", "3": "pending",
139
+ "4": "pending", "4.5": "pending", "5": "pending"
140
+ },
141
+ "subagent_status": {
142
+ "explore": "pending", "oracle": "pending",
143
+ "librarian": "pending", "general": "pending"
144
+ }
145
+ }
146
+ ```
147
+
148
+ ### Phase 3 Special Handling
149
+
150
+ Phase 3 runs 4 parallel subagents. After **EACH** subagent completes:
151
+ 1. Update `phase-3-subagents.json` with that subagent's findings and status
152
+ 2. Update `manifest.json` subagent_status to `"complete"` for that subagent
153
+ 3. On resume: only run subagents with status != `"complete"`
154
+
155
+ This allows resuming mid-Phase-3 if only some subagents completed before a crash.
156
+
157
+ ## Workflow (CRITICAL — Follow Exactly, NEVER Skip Phases)
158
+
159
+ **Full checklist**: [review-checklist.md](checklists/review-checklist.md) — use this to track every step.
160
+
161
+ **ABSOLUTE RULE: Execute every phase in order. No phase may be skipped, shortened, or "optimized away" based on PR size, change type, or perceived simplicity. A 1-line deletion PR gets the same phase coverage as a 500-line feature PR.**
162
+
163
+ ### Phase -1: Resume Detection (MANDATORY — Check Before Starting)
164
+
165
+ Before starting a new review, check for existing checkpoints to resume interrupted reviews.
166
+
167
+ **Steps:**
168
+
169
+ 1. **Look for existing checkpoint**:
170
+ ```bash
171
+ find /tmp -maxdepth 1 -type d -name "pr-review-${repo}-${pr_number}-*" 2>/dev/null
172
+ ```
173
+ For local reviews: check for `.checkpoints/manifest.json` in current directory.
174
+
175
+ 2. **If checkpoint found**, read `manifest.json`:
176
+ ```bash
177
+ cat "$REVIEW_DIR/.checkpoints/manifest.json"
178
+ ```
179
+
180
+ 3. **Validate checkpoint is still valid**:
181
+ - Check `pr.number` matches current PR
182
+ - For PR reviews: verify `head_sha` in manifest matches current PR head SHA (PR not updated since checkpoint)
183
+ - If SHA mismatch → checkpoint is stale, delete old directory and start fresh
184
+
185
+ 4. **Ask user to resume**:
186
+ ```
187
+ 📂 Found checkpoint from previous review:
188
+ Phase: {completed_phase} → {next_phase}
189
+ Started: {started_at}
190
+ Last updated: {last_updated}
191
+
192
+ Resume from phase {next_phase}? (y/n)
193
+ ```
194
+
195
+ 5. **If user says yes**:
196
+ - Load `manifest.json`
197
+ - Load all completed phase files (phase-0-clone.json, phase-1-context.json, etc.)
198
+ - Jump to `next_phase` in the workflow
199
+ - For Phase 3: check `subagent_status` and only run incomplete subagents
200
+
201
+ 6. **If user says no or checkpoint invalid**:
202
+ - Delete old checkpoint directory: `rm -rf "$REVIEW_DIR"`
203
+ - Start fresh from Phase 0
204
+
205
+ **For Local Reviews:** Checkpoint directory is `.checkpoints/` in current working directory. No SHA validation needed (working directory changes are expected).
206
+
207
+ ### Phase 0: Repository Preparation (MANDATORY for PR Reviews)
208
+
209
+ **Why**: Your local repo may be on any branch, have uncommitted changes, or not exist at all. Cloning to a temp folder ensures:
210
+ - You always read the **actual PR branch code**, not whatever is checked out locally
211
+ - You can review **multiple PRs simultaneously** without branch conflicts
212
+ - Your working directory is **never disturbed**
213
+
214
+ **Steps:**
215
+
216
+ 1. **Extract repo info** from PR URL or `gh pr view`:
217
+ - `owner/repo` (e.g., `zengamingx/tradeit-backend`)
218
+ - `pr_number` (e.g., `1159`)
219
+ - `head_branch` (e.g., `feature/dev-4650-callback-url-for-payment-method`)
220
+
221
+ 2. **Create unique temp directory**:
222
+ ```bash
223
+ REVIEW_DIR="/tmp/pr-review-${repo}-${pr_number}-$(date +%s)"
224
+ mkdir -p "$REVIEW_DIR"
225
+ ```
226
+ Format: `/tmp/pr-review-{repo}-{pr_number}-{unix_timestamp}`
227
+
228
+ 3. **Clone the repo** (shallow clone for speed):
229
+ ```bash
230
+ git clone --depth=50 --branch="${head_branch}" \
231
+ "https://github.com/${owner}/${repo}.git" "$REVIEW_DIR"
232
+ ```
233
+ If the branch doesn't exist on remote (force-pushed/deleted), fall back to:
234
+ ```bash
235
+ git clone --depth=50 "https://github.com/${owner}/${repo}.git" "$REVIEW_DIR"
236
+ cd "$REVIEW_DIR" && gh pr checkout ${pr_number}
237
+ ```
238
+
239
+ 4. **Verify clone succeeded**:
240
+ ```bash
241
+ cd "$REVIEW_DIR" && git log --oneline -1
242
+ ```
243
+ If this fails → STOP review, report error to user.
244
+
245
+ 5. **Record the temp path** — ALL subsequent phases use `$REVIEW_DIR` for file reads, grep, LSP, etc.
246
+
247
+ 6. **Print confirmation**:
248
+ ```
249
+ 📂 Cloned to: /tmp/pr-review-tradeit-backend-1159-1741502400
250
+ 🌿 Branch: feature/dev-4650-callback-url-for-payment-method
251
+ 📝 Ready for review
252
+ ```
253
+
254
+ **For Local Reviews (`--staged`):** Skip Phase 0 — use current working directory.
255
+
256
+ **CRITICAL**: Store `$REVIEW_DIR` path. Every file read, grep, and subagent prompt MUST reference this path, not the original workspace repo.
257
+
258
+ **Checkpoint:** Save clone metadata to `.checkpoints/phase-0-clone.json` (clone_dir, branches, head_sha, files_changed) and create `manifest.json` with `completed_phase: 0`, `next_phase: 1`, `phase_status: {"0": "complete", ...}`.
259
+
260
+ ### Phase 1: Context Gathering
261
+
262
+ **For PR Reviews (GitHub MCP):**
263
+ 1. `get_pull_request` → title, description, author, base branch
264
+ 2. `get_pull_request_files` → changed files with diff stats
265
+ 3. Read full file context from `$REVIEW_DIR` (NOT from GitHub API — local reads are faster and give full file)
266
+
267
+ **For Local Reviews (git):**
268
+ 1. `git diff --staged` or `git diff` → changed files
269
+ 2. `git log --oneline -5` → recent commit context
270
+
271
+ **Then for all reviews:**
272
+ 3. Classify each file's change type:
273
+ - **LOGIC**: Conditionals, business rules, state → DEEP TRACE
274
+ - **DELETION**: Removing existing behavior/features → DEEP TRACE + PREMISE CHECK (see Phase 2)
275
+ - **STYLE**: Formatting, naming, comments → SHALLOW TRACE
276
+ - **REFACTOR**: Structure changes, no logic change → MEDIUM TRACE
277
+ - **NEW**: New files → FULL REVIEW
278
+
279
+ **DELETION classification rules**: Any PR that removes user-facing behavior, error messages, validation logic, UI elements, or API responses MUST be classified as DELETION, not STYLE or REFACTOR. Deletions feel safe but can hide regressions — they require the same depth as LOGIC changes plus a Premise Check.
280
+ 4. Gather full context per changed file from `$REVIEW_DIR`: callers/callees, tests, types, usage sites
281
+ 5. **Query nano-brain** for project memory on each changed module — [query patterns](references/nano-brain-integration.md#phase-1-memory-queries)
282
+ 6. **Fetch Linear ticket context** (if ticket ID found) — see Phase 1.5
283
+
284
+ **Checkpoint:** Save results to `.checkpoints/phase-1-context.json` (PR metadata, file classifications, nano-brain context) and update `manifest.json` (`completed_phase: 1`, `next_phase: 1.5`).
285
+
286
+ ### Phase 1.5: Linear Ticket Context (Optional)
287
+
288
+ If a Linear ticket ID was extracted from the branch name, PR description, or PR title:
289
+
290
+ 1. **Fetch ticket**: `linear_get_issue(id)` → title, description (contains acceptance criteria), status, priority, labels, assignee
291
+ 2. **Fetch comments**: `linear_list_comments(issueId)` → discussion thread, clarifications, edge cases mentioned
292
+ 3. **Extract acceptance criteria** from ticket description — look for:
293
+ - Sections titled "Acceptance Criteria", "AC", "Requirements", "Definition of Done"
294
+ - Checkbox lists (`- [ ]` items)
295
+ - Numbered requirements
296
+ 4. **Extract images** if ticket description contains embedded images: `linear_extract_images(description)`
297
+
298
+ **What to do with ticket context:**
299
+ - Pass to ALL subagents as `## LINEAR TICKET CONTEXT` section
300
+ - Use acceptance criteria to verify PR completeness in Phase 4
301
+ - Flag in report if PR appears to miss acceptance criteria items
302
+ - Include ticket title + status in report header
303
+
304
+ **Ambiguity Detection (MANDATORY):**
305
+ If acceptance criteria are vague or open to multiple interpretations (e.g., "fix it", "make it correct", "improve this", "need to fix to make it correct"), you MUST:
306
+ 1. Flag it as a **warning** in the report: *"Acceptance criteria are ambiguous — PR may not match intended fix."*
307
+ 2. Identify the multiple interpretations (e.g., "remove the feature" vs "fix the condition")
308
+ 3. Evaluate which interpretation the PR implements
309
+ 4. Note in the report whether the PR's interpretation seems correct or if clarification is needed
310
+
311
+ **If Linear is unavailable or ticket not found:** Continue review without ticket context. Do NOT fail the review.
312
+
313
+ **Checkpoint:** Save results to `.checkpoints/phase-1.5-linear.json` (ticket details, acceptance criteria, comments, images) and update `manifest.json` (`completed_phase: 1.5`, `next_phase: 2`).
314
+
315
+ ### Phase 2: Smart Tracing (Based on Change Type)
316
+
317
+ **LOGIC changes:**
318
+ 1. Find ALL callers (LSP find_references) and callees
319
+ 2. Find ALL tests covering this code path
320
+ 3. Find ALL types/interfaces affected
321
+ 4. Trace data flow: input source → output destination
322
+ 5. Query nano-brain for known issues — [query patterns](references/nano-brain-integration.md#phase-2-memory-queries-logic-changes)
323
+
324
+ **DELETION changes (all LOGIC steps above, PLUS):**
325
+ 6. **Premise Check** — answer these questions before proceeding:
326
+ - Why was this code added originally? What problem did it solve?
327
+ - Is the underlying problem solved by this PR, or is a symptom being hidden?
328
+ - Would fixing the logic be more correct than removing it?
329
+ - Does removing this break any user-facing behavior that was intentional?
330
+ - Are there related components (backend config, i18n keys, API responses) that depend on this code existing?
331
+ 7. Document the Premise Check answers — they feed into the report (Phase 5)
332
+
333
+ **Cross-Repo API Tracing (MANDATORY for multi-repo workspaces):**
334
+ For any changed code that **consumes data from an API** (fetches, reads responses, uses values from backend):
335
+ 1. Identify the API endpoint being called (e.g., `/api/v2/inventory/my/data`)
336
+ 2. Find the backend repo that serves this endpoint (use workspace AGENTS.md domain mappings)
337
+ 3. Read the backend handler to understand:
338
+ - What the API actually returns and under what conditions
339
+ - Any config values that affect the response (e.g., cache TTLs, feature flags)
340
+ - Whether the frontend's assumptions about the data match the backend's behavior
341
+ 4. For any **hardcoded values** in the frontend that correspond to backend config (e.g., hardcoded `6 * 60 * 1000` vs backend's `steamCInvCacheTTLMinutes`), flag as a **warning**: values are out of sync.
342
+
343
+ **This applies even for deletions.** If the deleted code consumed API data, trace into the backend to understand whether the deletion is correct or whether the code should be fixed instead.
344
+
345
+ **STYLE changes:** Check convention consistency, verify no hidden logic changes.
346
+
347
+ **REFACTOR changes:** Verify behavior preservation, check all usages still work.
348
+
349
+ **Checkpoint:** Save results to `.checkpoints/phase-2-tracing.json` (tracing results per file, callers/callees, test coverage, data flow, premise check answers, cross-repo tracing) and update `manifest.json` (`completed_phase: 2`, `next_phase: 2.5`).
350
+
351
+ ### Phase 2.5: PR Summary Generation (REQUIRED)
352
+
353
+ Before launching subagents, generate a GitHub Copilot-style PR summary. Reviewers need this context.
354
+
355
+ 1. **What This PR Does** (1-3 sentences): Start with action verb, mention feature/bug, include business impact
356
+ 2. **Key Changes** by category: Feature, Bugfix, Refactor, Performance, Security, Docs, Tests, Config, Dependencies
357
+ 3. **File-by-File Summary**: What changed, why it matters, key modifications with line numbers
358
+ 4. **Ticket Reference**: If Linear ticket found, include ticket ID, title, and status
359
+
360
+ **Full guidelines + pseudocode**: [report-template.md](references/report-template.md#pr-summary-generation-guidelines)
361
+
362
+ **Checkpoint:** Save results to `.checkpoints/phase-2.5-summary.json` (PR summary text, key changes, file summaries) and update `manifest.json` (`completed_phase: 2.5`, `next_phase: 3`).
363
+
364
+ ### Phase 3: Parallel Subagent Execution (NEVER SKIP)
365
+
366
+ **ALL 4 subagents MUST run for EVERY review. No exceptions. No "this PR is too small." No "this is just a deletion." The phases exist because each subagent catches different classes of issues that you, the orchestrator, will miss.**
367
+
368
+ Launch ALL 4 subagents simultaneously with `run_in_background: true`. Include PR Summary, nano-brain memory, Premise Check results (if DELETION), cross-repo tracing results, and **`$REVIEW_DIR` path** in each prompt so subagents read from the correct clone.
369
+
370
+ | # | Agent | Type | Focus |
371
+ |---|-------|------|-------|
372
+ | 1 | Code Quality | `explore` | Style, naming, error handling, type safety, duplication, complexity, **code improvements** |
373
+ | 2 | Security & Logic | `oracle` | OWASP Top 10, logic correctness, edge cases, race conditions, auth, **logic improvements**, **cross-repo data flow**, **deletion premise validation** |
374
+ | 3 | Docs & Best Practices | `librarian` | API docs, framework best practices, anti-patterns, **idiomatic improvements** |
375
+ | 4 | Tests & Integration | `general` | Test coverage, edge cases, contract integrity, performance, **perf improvements** |
376
+
377
+ **Full prompt templates**: [subagent-prompts.md](references/subagent-prompts.md)
378
+
379
+ Each subagent returns JSON: `{findings: [{file, line, severity, category, message, suggestion, code_suggestion?, evidence, confidence, trace_path?}]}`
380
+
381
+ Severity values: `critical` (blocks merge), `warning` (should fix), `improvement` (code can be better), `suggestion` (nice-to-have)
382
+
383
+ New fields (v3.1): `evidence` (REQUIRED for critical/warning — concrete proof with file:line references), `confidence` (high/medium/low), `trace_path` (optional array of file:line strings showing verification trace)
384
+
385
+ **Checkpoint:** After **EACH** subagent completes, update `.checkpoints/phase-3-subagents.json` with that subagent's findings and update `manifest.json` subagent_status to `"complete"` for that subagent. After ALL subagents complete, update `manifest.json` (`completed_phase: 3`, `next_phase: 4`). On resume, only run subagents with status != `"complete"`.
386
+
387
+ ### Phase 4: Iterative Refinement & Filtering
388
+
389
+ 1. **Merge & Deduplicate**: Combine all subagent findings, remove duplicates (same issue from multiple agents)
390
+ 2. **Consensus Scoring** (NEW — reduces false positives):
391
+ - For each deduplicated finding, count how many subagents independently flagged it (match by file + line + category)
392
+ - `consensus_count >= 2` → boost confidence to `high` (multiple agents agree)
393
+ - `consensus_count == 1` + non-empty `evidence` with file:line references → keep original severity and confidence
394
+ - `consensus_count == 1` + empty/missing `evidence` + severity `critical` or `warning` → **AUTO-DOWNGRADE to `suggestion`**
395
+ 3. **Severity Filter** (CRITICAL — this makes reports short):
396
+ - `critical` + `warning` → **KEEP with full detail**
397
+ - `improvement` → **KEEP as one-liner** with optional code suggestion
398
+ - `suggestion` → **COUNT only** — report total number, omit individual details unless < 3 total
399
+ - Drop anything a linter/formatter would catch (let tools handle those)
400
+ - Drop style nits that don't affect readability or correctness
401
+ 4. **Gap Analysis**: Did any subagent fail? Untested code paths? Unreviewed files?
402
+ 5. **Second Pass** (if gaps found): Targeted follow-up on identified gaps only
403
+
404
+ **Checkpoint:** Save results to `.checkpoints/phase-4-refined.json` (deduplicated findings with consensus scores, filtered by severity, gap analysis results) and update `manifest.json` (`completed_phase: 4`, `next_phase: 4.5`).
405
+
406
+ ### Phase 4.5: Orchestrator Verification Spot-Check (Critical + Warning Only)
407
+
408
+ The orchestrator MUST verify each finding with severity `critical` or `warning` by reading the actual code at the cited evidence locations in `$REVIEW_DIR`. This catches false positives that survived subagent self-verification.
409
+
410
+ **If no critical/warning findings exist after Phase 4:** Skip Phase 4.5 (mark as complete immediately, proceed to Phase 5).
411
+
412
+ **For each critical/warning finding:**
413
+
414
+ 1. **Parse the evidence field** — extract file:line references cited by the subagent
415
+ 2. **Read the cited files** from `$REVIEW_DIR` at the referenced line numbers
416
+ 3. **Verify the claim** based on finding category:
417
+ - **Error handling claims**: Read the controller/route handler that calls this code path. If a try-catch exists at the HTTP boundary → finding is FALSE
418
+ - **Null safety claims**: Read the data source (SQL query, API contract). If the source guarantees non-null (PK, NOT NULL, JOIN constraint) → finding is FALSE
419
+ - **Logic error claims**: Trace the cited execution path. If no realistic input triggers the bug → finding is FALSE
420
+ - **Framework pattern claims**: Check if the specific usage context makes the pattern safe → finding is FALSE
421
+ 4. **Mark verification status**:
422
+ - `verified: true` — evidence checks out, issue is real → **KEEP** in report
423
+ - `verified: false` — evidence is wrong (e.g., try-catch DOES exist) → **DROP** from report
424
+ - `verified: "unverifiable"` — can't confirm within timeout → **DOWNGRADE** to `suggestion`
425
+
426
+ **Timeout**: 30 seconds per finding. If verification takes longer, mark as `unverifiable` and move on.
427
+
428
+ **Checkpoint:** Save results to `.checkpoints/phase-4.5-verification.json`:
429
+ ```json
430
+ {
431
+ "findings_checked": 5,
432
+ "verified_true": 3,
433
+ "verified_false": 1,
434
+ "unverifiable": 1,
435
+ "dropped_findings": [{ "original": { "file": "...", "line": 42, "message": "..." }, "reason": "try-catch exists at controller.js:28" }],
436
+ "downgraded_findings": [{ "original": { "file": "...", "line": 99, "message": "..." }, "new_severity": "suggestion" }]
437
+ }
438
+ ```
439
+ Update `manifest.json` (`completed_phase: 4.5`, `next_phase: 5`).
440
+
441
+ ### Phase 5: Report Generation
442
+ Save to `.opencode/reviews/{type}_{identifier}_{date}.md`. Create directory if needed.
443
+
444
+ **Report structure** (compact — omit empty sections):
445
+ 1. **TL;DR** — verdict (APPROVE/REQUEST CHANGES/COMMENT) + issue counts in 3 lines
446
+ 2. **PR Overview** — what this PR does (1-3 sentences) + key changes by category
447
+ 3. **Ticket Alignment** — acceptance criteria coverage check (only if Linear ticket found). Flag ambiguous criteria.
448
+ 4. **Premise Check** — only for DELETION changes: why the code existed, whether removal is correct vs fixing the logic, cross-repo implications
449
+ 5. **Critical Issues** — full detail: file, line, issue, impact, fix
450
+ 6. **Warnings** — full detail: file, line, issue, fix
451
+ 7. **Code Improvements** — one-liner each with optional code suggestion
452
+ 8. **Suggestions** — count + brief list (or omit if none)
453
+ 9. **File Summary** — table only (file, change type, one-line summary)
454
+
455
+ **Omit unless actionable**: Traced Dependencies, Memory Context, Test Coverage, Praise, Change Classification. Include only if they contain findings the developer must act on.
456
+
457
+ **Full template**: [report-template.md](references/report-template.md)
458
+
459
+ **Checkpoint:** Save final report to `.checkpoints/phase-5-report.md` (copy of the report saved to `.opencode/reviews/`) and update `manifest.json` (`completed_phase: 5`, `next_phase: 5.5`).
460
+
461
+ ### Phase 5.5: Save Review to nano-brain
462
+
463
+ Save key findings for future sessions. Includes PR number, title, date, files, critical issues, warnings, decisions, recommendation.
464
+
465
+ **Full save patterns**: [nano-brain-integration.md](references/nano-brain-integration.md#phase-55-save-review-to-nano-brain)
466
+
467
+ **Checkpoint:** Update `manifest.json` (`completed_phase: 5.5`, `next_phase: 6`).
468
+
469
+ ### Phase 6: Cleanup (MANDATORY for PR Reviews)
470
+
471
+ **NEVER delete the temp folder without asking the user.** The user may want to inspect files, run tests, or review multiple PRs.
472
+
473
+ 1. **Show the temp folder path and size**:
474
+ ```bash
475
+ du -sh "$REVIEW_DIR"
476
+ ```
477
+
478
+ 2. **Ask the user**:
479
+ ```
480
+ 🧹 Cleanup: Review temp folder exists at:
481
+ 📂 /tmp/pr-review-tradeit-backend-1159-1741502400 (45M)
482
+
483
+ Want me to remove it? (yes/no)
484
+ ```
485
+
486
+ 3. **Only if user confirms**: `rm -rf "$REVIEW_DIR"` (this also removes `.checkpoints/` since it's inside the clone directory)
487
+
488
+ 4. **If user declines**: Remind them to clean up later:
489
+ ```
490
+ ℹ️ Temp folder kept. Remove manually when done:
491
+ rm -rf /tmp/pr-review-tradeit-backend-1159-1741502400
492
+ ```
493
+
494
+ **If reviewing multiple PRs**: Each PR has its own temp folder. Ask about each one individually at the end.
495
+
496
+ **Note:** Checkpoints are automatically removed when the clone directory is deleted. For local reviews (`--staged`), checkpoints remain in `.checkpoints/` until manually deleted.
497
+
498
+ ### User Notification (CRITICAL)
499
+
500
+ After review completes, ALWAYS inform the user:
501
+
502
+ ```
503
+ ✅ Review complete!
504
+
505
+ 📄 Report saved to: .opencode/reviews/PR_123_2026-02-04.md
506
+
507
+ Summary:
508
+ • Critical: {count}
509
+ • Warnings: {count}
510
+ • Suggestions: {count}
511
+
512
+ 🧹 Temp clone: /tmp/pr-review-{repo}-{pr}-{ts} — want me to remove it?
513
+ ```
514
+
515
+ ## Usage Examples
516
+
517
+ ```
518
+ /review PR#123
519
+ /review https://github.com/owner/repo/pull/123
520
+ /review --staged
521
+ ```
522
+
523
+ ## Reference Documentation
524
+
525
+ | Document | Content | When to Read |
526
+ |----------|---------|--------------|
527
+ | [subagent-prompts.md](references/subagent-prompts.md) | Full prompt templates for all 4 subagents | Phase 3 execution |
528
+ | [report-template.md](references/report-template.md) | Report format, PR summary guidelines, pseudocode | Phase 2.5 + Phase 5 |
529
+ | [nano-brain-integration.md](references/nano-brain-integration.md) | Tool reference, query patterns, save patterns | Phase 1, 2, 5.5 |
530
+ | [config.json](assets/config.json) | Full workspace + output + trace config | Setup |
@@ -0,0 +1,47 @@
1
+ {
2
+ "version": "2.8.0",
3
+ "workspace": {
4
+ "name": "my-project",
5
+ "github": {
6
+ "owner": "acme-corp",
7
+ "default_base": "main",
8
+ "token_env": "GITHUB_TOKEN"
9
+ },
10
+ "linear": {
11
+ "enabled": true,
12
+ "workspace_id": "acme",
13
+ "team_id": "ENG",
14
+ "token_env": "LINEAR_API_KEY",
15
+ "extract_from": ["branch_name", "pr_description", "pr_title"],
16
+ "fetch_comments": true,
17
+ "fetch_attachments": false
18
+ },
19
+ "jira": {
20
+ "instance": "acme.atlassian.net",
21
+ "project_key": "ACME",
22
+ "token_env": "JIRA_TOKEN"
23
+ }
24
+ },
25
+ "output": {
26
+ "directory": ".opencode/reviews",
27
+ "filename_pattern": "{type}_{identifier}_{date}",
28
+ "github_comment": false,
29
+ "notify_user": true
30
+ },
31
+ "trace_depth": {
32
+ "logic": "deep",
33
+ "style": "shallow",
34
+ "refactor": "medium"
35
+ },
36
+ "report": {
37
+ "verbosity": "compact",
38
+ "show_suggestions": false,
39
+ "show_improvements": true,
40
+ "max_suggestions_listed": 3
41
+ },
42
+ "ignore_patterns": [
43
+ "*.test.ts",
44
+ "*.spec.ts",
45
+ "__mocks__/**"
46
+ ]
47
+ }