Summary
Leverage new Claude Code features (agent hooks, context: fork, skill agent field) to simplify our architecture:
- Consolidate 11 review agents → 1 parameterized
Reviewer
- Add self-review framework to Coder with fix-before-returning behavior
- Use agent hooks for lifecycle control and file persistence
- DRY review orchestration -
/implement calls /review
New Claude Code Features We're Leveraging
| Feature |
How We Use It |
context: fork |
Run Coder and Reviewer in isolated sub-agent contexts |
agent field in skills |
Skills can specify which agent executes them |
Agent hooks.Stop |
Self-review in Coder, file persistence in Reviewer |
type: prompt hooks |
Intelligent self-review decisions |
Design Decisions
| Decision |
Choice |
Rationale |
| Orchestrator context |
Main (visible) |
User sees progress, can intervene at gates |
| Review gating |
Report only |
Show findings, user decides |
| Coder → Review transition |
Orchestrator spawns |
/implement calls /review command |
| Review consolidation |
Parameterized Reviewer |
Pattern skills exist, methodology shared |
| Self-review behavior |
Fix, not just report |
Catch issues before external review |
| Review output format |
Markdown (.md) |
Human readable |
| Migration strategy |
Big bang + coexistence |
Keep old agents for rollback |
Architecture
Current (11 Review Agents)
/implement
├─→ Coder
└─→ SecurityReview ─┐
ArchitectureReview ├─→ Summary
PerformanceReview │
ComplexityReview │
ConsistencyReview │
TypescriptReview │
TestsReview │
DocumentationReview│
DependenciesReview │
RegressionReview │
DatabaseReview ─┘
Problem: 11 agents with duplicated methodology
Proposed (1 Parameterized Reviewer)
/implement (main context, visible)
│
▼
┌─────────────────────────────────────────────────────────────┐
│ Coder (context: fork) │
│ hooks: │
│ Stop: │
│ - type: prompt │
│ prompt: "Self-review using devflow-self-review. │
│ Fix all P0/P1 issues. Return when PASS." │
│ │
│ Output: implementation + self-review report │
└─────────────────────────────────────────────────────────────┘
│
▼ (orchestrator calls /review command)
┌─────────────────────────────────────────────────────────────┐
│ /review │
│ ┌────────────────────────────────────────────────────────┐ │
│ │ Reviewer × N (parallel, context: fork) │ │
│ │ focus: security | architecture | performance | ... │ │
│ │ Loads: devflow-review-methodology + devflow-{focus}-* │ │
│ │ │ │
│ │ hooks: │ │
│ │ Stop: │ │
│ │ - type: command │ │
│ │ command: "# findings already saved to file" │ │
│ │ │ │
│ │ Output: .docs/reviews/{branch}/{focus}.md │ │
│ └────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌────────────────────────────────────────────────────────┐ │
│ │ Summary (context: fork) │ │
│ │ Reads: .docs/reviews/{branch}/*.md │ │
│ │ Output: .docs/reviews/{branch}/SUMMARY.md │ │
│ └────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────┐
│ USER GATE │
│ Shows: Summary + recommendation │
│ Options: Create PR / Request fixes / Abort │
└─────────────────────────────────────────────────────────────┘
Component Specifications
1. New Skill: devflow-self-review
Iron Law: FIX BEFORE RETURNING
8 Pillars (prioritized):
| Priority |
Pillar |
Key Checks |
| P0 |
Design |
Fits architecture, interaction logic sound, not over-solving |
| P0 |
Functionality |
Works as intended, edge cases handled, no race conditions |
| P0 |
Security |
Input validation, no injection risks, no secrets exposed |
| P1 |
Complexity |
Understandable in <5 min, single responsibility, no over-abstraction |
| P1 |
Error Handling |
Explicit handling, Result types where appropriate, no silent failures |
| P1 |
Tests |
Cover new functionality, would fail if code breaks, edge cases tested |
| P2 |
Naming |
Descriptive names, comments explain "why" not "what" |
| P2 |
Consistency |
Follows style guide, matches surrounding patterns |
Behavior:
- Evaluate P0 → fix immediately → evaluate P1 → fix → evaluate P2 → fix if time
- If P0 issue unfixable → STOP and report blocker
- Only return when all P0 and P1 PASS
Based on: Google Engineering Practices, Microsoft Engineering Playbook
2. New Agent: Reviewer
---
name: Reviewer
description: Universal code review agent with parameterized focus
model: sonnet
skills: devflow-review-methodology, devflow-security-patterns,
devflow-architecture-patterns, devflow-performance-patterns, ...
tools: Read, Grep, Glob, LSP
---
Parameterization: Invoked with focus parameter that determines which pattern skill to apply:
focus: security → applies devflow-security-patterns
focus: architecture → applies devflow-architecture-patterns
- etc.
Output: Writes findings to .docs/reviews/{branch}/{focus}.md
3. Updated Agent: Coder
Add to frontmatter:
skills: devflow-core-patterns, devflow-implementation-patterns,
devflow-git-safety, devflow-self-review
hooks:
Stop:
- hooks:
- type: prompt
prompt: |
Before completing, run self-review using devflow-self-review.
Evaluate each pillar in order. FIX any issues found.
Only return when all P0 and P1 pillars PASS.
Output: fixes made + final status.
4. Updated Command: /implement
Change Phase 8-9 (review phases) to:
## Phase 8: Code Review
Invoke the /review command to run comprehensive review.
This ensures review orchestration logic is not duplicated.
5. Updated Command: /review
Replace individual review agent spawns with parameterized Reviewer:
## Phase 3: Parallel Reviews
Spawn Reviewer agent for each focus area in parallel:
| Focus | Condition |
|-------|-----------|
| security | Always |
| architecture | Always |
| performance | Always |
| complexity | Always |
| consistency | Always |
| tests | Always |
| regression | Always |
| typescript | If .ts/.tsx files changed |
| database | If migration/schema files changed |
| documentation | If docs changed |
| dependencies | If package.json/lock files changed |
Each invocation:
- Agent: Reviewer
- Parameter: focus={focus}
- Output: .docs/reviews/{branch}/{focus}.md
Self-Review vs External Review
| Aspect |
Self-Review (Coder) |
External Review (Reviewer) |
| Purpose |
Catch obvious issues before submitting |
Fresh eyes, specialized expertise |
| Action |
Fix immediately |
Report findings |
| Scope |
8 pillars, general quality |
Domain-specific deep dives |
| When |
Before returning from Coder |
After Coder completes |
| Output |
Fixed code + report |
Findings in .md files |
Migration Strategy
- Create new components (Reviewer, devflow-self-review)
- Update existing (Coder hooks, /review, /implement)
- Keep old review agents (deprecate but don't delete)
- Test end-to-end
- Remove old agents in next release (after validation)
Implementation Tasks
Phase 1: Pattern Skills Extraction
Phase 2: Self-Review Framework
Phase 3: Unified Reviewer
Phase 4: Pipeline Integration
Phase 5: Cleanup
Pattern Skills Gap Analysis
Existing pattern skills:
devflow-security-patterns - EXISTS
Missing pattern skills needed for Reviewer:
devflow-architecture-patterns - MISSING
devflow-performance-patterns - MISSING
devflow-complexity-patterns - MISSING
devflow-consistency-patterns - MISSING
devflow-tests-patterns - MISSING
devflow-database-patterns - MISSING
devflow-documentation-patterns - MISSING
devflow-dependencies-patterns - MISSING
devflow-regression-patterns - MISSING
Decision: Extract ALL patterns from existing review agents into skills upfront. Each current review-{type}.md agent contains specialized knowledge that becomes devflow-{type}-patterns skill.
This adds ~9 new skill files but:
- Makes patterns reusable (Coder can use them too)
- Single source of truth for each domain
- Cleaner separation of concerns
References
Summary
Leverage new Claude Code features (agent hooks,
context: fork, skillagentfield) to simplify our architecture:Reviewer/implementcalls/reviewNew Claude Code Features We're Leveraging
context: forkagentfield in skillshooks.Stoptype: prompthooksDesign Decisions
Architecture
Current (11 Review Agents)
Proposed (1 Parameterized Reviewer)
Component Specifications
1. New Skill:
devflow-self-reviewIron Law: FIX BEFORE RETURNING
8 Pillars (prioritized):
Behavior:
Based on: Google Engineering Practices, Microsoft Engineering Playbook
2. New Agent:
ReviewerParameterization: Invoked with
focusparameter that determines which pattern skill to apply:focus: security→ appliesdevflow-security-patternsfocus: architecture→ appliesdevflow-architecture-patternsOutput: Writes findings to
.docs/reviews/{branch}/{focus}.md3. Updated Agent:
CoderAdd to frontmatter:
4. Updated Command:
/implementChange Phase 8-9 (review phases) to:
## Phase 8: Code Review Invoke the /review command to run comprehensive review. This ensures review orchestration logic is not duplicated.5. Updated Command:
/reviewReplace individual review agent spawns with parameterized Reviewer:
Self-Review vs External Review
Migration Strategy
Implementation Tasks
Phase 1: Pattern Skills Extraction
review-architecture.md→devflow-architecture-patternsreview-performance.md→devflow-performance-patternsreview-complexity.md→devflow-complexity-patternsreview-consistency.md→devflow-consistency-patternsreview-tests.md→devflow-tests-patternsreview-database.md→devflow-database-patternsreview-documentation.md→devflow-documentation-patternsreview-dependencies.md→devflow-dependencies-patternsreview-regression.md→devflow-regression-patternsPhase 2: Self-Review Framework
skills/devflow-self-review/SKILL.mdwith 8 pillarsagents/coder.mdwith Stop hookPhase 3: Unified Reviewer
agents/reviewer.mdwith parameterized focuscommands/review.mdto use Revieweragents/review-summary.mdto read .md filesPhase 4: Pipeline Integration
commands/implement.mdto call /reviewPhase 5: Cleanup
Pattern Skills Gap Analysis
Existing pattern skills:
devflow-security-patterns- EXISTSMissing pattern skills needed for Reviewer:
devflow-architecture-patterns- MISSINGdevflow-performance-patterns- MISSINGdevflow-complexity-patterns- MISSINGdevflow-consistency-patterns- MISSINGdevflow-tests-patterns- MISSINGdevflow-database-patterns- MISSINGdevflow-documentation-patterns- MISSINGdevflow-dependencies-patterns- MISSINGdevflow-regression-patterns- MISSINGDecision: Extract ALL patterns from existing review agents into skills upfront. Each current
review-{type}.mdagent contains specialized knowledge that becomesdevflow-{type}-patternsskill.This adds ~9 new skill files but:
References