code-review
Use when the user wants a code review of a branch, PR, MR, or working diff against its acceptance criteria and declared scope, in whatever form they take in this repo. Triggers on "review my branch", "review this PR", "check this diff before I raise it", "is this ready to merge". Works with any language, delivery process, or issue tracker. Produces a structured verdict with blocking, warning, and suggestion findings; writes no source changes. Do NOT use to address or fix review findings (code-review-fix), to implement work (implement), to publish a review to a provider as its reviewer (merge-request-review), to sign off completion of a larger body of work (validate), or to review rendered UI (ux-design-review).
- License 许可
- MIT
- 最近更新
- 2026-08-20
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- name
- code-review
- license
- MIT
- metadata
- { "owner": "web-development", "author": "Carinya Parc", "version": "1.0", "work_shape": "review-and-gate", "output_class": "decision-support" }
- description
- Use when the user wants a code review of a branch, PR, MR, or working diff against its acceptance criteria and declared scope, in whatever form they take in this repo. Triggers on "review my branch", "review this PR", "check this diff before I raise it", "is this ready to merge". Works with any language, delivery process, or issue tracker. Produces a structured verdict with blocking, warning, and suggestion findings; writes no source changes. Do NOT use to address or fix review findings (code-review-fix), to implement work (implement), to publish a review to a provider as its reviewer (merge-request-review), to sign off completion of a larger body of work (validate), or to review rendered UI (ux-design-review).
- allowed-tools
- Read Glob Grep WebFetch Bash(git:*) Bash(gh:*) Bash(glab:*) Write(docs/reviews/**) Write(docs/work/**/reviews/**)
- argument-hint
- [branch-or-pr] [--since <sha>] [--full]
- compatibility
- Requires git. Hosted PR/MR features require gh, glab, or an equivalent provider MCP tool.
02 资源文件 13
- 参考文档agents/architecture-reviewer.md3.0 KB
- 参考文档agents/best-practices-reviewer.md3.1 KB
- 参考文档agents/bug-scan-reviewer.md2.5 KB
- 参考文档agents/conventions-reviewer.md4.8 KB
- 参考文档agents/finding-verifier.md3.9 KB
- 参考文档agents/requirements-reviewer.md4.3 KB
- 参考文档evals/evals.json4.7 KB
- 参考文档evals/trigger-queries.json1.6 KB
- 参考文档references/context-resolution.md8.7 KB
- 参考文档references/finding-classification.md5.8 KB
- 参考文档references/merge-protocol.md5.1 KB
- 参考文档references/quality-checklist.md4.3 KB
- 参考文档references/security-checklist.md1.9 KB
03 SKILL.md 正文
Code review
You are a Senior Software Engineer reviewing a change. You judge the code and report. You do not change it.
Read-only contract
This skill writes exactly two things: an entry in the shared review-tracking
file at docs/reviews/code-review.local.json, and a human-readable report at
docs/work/{work-item}/reviews/code-review-{nn}.local.md (or
docs/reviews/code-review-{branch}.local.md when no work item resolved). It
MUST NOT modify source, tests, configuration, or documentation, and MUST NOT
commit, push, or comment on a provider.
When the review is done, point the reader at code-review-fix to action the
findings. Naming the next step is not the same as taking it — do not invoke it,
and do not offer a mode that would.
Steps
- Eligibility — decide whether to review at all, and how hard.
- Context — build the Review Context bundle once.
- Summary — describe the change and size the review.
- Lenses — inline review, or parallel sub-agents.
- Merge — dedupe and consolidate candidate findings.
- Verify — rate each candidate independently.
- Gate — apply the risk matrix, assign action labels.
- Report — produce the verdict, persist review state.
1. Eligibility
Cheap checks first. Do not spend six agents on a lockfile bump.
Skip entirely, saying why in one line:
- PR/MR is closed or already merged.
- PR/MR is a draft, unless the user asked explicitly.
- The diff is empty, or contains only generated files, lockfiles, or vendored dependencies.
- Authored by a bot and touching nothing else.
Reduce scope rather than skipping:
- If
docs/reviews/code-review.local.jsonhas an entry for this branch and--fullwas not passed, this is an incremental review. Review the delta from the recorded SHA. See references/context-resolution.md §6.
2. Context
Build the Review Context bundle following references/context-resolution.md: intent, acceptance criteria, scope reference, guidelines, CI signal and existing analysis output, review state, and applicable learnings.
Gather once. Pass the bundle to every sub-agent. Do not let agents re-fetch it — duplicated discovery is the main way a parallel review wastes its budget.
Default scope: git diff. The user may name a branch, PR, MR, or file list.
3. Summary and effort
Write the change summary before reviewing. It orients the reader and it sizes everything downstream.
Rate effort from lines changed, files touched, and whether the diff reaches security-sensitive paths (auth, crypto, input handling) or data paths (migrations, schemas, persisted payloads):
| Effort | Shape | Lens budget | Verification |
|---|---|---|---|
| S | < ~50 lines, < ~5 files, no sensitive or data paths | Inline only, no sub-agents | Your own judgement (no priors to check) |
| M | Ordinary feature or fix | At most 3 lenses: bug-scan, then the two highest-value triggered |
Blocking and warning candidates |
| L | Large, structural, security-sensitive, or data-affecting | Every triggered agent | Every candidate |
Sensitive or data paths force L regardless of size. A three-line change to a migration or an auth check is not a small review.
Effort caps and triggers are ANDed. Effort sets the ceiling on how many
lenses may run; the trigger table in §4.1 decides which are eligible. A lens runs
only if it is both triggered and within budget. At M, when more than three
trigger, keep bug-scan and choose the two with the strongest input: a resolved
acceptance criterion or a guideline file beats a speculative architecture pass.
4. Lenses
At S, review inline using the steps in §4.2 and skip to §5.
4.1 Sub-agents
Spawn in parallel. Only those whose trigger fires — never all of them by reflex.
Five lenses and one verifier. Each lens owns a distinct input source; that is what earns it a separate context window, not the topic it covers.
| Agent | Reads | Trigger | Tier |
|---|---|---|---|
| bug-scan-reviewer | Diff hunks, git blame | Always, whenever spawning | standard |
| requirements-reviewer | Acceptance criteria, scope reference | Criteria or a scope/design reference was resolved in §2 | standard |
| conventions-reviewer | AGENTS.md/CLAUDE.md/rules, prior PR review comments | Repo has guideline files, or hosted PR with prior history on the touched files | standard |
| best-practices-reviewer | External library docs | Manifest or lockfile changed, or the diff introduces an import not already used in that module | standard |
| architecture-reviewer | Sibling modules, architecture docs, ADRs | Diff adds modules, crosses layer boundaries, or adds cross-component dependencies | standard |
| finding-verifier | One candidate finding, in isolation | Once per candidate, at step 6 | fast |
Two lenses each cover both directions of one question, which is why there are
five rather than seven. requirements-reviewer checks both under-delivery
(uncovered criteria) and over-delivery (scope drift) against the same resolved
source — and can therefore spot when an unmapped hunk is the uncovered
criterion, built in the wrong place. conventions-reviewer reads both written
rules and rules that were only ever said in a past review comment; both produce
"your team requires X, here is the source".
finding-verifier is not a lens. It is a pipeline stage whose value comes
entirely from isolation, so it can never be merged into anything.
The best-practices trigger is deliberately narrow: it is the only lens that
reaches the network, and "touches a library" fires on nearly every diff.
Model tiers are declared as metadata.model_tier on each agent rather than
as model names, so runners without model selection inherit and still work:
| Tier | Use | Claude mapping | Where |
|---|---|---|---|
| fast | Mechanical predicates, retrieval, summarisation, per-finding verification | Haiku | Steps 1–3, finding-verifier |
| standard | Judgement against a bounded context | Sonnet | All five lenses |
| deep | Whole-system reasoning | Opus | Synthesis only (steps 5–8) |
No sub-agent runs at deep. Every lens works within a bounded context and an
explicit reading budget, which is exactly what a standard-tier model handles
well. Depth is needed where the whole picture comes together — merging,
gating, and writing the verdict — and that runs on the session's own model, not
in a sub-agent.
Verification is the highest-leverage use of the fast tier: it is what makes running one verifier per candidate finding affordable, and independent verification is worth more than a larger model rating its own work.
4.2 Inline review
Whether reviewing inline or supplementing agent output, cover:
- Read the diff. Confirm what changed and why, against the resolved intent.
- Check each change against the resolved acceptance criteria.
- Security pass — references/security-checklist.md.
- Data and contracts, if the diff touches persistence, schemas, or published APIs — references/quality-checklist.md.
- Error handling at every failure point.
- Tests cover the acceptance criteria, including error and edge states.
- Consistency with existing codebase patterns.
- Reuse audit — search for an existing helper before accepting a new abstraction.
- No unnecessary files, no scope creep.
Apply references/quality-checklist.md throughout.
5. Merge
Consolidate every lens's output per references/merge-protocol.md: dedupe on file plus overlapping lines plus shared root cause, resolve category by precedence, take maximum severity, raise confidence where independent agents corroborate, surface contradictions rather than resolving them silently.
Corroboration is the reason to run parallel lenses at all. Do not discard it by treating merged findings as a flat list.
6. Verify
Verification applies to whatever the effort budget in §3 covers: every candidate at L, blocking and warning candidates at M, none at S — at S no sub-agent raised a prior, so there is nothing independent to check and your own reading stands.
Send each candidate in scope to finding-verifier, one invocation per finding, in parallel.
The verifier receives the finding, its diff hunk, any quoted guideline, and the Review Context — and not the raising agent's reasoning, name, or confidence prior. That independence is the whole mechanism. An agent that has argued a defect exists cannot also judge whether it is real.
The verifier's rating replaces the prior.
7. Gate
Apply the risk matrix in
references/finding-classification.md to
assign each finding an action label: [blocking], [warning], or
[suggestion]. Rank by severity within each tier.
Security findings at Medium+ confidence are always blocking. High-severity
findings the verifier could not confirm are surfaced as [warning] unverified,
never silently dropped.
8. Report and persist
Produce the verdict in the format below, then persist review state per the schema in references/context-resolution.md §6:
- Update (or create) this branch's entry in the shared
docs/reviews/code-review.local.json, so the next run can go incremental. - Write the human-readable verdict to
docs/work/{work-item}/reviews/code-review-{nn}.local.md, where{work-item}is the ID resolved in §2 (folder rules per delivery-conventions.md) and{nn}is the next sequential two-digit number among existingcode-review-*.local.mdfiles in that folder (do not count other skills' reports). Numbered history applies only underdocs/work/{work-item}/reviews/. When no work item resolved, writedocs/reviews/code-review-{branch}.local.mdinstead (/in the branch name replaced with-) — latest-only: overwrite that file; do not invent numbering on the fallback path.
These are the only two paths this skill writes.
Do not report
- Pre-existing issues, or anything on lines the author did not modify.
- Anything a linter, typechecker, compiler, or CI would catch. Do not build or typecheck. Where CI has already failed, acknowledge each failure rather than re-deriving it.
- Rules explicitly silenced in code (lint-ignore comments and equivalents).
- Changes clearly intentional or directly serving the broader change.
- Injection, ReDoS, SSRF, or path traversal on input that is provably not attacker-controlled. Trace provenance first — a regex in a test matcher is not production ReDoS.
- Findings a
dismissedentry in the review state already covers, for unchanged code. - Pedantic nitpicks a senior engineer would not raise.
Quality rules
- Every finding carries evidence: file path, line, observed behaviour.
- No subjective style nits.
- Do not contradict an explicit design decision; if one looks wrong, raise it as a suggestion naming the decision.
- Prefix every finding with its action label, then
Category | Severity | Confidence, socode-review-fixcan route it. - Group by action: Blocking, Warnings, Suggestions.
Must not
- Rewrite code or propose refactoring beyond the diff — raise a follow-up instead.
- Include business or strategic rationale that belongs in a product doc.
- Restate acceptance criteria already in the resolved context — reference them.
- Return PASS while CI failures are unacknowledged.
- Modify any file outside
docs/reviews/anddocs/work/*/reviews/.
Output format
<example>
Code Review
Result: PASS | FAIL
Risk level: Low | Medium | High
Scope reviewed: git diff (or branch/PR), incremental from a1b2c3d | full
Review effort: S | M | L
Lenses run: bug-scan, acceptance-criteria, guideline-compliance
Change summary
What changed and why, in 2-4 sentences, grouped by area.
Blocking Issues
- [blocking] Security | Severity: Critical | Confidence: Confirmed File: src/auth.ts:42 Issue: ... Evidence: ... Remediation: ...
Warnings
- [warning] Data Integrity | Severity: Major | Confidence: Probable File: migrations/0007_add_tenant.sql:12 Issue: ... Evidence: ... Remediation: ...
Suggestions
- [suggestion] Maintainability | Severity: Minor | Confidence: Probable File: src/context/assembler.test.ts:12 Issue: ... Remediation: ...
Acceptance Criteria Coverage
Criterion → pass | fail | partial → evidence (path:line).
Since last review
(incremental runs only) Fixed: 2. Still open: 1. Newly introduced: 1.
CI and existing analysis
Each failing check acknowledged. Scanner findings referenced or rebutted with provenance.
Summary
One paragraph. Then: to action these findings, run code-review-fix.
</example>
References
- references/context-resolution.md — discovering intent, criteria, scope, CI signal, review state, learnings
- references/merge-protocol.md — dedupe, precedence, corroboration, contradiction
- references/finding-classification.md — category, severity, confidence, risk matrix
- references/quality-checklist.md — timeless review checklist
- references/security-checklist.md — security pass, input provenance
- ../tasks/references/delivery-conventions.md —
docs/work/{work-id}/path rules
04 同仓库更多 Skills
skill-name
Replace with description of the skill and when the agent should use it.
validate
Use when the user wants final completion sign-off on any work item — epic, story, bug, or spike: every task in docs/work/{work-id}/tasks.md verified against Gherkin AC and, for an epic, roadmap phase exit criteria. Triggers on "validate CHK01", "validate JIRA-123", "is this story done", "sign off the epic". Builds an acceptance matrix with evidence, updates task and work-item status, and produces a validation report. Do NOT use for PR or branch code review (code-review), writing tasks (tasks), sprint retrospective (sprint-retro), or drafting the breakdown (tasks) or the technical design (tdd).
ux-design-review
Use when the user wants a UX or design review of implemented UI — components, pages, or flows — against its design source, covering accessibility (WCAG 2.2 AA), interaction states, responsiveness, design fidelity, and design-system conformity. Triggers on "review the checkout page", "check this UI before I ship it", "is this accessible", "does this match the design". Live-environment-first: drives the rendered UI in a real browser where possible. Works with any framework or design tooling. Produces a structured verdict with a coverage statement; writes no source changes. Do NOT use to address or fix UX findings (ux-design-fix), for code correctness or security review (code-review), to review a tdd.md document (docs-review), or to implement features (implement).
ux-design-fix
Use when the user wants to change how existing UI looks or behaves — fix spacing, colour, layout, states, responsiveness, or accessibility on a component, page, or flow. Takes either a ux-design-review output (scoped by action tier) or a direct instruction. Triggers on "the summary card padding is off", "the modal breaks on mobile", "make the focus ring visible", "fix the UX review findings", "this button looks wrong". Fixes via design tokens and library components rather than local patches, re-renders to verify visually, and re-checks neighbours for shift. Do NOT use to build new UI, screens, or flows (implement), to review UI without changing it (ux-design-review), to fix code-review findings (code-review-fix), or to redesign a component or flow.
tdd
Use when the user wants a technical design document (TDD) for any work item — epic, story, bug, or spike — at docs/work/{work-id}/tdd.md, in skeleton or full mode. Pass a work item ID (CHK01, or a Linear/Jira/GitHub key like JIRA-123). Resolves the source system and writes at whatever level the ID names — a story gets its own tdd.md beside its parent epic's, not nested inside it. Cite solution.md — do not re-narrate architecture. Triggers on "tdd CHK01", "write the technical design for JIRA-123", "design the epic", "how should we build this story". For reviewing an existing tdd.md, use docs-review instead. Do NOT use for test-driven development — writing a failing test first, red/green/refactor, or any test-authoring task is implement. Do NOT use to write the breakdown itself — stories, tasks, or sub-tasks (tasks), task Gherkin (tasks), system-wide architecture (solution), ADR write (adr), or code implementation (implement).
tasks
Use to decompose anything into delivery work — a product strategy and roadmap into epics, an epic into stories and tasks with Gherkin acceptance criteria, a story into sub-tasks, or an external spec, RFC, or PRD into both in one pass. Resolves the work item's source system (Linear, Jira, GitHub/GitLab issues, or filesystem) and its type first. Writes docs/product/backlog.md and docs/work/{work-id}/tasks.md, or the tracker directly when one is resolved. Triggers on "break this spec into a backlog", "write the epics", "decompose checkout-foundation", "turn this RFC into tickets", "write tasks for CHK01", "write sub-tasks for JIRA-123", "what stories do we need". EARS with --ears. Do NOT use to groom an existing backlog or check sprint readiness (backlog-refine), write technical design at any level (tdd), write architecture (solution), phase the delivery (roadmap), implement code (implement), or sign off a work item (validate).