BMAD-METHOD/.agents/skills/bmad-code-review/steps/step-02-review.md

5.0 KiB

failed_layers

Step 2: Review

RULES

  • YOU MUST ALWAYS SPEAK OUTPUT in your Agent communication style with the config {communication_language}
  • The Blind Hunter subagent receives NO project context — diff only.
  • The Edge Case Hunter subagent receives diff and project read access.
  • The Acceptance Auditor subagent receives diff, spec, and context docs.
  • All review subagents must run at the same model capability as the current session.

INSTRUCTIONS

  1. If {review_mode} = "no-spec", note to the user: "Acceptance Auditor skipped — no spec file provided."

  2. Launch parallel subagents without conversation context. If subagents are not available, generate prompt files in {implementation_artifacts} — one per reviewer role below — and HALT. Ask the user to run each in a separate session (ideally a different LLM) and paste back the findings. When findings are pasted, resume from this point and proceed to step 3.

    • Blind Hunter — receives {diff_output} only. No spec, no context docs, no project access. Invoke via the bmad-review-adversarial-general skill.

    • Edge Case Hunter — receives {diff_output} and read access to the project. Invoke via the bmad-review-edge-case-hunter skill.

      • Acceptance Auditor (only if {review_mode} = "full") — receives {diff_output}, the content of the file at {spec_file}, and any loaded context docs. Its prompt:

        You are an Acceptance Auditor. Review this diff against the spec and context docs. Check for: violations of acceptance criteria, deviations from spec intent, missing implementation of specified behavior, contradictions between spec constraints and actual code.

        Quality Gate — Test Coverage Justification: Check whether the spec/story file or diff commentary includes a "Test Coverage Justification" section that maps impacted modules/nodes to specific test files. Apply these rules:

        • If {review_mode} = "full" (spec/story file is present) and the spec file lacks a Test Coverage Justification section → raise a decision_needed finding: "Missing Test Coverage Justification — blast radius report exists but no test mapping was provided."
        • If {review_mode} = "no-spec" (diff-only review) → check the diff commentary or commit messages for test coverage evidence. If absent, raise a patch finding: "Quality gate artifact missing — no Test Coverage Justification found in diff commentary or commit message."
        • If Test Coverage Justification exists but has any node listed with coverage status None or no coverage found → raise a separate decision_needed finding for each such node: "Uncovered impacted node: [node-name] — tests required before merge."
        • Reference any blast radius report embedded in the spec/story file to cross-validate the affected modules listed in the justification.
        • Fallback detection: If no section titled "Test Coverage Justification" is found, search for a markdown table with columns containing "Module", "Affected Symbols", "Test Files", and "Coverage". If such a table exists, treat it as meeting the quality gate regardless of section title.

        Quality Gate — Mathematical Gate Output: Check whether the spec/story file includes a "Mathematical Quality Gate Output" section (JSON output from qa-memtrace.mjs). Apply these rules:

        • If the spec file contains "Mathematical Quality Gate Output": use the uncovered_nodes from the script's JSON output as the ground truth for uncovered nodes — NOT the agent's textual claims in the justification table. Cross-validate: if the script found a node as uncovered but the justification table lists it as Yes coverage → raise a decision_needed finding per mismatch: "Coverage mismatch — agent claimed [node] is covered but mathematical gate shows it is not."
        • If the spec file contains a blast radius report AND a Test Coverage Justification BUT no "Mathematical Quality Gate Output": this is a Phase 1-level story using only textual justification. Flag as patch (not decision_needed): "Phase 1 story — consider upgrading to mathematical quality gate via qa-memtrace.mjs."
        • If the spec file contains only a blast radius report (no test justification, no mathematical gate): raise a decision_needed finding: "Missing both Test Coverage Justification and Mathematical Quality Gate Output — Phase 2 story must include qa-memtrace.mjs execution results."

        Output findings as a Markdown list. Each finding: one-line title, which quality gate rule it violates, and evidence from the diff/story file.

  3. Subagent failure handling: If any subagent fails, times out, or returns empty results, append the layer name to {failed_layers} (comma-separated) and proceed with findings from the remaining layers.

  4. Collect all findings from the completed layers.

NEXT

Read fully and follow ./step-03-triage.md