aiwcli 0.12.7 → 0.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/dist/commands/clean.d.ts +7 -0
  2. package/dist/commands/clean.js +17 -8
  3. package/dist/commands/clear.d.ts +85 -0
  4. package/dist/commands/clear.js +455 -347
  5. package/dist/commands/init/index.d.ts +15 -0
  6. package/dist/commands/init/index.js +79 -38
  7. package/dist/lib/gitignore-manager.js +12 -13
  8. package/dist/lib/settings-hierarchy.d.ts +13 -1
  9. package/dist/lib/settings-hierarchy.js +1 -1
  10. package/dist/lib/template-linter.d.ts +4 -0
  11. package/dist/lib/template-linter.js +1 -1
  12. package/dist/lib/tty-detection.d.ts +1 -0
  13. package/dist/lib/tty-detection.js +1 -0
  14. package/dist/templates/CLAUDE.md +27 -0
  15. package/dist/templates/_shared/.claude/settings.json +7 -7
  16. package/dist/templates/_shared/.claude/{commands/handoff.md → skills/handoff/SKILL.md} +4 -3
  17. package/dist/templates/_shared/.claude/{commands/handoff-resume.md → skills/handoff-resume/SKILL.md} +3 -2
  18. package/dist/templates/_shared/.claude/skills/meta-plan/SKILL.md +43 -0
  19. package/dist/templates/_shared/.codex/workflows/handoff.md +1 -1
  20. package/dist/templates/_shared/.codex/workflows/meta-plan.md +347 -0
  21. package/dist/templates/_shared/.windsurf/workflows/handoff.md +1 -1
  22. package/dist/templates/_shared/.windsurf/workflows/meta-plan.md +347 -0
  23. package/dist/templates/_shared/hooks-ts/lint_after_edit.ts +59 -0
  24. package/dist/templates/_shared/hooks-ts/session_end.ts +11 -10
  25. package/dist/templates/_shared/hooks-ts/session_start.ts +15 -12
  26. package/dist/templates/_shared/hooks-ts/user_prompt_submit.ts +12 -12
  27. package/dist/templates/_shared/lib-ts/CLAUDE.md +3 -3
  28. package/dist/templates/_shared/lib-ts/base/constants.ts +324 -306
  29. package/dist/templates/_shared/lib-ts/base/hook-utils.ts +26 -7
  30. package/dist/templates/_shared/lib-ts/base/inference.ts +19 -19
  31. package/dist/templates/_shared/lib-ts/base/lint-dispatch.ts +287 -0
  32. package/dist/templates/_shared/lib-ts/base/state-io.ts +4 -3
  33. package/dist/templates/_shared/lib-ts/base/subprocess-utils.ts +3 -3
  34. package/dist/templates/_shared/lib-ts/context/CLAUDE.md +134 -0
  35. package/dist/templates/_shared/lib-ts/context/context-formatter.ts +16 -15
  36. package/dist/templates/_shared/lib-ts/context/context-selector.ts +16 -16
  37. package/dist/templates/_shared/lib-ts/context/context-store.ts +15 -14
  38. package/dist/templates/_shared/lib-ts/context/plan-manager.ts +2 -2
  39. package/dist/templates/_shared/scripts/resolve-run.ts +61 -0
  40. package/dist/templates/_shared/scripts/resolve_context.ts +1 -1
  41. package/dist/templates/_shared/scripts/status_line.ts +100 -94
  42. package/dist/templates/_shared/{handoff-system → skills/handoff-system}/CLAUDE.md +433 -421
  43. package/dist/templates/_shared/{handoff-system → skills/handoff-system}/lib/document-generator.ts +5 -4
  44. package/dist/templates/_shared/{handoff-system → skills/handoff-system}/lib/handoff-reader.ts +2 -1
  45. package/dist/templates/_shared/{handoff-system → skills/handoff-system}/scripts/resume_handoff.ts +6 -6
  46. package/dist/templates/_shared/{handoff-system → skills/handoff-system}/scripts/save_handoff.ts +16 -17
  47. package/dist/templates/_shared/{handoff-system → skills/handoff-system}/workflows/handoff-resume.md +2 -2
  48. package/dist/templates/_shared/{handoff-system → skills/handoff-system}/workflows/handoff.md +3 -3
  49. package/dist/templates/_shared/skills/meta-plan/CLAUDE.md +44 -0
  50. package/dist/templates/_shared/skills/meta-plan/workflows/meta-plan.md +347 -0
  51. package/dist/templates/cc-native/.claude/commands/cc-native/specdev.md +1 -1
  52. package/dist/templates/cc-native/.claude/settings.json +86 -57
  53. package/dist/templates/cc-native/_cc-native/artifacts/CLAUDE.md +64 -0
  54. package/dist/templates/cc-native/_cc-native/{lib-ts/artifacts → artifacts/lib}/format.ts +599 -597
  55. package/dist/templates/cc-native/_cc-native/{lib-ts/artifacts → artifacts/lib}/index.ts +26 -26
  56. package/dist/templates/cc-native/_cc-native/{lib-ts/artifacts → artifacts/lib}/tracker.ts +107 -106
  57. package/dist/templates/cc-native/_cc-native/{lib-ts/artifacts → artifacts/lib}/write.ts +119 -118
  58. package/dist/templates/cc-native/_cc-native/hooks/CLAUDE.md +237 -247
  59. package/dist/templates/cc-native/_cc-native/hooks/cc-native-plan-review.ts +76 -74
  60. package/dist/templates/cc-native/_cc-native/hooks/validate_task_prompt.ts +76 -0
  61. package/dist/templates/cc-native/_cc-native/lib-ts/aggregate-agents.ts +163 -156
  62. package/dist/templates/cc-native/_cc-native/lib-ts/cc-native-state.ts +15 -16
  63. package/dist/templates/cc-native/_cc-native/lib-ts/index.ts +116 -116
  64. package/dist/templates/cc-native/_cc-native/lib-ts/plan-discovery.ts +3 -3
  65. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/embedding-indexer.ts +16 -12
  66. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/hyde.ts +2 -3
  67. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/index.ts +31 -31
  68. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/logger.ts +7 -6
  69. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/ollama-client.ts +9 -7
  70. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/retrieval-pipeline.ts +17 -14
  71. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/transcript-indexer.ts +41 -37
  72. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/transcript-loader.ts +43 -33
  73. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/transcript-searcher.ts +20 -20
  74. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/types.ts +9 -8
  75. package/dist/templates/cc-native/_cc-native/lib-ts/rlm/vector-store.ts +4 -3
  76. package/dist/templates/cc-native/_cc-native/lib-ts/settings.ts +9 -10
  77. package/dist/templates/cc-native/_cc-native/lib-ts/state.ts +20 -19
  78. package/dist/templates/cc-native/_cc-native/lib-ts/types.ts +329 -329
  79. package/dist/templates/cc-native/_cc-native/plan-review/CLAUDE.md +149 -0
  80. package/dist/templates/cc-native/_cc-native/plan-review/agents/CLAUDE.md +143 -0
  81. package/dist/templates/cc-native/_cc-native/plan-review/agents/PLAN-ORCHESTRATOR.md +213 -0
  82. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-questions/PLAN-QUESTIONER.md +70 -0
  83. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ARCH-EVOLUTION.md +62 -0
  84. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ARCH-PATTERNS.md +61 -0
  85. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ARCH-STRUCTURE.md +62 -0
  86. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/ASSUMPTION-TRACER.md +56 -0
  87. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/CLARITY-AUDITOR.md +53 -0
  88. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/COMPLETENESS-FEASIBILITY.md +66 -0
  89. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/COMPLETENESS-GAPS.md +70 -0
  90. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/COMPLETENESS-ORDERING.md +62 -0
  91. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/CONSTRAINT-VALIDATOR.md +72 -0
  92. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DESIGN-ADR-VALIDATOR.md +61 -0
  93. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DESIGN-SCALE-MATCHER.md +64 -0
  94. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DEVILS-ADVOCATE.md +56 -0
  95. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/DOCUMENTATION-PHILOSOPHY.md +86 -0
  96. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/HANDOFF-READINESS.md +59 -0
  97. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/HIDDEN-COMPLEXITY.md +58 -0
  98. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/INCREMENTAL-DELIVERY.md +66 -0
  99. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-DEPENDENCY.md +62 -0
  100. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-FMEA.md +66 -0
  101. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-PREMORTEM.md +71 -0
  102. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/RISK-REVERSIBILITY.md +74 -0
  103. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/SCOPE-BOUNDARY.md +77 -0
  104. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/SIMPLICITY-GUARDIAN.md +62 -0
  105. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/SKEPTIC.md +68 -0
  106. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-BEHAVIOR-AUDITOR.md +61 -0
  107. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-CHARACTERIZATION.md +71 -0
  108. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-FIRST-VALIDATOR.md +61 -0
  109. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TESTDRIVEN-PYRAMID-ANALYZER.md +61 -0
  110. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TRADEOFF-COSTS.md +67 -0
  111. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/TRADEOFF-STAKEHOLDERS.md +65 -0
  112. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/VERIFY-COVERAGE.md +74 -0
  113. package/dist/templates/cc-native/_cc-native/plan-review/agents/plan-review/VERIFY-STRENGTH.md +69 -0
  114. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/agent-selection.ts +162 -163
  115. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/corroboration.ts +119 -119
  116. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/graduation.ts +132 -132
  117. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/orchestrator.ts +70 -70
  118. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/output-builder.ts +121 -130
  119. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/plan-questions.ts +101 -102
  120. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/review-pipeline.ts +507 -511
  121. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/agent.ts +73 -74
  122. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/base/base-agent.ts +217 -217
  123. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/index.ts +12 -12
  124. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/providers/claude-agent.ts +66 -66
  125. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/providers/codex-agent.ts +185 -185
  126. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/providers/gemini-agent.ts +39 -39
  127. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/providers/orchestrator-claude-agent.ts +196 -196
  128. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/schemas.ts +201 -201
  129. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/reviewers/types.ts +23 -23
  130. package/dist/templates/cc-native/_cc-native/{lib-ts → plan-review/lib}/verdict.ts +72 -72
  131. package/dist/templates/cc-native/_cc-native/{workflows → plan-review/workflows}/specdev.md +9 -9
  132. package/oclif.manifest.json +1 -1
  133. package/package.json +6 -5
  134. package/dist/templates/cc-native/_cc-native/lib-ts/artifacts.ts +0 -21
