speckit-code-review
Deep line-by-line code review against the feature spec at specs/<feature-folder>/spec.md, produced by either speckit.specify (GitHub Spec Kit) or superpowers:brainstorming. Produces strict JSON pass/fail with business coverage, missing requirements, code issues, security issues, architecture issues, and unit test coverage. Triggers: "speckit code review", "review with spec", "compare code to spec.md", "spec coverage audit", "invoke speckit-code-review", "run speckit-code-review".
How do I install this agent skill?
npx skills add https://github.com/chuongxl/agents-skills --skill speckit-code-reviewIs this agent skill safe to install?
- Gen Agent Trust Hubpass
The skill is a code review framework that automates specification compliance checks. It is safe for use but carries a low risk of indirect prompt injection, as it processes untrusted project specifications and source code which could contain malicious instructions designed to manipulate the review process or influence the agent's behavior.
- Socketpass
No alerts
- Snykpass
Risk: LOW · No issues
What does this agent skill do?
Speckit Code Review
Compare implementation code to specs/<feature-folder>/spec.md and return a strict JSON verdict.
The spec may come from speckit.specify (usually already has FR-*/NFR-* IDs) or from
superpowers:brainstorming (narrative design doc, usually no IDs) — both are reviewed identically.
Always run inline. Never dispatch as a background task or sub-agent; the caller needs the JSON in-band.
Portability note: allowed-tools uses GitHub Copilot-style names (bash glob grep view create edit).
Claude Code and OpenCode expose the same capabilities under their own names (Bash, Read, Edit,
Write, Glob, Grep). Hermes Agent exposes them as terminal, read_file, patch,
write_file, search_files. The review procedure below is identical on all four hosts.
Inputs
spec.mdfor the target feature. If no path is given, resolve fromspecs/*/spec.mdusing the current branch name or changed files; ask the user only if still ambiguous.- Review scope = current git change set (staged + unstaged, incl. renames/deletes), evaluated in
the current working directory. Optional
base_refinput (a commit/ref, e.g. the merge-base with the base branch): when provided, scope = the union ofgit diff <base_ref>...HEADand the working-tree change set, so committed feature work is reviewed even when the tree is clean.speckit-autoalways passes this. When invoked fromspeckit-auto, the caller must run this skill inline from inside the Stage 01 linked worktree, never from the base checkout. - Submodule expansion (mandatory when
.gitmodulesexists): a top-levelgit diff/git statusonly ever shows a changed submodule as a single gitlink entry (mode160000), never the files changed inside it — reviewing that entry alone is reviewing nothing. Resolve every area's "git change set" as follows before any area review runs:- Compute the top-level change set as above. For every changed path that appears in
.gitmodules, that path is a submodule, not a regular file. - For each changed submodule path:
old_sha = git rev-parse <base_ref>:<path>(skip if the path didn't exist atbase_ref— treat every tracked file in the submodule as new),new_sha = git rev-parse HEAD:<path>. - Get its real file-level diff:
git -C <path> diff <old_sha> <new_sha>(committed range) uniongit -C <path> diffandgit -C <path> status --porcelain(uncommitted work inside the submodule). Prefix every resulting file path with<path>/so it composes with the rest of the scope. - Replace the gitlink entry in the change set with these expanded file paths. The change set every area below operates on is this expanded set, never the raw gitlink line.
- Log one line per expanded submodule:
[Code Review] Expanded submodule <path>: <old_sha>..<new_sha>, <n> file(s). Nested submodules (a submodule with its own.gitmodules) are out of scope — flag any found as aCODE-*finding recommending manual review instead of expanding recursively.
- Compute the top-level change set as above. For every changed path that appears in
Spec ID
<spec-id> drives all output paths. Derive it from the feature folder name — never invent one, so
reruns resolve to the same paths:
| Folder | <spec-id> | Rule |
|---|---|---|
010-user-login | 010 | leading numeric prefix |
ddm-6157-user-login | ddm-6157 | leading issue key (<letters>-<digits>) |
some-feature | some-feature | whole folder name |
Lowercase; strip any character outside [a-z0-9-].
Requirement Checklist
Step 1 must always yield a numbered checklist.
- IDs present → use verbatim; set
requirements_source: "declared". - No IDs → synthesize; set
requirements_source: "synthesized":- Extract one testable statement per requirement, in priority order: acceptance criteria, requirements/behaviour sections, user stories, explicit constraints, any must/should sentence.
- Classify
FR-(functional) vsNFR-(performance, reliability, security posture, scalability, maintainability, compliance, UX). - Number in document order so IDs stay stable across reruns.
- Record each as
{id, statement, spec_anchor}undersynthesized_requirementsin thebusiness-gapdetail file, so findings trace back to the spec.
If zero requirements are extractable, return failed with one FR-000 fix telling the user to add
testable requirements to the spec. Never return pass against an empty checklist.
Procedure
-
Build the requirement checklist (see above).
-
Resolve the git change set as review scope (union with
git diff <base_ref>...HEADwhen abase_refwas passed), applying the Submodule Expansion rules above when.gitmodulesexists. This expanded set is what every area below means by "the git change set" — no area re-derives it independently. -
Project guidelines (conditional) — if
docs/guidelines/architecture.mdexists, load references/project-guidelines-review.md and follow its Steps 1–4 to load only the guideline files matching the changed-file categories. Skip silently if that file is absent. -
Run each standard area — load its reference file, run the review, then discard it from context before loading the next:
Area Reference Issue IDs Business Gap business-gap.md FR-*,NFR-*Code Quality (incl. conditional SonarQube MCP scan) code-quality.md CODE-*Security security.md SEC-*Architecture architecture.md ARCH-*Unit Test Coverage (last) unit-test-coverage.md TEST-* -
If guideline files were loaded in step 3, run the advanced pass (Step 5 of project-guidelines-review.md) and merge its findings into the standard results, tagging each with
guideline_source. -
Business cover = round(covered / total * 100). -
Write
state_file, plus one detail file per category that has issues. Skip empty categories; onpasswrite onlystate_file. -
Build
fixesfrom all blocking findings ordered high → medium → low severity, then keep only the top 3 inline. Every finding is blocking except aTEST-*advisory gap (see unit-test-coverage.md Step 4): those are recorded inunit-tests.jsonfor visibility only and never enterfixesor count toward step 9. The rest of the blocking findings live instate_fileand the category detail files. -
status=passonly if the blocking-finding count is zero and coverage ≥ 80% (orN/A) and the checklist is non-empty; otherwisefailed.fixesreflects the same blocking set, sofixesempty and blocking-finding count zero always agree.
Output Contract
Return exactly one compact JSON object, ≤ 400 tokens, no markdown, no prose outside the JSON. Field names are literal (keep spaces and capitalization). Never mirror verbose findings inline — they already live in the files.
| Field | Value |
|---|---|
status | "pass" or "failed" |
Business cover | percent string, "0%"–"100%" |
unit-test-coverage | percent string, or "N/A (no test runner detected)" — N/A counts as passing |
state_file | .speckit/review-<spec-id>-<ts>/state.json — ordered issue inventory + next fix queue, so speckit-auto can resume without reloading findings |
detail_files | map of category → path; {} on pass. Keys: business-gap, architecture, security, code-quality, unit-tests, each at .speckit/review-<spec-id>-<ts>/<key>.json |
fixes | [] on pass; else ≤ 3 objects with exactly id, file, method, lines, action |
fixes entry fields:
id— prefix selects the detail file:FR-*/NFR-*→ business-gap,ARCH-*→ architecture,SEC-*→ security,CODE-*→ code-quality,TEST-*→ unit-testsfile— relative path ·method—Class::methodor function namelines— range like"88-140", or"new"when the file/method must be createdaction— one imperative sentence, no sub-bullets, specific enough to act on without opening the detail file
{
"status": "failed",
"Business cover": "70%",
"unit-test-coverage": "61.2%",
"state_file": ".speckit/review-010-1722348000/state.json",
"detail_files": {
"business-gap": ".speckit/review-010-1722348000/business-gap.json",
"security": ".speckit/review-010-1722348000/security.json",
"unit-tests": ".speckit/review-010-1722348000/unit-tests.json"
},
"fixes": [
{"id": "FR-004", "file": "src/account/service.ts", "method": "AccountService::createAccount", "lines": "88-140", "action": "Add password minimum-length validation (>=8 chars) before calling hashPassword"},
{"id": "SEC-001", "file": "src/auth/password.ts", "method": "validatePassword", "lines": "5-20", "action": "Enforce min 12 chars, 1 uppercase, 1 digit, 1 symbol in password policy"},
{"id": "TEST-001", "file": "src/account/service.spec.ts", "method": "AccountService::createAccount", "lines": "new", "action": "Add test: password shorter than 8 chars throws ValidationException"}
]
}
A passing result is the same shape with "status": "pass", detail_files: {}, fixes: [].
Quality Bar
- Never report
passwhile a blocking finding exists (fixesnon-empty), coverage < 80%, or the checklist is empty. ATEST-*advisory gap (unit-test-coverage.md Step 4, coverage already ≥ 80%) is not a blocking finding and never fails a pass on its own. - Keep verbose analysis in the category files; the inline object stays under 400 tokens.
- Severity scale for every area:
high= exploitable or breaks a requirement/invariant;medium= degrades correctness, security posture, or maintainability;low= cosmetic or non-exploitable.
How can the creator link this skill?
Add the canonical catalog link to the repository README so users can inspect current installs and available audits. The publishing guide covers the complete discovery path.
<a href="https://skillzs.dev/skills/chuongxl/agents-skills/speckit-code-review">View speckit-code-review on skillZs</a>