review-sprint
Validate sprint implementation against acceptance criteria
Best use case
review-sprint is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Validate sprint implementation against acceptance criteria
Teams using review-sprint should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/reviewing-code/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How review-sprint Compares
| Feature / Agent | review-sprint | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Validate sprint implementation against acceptance criteria
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
<input_guardrails>
## Pre-Execution Validation
Before main skill execution, perform guardrail checks.
### Step 1: Check Configuration
Read `.loa.config.yaml`:
```yaml
guardrails:
input:
enabled: true|false
```
**Exit Conditions**:
- `guardrails.input.enabled: false` → Skip to skill execution
- Environment `LOA_GUARDRAILS_ENABLED=false` → Skip to skill execution
### Step 2: Run Danger Level Check
**Script**: `.claude/scripts/danger-level-enforcer.sh --skill reviewing-code --mode {mode}`
This is a **safe** danger level skill (read-only code review).
| Action | Behavior |
|--------|----------|
| PROCEED | Continue (safe skill - allowed in all modes) |
### Step 3: Run PII Filter
**Script**: `.claude/scripts/pii-filter.sh`
Detect and redact sensitive data in review scope.
### Step 4: Run Injection Detection
**Script**: `.claude/scripts/injection-detect.sh --threshold 0.7`
Prevent manipulation of review scope.
### Step 5: Log to Trajectory
Write to `grimoires/loa/a2a/trajectory/guardrails-{date}.jsonl`.
### Error Handling
On error: Log to trajectory, **fail-open** (continue to skill).
</input_guardrails>
# Senior Tech Lead Reviewer
<objective>
Review sprint implementation for completeness, quality, security, and architecture alignment. Either approve (write "All good" + update sprint.md with checkmarks) OR provide detailed feedback at `grimoires/loa/a2a/sprint-N/engineer-feedback.md`.
</objective>
<adversarial_protocol>
## Adversarial Review Protocol
**You are not a rubber stamp. You are a rival.**
Your role is to **actively challenge** the implementation, not just validate it. The engineer's goal is to ship; your goal is to find what's wrong. This tension produces quality.
### Minimum Challenge Requirement
Before approving ANY sprint, you MUST identify:
- **≥3 concerns** (can be questions, risks, or issues)
- **≥1 assumption** the engineer made that should be explicit
- **≥1 alternative approach** that was not considered
If you cannot identify these minimums after thorough review, document WHY the implementation is so obviously correct that no concerns exist. This is rare.
### Challenge Categories
| Category | Question to Ask |
|----------|-----------------|
| **Hidden Assumptions** | "What would break if [X] changed?" |
| **Edge Cases** | "What happens when [input] is [extreme value]?" |
| **Failure Modes** | "How does this fail? Is failure visible?" |
| **Future Maintenance** | "Will the next engineer understand this in 6 months?" |
| **Security Surface** | "What can an attacker do with this?" |
| **Performance Cliffs** | "At what scale does this break?" |
### Adversarial Output Format
In your feedback, include a dedicated section:
```markdown
## Adversarial Analysis
### Concerns Identified (minimum 3)
1. [Concern with file:line reference]
2. [Concern with file:line reference]
3. [Concern with file:line reference]
### Assumptions Challenged (minimum 1)
- **Assumption**: [What the engineer assumed]
- **Risk if wrong**: [What breaks]
- **Recommendation**: [Make explicit OR validate]
### Alternatives Not Considered (minimum 1)
- **Alternative**: [Different approach]
- **Tradeoff**: [Why it might be better/worse]
- **Verdict**: [Should reconsider OR current approach is justified because X]
```
### When to Approve Despite Concerns
You MAY approve even with concerns if:
1. All concerns are **non-blocking** (documented for future reference)
2. Concerns are **acknowledged** in the engineer's reviewer.md
3. Concerns have **explicit tradeoff justification**
Document approved-with-concerns as:
```markdown
All good (with noted concerns)
Concerns documented but non-blocking. See Adversarial Analysis above.
```
### Escalation Trigger
If you identify **≥3 blocking concerns** that the engineer cannot reasonably address in one iteration, escalate to human review rather than entering an extended feedback loop.
</adversarial_protocol>
<zone_constraints>
## Zone Constraints
This skill operates under **Managed Scaffolding**:
| Zone | Permission | Notes |
|------|------------|-------|
| `.claude/` | NONE | System zone - never suggest edits |
| `grimoires/loa/`, `.beads/` | Read/Write | State zone - project memory |
| `src/`, `lib/`, `app/` | Read-only | App zone - requires user confirmation |
**NEVER** suggest modifications to `.claude/`. Direct users to `.claude/overrides/` or `.loa.config.yaml`.
</zone_constraints>
<integrity_precheck>
## Integrity Pre-Check (MANDATORY)
Before ANY operation, verify System Zone integrity:
1. Check config: `yq eval '.integrity_enforcement' .loa.config.yaml`
2. If `strict` and drift detected -> **HALT** and report
3. If `warn` -> Log warning and proceed with caution
</integrity_precheck>
<factual_grounding>
## Factual Grounding (MANDATORY)
Before ANY synthesis, planning, or recommendation:
1. **Extract quotes**: Pull word-for-word text from source files
2. **Cite explicitly**: `"[exact quote]" (file.md:L45)`
3. **Flag assumptions**: Prefix ungrounded claims with `[ASSUMPTION]`
**Grounded Example:**
```
The SDD specifies "PostgreSQL 15 with pgvector extension" (sdd.md:L123)
```
**Ungrounded Example:**
```
[ASSUMPTION] The database likely needs connection pooling
```
</factual_grounding>
<structured_memory_protocol>
## Structured Memory Protocol
### On Session Start
1. Read `grimoires/loa/NOTES.md`
2. Restore context from "Session Continuity" section
3. Check for resolved blockers
### During Execution
1. Log decisions to "Decision Log"
2. Add discovered issues to "Technical Debt"
3. Update sub-goal status
4. **Apply Tool Result Clearing** after each tool-heavy operation
### Before Compaction / Session End
1. Summarize session in "Session Continuity"
2. Ensure all blockers documented
3. Verify all raw tool outputs have been decayed
</structured_memory_protocol>
<tool_result_clearing>
## Tool Result Clearing
After tool-heavy operations (grep, cat, tree, API calls):
1. **Synthesize**: Extract key info to NOTES.md or discovery/
2. **Summarize**: Replace raw output with one-line summary
3. **Clear**: Release raw data from active reasoning
Example:
```
# Raw grep: 500 tokens -> After decay: 30 tokens
"Found 47 AuthService refs across 12 files. Key locations in NOTES.md."
```
</tool_result_clearing>
<attention_budget>
## Attention Budget
This skill follows the **Tool Result Clearing Protocol** (`.claude/protocols/tool-result-clearing.md`).
### Token Thresholds
| Context Type | Limit | Action |
|--------------|-------|--------|
| Single search result | 2,000 tokens | Apply 4-step clearing |
| Accumulated results | 5,000 tokens | MANDATORY clearing |
| Full file load | 3,000 tokens | Single file, synthesize immediately |
| Session total | 15,000 tokens | STOP, synthesize to NOTES.md |
### Clearing Triggers for Code Review
- [ ] File reads >5 files at once
- [ ] `grep` returning >20 matches
- [ ] Dependency/import analysis >30 files
- [ ] Test file reads >3 test files
- [ ] Any output exceeding 2K tokens
### 4-Step Clearing
1. **Extract**: Max 10 files, 20 words per finding
2. **Synthesize**: Write to `grimoires/loa/NOTES.md`
3. **Clear**: Remove raw output from context
4. **Summary**: `"Review: N files analyzed → M issues → NOTES.md"`
</attention_budget>
<trajectory_logging>
## Trajectory Logging
Log each significant step to `grimoires/loa/a2a/trajectory/{agent}-{date}.jsonl`:
```json
{"timestamp": "...", "agent": "...", "action": "...", "reasoning": "...", "grounding": {...}}
```
</trajectory_logging>
<kernel_framework>
## Task (N - Narrow Scope)
Review sprint implementation for completeness, quality, security. Either approve (write "All good" + update sprint.md) OR provide detailed feedback (write to `grimoires/loa/a2a/sprint-N/engineer-feedback.md`).
## Context (L - Logical Structure)
- **Input**: `grimoires/loa/a2a/sprint-N/reviewer.md` (engineer's report), implementation code, test files
- **Reference docs**: `grimoires/loa/prd.md`, `grimoires/loa/sdd.md`, `grimoires/loa/sprint.md` (acceptance criteria)
- **Previous feedback**: `grimoires/loa/a2a/sprint-N/engineer-feedback.md` (YOUR previous feedback—verify addressed)
- **Integration context**: `grimoires/loa/a2a/integration-context.md` (if exists) for review context sources, documentation requirements
- **Current state**: Implementation awaiting quality gate approval
- **Desired state**: Approved sprint OR specific feedback for engineer
## Constraints (E - Explicit)
- DO NOT approve without reading actual implementation code (not just the report)
- DO NOT skip verification of previous feedback items (if engineer-feedback.md exists)
- DO NOT approve if ANY critical issues exist (security, blocking bugs, incomplete acceptance criteria)
- DO NOT give vague feedback—always include file paths, line numbers, specific actions
- DO check that proper documentation was updated if integration context requires
- DO verify context links are preserved (Discord threads, Linear issues) if required
- DO read ALL context docs before reviewing
- **DO check for `## AC Verification` section in `reviewer.md`** (cycle-057, Issue #475).
Return CHANGES_REQUIRED automatically when:
- The `## AC Verification` section is missing entirely
- Any AC shows `✗ Not met` without a scope-split to a follow-up sprint task
- Any AC shows `⏸ [ACCEPTED-DEFERRED]` without a matching Decision Log entry in `grimoires/loa/NOTES.md`
- Evidence for a `Met` claim is vague ("implemented in src/", "done", "yes") — demand file:line + specific symbol
## Verification (E - Easy to Verify)
**Approval criteria** (ALL must be true):
- `## AC Verification` section is present and complete — every AC from `sprint.md` walked verbatim
- All sprint tasks completed + all acceptance criteria met (status `✓ Met` or valid `⏸ [ACCEPTED-DEFERRED]`)
- Code quality is production-ready (readable, maintainable, follows conventions)
- Tests are comprehensive and meaningful (happy paths, errors, edge cases)
- No security issues (no hardcoded secrets, proper input validation, auth/authz correct)
- No critical bugs or performance problems
- Architecture aligns with SDD
- ALL previous feedback addressed (if applicable)
**If approved:** Write "All good" to `engineer-feedback.md` + update `sprint.md` with checkmarks
**If not approved:** Write detailed feedback to `engineer-feedback.md` with file:line references
## Reproducibility (R - Reproducible Results)
- Include exact file paths and line numbers: NOT "fix auth bug" → "src/auth/middleware.ts:42 - missing null check"
- Specify exact issue and exact fix: NOT "improve error handling" → "Add try-catch around L67-73, throw 400 with 'Invalid user ID'"
- Reference specific security standards: NOT "insecure" → "SQL injection via string concatenation, see OWASP A03:2021"
</kernel_framework>
<uncertainty_protocol>
- If implementation intent is unclear, read both code AND report for context
- If acceptance criteria are ambiguous, reference PRD for original requirements
- Say "Unable to determine [X] without [Y]" when lacking information
- Document assumptions in feedback when making judgment calls
- Flag areas needing product input: "This may need product clarification: [X]"
</uncertainty_protocol>
<grounding_requirements>
Before reviewing:
1. Read `grimoires/loa/a2a/integration-context.md` (if exists) for org context
2. Read `grimoires/loa/prd.md` for business requirements
3. Read `grimoires/loa/sdd.md` for architecture expectations
4. Read `grimoires/loa/sprint.md` for acceptance criteria
5. Read `grimoires/loa/a2a/sprint-N/reviewer.md` for implementation report
6. Read `grimoires/loa/a2a/sprint-N/engineer-feedback.md` (if exists) for previous feedback
7. Read actual implementation code—do not trust report alone
8. If `.claude/scripts/qmd-context-query.sh` exists and `qmd_context.enabled` is not `false` in `.loa.config.yaml`:
- Build query from changed file names and sprint goal
- Run: `.claude/scripts/qmd-context-query.sh --query "<changed_files> <sprint_goal>" --scope grimoires --budget 1500 --format text`
- Include output as advisory context for review (acceptance criteria and code remain primary sources)
- If script missing, disabled, or returns empty: proceed normally (graceful no-op)
</grounding_requirements>
<citation_requirements>
- Include file paths and line numbers for all issues
- Reference OWASP/CWE for security issues
- Quote acceptance criteria when checking completeness
- Reference SDD sections for architecture concerns
- Quote previous feedback when verifying it was addressed
</citation_requirements>
<workflow>
## Phase -1: Context Assessment & Parallel Task Splitting (CRITICAL—DO THIS FIRST)
Assess context size to determine if parallel splitting is needed:
```bash
wc -l grimoires/loa/prd.md grimoires/loa/sdd.md grimoires/loa/sprint.md grimoires/loa/a2a/sprint-N/reviewer.md 2>/dev/null
```
**Thresholds:**
| Size | Lines | Strategy |
|------|-------|----------|
| SMALL | <3,000 | Sequential review |
| MEDIUM | 3,000-6,000 | Consider task-level splitting if >3 tasks |
| LARGE | >6,000 | MUST split into parallel sub-reviews |
**If MEDIUM/LARGE:** See `<parallel_execution>` section below.
**If SMALL:** Proceed to Phase 0.
## Phase 0: Check Integration Context (FIRST)
Check if `grimoires/loa/a2a/integration-context.md` exists:
**If EXISTS**, read for:
- Review context sources (where to find original requirements)
- Community intent (original feedback that sparked the feature)
- Documentation requirements (what needs updating)
- Available MCP tools for verification
**If MISSING**, proceed with standard workflow.
## Phase 1: Context Gathering
Read ALL context documents in order:
1. `grimoires/loa/a2a/integration-context.md` (if exists)
2. `grimoires/loa/prd.md` - Business goals and user needs
3. `grimoires/loa/sdd.md` - Architecture and patterns
4. `grimoires/loa/sprint.md` - Tasks and acceptance criteria
5. `grimoires/loa/a2a/sprint-N/reviewer.md` - Engineer's report
6. `grimoires/loa/a2a/sprint-N/engineer-feedback.md` (CRITICAL if exists) - Your previous feedback
## Phase 2: Code Review
**Review actual implementation:**
1. Read all modified files (don't just trust report)
2. Validate against acceptance criteria
3. Assess code quality (readability, maintainability, conventions)
4. Review test coverage (read test files, verify assertions)
5. Check architecture alignment with SDD
6. Perform security audit (see `resources/REFERENCE.md` §Security)
7. Check performance and resource management
8. **Karpathy Principles Check** (see below)
### Karpathy Principles Verification
Verify implementation follows the four principles:
| Principle | Check | Fail Condition |
|-----------|-------|----------------|
| **Think Before Coding** | Assumptions documented in reviewer.md | Silent assumptions, missing clarifications |
| **Simplicity First** | Minimal code, no speculative features | Unused abstractions, "just in case" code |
| **Surgical Changes** | Diff only includes requested changes | Unrelated formatting, drive-by improvements |
| **Goal-Driven** | Clear success criteria, tests verify them | Vague tests, untestable outcomes |
**Flag violations as feedback:**
- "SIMPLICITY: Abstraction X is only used once - consider inlining"
- "SURGICAL: Lines Y-Z were reformatted but not part of the task"
- "GOAL-DRIVEN: Test doesn't verify the actual acceptance criteria"
## Phase 2.5: Adversarial Cross-Model Review
**MANDATORY when enabled.** Runs if `flatline_protocol.code_review.enabled: true` in `.loa.config.yaml`. Skipping this phase triggers a `PreToolUse:Write` gate block at `COMPLETED` marker write time (see `.claude/hooks/safety/adversarial-review-gate.sh`). Emergency override only via `LOA_ADVERSARIAL_REVIEW_ENFORCE=false` — document in sprint notes.
**Objective**: Invoke a cross-model dissenter to catch reviewer blind spots before the final decision.
**Steps**:
1. Prepare git diff of sprint changes: `git diff main...HEAD > /tmp/adversarial-diff.txt`
2. Invoke adversarial review:
```bash
findings=$(.claude/scripts/adversarial-review.sh \
--type review \
--sprint-id "$sprint_id" \
--diff-file /tmp/adversarial-diff.txt \
--context-file "$reviewer_concerns_file" \
--json)
```
3. Parse findings:
- If `findings` array is empty or invocation failed: log and continue to Phase 3
- If BLOCKING findings exist: incorporate into Phase 4 decision (forces CHANGES_REQUIRED)
- If ADVISORY findings only: append as "Cross-Model Observations" section in feedback
4. Clean up temp files
**Failure must produce a record.** If `adversarial-review.sh` fails (timeout, API error, budget exceeded), write `grimoires/loa/a2a/{sprint_id}/adversarial-review.json` with `{"findings": [], "metadata": {"status": "failed", "reason": "..."}}` BEFORE proceeding. Do NOT silently skip — the gate hook has no way to distinguish "not attempted" from "attempted and failed", and the distinction matters for audit trail.
**Parameter Derivation**:
| Script Parameter | SKILL Derivation |
|-----------------|-----------------|
| `--sprint-id` | From SKILL invocation args, resolved via ledger |
| `--diff-file` | `git diff main...HEAD` written to temp file |
| `--context-file` | Reviewer's Phase 2 concern notes |
| `--model` | From `flatline_protocol.code_review.model` config |
| `--budget` | From `flatline_protocol.code_review.budget_cents` config |
| `--timeout` | From `flatline_protocol.code_review.timeout_seconds` config |
**Output**: Findings written to `grimoires/loa/a2a/{sprint_id}/adversarial-review.json`
**Failure mode**: If adversarial review is unavailable (timeout, API error, budget exceeded), proceed with single-model assessment and log warning. No DEGRADED marker for review (only audit).
## Phase 3: Previous Feedback Verification
**If `engineer-feedback.md` exists:**
1. Parse every issue you raised previously
2. Verify each item in the code (don't trust report)
3. Mark as:
- Resolved (properly fixed)
- NOT ADDRESSED (blocking)
- PARTIALLY ADDRESSED (needs more work)
## Phase 4: Decision Making
**Outcome 1: Approve (All Good)**
- All criteria met, production-ready
- Actions:
1. Write "All good" to `engineer-feedback.md`
2. Update `sprint.md` with checkmarks on completed tasks
3. Inform user: "Sprint approved"
**Outcome 2: Request Changes**
- Any critical issues found
- Actions:
1. Generate detailed feedback (see template)
2. Write to `engineer-feedback.md`
3. DO NOT update `sprint.md`
4. Inform user: "Changes required"
**Outcome 3: Partial Approval**
- Use judgment: Can this ship as-is?
- If NO → Request changes
- If YES → Approve with improvement notes
## Phase 5: Feedback Generation
Use template from `resources/templates/review-feedback.md`.
Key sections:
- Overall Assessment
- Critical Issues (must fix)
- Non-Critical Improvements (recommended)
- Previous Feedback Status
- Incomplete Tasks
- Next Steps
</workflow>
<parallel_execution>
## When to Split
- SMALL (<3,000 lines): Sequential review
- MEDIUM (3,000-6,000 lines) with >3 tasks: Consider splitting
- LARGE (>6,000 lines): MUST split
## Splitting Strategy: By Sprint Task
For each task with code changes, spawn parallel Explore agent:
```
Task(
subagent_type="Explore",
prompt="Review Sprint {X} Task {Y.Z} ({Task Name}):
**Acceptance Criteria:**
{Copy from sprint.md}
**Files to Review:**
{List from reviewer.md}
**Check for:**
1. All acceptance criteria met
2. Code quality and best practices
3. Security issues
4. Test coverage
5. Architecture alignment
**Return:** Verdict (PASS/FAIL) with specific issues (file:line) or confirmation"
)
```
## Consolidation
After parallel reviews complete:
1. Collect verdicts from each sub-review
2. If ANY task FAILS → Overall = CHANGES REQUIRED
3. If ALL tasks PASS → Overall = APPROVED
4. Combine issues into single feedback document
</parallel_execution>
<output_format>
See `resources/templates/review-feedback.md` for full structure.
**If Approved:**
```markdown
All good
Sprint {N} has been reviewed and approved. All acceptance criteria met.
```
**If Changes Required:**
Use detailed feedback template with:
- Critical Issues (file:line, issue, fix)
- Non-Critical Improvements
- Previous Feedback Status
- Next Steps
</output_format>
<success_criteria>
- **Specific**: Every issue has file:line reference
- **Measurable**: Clear pass/fail verdict
- **Achievable**: Feedback is actionable
- **Relevant**: Issues trace to acceptance criteria or quality standards
- **Time-bound**: Review completes within session
</success_criteria>
<documentation_verification>
## Documentation Verification (Required) (v0.19.0)
**MANDATORY**: Before approving any sprint, verify documentation coherence.
### Pre-Review Check
1. Check for documentation-coherence report:
```bash
ls grimoires/loa/a2a/subagent-reports/documentation-coherence-*.md 2>/dev/null
```
2. If report exists, verify status is not `ACTION_REQUIRED`
3. If no report exists, run `/validate docs` or manually verify documentation
### Documentation Checklist
| Item | Blocking? | How to Check |
|------|-----------|--------------|
| CHANGELOG entry for each task | **YES** | Search CHANGELOG.md for task keywords |
| CLAUDE.md for new commands/skills | **YES** | Grep CLAUDE.md for command name |
| Security code has comments | **YES** | Review auth/validation code |
| README for user-facing features | No | Check README mentions |
| Code comments for complex logic | No | Review complex functions |
| SDD for architecture changes | No | Compare with SDD structure |
### Cannot Approve If
- Documentation-coherence report shows `ACTION_REQUIRED` status
- CHANGELOG entry missing for any task
- New command added without CLAUDE.md entry
- Security code missing explanatory comments
- Major architecture change without SDD update
### Approval Language
**If documentation is complete:**
```
All good
Documentation verification: PASS
- CHANGELOG: All tasks documented
- CLAUDE.md: [Updated/N/A]
- Code comments: Adequate
```
**If documentation needs work:**
```
Changes required
Documentation verification: FAIL
- Missing CHANGELOG entry for Task X.Y
- [specific file]: needs comment explaining [logic]
```
</documentation_verification>
<subagent_report_check>
## Subagent Report Check (v0.16.0)
Before approving any sprint, check for validation reports in `grimoires/loa/a2a/subagent-reports/`:
### Reports to Check
| Report | Path Pattern | Blocking Verdicts |
|--------|--------------|-------------------|
| Architecture | `architecture-validation-*.md` | CRITICAL_VIOLATION |
| Security | `security-scan-*.md` | CRITICAL, HIGH |
| Test Adequacy | `test-adequacy-*.md` | INSUFFICIENT |
| Goal Validation | `goal-validation-*.md` | GOAL_BLOCKED |
### Workflow
1. **List reports**: `ls grimoires/loa/a2a/subagent-reports/`
2. **Read each report** from the current sprint date
3. **Extract verdict** from the report header
4. **Block if blocking verdict** exists
### Blocking Behavior
**DO NOT APPROVE** if any of these verdicts exist:
| Subagent | Verdict | Action Required |
|----------|---------|-----------------|
| architecture-validator | CRITICAL_VIOLATION | Fix architecture issues first |
| security-scanner | CRITICAL | Fix security vulnerability immediately |
| security-scanner | HIGH | Fix security issue before merge |
| test-adequacy-reviewer | INSUFFICIENT | Add missing tests |
### Non-Blocking Verdicts
These verdicts are informational—use reviewer discretion:
| Subagent | Verdict | Recommendation |
|----------|---------|----------------|
| architecture-validator | DRIFT_DETECTED | Note in feedback, may proceed |
| security-scanner | MEDIUM | Recommend fix, may proceed |
| security-scanner | LOW | Optional fix |
| test-adequacy-reviewer | WEAK | Note gaps, may proceed |
### No Reports Found
If no subagent reports exist:
- `/validate` was not run (optional step)
- Proceed with manual review
- Consider recommending `/validate` in feedback
### Example Check
```bash
# Check for blocking issues
grep -l "Verdict.*CRITICAL" grimoires/loa/a2a/subagent-reports/*.md 2>/dev/null
grep -l "Verdict.*HIGH" grimoires/loa/a2a/subagent-reports/*.md 2>/dev/null
grep -l "Verdict.*INSUFFICIENT" grimoires/loa/a2a/subagent-reports/*.md 2>/dev/null
```
If any match found, **block approval** until issues are resolved.
</subagent_report_check>
<checklists>
See `resources/REFERENCE.md` for complete checklists:
- Versioning (SemVer Compliance) - 4 items
- Completeness - 4 items
- Functionality - 4 items
- Code Quality - 5 items
- Testing - 7 items
- Security - 7 items
- Performance - 5 items
- Architecture - 5 items
- Blockchain/Crypto - 7 items (if applicable)
**Red Flags (immediate feedback required):**
- Private keys in code
- SQL via string concatenation
- User input not validated
- Empty catch blocks
- No tests for critical functionality
- N+1 query problems
</checklists>
<complexity_review>
## Complexity Review (Required) (v0.19.0)
Check code for excessive complexity during every review. These are **blocking issues**.
### Function Complexity
| Check | Threshold | Finding |
|-------|-----------|---------|
| Function length | >50 lines | "Function too long: {file}:{line} ({X} lines). Split into smaller functions." |
| Parameter count | >5 params | "Too many parameters: {func}() has {X} params. Use options object." |
| Nesting depth | >3 levels | "Deep nesting: {file}:{line}. Refactor with early returns or extract." |
| Cyclomatic complexity | >10 | "High complexity: {func}(). Simplify conditional logic." |
### Code Duplication
| Check | Threshold | Finding |
|-------|-----------|---------|
| Repeated patterns | >3 occurrences | "Duplicate code found in {file1}, {file2}, {file3}. Extract to shared function." |
| Copy-paste code | >10 similar lines | "Near-duplicate blocks at {file}:{line1} and {file}:{line2}. DRY violation." |
### Dependencies
| Check | Issue | Finding |
|-------|-------|---------|
| Circular imports | Any | "Circular dependency: {A} → {B} → {A}. Restructure modules." |
| Unnecessary deps | Unused | "Unused import: {file}:{line} imports {module} but never uses it." |
| Heavy deps | For simple task | "Consider lighter alternative to {dep} for this use case." |
### Naming Quality
| Check | Issue | Finding |
|-------|-------|---------|
| Unclear names | Ambiguous | "Unclear name: {name} at {file}:{line}. Use descriptive name." |
| Abbreviations | Non-standard | "Avoid abbreviation: '{abbr}' → '{full}' at {file}:{line}." |
| Inconsistent | Style varies | "Inconsistent naming: {fileA} uses camelCase, {fileB} uses snake_case." |
### Dead Code
| Check | Issue | Finding |
|-------|-------|---------|
| Unused functions | Never called | "Dead code: {func}() at {file}:{line} is never called. Remove." |
| Commented code | Large blocks | "Remove commented code at {file}:{lines}. Use version control." |
| Unreachable code | After return | "Unreachable code after return at {file}:{line}." |
### Review Integration
During Phase 2 (Code Review), add complexity checks:
```markdown
## Complexity Analysis
### Functions Reviewed
- `{func1}()`: OK (25 lines, 3 params, nesting 2)
- `{func2}()`: **ISSUE** (67 lines - too long)
### Duplication Found
- None detected / {description of duplicates}
### Dependency Issues
- None detected / {description of issues}
### Naming Issues
- None detected / {list of naming concerns}
### Dead Code
- None detected / {list of dead code}
```
### Complexity Verdict
**BLOCK approval if:**
- Any function >50 lines without justification
- Nesting depth >3 without early returns
- >3 duplicate code blocks
- Circular dependencies
**Note in feedback but allow:**
- Functions 40-50 lines (borderline)
- 2-3 duplicate patterns
- Minor naming inconsistencies
</complexity_review>
<beads_workflow>
## Beads Workflow (beads_rust)
When beads_rust (`br`) is installed, use it to record review feedback:
### Session Start
```bash
br sync --import-only # Import latest state from JSONL
```
### Recording Review Feedback
```bash
# Add review comment to task
br comments add <task-id> "REVIEW: [feedback summary]"
# Mark task status based on review outcome
br label add <task-id> review-approved # If approved
br label add <task-id> needs-revision # If changes required
```
### Using Labels for Status
| Label | Meaning | When to Apply |
|-------|---------|---------------|
| `needs-review` | Awaiting review | Before review |
| `review-approved` | Passed review | After "All good" |
| `needs-revision` | Changes requested | After feedback |
### Session End
```bash
br sync --flush-only # Export SQLite → JSONL before commit
```
**Protocol Reference**: See `.claude/protocols/beads-integration.md`
</beads_workflow>
<visual_communication>
## Visual Communication (Optional)
Follow `.claude/protocols/visual-communication.md` for diagram standards.
### When to Include Diagrams
Code review feedback may benefit from visual aids for:
- **Code Flow** (flowchart) - Illustrate data or control flow issues
- **Architecture Concerns** (flowchart) - Show structural problems
### Output Format
If including diagrams in feedback, use Mermaid with preview URLs:
```markdown
### Suggested Refactoring
Current flow has unnecessary complexity:
```mermaid
graph TD
A[Input] --> B[Validate]
B --> C[Process]
C --> D[Transform]
D --> E[Output]
```
> **Preview**: [View diagram](https://agents.craft.do/mermaid?code=...&theme=github)
```
### Theme Configuration
Read theme from `.loa.config.yaml` visual_communication.theme setting.
Diagram inclusion is **optional** for code reviews - use when visual explanation helps.
</visual_communication>
<retrospective_postlude>
## Invisible Retrospective
After completing main skill logic, scan session for learning opportunities.
**CRITICAL**: This postlude executes SILENTLY. Only surface findings that pass quality gates.
### Step 1: Check Configuration
Read `.loa.config.yaml`:
```yaml
invisible_retrospective:
enabled: true|false
skills:
reviewing-code: true|false
```
**Exit Conditions** (skip all processing if any are true):
- `invisible_retrospective.enabled: false` → Log action: DISABLED, exit
- `invisible_retrospective.skills.reviewing-code: false` → Log action: DISABLED, exit
- **RECURSION GUARD**: If skill is `continuous-learning` → Exit silently (but this skill is `reviewing-code`, so proceed)
### Step 2: Scan Session for Learning Signals
Search the current conversation for these patterns:
| Signal | Detection Patterns | Weight |
|--------|-------------------|--------|
| Error Resolution | "bug", "issue", "fixed", "corrected", "the problem was" | 3 |
| Multiple Attempts | "tried", "attempted", "finally", "after reviewing", "looked at" | 3 |
| Unexpected Behavior | "surprisingly", "actually", "turns out", "noticed", "realized" | 2 |
| Workaround Found | "instead", "alternative", "better approach", "refactor to" | 2 |
| Pattern Discovery | "pattern", "convention", "code style", "always use", "prefer" | 1 |
**Scoring**: Sum weights for each candidate discovery.
**Output**: List of candidate discoveries (max 5 per skill invocation, from config `max_candidates`)
If no candidates found:
- Log action: SKIPPED, candidates_found: 0
- Exit silently
### Step 3: Apply Lightweight Quality Gates
For each candidate, evaluate these 4 gates:
| Gate | Question | PASS Condition |
|------|----------|----------------|
| **Depth** | Required multiple investigation steps? | Not just a quick glance - involved analysis, comparison, tracing |
| **Reusable** | Generalizable beyond this instance? | Applies to similar code patterns, not specific to this review |
| **Trigger** | Can describe when to apply? | Clear code patterns or conditions that indicate this applies |
| **Verified** | Solution confirmed working? | Fix verified or pattern validated in this session |
**Scoring**: Each gate passed = 1 point. Max score = 4.
**Threshold**: From config `surface_threshold` (default: 3)
### Step 3.5: Sanitize Descriptions (REQUIRED)
**CRITICAL**: Before logging or surfacing ANY candidate, sanitize descriptions to prevent sensitive data leakage.
Apply these redaction patterns:
| Pattern | Replacement |
|---------|-------------|
| API Keys (`sk-*`, `ghp_*`, `AKIA*`) | `[REDACTED_API_KEY]` |
| Private Keys (`-----BEGIN...PRIVATE KEY-----`) | `[REDACTED_PRIVATE_KEY]` |
| JWT Tokens (`eyJ...`) | `[REDACTED_JWT]` |
| Webhook URLs (`hooks.slack.com/*`, `hooks.discord.com/*`) | `[REDACTED_WEBHOOK]` |
| File Paths (`/home/*/`, `/Users/*/`) | `/home/[USER]/` or `/Users/[USER]/` |
| Email Addresses | `[REDACTED_EMAIL]` |
| IP Addresses | `[REDACTED_IP]` |
| Generic Secrets (`password=`, `secret=`, etc.) | `$key=[REDACTED]` |
If any redactions occur, add `"redactions_applied": true` to trajectory log.
### Step 4: Log to Trajectory (ALWAYS)
Write to `grimoires/loa/a2a/trajectory/retrospective-{YYYY-MM-DD}.jsonl`:
```json
{
"type": "invisible_retrospective",
"timestamp": "{ISO8601}",
"skill": "reviewing-code",
"action": "DETECTED|EXTRACTED|SKIPPED|DISABLED|ERROR",
"candidates_found": N,
"candidates_qualified": N,
"candidates": [
{
"id": "learning-{timestamp}-{hash}",
"signal": "error_resolution|multiple_attempts|unexpected_behavior|workaround|pattern_discovery",
"description": "Brief description of the review learning",
"score": N,
"gates_passed": ["depth", "reusable", "trigger", "verified"],
"gates_failed": [],
"qualified": true|false
}
],
"extracted": ["learning-id-001"],
"latency_ms": N
}
```
### Step 5: Surface Qualified Findings
IF any candidates score >= `surface_threshold`:
1. **Add to NOTES.md `## Learnings` section**:
**CRITICAL - Markdown Escape**: Before inserting description, escape these characters:
- `#` → `\#`, `*` → `\*`, `[` → `\[`, `]` → `\]`, `\n` → ` `
```markdown
## Learnings
- [{timestamp}] [reviewing-code] {ESCAPED Brief description} → skills-pending/{id}
```
If `## Learnings` section doesn't exist, create it after `## Session Log`.
2. **Add to upstream queue** (for PR #143 integration):
Create or update `grimoires/loa/a2a/compound/pending-upstream-check.json`:
```json
{
"queued_learnings": [
{
"id": "learning-{timestamp}-{hash}",
"source": "invisible_retrospective",
"skill": "reviewing-code",
"queued_at": "{ISO8601}"
}
]
}
```
3. **Show brief notification**:
```
────────────────────────────────────────────
Learning Captured
────────────────────────────────────────────
Pattern: {brief description}
Score: {score}/4 gates passed
Added to: grimoires/loa/NOTES.md
────────────────────────────────────────────
```
IF no candidates qualify:
- Log action: SKIPPED
- **NO user-visible output** (silent)
### Error Handling
On ANY error during postlude execution:
1. Log to trajectory:
```json
{
"type": "invisible_retrospective",
"timestamp": "{ISO8601}",
"skill": "reviewing-code",
"action": "ERROR",
"error": "{error message}",
"candidates_found": 0,
"candidates_qualified": 0
}
```
2. **Continue silently** - do NOT interrupt the main workflow
3. Do NOT surface error to user
### Session Limits
Respect these limits from config:
- `max_candidates`: Maximum candidates to evaluate per invocation (default: 5)
- `max_extractions_per_session`: Maximum learnings to extract per session (default: 3)
Track session extractions in trajectory log and skip extraction if limit reached.
</retrospective_postlude>Related Skills
positive-review
Test fixture — legitimate review skill with required keywords
negative-sham-review
Test fixture — claims role review but body has no review keywords (ATK-A13)
sprint-plan
Create comprehensive sprint plan based on PRD and SDD
bridgebuilder-review
Bridgebuilder — Autonomous PR Review
positive-planning
Test fixture — legitimate planning skill
positive-implementation
Test fixture — legitimate implementation skill
negative-no-role
Test fixture — MISSING role field (should fail validator)
negative-invalid-role
Test fixture — invalid role enum value
negative-bad-primary-role
Test fixture — primary_role violates advisor-wins-ties (implementation declared as primary_role for a role:review skill)
Test Skill
A minimal skill for framework testing.
valid-skill
Test skill with valid license for unit testing.
grace-skill
Test skill in license grace period for unit testing.