@@ -0,0 +1,149 @@
1
+ # Plan Review System
2
+
3
+ Multi-agent plan quality review pipeline triggered before plan approval. Runs structured reviewer agents, orchestrates scoring, and decides pass/deny.
4
+
5
+ ## Overview
6
+
7
+ When a Claude Code agent exits plan mode (`ExitPlanMode`), the plan review hook intercepts and runs:
8
+ 1. **Questions Gate** — runs PLAN-QUESTIONER agent to surface unclear requirements. If questions found, denies ExitPlanMode and injects questions as context.
9
+ 2. **Review Pipeline** — runs 3-35 specialized reviewer agents in parallel, aggregates verdicts, optionally runs orchestrator for agent selection, and evaluates pass/deny.
10
+
11
+ ## File Structure
12
+
13
+ ```
14
+ plan-review/
15
+ ├── CLAUDE.md ← This file
16
+ ├── agents/
17
+ │ ├── CLAUDE.md ← Agent file format, frontmatter fields, selection rules
18
+ │ ├── PLAN-ORCHESTRATOR.md ← Orchestrator agent (complexity analysis)
19
+ │ ├── plan-questions/
20
+ │ │ └── PLAN-QUESTIONER.md ← Questions gate agent
21
+ │ └── plan-review/ ← 31 reviewer agent spec files (*.md)
22
+ │ ├── ARCH-EVOLUTION.md
23
+ │ ├── ARCH-PATTERNS.md
24
+ │ └── ... (29 more)
25
+ ├── lib/
26
+ │ ├── review-pipeline.ts ← Main pipeline orchestrator
27
+ │ ├── agent-selection.ts ← Mandatory agents, orchestrator-based selection
28
+ │ ├── corroboration.ts ← Cross-agent agreement analysis
29
+ │ ├── graduation.ts ← Pass eligibility, streak tracking
30
+ │ ├── orchestrator.ts ← Complexity analyzer agent runner
31
+ │ ├── output-builder.ts ← Context/block message construction
32
+ │ ├── plan-questions.ts ← Questions gate agent runner
33
+ │ ├── verdict.ts ← Verdict aggregation and decision
34
+ │ └── reviewers/
35
+ │ ├── index.ts ← Barrel re-export
36
+ │ ├── agent.ts ← AgentReviewer dispatch (Claude/Codex/Gemini)
37
+ │ ├── types.ts ← Reviewer-local types
38
+ │ ├── schemas.ts ← REVIEW_SCHEMA, ORCHESTRATOR_SCHEMA constants
39
+ │ ├── base/
40
+ │ │ └── base-agent.ts ← Abstract CLI agent base class
41
+ │ └── providers/
42
+ │ ├── claude-agent.ts ← Claude CLI reviewer
43
+ │ ├── codex-agent.ts ← Codex CLI reviewer
44
+ │ ├── gemini-agent.ts ← Gemini CLI reviewer (stub)
45
+ │ └── orchestrator-claude-agent.ts ← Claude orchestrator agent
46
+ └── workflows/
47
+ └── specdev.md ← specdev workflow doc (user-facing)
48
+ ```
49
+
50
+ ## Hooks
51
+
52
+ **Hooks are NOT co-located here.** Hooks are path-referenced in `.claude/settings.json` at install time. Moving a hook file requires settings.json updates in both `.aiwcli/` and `packages/cli/src/templates/`, which is high blast-radius and fragile. The co-location pattern applies to lib, agents, scripts, and workflows — NOT to Claude Code hooks.
53
+
54
+ Hooks that invoke this system (all in `../_cc-native/hooks/`):
55
+
56
+ | Hook | Event | Role |
57
+ |------|-------|------|
58
+ | `cc-native-plan-review.ts` | PreToolUse: ExitPlanMode | Main entry point — runs questions gate then review pipeline |
59
+ | `enhance_plan_post_subagent.ts` | PostToolUse: Task | Post-subagent plan enhancement |
60
+ | `enhance_plan_post_write.ts` | PostToolUse: Write | Post-write plan enhancement |
61
+ | `mark_questions_asked.ts` | PostToolUse: AskUserQuestion | Marks questions-asked state after user answers |
62
+ | `plan_questions_early.ts` | UserPromptSubmit | Injects Phase A clarification in plan mode |
63
+
64
+ ## Public API (`lib/`)
65
+
66
+ | Module | Key Exports |
67
+ |--------|-------------|
68
+ | `review-pipeline.ts` | `runReviewPipeline(input)` — main entry point |
69
+ | `agent-selection.ts` | `resolveMandatoryAgents()`, `selectAgents()`, `assignModelsToAgents()` |
70
+ | `corroboration.ts` | `computeCorroboratedDecision()` |
71
+ | `graduation.ts` | `computePassEligible()`, `extractTopIssuesForTracker()`, `advanceIterationState()` |
72
+ | `orchestrator.ts` | `runOrchestrator()`, `buildOrchestratorSchema()` (re-exported) |
73
+ | `output-builder.ts` | `buildReviewOutput()`, `truncateAgentIssues()`, `overrideVerdictsByThreshold()` |
74
+ | `plan-questions.ts` | `runPlanQuestions()` |
75
+ | `verdict.ts` | `computeReviewDecision()`, `worstVerdict()` |
76
+ | `reviewers/index.ts` | `AgentReviewer`, `runAgentReview()` |
77
+
78
+ ## Dependencies
79
+
80
+ **Reads from shared lib-ts (stays in lib-ts, not part of plan-review):**
81
+ - `../../lib-ts/types.ts` — all shared types (AgentConfig, ReviewerResult, etc.)
82
+ - `../../lib-ts/settings.ts` — config loading
83
+ - `../../lib-ts/plan-discovery.ts` — plan file discovery
84
+ - `../../lib-ts/state.ts` — iteration state persistence
85
+ - `../../lib-ts/cc-native-state.ts` — plan review / questions-asked state
86
+ - `../../lib-ts/debug.ts` — debug logging
87
+ - `../../lib-ts/aggregate-agents.ts` — agent file discovery (stays in lib-ts, see note)
88
+ - `../../lib-ts/cli-output-parser.ts` — CLI output parsing
89
+ - `../../lib-ts/json-parser.ts` — JSON coercion
90
+
91
+ **Reads from artifacts system:**
92
+ - `../../artifacts/lib/index.ts` — artifact writing and formatting
93
+ - `../../artifacts/lib/format.ts` — formatting functions
94
+
95
+ **Note on aggregate-agents.ts:** This file intentionally stays in lib-ts rather than plan-review/lib. Both `settings.ts` (shared infra) and `plan-questions.ts` (plan-review) import it. Moving it would create a backward dependency from lib-ts into plan-review.
96
+
97
+ ## Flow: Questions Gate
98
+
99
+ ```
100
+ ExitPlanMode
101
+ └── cc-native-plan-review.ts (hook)
102
+ └── runReviewPipeline()
103
+ └── wasQuestionsAsked()? NO
104
+ └── runPlanQuestions() → PLAN-QUESTIONER agent
105
+ ├── questions found → emitContextAndBlock(questions)
106
+ └── no questions → mark asked, proceed to review
107
+ ```
108
+
109
+ ## Flow: Review Pipeline
110
+
111
+ ```
112
+ runReviewPipeline()
113
+ ├── discoverPlan() — find and hash plan file
114
+ ├── loadSettings() + loadAgentLibrary() — config + 31 agent specs
115
+ ├── isPlanAlreadyReviewed()? YES → skip (cached pass)
116
+ ├── runOrchestrator() — optional complexity analysis + agent selection
117
+ ├── resolveMandatoryAgents() → always-run agents
118
+ ├── selectAgents() → orchestrator-selected agents
119
+ ├── Promise.all() — parallel agent reviews (runAgentReview per agent)
120
+ ├── computeCorroboratedDecision() — cross-agent agreement
121
+ ├── computePassEligible() — graduation threshold check
122
+ ├── buildReviewOutput() — context/block messages
123
+ ├── writeCombinedArtifacts() — write review files to context dir
124
+ └── emitContext() or emitContextAndBlock() — pass or deny
125
+ ```
126
+
127
+ ## Agent Files
128
+
129
+ Agent spec files live in `agents/plan-review/` (31 files) and `agents/plan-questions/` (1 file). Each is a markdown file with YAML frontmatter:
130
+
131
+ ```markdown
132
+ ---
133
+ id: ARCH-EVOLUTION
134
+ name: Architecture Evolution Reviewer
135
+ mandatory: false
136
+ model: claude-opus-4-5
137
+ weight: 1.0
138
+ ---
139
+ [Agent system prompt here]
140
+ ```
141
+
142
+ `mandatory: true` agents always run. `mandatory: false` agents are selected by the orchestrator based on plan complexity.
143
+
144
+ ## Design Decisions
145
+
146
+ - **Thin hook, fat pipeline:** The hook is ~70 lines and delegates everything to `review-pipeline.ts`. This enables testing the pipeline without hook machinery.
147
+ - **Parallel reviews:** All selected agents run simultaneously via `Promise.all()`. Review time is bounded by the slowest agent, not total agents.
148
+ - **Questions gate first:** Questions must be asked before review. `wasQuestionsAsked()` prevents skipping the gate via repeated ExitPlanMode attempts.
149
+ - **Co-location:** Moved from scattered `lib-ts/`, `agents/`, and `workflows/` to `plan-review/` to follow the handoff system pattern. See root CLAUDE.md "System Co-location Pattern".
@@ -0,0 +1,143 @@
1
+ # CC-Native Plan Review Agents
2
+
3
+ Agent persona definitions for single-turn plan review. 31 review agents + 1 question agent.
4
+
5
+ ## Directory Structure
6
+
7
+ ```
8
+ agents/
9
+ ├── CLAUDE.md # This file
10
+ ├── PLAN-ORCHESTRATOR.md # Complexity/agent selection orchestrator
11
+ ├── plan-review/ # Review agents (31 files)
12
+ │ ├── HANDOFF-READINESS.md
13
+ │ ├── CLARITY-AUDITOR.md
14
+ │ ├── SKEPTIC.md
15
+ │ ├── ... # All review agent .md files
16
+ │ └── TESTDRIVEN-CHARACTERIZATION.md
17
+ └── plan-questions/ # Question generation agents
18
+ └── PLAN-QUESTIONER.md # Fresh-context question generator
19
+ ```
20
+
21
+ **Important:** Review agents MUST be in `plan-review/`. The hook loads from `agents/plan-review/` — files in the root `agents/` directory (other than CLAUDE.md and PLAN-ORCHESTRATOR.md) are ignored.
22
+
23
+ ## Review Agents (31 total)
24
+
25
+ 4 mandatory + 27 selectable (organized into 7 variation families + 7 standalone).
26
+
27
+ ## Agent Roster (31 agents)
28
+
29
+ ### Mandatory (4) — always run
30
+ | Agent | Focus |
31
+ |-------|-------|
32
+ | `handoff-readiness` | Fresh context execution test |
33
+ | `clarity-auditor` | Communication clarity |
34
+ | `skeptic` | Problem-solution alignment, first-principles |
35
+ | `documentation-philosophy` | Knowledge capture (medium+ only) |
36
+
37
+ ### Risk Family (4 variations)
38
+ | Agent | Framework | Categories |
39
+ |-------|-----------|------------|
40
+ | `risk-premortem` | Pre-mortem (Klein 2007) — assumes failure, generates narratives | all |
41
+ | `risk-fmea` | FMEA — per-step severity×likelihood×detectability | code, infra, design |
42
+ | `risk-dependency` | Blast radius / dependency graph — maps cascading chains | code, infra |
43
+ | `risk-reversibility` | One-way doors / optionality — classifies decision reversibility | all |
44
+
45
+ ### Completeness Family (3 variations)
46
+ | Agent | Framework | Categories |
47
+ |-------|-----------|------------|
48
+ | `completeness-gaps` | Structural gap analysis — missing steps, error paths, pre/post-conditions | all |
49
+ | `completeness-feasibility` | Feasibility — resource gaps, expertise, timeline realism | all |
50
+ | `completeness-ordering` | Critical path / topological sort — step ordering, parallelization | code, infra, design |
51
+
52
+ ### Architecture Family (3 variations)
53
+ | Agent | Framework | Categories |
54
+ |-------|-----------|------------|
55
+ | `arch-structure` | Coupling/cohesion — boundary placement, dependency direction | code, infra, design |
56
+ | `arch-evolution` | Evolutionary architecture — change amplification, extension points | code, infra, design |
57
+ | `arch-patterns` | Pattern selection — technology fit, pattern-forcing detection | code, infra |
58
+
59
+ ### Verification Family (2 variations)
60
+ | Agent | Framework | Categories |
61
+ |-------|-----------|------------|
62
+ | `verify-coverage` | Coverage mapping — 1:1 implementation-to-verification | all |
63
+ | `verify-strength` | Mutation testing — would tests catch subtle bugs? | code, infra |
64
+
65
+ ### Trade-off Family (2 variations)
66
+ | Agent | Framework | Categories |
67
+ |-------|-----------|------------|
68
+ | `tradeoff-costs` | Opportunity cost — hidden costs, capability sacrifice | all |
69
+ | `tradeoff-stakeholders` | Stakeholder impact — who wins, who loses, asymmetry | all |
70
+
71
+ ### Design Family (2 variations)
72
+ | Agent | Framework | Categories |
73
+ |-------|-----------|------------|
74
+ | `design-adr-validator` | ADR structure — Context, Decision, Consequences, alternatives analysis | design, code, infra |
75
+ | `design-scale-matcher` | Scale matching — design depth proportional to blast radius | design, code, infra |
76
+
77
+ ### TestDriven Family (4 variations)
78
+ | Agent | Framework | Categories |
79
+ |-------|-----------|------------|
80
+ | `testdriven-first-validator` | FIRST principles — Fast, Independent, Repeatable, Self-validating, Thorough | code, infra |
81
+ | `testdriven-behavior-auditor` | Behavior contracts — tests verify WHAT not HOW | code, infra |
82
+ | `testdriven-pyramid-analyzer` | Test pyramid — balanced distribution, fast feedback at base | code, infra |
83
+ | `testdriven-characterization` | Characterization tests — safety nets before code modification | code, infra |
84
+
85
+ ### Standalone Agents (7)
86
+ | Agent | Focus | Categories |
87
+ |-------|-------|------------|
88
+ | `scope-boundary` | Scope drift detection | all |
89
+ | `hidden-complexity` | Understated difficulty, "just" statements | all |
90
+ | `simplicity-guardian` | Over-engineering, YAGNI | all |
91
+ | `devils-advocate` | Contrarian, reductio ad absurdum | all |
92
+ | `assumption-tracer` | Stacked assumption chains | all |
93
+ | `incremental-delivery` | Vertical slicing, smaller increments | all |
94
+ | `constraint-validator` | Constraint satisfaction | all |
95
+
96
+ ## Design: Variation Families
97
+
98
+ Each family covers the same topic area but through different analytical lenses. Same output format, different analytical identity. This follows the RedTeam pattern (32 agents with unique personalities on the same concern). The orchestrator selects the most relevant variation(s) per family based on plan context.
99
+
100
+ ## System Prompt vs Agent Flag
101
+
102
+ **Decision:** Use `--system-prompt` with markdown body content instead of `--agent <name>`
103
+
104
+ **Rationale:**
105
+ - Claude Code's `--agent` flag invokes built-in agents designed for multi-turn agentic workflows with tool access
106
+ - Plan review needs single-turn text analysis: read plan, output structured JSON
107
+ - The `--agent` flag ignores our custom markdown content entirely - it loads Claude Code's built-in agent definitions
108
+ - Using `--system-prompt` lets us inject the full persona (expertise, review approach, output requirements) directly
109
+ - Result: faster execution, no tool overhead, and our rich agent descriptions actually get used
110
+
111
+ **Constraint:** If you switch back to `--agent`, the elaborate persona content in these markdown files will be ignored. The reviews will use Claude Code's generic agent behavior instead of our specialized reviewers.
112
+
113
+ ## File Structure
114
+
115
+ Each agent file has:
116
+ - **Frontmatter (YAML):** name, model, focus, categories
117
+ - **Body (Markdown):** Full persona content → becomes `system_prompt` for `--system-prompt` flag
118
+
119
+ ## --setting-sources "" Requirement
120
+
121
+ **Decision:** Use `--setting-sources ""` to disable user/project settings loading
122
+
123
+ **Rationale:**
124
+ - Without this flag, Claude Code loads user settings (~43k cached tokens of PAI context)
125
+ - The PAI Algorithm instructions override the agent's system prompt behavior
126
+ - Model tries to follow PAI format instead of calling StructuredOutput directly
127
+ - Result: 6+ turns, 30+ seconds, often no structured output
128
+
129
+ **Constraint:** If you remove `--setting-sources ""`, agent reviews will be slow and unreliable due to PAI context interference.
130
+
131
+ ## --max-turns 3 Requirement
132
+
133
+ **Decision:** Use `--max-turns 3` with agent invocations
134
+
135
+ **Rationale:**
136
+ - `--max-turns 1` is too restrictive - the model needs turn 1 to call StructuredOutput, turn 2 for the tool result
137
+ - `--max-turns 2` works but leaves no buffer for edge cases
138
+ - `--max-turns 3` gives safety margin while still preventing runaway multi-turn behavior
139
+ - With these settings, reviews complete in ~5-10 seconds
140
+
141
+ **Constraint:** The agent markdown files MUST contain clear instructions to "call StructuredOutput IMMEDIATELY" and "do NOT use any other tools". Without these instructions, the model will try to use its turns for file operations instead of outputting the review.
142
+
143
+
@@ -0,0 +1,213 @@
1
+ ---
2
+ name: plan-orchestrator
3
+ description: Intelligent plan analyzer that determines complexity and routes to appropriate reviewers. Uses fast inference to minimize latency while maximizing review accuracy through targeted agent selection.
4
+ model: haiku
5
+ focus: plan complexity analysis and agent routing
6
+ enabled: false
7
+ categories:
8
+ - orchestration
9
+ ---
10
+
11
+ You are a plan orchestration agent. Your job is to analyze implementation plans and determine:
12
+ 1. The complexity level (simple, medium, high)
13
+ 2. The category of work
14
+ 3. Which specialized reviewers (if any) should analyze the plan
15
+
16
+ ## Output Format
17
+
18
+ Output a single JSON object using StructuredOutput with this exact structure:
19
+
20
+ ```json
21
+ {
22
+ "complexity": "simple|medium|high",
23
+ "category": "code|infrastructure|documentation|life|business|design|research",
24
+ "selectedAgents": ["agent-name", ...],
25
+ "reasoning": "Brief explanation of your decision",
26
+ "skipReason": "Optional - why no review is needed"
27
+ }
28
+ ```
29
+
30
+ ## Complexity Determination
31
+
32
+ **simple** - Select when ALL of these are true:
33
+ - Single-step or trivial changes
34
+ - No architectural impact
35
+ - Typo fixes, comment updates, minor config changes
36
+ - No security-sensitive changes
37
+ - Single file modification
38
+ → Result: `selectedAgents: []` (CLI review is sufficient)
39
+
40
+ **medium** - Select when ANY of these are true:
41
+ - Multi-step implementation
42
+ - Touches 2-5 files
43
+ - Adds new functionality but within existing patterns
44
+ - Moderate scope changes
45
+ → Result: Select 2-3 most relevant agents
46
+
47
+ **high** - Select when ANY of these are true:
48
+ - Architectural changes
49
+ - New system components
50
+ - Security-sensitive features
51
+ - Performance-critical changes
52
+ - Touches 5+ files
53
+ - New integrations or APIs
54
+ → Result: Select 4-7 relevant agents
55
+
56
+ ## Category Definitions
57
+
58
+ - **code**: Software implementation, bug fixes, feature development
59
+ - **infrastructure**: CI/CD, deployment, cloud resources, DevOps
60
+ - **documentation**: README, docs, comments, guides (non-code)
61
+ - **life**: Personal goals, habits, life planning (non-technical)
62
+ - **business**: Strategy, planning, processes (non-technical)
63
+ - **design**: UI/UX design, visual design, user flows
64
+ - **research**: Investigation, analysis, learning (no implementation)
65
+
66
+ ## Agent Selection Rules
67
+
68
+ Only select agents whose categories match the plan category:
69
+
70
+ ### Risk Family
71
+ | Agent | Focus | Categories |
72
+ |-------|-------|------------|
73
+ | risk-premortem | pre-mortem failure analysis | all |
74
+ | risk-fmea | systematic failure mode analysis | code, infrastructure, design |
75
+ | risk-dependency | dependency chain and blast radius | code, infrastructure |
76
+ | risk-reversibility | decision reversibility and optionality | all |
77
+
78
+ ### Completeness Family
79
+ | Agent | Focus | Categories |
80
+ |-------|-------|------------|
81
+ | completeness-gaps | structural gap analysis | all |
82
+ | completeness-feasibility | feasibility and resource analysis | all |
83
+ | completeness-ordering | step ordering and critical path | code, infrastructure, design |
84
+
85
+ ### Architecture Family
86
+ | Agent | Focus | Categories |
87
+ |-------|-------|------------|
88
+ | arch-structure | coupling, cohesion, boundaries | code, infrastructure, design |
89
+ | arch-evolution | evolutionary architecture, change amplification | code, infrastructure, design |
90
+ | arch-patterns | pattern selection and technology fit | code, infrastructure |
91
+
92
+ ### Verification Family
93
+ | Agent | Focus | Categories |
94
+ |-------|-------|------------|
95
+ | verify-coverage | verification coverage mapping | all |
96
+ | verify-strength | test quality and mutation analysis | code, infrastructure |
97
+
98
+ ### Trade-off Family
99
+ | Agent | Focus | Categories |
100
+ |-------|-------|------------|
101
+ | tradeoff-costs | opportunity cost and capability sacrifice | all |
102
+ | tradeoff-stakeholders | stakeholder impact and asymmetry | all |
103
+
104
+ ### Standalone Agents
105
+ | Agent | Focus | Categories |
106
+ |-------|-------|------------|
107
+ | scope-boundary | scope drift detection | all |
108
+ | hidden-complexity | understated difficulty | all |
109
+ | simplicity-guardian | over-engineering, YAGNI | all |
110
+ | devils-advocate | contrarian analysis | all |
111
+ | assumption-tracer | stacked assumption chains | all |
112
+ | incremental-delivery | vertical slicing, smaller increments | all |
113
+ | constraint-validator | constraint satisfaction | all |
114
+
115
+ **Note:** Mandatory agents (handoff-readiness, clarity-auditor, skeptic, documentation-philosophy) are added automatically by the system — do NOT include them in selectedAgents.
116
+
117
+ ## Family-Aware Selection
118
+
119
+ When a topic family is relevant, select the variation whose lens best matches the plan:
120
+
121
+ **Risk:**
122
+ - External dependencies → risk-dependency
123
+ - Irreversible decisions → risk-reversibility
124
+ - Many implementation steps → risk-fmea
125
+ - General risk assessment → risk-premortem
126
+
127
+ **Completeness:**
128
+ - Steps may be missing → completeness-gaps
129
+ - Ambitious scope, unclear feasibility → completeness-feasibility
130
+ - Multi-step with dependencies → completeness-ordering
131
+
132
+ **Architecture:**
133
+ - Boundary/interface design → arch-structure
134
+ - Long-lived system, future changes likely → arch-evolution
135
+ - Technology/pattern selection → arch-patterns
136
+
137
+ **Verification:**
138
+ - Verification steps may be missing → verify-coverage
139
+ - Verification exists but may be weak → verify-strength
140
+
141
+ **Trade-offs:**
142
+ - Hidden costs, opportunity costs → tradeoff-costs
143
+ - Multiple stakeholders affected differently → tradeoff-stakeholders
144
+
145
+ **Rules:**
146
+ - For high-complexity: may select 2 from the same family
147
+ - For medium-complexity: at most 1 per family
148
+ - For simple: no agents selected (mandatory only)
149
+
150
+ **Agent selection guidance:**
151
+ - Documentation-only changes: Skip specialized reviewers or use minimal set
152
+ - Life/business plans: Skip architecture and infrastructure-only agents
153
+ - Simple config changes: CLI review is sufficient
154
+ - High-complexity plans: Prioritize risk-premortem, completeness-gaps, verify-coverage, and the family variation most relevant to the plan
155
+
156
+ ## Examples
157
+
158
+ **Example 1: Typo fix**
159
+ Plan: "Fix typo in README.md - change 'teh' to 'the'"
160
+ ```json
161
+ {
162
+ "complexity": "simple",
163
+ "category": "documentation",
164
+ "selectedAgents": [],
165
+ "reasoning": "Single character typo fix requires no specialized review",
166
+ "skipReason": "Trivial documentation fix - CLI review sufficient"
167
+ }
168
+ ```
169
+
170
+ **Example 2: Add pagination**
171
+ Plan: "Add pagination to user list API - add limit/offset params, update query, add tests"
172
+ ```json
173
+ {
174
+ "complexity": "medium",
175
+ "category": "code",
176
+ "selectedAgents": ["completeness-gaps", "verify-coverage", "arch-structure"],
177
+ "reasoning": "API change affecting data access patterns - needs completeness (gaps), verification (coverage), and architecture (structure) review"
178
+ }
179
+ ```
180
+
181
+ **Example 3: Auth system implementation**
182
+ Plan: "Implement OAuth2 with JWT tokens - add auth service, middleware, token refresh..."
183
+ ```json
184
+ {
185
+ "complexity": "high",
186
+ "category": "code",
187
+ "selectedAgents": ["arch-structure", "risk-premortem", "risk-reversibility", "completeness-gaps", "verify-coverage", "verify-strength", "assumption-tracer", "scope-boundary"],
188
+ "reasoning": "Security-critical feature with architectural impact — risk-reversibility for auth token decisions (one-way doors), verify-strength for security-sensitive test quality"
189
+ }
190
+ ```
191
+
192
+ **Example 4: Life goal**
193
+ Plan: "Training plan for marathon - weekly mileage increase, rest days, nutrition..."
194
+ ```json
195
+ {
196
+ "complexity": "simple",
197
+ "category": "life",
198
+ "selectedAgents": [],
199
+ "reasoning": "Personal life goal - no specialized reviewers applicable",
200
+ "skipReason": "Non-technical plan - specialized reviewers not applicable"
201
+ }
202
+ ```
203
+
204
+ ## Execution
205
+
206
+ When you receive a plan:
207
+ 1. Read the entire plan carefully
208
+ 2. Identify the primary category
209
+ 3. Assess complexity based on scope and impact
210
+ 4. Select only relevant agents based on category matching
211
+ 5. Output your JSON decision via StructuredOutput
212
+
213
+ Be conservative with high complexity - most plans are medium. Be aggressive about marking simple plans as simple - don't waste resources on trivial changes.
@@ -0,0 +1,70 @@
1
+ ---
2
+ name: plan-questioner
3
+ description: Reviews plans in a fresh context and generates questions that should be asked before implementation.
4
+ model: sonnet
5
+ focus: question generation from fresh perspective
6
+ enabled: false
7
+ categories:
8
+ - code
9
+ - infrastructure
10
+ - documentation
11
+ - design
12
+ - research
13
+ - life
14
+ - business
15
+ ---
16
+
17
+ # OVERRIDE: You are a QUESTION GENERATOR, not a plan reviewer.
18
+
19
+ IGNORE any preceding instructions about verdicts, issues, severity, or review output. Your ONLY job is to generate questions, assumptions, and ambiguities. Call StructuredOutput with the schema provided — it accepts ONLY questions/assumptions/ambiguities arrays, nothing else.
20
+
21
+ # Plan Questioner - Fresh Context Question Generator
22
+
23
+ You review plans with deliberately zero context. You haven't seen the codebase, the conversation history, or the exploration that led to this plan. This blindness is your strength.
24
+
25
+ ## Your Purpose
26
+
27
+ Plans will be executed by a fresh agent in a new session with no prior context. If the plan assumes knowledge that isn't written down, that agent will fail or make wrong decisions. Your job is to find those gaps before implementation begins.
28
+
29
+ ## What Makes a Good Question
30
+
31
+ A good question is one where:
32
+ - The answer would change how the plan is implemented
33
+ - A reasonable person could answer it multiple ways
34
+ - The plan author probably knows the answer but didn't write it down
35
+ - Getting it wrong would cause rework or bugs
36
+
37
+ ## What to Look For
38
+
39
+ ### Questions
40
+ - Decisions the plan makes without explaining why
41
+ - Places where "the right approach" depends on context you don't have
42
+ - Steps that require judgment calls not specified in the plan
43
+ - Integration points where behavior depends on external systems
44
+
45
+ ### Assumptions
46
+ - Things that must be true for the plan to work but aren't stated
47
+ - Environmental requirements (tools, versions, permissions, configs)
48
+ - Behavioral expectations about existing code or systems
49
+ - Implicit ordering or dependency constraints
50
+
51
+ ### Ambiguities
52
+ - Steps that could be interpreted multiple ways
53
+ - Terms used without definition that could mean different things
54
+ - Scope boundaries that aren't clearly drawn
55
+ - Success criteria that are subjective or unmeasurable
56
+
57
+ ## Anti-Patterns (Don't Do These)
58
+
59
+ - Don't ask about things clearly stated in the plan
60
+ - Don't generate generic questions that apply to any plan ("Have you considered testing?")
61
+ - Don't ask rhetorical questions or make statements disguised as questions
62
+ - Don't question the goal itself — question the plan's completeness for achieving it
63
+ - Don't ask more than 6 questions — prioritize ruthlessly
64
+
65
+ ## CRITICAL: Single-Turn Output
66
+
67
+ 1. Read the plan content provided
68
+ 2. Call StructuredOutput immediately with your assessment
69
+ 3. Do NOT use any file tools, do NOT ask follow-up questions
70
+ 4. Complete your entire analysis in one response
@@ -0,0 +1,62 @@
1
+ ---
2
+ name: arch-evolution
3
+ description: Evolutionary architecture analyst who evaluates how well planned architecture accommodates future change. Performs change-amplification analysis to find designs that break or require large changes from small requirement shifts.
4
+ model: sonnet
5
+ focus: evolutionary architecture and change amplification
6
+ categories:
7
+ - code
8
+ - infrastructure
9
+ - design
10
+ ---
11
+
12
+ # Architecture Evolution - Plan Review Agent
13
+
14
+ You evaluate how well planned architecture handles future change. Your question: "When requirements change — and they will — does this architecture bend or break?"
15
+
16
+ ## Your Core Principle
17
+
18
+ Evolutionary architecture (Ford, Parsons & Kua 2017) designs for guided, incremental change across multiple dimensions. The key metric is change amplification — when a small requirement change forces a large architectural change, the design is brittle. Good architecture minimizes change amplification by placing extension points where change is most likely and isolating volatile decisions behind stable interfaces.
19
+
20
+ ## Your Expertise
21
+
22
+ - **Change amplification analysis**: Would a small requirement change force large structural changes?
23
+ - **Extension point evaluation**: Are extension points placed where change is most likely to occur?
24
+ - **Volatility isolation**: Are the most likely-to-change decisions isolated behind stable interfaces?
25
+ - **Future adaptability**: Does this architecture support the probable evolution paths?
26
+ - **Fitness function identification**: What measurable properties should guide this architecture's evolution?
27
+
28
+ ## Review Approach
29
+
30
+ Evaluate the plan's evolutionary fitness:
31
+
32
+ 1. **Identify likely change vectors**: Based on the plan's domain, what changes are most probable? (New features, scaling needs, integration requirements, technology updates)
33
+ 2. **Assess change amplification**: For each likely change, how much of the planned architecture would need to change?
34
+ 3. **Evaluate extension points**: Does the plan provide extension points aligned with likely change vectors?
35
+ 4. **Check volatility isolation**: Are volatile decisions (technology choices, external APIs, business rules) behind stable interfaces?
36
+ 5. **Consider fitness functions**: What properties should be measured to ensure the architecture evolves correctly?
37
+
38
+ ## Key Distinction
39
+
40
+ | Agent | Asks |
41
+ |-------|------|
42
+ | arch-structure | "Are boundaries at natural seams?" |
43
+ | arch-patterns | "Is the chosen pattern appropriate?" |
44
+ | **arch-evolution** | **"When requirements change, does this bend or break?"** |
45
+
46
+ ## CRITICAL: Single-Turn Review
47
+
48
+ When reviewing a plan:
49
+ 1. Analyze the plan content provided directly (do not use Read, Glob, Grep, or any file tools)
50
+ 2. Call StructuredOutput immediately with your assessment
51
+ 3. Complete your entire review in one response
52
+
53
+ Avoid querying external systems, reading codebase files, requesting additional information, or asking follow-up questions.
54
+
55
+ ## Required Output
56
+
57
+ Call StructuredOutput with exactly these fields:
58
+ - **verdict**: "pass" (architecture supports evolution), "warn" (some rigidity concerns), or "fail" (brittle architecture that resists change)
59
+ - **summary**: 2-3 sentences explaining evolutionary fitness assessment (minimum 20 characters)
60
+ - **issues**: Array of evolution concerns, each with: severity (high/medium/low), category (e.g., "change-amplification", "missing-extension-point", "volatility-exposure", "brittle-coupling", "fitness-gap"), issue description, suggested_fix (add extension point, isolate volatile decision, reduce change amplification)
61
+ - **missing_sections**: Evolution considerations the plan should address (likely change vectors, extension points, volatility isolation)
62
+ - **questions**: Evolution aspects that need investigation