all-for-claudecode 2.13.0 → 2.14.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.
- package/.claude-plugin/marketplace.json +24 -5
- package/.claude-plugin/plugin.json +15 -4
- package/README.md +12 -0
- package/agents/afc-appsec-expert.md +19 -26
- package/agents/afc-architect.md +9 -2
- package/agents/afc-backend-expert.md +16 -4
- package/agents/afc-design-expert.md +17 -7
- package/agents/afc-impl-worker.md +7 -1
- package/agents/afc-infra-expert.md +16 -6
- package/agents/afc-legal-expert.md +16 -18
- package/agents/afc-marketing-expert.md +15 -5
- package/agents/afc-pm-expert.md +16 -5
- package/agents/afc-pr-analyst.md +1 -1
- package/agents/afc-security.md +7 -2
- package/agents/afc-tech-advisor.md +18 -30
- package/docs/agent-authoring-guide.md +144 -0
- package/docs/context-management-harness.md +293 -0
- package/docs/orchestration-modes.md +228 -0
- package/docs/skill-authoring-guide.md +153 -0
- package/hooks/hooks.json +27 -2
- package/package.json +4 -3
- package/schemas/hooks.schema.json +1 -1
- package/schemas/marketplace.schema.json +6 -1
- package/schemas/plugin.schema.json +0 -4
- package/scripts/afc-pipeline-manage.sh +1 -0
- package/scripts/afc-post-compact.sh +54 -0
- package/scripts/afc-spec-guard.sh +7 -7
- package/scripts/afc-stop-failure.sh +46 -0
- package/scripts/afc-sync-cache.sh +8 -2
- package/scripts/afc-tdd-guard.sh +7 -5
- package/scripts/afc-user-prompt-submit.sh +38 -0
- package/scripts/pre-compact-checkpoint.sh +10 -0
- package/scripts/session-start-context.sh +10 -0
- package/skills/architect/SKILL.md +1 -9
- package/skills/auto/SKILL.md +228 -910
- package/skills/auto/skill-advisor.md +306 -0
- package/skills/checkpoint/SKILL.md +7 -1
- package/skills/clarify/SKILL.md +3 -2
- package/skills/consult/SKILL.md +30 -123
- package/skills/consult/peer-mode.md +61 -0
- package/skills/debug/SKILL.md +3 -21
- package/skills/ideate/SKILL.md +1 -77
- package/skills/ideate/brief-template.md +73 -0
- package/skills/implement/SKILL.md +68 -260
- package/skills/init/SKILL.md +79 -129
- package/skills/init/reference.md +55 -0
- package/skills/issue/SKILL.md +51 -76
- package/skills/launch/SKILL.md +5 -0
- package/skills/learner/SKILL.md +1 -25
- package/skills/learner/suggestion-format.md +49 -0
- package/skills/plan/SKILL.md +1 -5
- package/skills/pr-comment/SKILL.md +38 -51
- package/skills/principles/SKILL.md +3 -7
- package/skills/qa/SKILL.md +3 -14
- package/skills/release-notes/SKILL.md +6 -5
- package/skills/resolve/SKILL.md +75 -158
- package/skills/resolve/graphql.md +48 -0
- package/skills/resume/SKILL.md +10 -5
- package/skills/review/SKILL.md +56 -202
- package/skills/review/perspectives.md +118 -0
- package/skills/security/SKILL.md +4 -22
- package/skills/security/cross-boundary-verification.md +22 -0
- package/skills/setup/SKILL.md +38 -87
- package/skills/setup/conflict-detection.md +33 -0
- package/skills/spec/SKILL.md +1 -5
- package/skills/tasks/SKILL.md +47 -70
- package/skills/test/SKILL.md +4 -16
- package/skills/triage/SKILL.md +38 -85
- package/skills/triage/coupling-detection.md +13 -0
- package/skills/triage/pr-analysis-prompt.md +46 -0
- package/skills/validate/SKILL.md +24 -62
- package/skills/validate/validation-categories.md +39 -0
package/skills/auto/SKILL.md
CHANGED
|
@@ -8,9 +8,9 @@ argument-hint: "[feature description in natural language]"
|
|
|
8
8
|
|
|
9
9
|
> Runs clarify? → spec → plan → implement → review → clean fully automatically from a single feature description.
|
|
10
10
|
> Tasks are generated automatically at implement start (no separate tasks phase).
|
|
11
|
-
> Critic Loop runs at each phase
|
|
12
|
-
> Pre-implementation gates (clarify, TDD pre-gen, blast-radius) run conditionally
|
|
13
|
-
> **Skill Advisor**: 5 checkpoints (A–E) at phase boundaries
|
|
11
|
+
> Critic Loop runs at each phase (unified safety cap: 5). Convergence terminates early when quality is sufficient.
|
|
12
|
+
> Pre-implementation gates (clarify, TDD pre-gen, blast-radius) run conditionally.
|
|
13
|
+
> **Skill Advisor**: 5 checkpoints (A–E) at phase boundaries; max 5 auxiliary invocations per pipeline. See `skills/auto/skill-advisor.md` for details.
|
|
14
14
|
|
|
15
15
|
## Arguments
|
|
16
16
|
|
|
@@ -22,74 +22,20 @@ argument-hint: "[feature description in natural language]"
|
|
|
22
22
|
|
|
23
23
|
## Config Load
|
|
24
24
|
|
|
25
|
-
**Always** read `.claude/afc.config.md` first
|
|
26
|
-
- `{config.ci}` — full CI command
|
|
27
|
-
- `{config.gate}` — phase gate command
|
|
28
|
-
- `{config.test}` — test command
|
|
29
|
-
- `{config.architecture}` — architecture
|
|
30
|
-
- `{config.code_style}` — code style rules
|
|
25
|
+
**Always** read `.claude/afc.config.md` first. Values referenced as `{config.*}`:
|
|
26
|
+
- `{config.ci}` — full CI command
|
|
27
|
+
- `{config.gate}` — phase gate command
|
|
28
|
+
- `{config.test}` — test command
|
|
29
|
+
- `{config.architecture}` — architecture rules
|
|
30
|
+
- `{config.code_style}` — code style rules
|
|
31
31
|
|
|
32
|
-
If config
|
|
33
|
-
1. Ask the user: "`.claude/afc.config.md` not found. Run `/afc:init` to set up the project?"
|
|
34
|
-
2. If user accepts → run `/afc:init`, then **restart this command** with the original `$ARGUMENTS`
|
|
35
|
-
3. If user declines → **abort**
|
|
32
|
+
If config missing: ask user to run `/afc:init`. If declined → **abort**.
|
|
36
33
|
|
|
37
34
|
---
|
|
38
35
|
|
|
39
|
-
##
|
|
36
|
+
## Critic Loop Rules
|
|
40
37
|
|
|
41
|
-
>
|
|
42
|
-
|
|
43
|
-
### Core Principle: Intent-Based Evaluation
|
|
44
|
-
|
|
45
|
-
Each checkpoint contains a **structured evaluation prompt** that the orchestrator answers by reading the actual artifact content (not scanning for keywords). The evaluation produces a 1–5 score per signal. Score >= 3 triggers the corresponding skill.
|
|
46
|
-
|
|
47
|
-
**Why not keywords**: Keyword matching produces false positives (e.g., "token" in CSS vs auth context) and misses implicit intent (e.g., "user upload feature" implies security concerns without mentioning "XSS"). The orchestrator is an LLM — it should use semantic understanding.
|
|
48
|
-
|
|
49
|
-
### Execution Modes
|
|
50
|
-
|
|
51
|
-
| Mode | Description | Context cost | Example |
|
|
52
|
-
|------|-------------|-------------|---------|
|
|
53
|
-
| **Transform** | Skill output **replaces or restructures** the next phase's input | High (blocking) | ideate → $ARGUMENTS restructured |
|
|
54
|
-
| **Enrich** | Skill output **appends context** to the next phase's input | Low (fork/Task) | consult → domain constraints section added |
|
|
55
|
-
| **Observe** | Skill output is **metadata only** (logged, flags set) | Low (fork) | qa → quality score recorded |
|
|
56
|
-
|
|
57
|
-
### Budget Control
|
|
58
|
-
|
|
59
|
-
| Constraint | Limit | Rationale |
|
|
60
|
-
|-----------|-------|-----------|
|
|
61
|
-
| Per checkpoint | max 2 skills | Phase transition delay cap |
|
|
62
|
-
| Pipeline total | max 5 auxiliary invocations | Total execution time cap |
|
|
63
|
-
| Transform mode | max 1 per pipeline | Main context pollution prevention |
|
|
64
|
-
| Concurrent fork | max 3 per checkpoint | Agent resource limit |
|
|
65
|
-
|
|
66
|
-
Track auxiliary invocations in `ADVISOR_COUNT` (starts at 0, increments per invocation). If `ADVISOR_COUNT >= 5`, skip remaining checkpoints. Transform invocations tracked in `ADVISOR_TRANSFORM_USED` (boolean). **Every increment** must persist to pipeline state: `afc_state_write "advisorCount" "$ADVISOR_COUNT"`. On context recovery, restore from state: `ADVISOR_COUNT = afc_state_read "advisorCount"`.
|
|
67
|
-
|
|
68
|
-
### Expert Agent Routing
|
|
69
|
-
|
|
70
|
-
When a checkpoint determines that domain expertise is needed, route to the appropriate expert agent:
|
|
71
|
-
|
|
72
|
-
| Domain | Agent ID | When to route |
|
|
73
|
-
|--------|----------|---------------|
|
|
74
|
-
| backend | `afc-backend-expert` | API design, database schema, server architecture, auth flows |
|
|
75
|
-
| infra | `afc-infra-expert` | Deployment, CI/CD, cloud infrastructure, containerization, scaling |
|
|
76
|
-
| pm | `afc-pm-expert` | Product decisions, user stories, prioritization, metrics |
|
|
77
|
-
| design | `afc-design-expert` | UI/UX, accessibility, component design, visual hierarchy |
|
|
78
|
-
| marketing | `afc-marketing-expert` | SEO, analytics, growth, conversion optimization |
|
|
79
|
-
| legal | `afc-legal-expert` | Privacy regulations, licensing, compliance, data protection |
|
|
80
|
-
| security | `afc-appsec-expert` | Application security, vulnerability patterns, secure coding |
|
|
81
|
-
| advisor | `afc-tech-advisor` | Technology selection, library comparison, stack decisions |
|
|
82
|
-
|
|
83
|
-
Route based on **what expertise the feature actually needs**, not keyword presence. Consider the project's `{config.architecture}` and tech stack — skip domains irrelevant to the project.
|
|
84
|
-
|
|
85
|
-
**Agent ID lookup**: Use the Agent ID column directly as the `subagent_type` value (e.g., `subagent_type: "afc:afc-backend-expert"`). Do NOT construct agent names from the domain name — `security` maps to `afc-appsec-expert` (not `afc-security-expert`), and `advisor` maps to `afc-tech-advisor` (not `afc-advisor-expert`).
|
|
86
|
-
|
|
87
|
-
---
|
|
88
|
-
|
|
89
|
-
## Critic Loop Rules (common to all phases)
|
|
90
|
-
|
|
91
|
-
> **Always** read `${CLAUDE_SKILL_DIR}/../../docs/critic-loop-rules.md` first and follow it.
|
|
92
|
-
> Core: minimum 1 concern per criterion + mandatory Adversarial failure scenario each pass + quantitative evidence required. "PASS" as a single word is prohibited. Uses convergence-based termination with 4 verdicts (PASS/FAIL/ESCALATE/DEFER). On ESCALATE: pause and present options to user even in auto mode.
|
|
38
|
+
> **Always** read `${CLAUDE_SKILL_DIR}/../../docs/critic-loop-rules.md` before running any Critic pass. Core: minimum 1 concern per criterion + mandatory Adversarial failure scenario each pass + quantitative evidence required. "PASS" as a single word is prohibited. On ESCALATE: pause and present options via AskUserQuestion even in auto mode.
|
|
93
39
|
|
|
94
40
|
---
|
|
95
41
|
|
|
@@ -97,25 +43,20 @@ Route based on **what expertise the feature actually needs**, not keyword presen
|
|
|
97
43
|
|
|
98
44
|
### Phase 0: Preparation
|
|
99
45
|
|
|
100
|
-
1. If `$ARGUMENTS` is empty → print "Please enter a feature description." and abort
|
|
101
|
-
2. Check current branch → `BRANCH_NAME
|
|
102
|
-
3.
|
|
103
|
-
3.5. **Preflight Check**:
|
|
46
|
+
1. If `$ARGUMENTS` is empty → print "Please enter a feature description." and **abort**
|
|
47
|
+
2. Check current branch → `BRANCH_NAME`. Determine feature name (2-3 keywords, kebab-case).
|
|
48
|
+
3. **Preflight Check**:
|
|
104
49
|
```bash
|
|
105
50
|
"${CLAUDE_SKILL_DIR}/../../scripts/afc-preflight-check.sh"
|
|
106
51
|
```
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
4. **Activate Pipeline Flag** (hook integration):
|
|
52
|
+
Exit 1 → **abort**. Warnings (exit 0) → print and continue.
|
|
53
|
+
4. **Activate Pipeline Flag**:
|
|
110
54
|
```bash
|
|
111
55
|
"${CLAUDE_SKILL_DIR}/../../scripts/afc-pipeline-manage.sh" start {feature}
|
|
112
56
|
```
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
- Timeline log: `"${CLAUDE_SKILL_DIR}/../../scripts/afc-pipeline-manage.sh" log pipeline-start "Auto pipeline: {feature}"`
|
|
117
|
-
5. Create `.claude/afc/specs/{feature}/` directory → **record path as `PIPELINE_ARTIFACT_DIR`** (for Clean scope)
|
|
118
|
-
6. **Initialize Skill Advisor**: `ADVISOR_COUNT = 0`, `ADVISOR_TRANSFORM_USED = false`. Persist to pipeline state for context-loss resilience:
|
|
57
|
+
Creates `afc/pre-auto` safety snapshot, activates Stop Gate Hook, starts change tracking.
|
|
58
|
+
5. Create `.claude/afc/specs/{feature}/` → **record as `PIPELINE_ARTIFACT_DIR`**
|
|
59
|
+
6. **Initialize Skill Advisor**: `ADVISOR_COUNT = 0`, `ADVISOR_TRANSFORM_USED = false`
|
|
119
60
|
```bash
|
|
120
61
|
afc_state_write "advisorCount" "0"
|
|
121
62
|
afc_state_write "advisorTransformUsed" "false"
|
|
@@ -129,54 +70,30 @@ Route based on **what expertise the feature actually needs**, not keyword presen
|
|
|
129
70
|
|
|
130
71
|
### Phase 0.3: Request Triage
|
|
131
72
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
- If the feature substantially exists → ask user via AskUserQuestion:
|
|
136
|
-
- "This feature appears to already exist at {path}. (1) Enhance existing (2) Replace entirely (3) Abort"
|
|
137
|
-
- If user chooses abort → release pipeline flag (`"${CLAUDE_SKILL_DIR}/../../scripts/afc-pipeline-manage.sh" end`), end with: `"Pipeline aborted — feature already exists."`
|
|
138
|
-
|
|
139
|
-
2. **Scope check**: Estimate the scope of `$ARGUMENTS`:
|
|
140
|
-
- If description implies 10+ files or multiple unrelated concerns → warn:
|
|
141
|
-
- "This request spans multiple concerns: {list}. Recommended: split into {N} separate pipeline runs."
|
|
142
|
-
- Ask: "(1) Proceed as single pipeline (2) Reduce scope to {suggestion} (3) Abort"
|
|
143
|
-
|
|
144
|
-
3. **Proportionality check**: If the request is trivially small (single file, single-line change, config edit):
|
|
145
|
-
- Suggest: "This change is small enough to implement directly. Skip full pipeline?"
|
|
146
|
-
- If user agrees → execute fast-path directly, skip spec/plan/tasks
|
|
147
|
-
|
|
148
|
-
If all checks pass, proceed to Phase 0.8.
|
|
73
|
+
1. **Necessity**: Explore codebase for existing implementations. If feature substantially exists → ask: "(1) Enhance existing (2) Replace entirely (3) Abort". Abort → release pipeline flag and end.
|
|
74
|
+
2. **Scope**: If `$ARGUMENTS` implies 10+ files or multiple unrelated concerns → warn and ask: "(1) Proceed (2) Reduce scope (3) Abort".
|
|
75
|
+
3. **Proportionality**: If trivially small (single file, single-line, config edit) → suggest fast-path skip.
|
|
149
76
|
|
|
150
77
|
### Phase 0.8: Size-Based Fast-Path Detection (conditional)
|
|
151
78
|
|
|
152
|
-
**
|
|
79
|
+
**ALL 3 criteria must be met** to trigger fast-path:
|
|
153
80
|
|
|
154
|
-
| Criterion | Check |
|
|
155
|
-
|
|
156
|
-
| Trivial scope |
|
|
157
|
-
| No script impact |
|
|
158
|
-
| Low ambiguity | Clarify gate score < 2
|
|
81
|
+
| Criterion | Check |
|
|
82
|
+
|-----------|-------|
|
|
83
|
+
| Trivial scope | Explicitly mentions 1-2 specific files or a single-line fix |
|
|
84
|
+
| No script impact | Does not reference `.sh` scripts, hooks, or pipeline logic |
|
|
85
|
+
| Low ambiguity | Clarify gate score < 2 |
|
|
159
86
|
|
|
160
|
-
**If ALL 3
|
|
87
|
+
**If ALL 3 met** (fast-path):
|
|
161
88
|
1. Print: `⚡ Fast path detected — skipping spec/plan phases`
|
|
162
|
-
2.
|
|
163
|
-
3.
|
|
164
|
-
|
|
165
|
-
**If ANY criterion fails**: proceed to Phase 0.5 (full pipeline).
|
|
166
|
-
|
|
167
|
-
**Fast-Path Execution** (implement → review → clean):
|
|
168
|
-
1. Implement the change directly (no tasks.md, no plan.md)
|
|
169
|
-
2. Run `{config.ci}` verification
|
|
170
|
-
- On fail: **rollback fast-path changes** (`git reset --hard afc/pre-auto`), then restart with full pipeline: `⚠ Fast-path aborted — change is more complex than expected. Rolling back and running full pipeline.`
|
|
171
|
-
3. If change touches > 2 files OR modifies any `.sh` script: **rollback fast-path changes** (`git reset --hard afc/pre-auto`), then restart with full pipeline
|
|
172
|
-
4. **Checkpoint**:
|
|
173
|
-
```bash
|
|
89
|
+
2. Implement the change directly (no tasks.md, no plan.md)
|
|
90
|
+
3. Run `{config.ci}` — on fail or if > 2 files modified: rollback (`git reset --hard afc/pre-auto`) and restart with full pipeline
|
|
91
|
+
4. ```bash
|
|
174
92
|
"${CLAUDE_SKILL_DIR}/../../scripts/afc-pipeline-manage.sh" phase fast-path
|
|
175
93
|
"${CLAUDE_SKILL_DIR}/../../scripts/afc-pipeline-manage.sh" ci-pass
|
|
176
94
|
```
|
|
177
|
-
5. Run
|
|
178
|
-
6.
|
|
179
|
-
7. Final output:
|
|
95
|
+
5. Run mini-review (single Critic pass). Then run Phase 5 Clean logic.
|
|
96
|
+
6. Final output:
|
|
180
97
|
```
|
|
181
98
|
Fast path complete: {feature}
|
|
182
99
|
├─ Mode: ⚡ Fast path (spec/plan skipped)
|
|
@@ -185,92 +102,32 @@ If all checks pass, proceed to Phase 0.8.
|
|
|
185
102
|
└─ Review: mini-review passed
|
|
186
103
|
```
|
|
187
104
|
|
|
105
|
+
**If ANY criterion fails**: proceed to Phase 0.5 (full pipeline).
|
|
106
|
+
|
|
188
107
|
### Phase 0.5: Auto-Clarify Gate (conditional)
|
|
189
108
|
|
|
190
109
|
`"${CLAUDE_SKILL_DIR}/../../scripts/afc-pipeline-manage.sh" phase clarify`
|
|
191
110
|
|
|
192
|
-
|
|
111
|
+
Score `$ARGUMENTS` on 5 ambiguity signals (vague scope, missing quantifiers, undefined entities, unclear boundaries, multiple interpretations). If score >= 3: generate at most 3 questions via AskUserQuestion. Apply answers to refine `$ARGUMENTS`. In full-auto mode: auto-resolve with best-guess, tag `[AUTO-RESOLVED: clarify]`.
|
|
193
112
|
|
|
194
|
-
|
|
195
|
-
|--------|-----------|---------|
|
|
196
|
-
| Vague scope | No specific file, component, or module mentioned | "add caching" |
|
|
197
|
-
| Missing quantifiers | No numbers, sizes, limits, or thresholds | "improve performance" |
|
|
198
|
-
| Undefined entities | References to concepts not in the codebase | "integrate the new service" |
|
|
199
|
-
| Unclear boundaries | No start/end conditions or scope limits | "refactor the system" |
|
|
200
|
-
| Multiple interpretations | Ambiguous verbs or overloaded terms | "fix the pipeline" (which one?) |
|
|
113
|
+
**If score < 3**: skip silently.
|
|
201
114
|
|
|
202
|
-
|
|
203
|
-
1. Generate at most 3 clarification questions targeting the highest-signal areas
|
|
204
|
-
2. Present via AskUserQuestion with multiple-choice options
|
|
205
|
-
3. Apply answers to refine `$ARGUMENTS` before proceeding to Spec
|
|
206
|
-
4. If in full-auto mode and user prefers no interruption: auto-resolve with best-guess, tag with `[AUTO-RESOLVED: clarify]`, emit warning
|
|
207
|
-
5. Progress: `✓ Clarify gate triggered ({N} questions, {M} auto-resolved)`
|
|
208
|
-
|
|
209
|
-
**If score < 3** (clear): skip silently, proceed to Phase 1.
|
|
115
|
+
---
|
|
210
116
|
|
|
211
117
|
### Skill Advisor Checkpoint A (Pre-Spec)
|
|
212
118
|
|
|
213
|
-
> Evaluate
|
|
119
|
+
> Evaluate BEFORE Phase 1. See `skills/auto/skill-advisor.md#checkpoint-a--pre-spec` for full evaluation prompts, invocation patterns, and state management. Budget: max 2 skills, max 1 Transform. Skip if `ADVISOR_COUNT >= 5`.
|
|
214
120
|
|
|
215
|
-
|
|
121
|
+
Signals: A1 (idea-level request → `ideate` Transform), A2 (domain expertise needed → `consult({domain})` Enrich).
|
|
216
122
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
1. Execute `/afc:ideate` inline with `$ARGUMENTS`
|
|
224
|
-
2. If ideate fails or produces no output:
|
|
225
|
-
- Do NOT set `ADVISOR_TRANSFORM_USED = true`
|
|
226
|
-
- Proceed with original `$ARGUMENTS`
|
|
227
|
-
- Log: `"Skill Advisor [A]: ideate failed, proceeding with original input"`
|
|
228
|
-
3. On success: read generated `ideate.md` → extract `## Problem Statement` + `## Value Proposition` + `## Core Features (MoSCoW)` sections
|
|
229
|
-
4. Construct enriched spec input:
|
|
230
|
-
```
|
|
231
|
-
SPEC_INPUT = "$ARGUMENTS
|
|
232
|
-
|
|
233
|
-
## Ideation Context (auto-generated)
|
|
234
|
-
{extracted Problem Statement section}
|
|
235
|
-
{extracted Value Proposition section}
|
|
236
|
-
{extracted Core Features (MoSCoW) — Must Have items only}"
|
|
237
|
-
```
|
|
238
|
-
5. Replace `$ARGUMENTS` with `SPEC_INPUT` for Phase 1
|
|
239
|
-
6. Set `ADVISOR_TRANSFORM_USED = true`, increment `ADVISOR_COUNT`, persist: `afc_state_write "advisorCount" "$ADVISOR_COUNT"` and `afc_state_write "advisorTransformUsed" "true"`
|
|
240
|
-
7. Progress: ` ├─ Skill Advisor [A]: ideate (score: {N}/5, input restructured from idea to structured brief)`
|
|
241
|
-
|
|
242
|
-
**If A2 >= 3** (Enrich):
|
|
243
|
-
1. Determine which domain from Expert Agent Routing table best matches the **actual expertise gap** (not keyword presence)
|
|
244
|
-
2. Verify domain relevance: does this project's `{config.architecture}` and tech stack make this domain applicable? (e.g., skip `design` for a CLI tool, skip `infra` if the project has no deployment config)
|
|
245
|
-
3. Invoke expert agent (look up the agent-id from the Expert Agent Routing table — do NOT construct from domain name):
|
|
246
|
-
```
|
|
247
|
-
Task("Domain pre-consultation: {domain}", subagent_type: "afc:{agent-id-from-routing-table}",
|
|
248
|
-
prompt: "You are being consulted automatically during pipeline spec preparation.
|
|
249
|
-
|
|
250
|
-
## Feature Context
|
|
251
|
-
{$ARGUMENTS}
|
|
252
|
-
|
|
253
|
-
## Why You Were Consulted
|
|
254
|
-
{1-sentence explanation of what domain expertise gap was identified}
|
|
255
|
-
|
|
256
|
-
## Instructions
|
|
257
|
-
1. Read your MEMORY.md for prior project context
|
|
258
|
-
2. Read .claude/afc/project-profile.md if it exists
|
|
259
|
-
3. Provide domain-specific constraints, regulations, and anti-patterns that MUST be reflected in the spec
|
|
260
|
-
4. Format your response EXACTLY as:
|
|
261
|
-
## Domain Constraints ({domain})
|
|
262
|
-
- [MUST] {constraint}: {rationale}
|
|
263
|
-
- [MUST NOT] {anti-pattern}: {risk}
|
|
264
|
-
- [CONSIDER] {best practice}: {benefit}
|
|
265
|
-
5. Keep to max 10 items. Prioritize by risk severity.
|
|
266
|
-
6. Update your MEMORY.md with the consultation context")
|
|
267
|
-
```
|
|
268
|
-
4. Store output as `DOMAIN_CONSTRAINTS` → injected into Phase 1 spec context
|
|
269
|
-
5. Spec phase MUST include a `## Domain Constraints` section reflecting these items
|
|
270
|
-
6. Increment `ADVISOR_COUNT`
|
|
271
|
-
7. Progress: ` ├─ Skill Advisor [A]: consult({domain}) (score: {N}/5, {M} constraints injected)`
|
|
123
|
+
After advisor skill completes, append result summary to `context.md`:
|
|
124
|
+
```
|
|
125
|
+
## Advisor: {skill_name} (Checkpoint A)
|
|
126
|
+
- Insight: {1-line key finding}
|
|
127
|
+
- Action: {1-line required action or "none"}
|
|
128
|
+
```
|
|
272
129
|
|
|
273
|
-
|
|
130
|
+
---
|
|
274
131
|
|
|
275
132
|
### Phase 1: Spec (1/5)
|
|
276
133
|
|
|
@@ -278,106 +135,36 @@ If all checks pass, proceed to Phase 0.8.
|
|
|
278
135
|
|
|
279
136
|
Execute `/afc:spec` logic inline:
|
|
280
137
|
|
|
281
|
-
1. Explore codebase
|
|
282
|
-
2. **Research Gate** (conditional):
|
|
283
|
-
- Scan `$ARGUMENTS` for external library/API/technology references not present in the codebase
|
|
284
|
-
- If external references found: run focused WebSearch for each (latest stable version, key constraints, compatibility)
|
|
285
|
-
- Optionally use Context7 for library-specific documentation
|
|
286
|
-
- Use research findings to inform spec writing (accurate requirements instead of guesses)
|
|
287
|
-
- Tag researched items with `[RESEARCHED]` in spec
|
|
288
|
-
- If no external references: skip (all internal → no research needed)
|
|
138
|
+
1. Explore codebase (Glob, Grep) by `{config.architecture}` layer
|
|
139
|
+
2. **Research Gate** (conditional): scan `$ARGUMENTS` for external library/API references not in codebase. If found: WebSearch (or Context7) for latest stable version, key constraints. Tag researched items `[RESEARCHED]`. Skip if all internal.
|
|
289
140
|
3. Create `.claude/afc/specs/{feature}/spec.md`
|
|
290
|
-
4. `[NEEDS CLARIFICATION]` items:
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
-
|
|
295
|
-
-
|
|
296
|
-
|
|
297
|
-
-
|
|
298
|
-
-
|
|
299
|
-
|
|
300
|
-
- EDGE_CASES: are at least 2 identified? Any missing boundary conditions?
|
|
301
|
-
- TESTABILITY: Does every System Requirement follow one of the 5 EARS patterns (WHEN/WHILE/IF/WHERE/SHALL)? Does each EARS requirement have a mapped TC (`→ TC: should_...`)? If not → FAIL and auto-fix: rewrite to EARS + generate TC mapping.
|
|
302
|
-
- FAIL → auto-fix and continue. ESCALATE → pause, present options, resume after response. DEFER → record reason, mark clean.
|
|
303
|
-
7. **Checkpoint**: phase transition already recorded by `afc-pipeline-manage.sh phase spec` at phase start
|
|
304
|
-
8. Progress: `✓ 1/5 Spec complete (US: {N}, FR: {N}, researched: {N}, Critic: converged ({N} passes, {M} fixes, {E} escalations))`
|
|
141
|
+
4. `[NEEDS CLARIFICATION]` items: research first, then auto-resolve remaining as `[AUTO-RESOLVED]`
|
|
142
|
+
5. **Retrospective check**: load most recent 10 `.claude/afc/memory/retrospectives/` files (if exist) — flag `[AUTO-RESOLVED]` patterns that previously went wrong
|
|
143
|
+
6. **Critic Loop until convergence** (safety cap: 5, follow `docs/critic-loop-rules.md`):
|
|
144
|
+
- COMPLETENESS: every User Story has acceptance scenarios?
|
|
145
|
+
- MEASURABILITY: criteria measurable, quantitative evidence for numerical targets?
|
|
146
|
+
- INDEPENDENCE: no implementation details (code, library names) in spec?
|
|
147
|
+
- EDGE_CASES: at least 2 identified?
|
|
148
|
+
- TESTABILITY: every System Requirement follows EARS pattern? Each has mapped TC (`→ TC: should_...`)?
|
|
149
|
+
- Verdicts: follow `docs/critic-loop-rules.md`
|
|
150
|
+
7. Progress: `✓ 1/5 Spec complete (US: {N}, FR: {N}, researched: {N}, Critic: converged ({N} passes, {M} fixes, {E} escalations))`
|
|
305
151
|
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
> Evaluate auxiliary skill triggers AFTER spec completion, BEFORE plan creation. Budget: max 2 skills. Skip all if `ADVISOR_COUNT >= 5`.
|
|
152
|
+
---
|
|
309
153
|
|
|
310
|
-
|
|
154
|
+
### Skill Advisor Checkpoint B (Post-Spec)
|
|
311
155
|
|
|
312
|
-
|
|
313
|
-
|---|----------|-----------|---------|-------|------|
|
|
314
|
-
| B1 | Does this feature **handle, store, or transmit sensitive data or trust boundaries**? Consider: user authentication/authorization, cryptographic operations, PII/financial data processing, external input that reaches internal systems, session/token lifecycle. Judge by the feature's actual behavior, not by whether security-related words appear. | 1=no trust boundary touched, 5=core security feature | `security` | Enrich (fork) |
|
|
315
|
-
| B2 | Does this feature **cross multiple architectural boundaries** or introduce a new structural pattern? Consider: does it touch 3+ layers (e.g., API + service + data + external), create a new component type not seen in the codebase, or require coordination between independently-deployable units? | 1=single-layer change, 5=cross-cutting architectural change | `architect` | Enrich (fork) |
|
|
156
|
+
> Evaluate AFTER Phase 1, BEFORE Phase 2. See `skills/auto/skill-advisor.md#checkpoint-b--post-spec` for full invocation patterns. Budget: max 2 skills. Skip if `ADVISOR_COUNT >= 5`.
|
|
316
157
|
|
|
317
|
-
|
|
318
|
-
1. Invoke security agent for pre-plan threat modeling:
|
|
319
|
-
```
|
|
320
|
-
Task("Threat Model: {feature}", subagent_type: "afc:afc-security",
|
|
321
|
-
prompt: "Generate a threat model BEFORE implementation planning begins.
|
|
322
|
-
|
|
323
|
-
## Spec Summary
|
|
324
|
-
{spec.md FR/NFR/Key Entities — security-relevant items only}
|
|
325
|
-
|
|
326
|
-
## Why This Was Triggered
|
|
327
|
-
{1-sentence explanation of which trust boundary or sensitive data flow was identified}
|
|
328
|
-
|
|
329
|
-
## Instructions
|
|
330
|
-
1. Read your MEMORY.md for known vulnerability patterns in this project
|
|
331
|
-
2. Identify attack surfaces from the spec requirements
|
|
332
|
-
3. For each threat, specify the mitigation that MUST appear in the plan
|
|
333
|
-
4. Format your response EXACTLY as:
|
|
334
|
-
## Threat Model (pre-scan)
|
|
335
|
-
| Threat | Attack Surface | Mitigation Required | Priority |
|
|
336
|
-
|--------|---------------|-------------------|----------|
|
|
337
|
-
5. Max 8 threats. Prioritize by exploitability and impact.")
|
|
338
|
-
```
|
|
339
|
-
2. Store output as `THREAT_MODEL` → injected into Phase 2 plan context
|
|
340
|
-
3. Plan phase MUST address each mitigation in its Risk & Mitigation section
|
|
341
|
-
4. Plan Critic RISK criterion MUST verify: `{M}/{N} threat mitigations addressed`
|
|
342
|
-
5. Increment `ADVISOR_COUNT`
|
|
343
|
-
6. Progress: ` ├─ Skill Advisor [B]: security (score: {N}/5, threat model: {M} threats identified)`
|
|
344
|
-
|
|
345
|
-
**If B2 >= 3** (Enrich):
|
|
346
|
-
1. Invoke architect agent for pre-plan guidance:
|
|
347
|
-
```
|
|
348
|
-
Task("Architecture Advisory: {feature}", subagent_type: "afc:afc-architect",
|
|
349
|
-
prompt: "Provide architecture guidance BEFORE plan creation.
|
|
350
|
-
|
|
351
|
-
## Spec Summary
|
|
352
|
-
{spec.md Key Entities + layer analysis from {config.architecture}}
|
|
353
|
-
|
|
354
|
-
## Why This Was Triggered
|
|
355
|
-
{1-sentence explanation of which architectural boundary crossing was identified}
|
|
356
|
-
|
|
357
|
-
## Instructions
|
|
358
|
-
1. Read your MEMORY.md for prior ADRs and architecture patterns
|
|
359
|
-
2. Recommend: component placement, layer boundaries, interface contracts
|
|
360
|
-
3. Flag conflicts with existing architecture patterns
|
|
361
|
-
4. Format your response EXACTLY as:
|
|
362
|
-
## Architecture Advisory (pre-plan)
|
|
363
|
-
- [PLACE] {component} → {layer/module}: {rationale}
|
|
364
|
-
- [BOUNDARY] {interface}: {contract description}
|
|
365
|
-
- [CONFLICT] {existing} ↔ {new}: {resolution recommendation}
|
|
366
|
-
- [PATTERN] {recommended pattern}: {why it fits}
|
|
367
|
-
5. Max 10 items.
|
|
368
|
-
6. Update your MEMORY.md if new patterns are identified")
|
|
369
|
-
```
|
|
370
|
-
2. Store output as `ARCH_ADVISORY` → injected into Phase 2 plan context
|
|
371
|
-
3. Plan Critic ARCHITECTURE criterion MUST validate against this advisory
|
|
372
|
-
4. Increment `ADVISOR_COUNT`
|
|
373
|
-
5. Progress: ` ├─ Skill Advisor [B]: architect (score: {N}/5, advisory: {M} recommendations, {K} conflicts)`
|
|
158
|
+
Signals: B1 (sensitive data/trust boundary → `security` Enrich), B2 (cross-architectural boundary → `architect` Enrich). If both >= 3: launch parallel. Security/architecture conflicts → **ESCALATE**.
|
|
374
159
|
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
160
|
+
After advisor skill completes, append result summary to `context.md`:
|
|
161
|
+
```
|
|
162
|
+
## Advisor: {skill_name} (Checkpoint B)
|
|
163
|
+
- Insight: {1-line key finding}
|
|
164
|
+
- Action: {1-line required action or "none"}
|
|
165
|
+
```
|
|
379
166
|
|
|
380
|
-
|
|
167
|
+
---
|
|
381
168
|
|
|
382
169
|
### Phase 2: Plan (2/5)
|
|
383
170
|
|
|
@@ -386,710 +173,247 @@ Execute `/afc:spec` logic inline:
|
|
|
386
173
|
Execute `/afc:plan` logic inline:
|
|
387
174
|
|
|
388
175
|
1. Load spec.md
|
|
389
|
-
2. **Research (ReWOO pattern, if needed)**:
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
-
|
|
393
|
-
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
-
|
|
397
|
-
- **
|
|
398
|
-
- **
|
|
399
|
-
|
|
400
|
-
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
1. Entity coverage: every spec Key Entity → File Change Map row. `{M}/{N} entities covered`
|
|
405
|
-
2. NFR traceability: every NFR-* → Architecture Decision or Risk mitigation. `{M}/{N} NFRs traced`
|
|
406
|
-
3. Terminology consistency: same concept = same name across spec and plan
|
|
407
|
-
4. Constraint propagation: every spec Constraint → Risk & Mitigation or Implementation Context Must NOT. `{M}/{N} constraints propagated`
|
|
408
|
-
5. Acceptance anchor alignment: Implementation Context Acceptance Anchors faithfully reflect spec acceptance scenarios
|
|
409
|
-
- **RISK criterion mandatory checks**:
|
|
410
|
-
- Enumerate **at least 3** `{config.ci}` failure scenarios and describe mitigation
|
|
411
|
-
- Check each risk pattern described in config's Project Context section one by one
|
|
412
|
-
- Consider framework characteristics from config's Project Context (server/client boundary etc.)
|
|
413
|
-
- **ARCHITECTURE criterion**: explicitly describe import paths for moved/created files and pre-validate against `{config.architecture}` rules
|
|
414
|
-
- Each pass must **explicitly explore what was missed in the previous pass** ("Pass 2: {X} was missed in pass 1. Further review: ...")
|
|
415
|
-
- FAIL → auto-fix and continue. ESCALATE → pause, present options, resume after response. DEFER → record reason, mark clean.
|
|
416
|
-
6. **Research persistence**: If research.md was created in step 2, persist a copy to long-term memory:
|
|
417
|
-
- Copy research findings to `.claude/afc/memory/research/{feature}.md`
|
|
418
|
-
- This enables future pipelines to reference prior research decisions
|
|
419
|
-
7. **ADR recording via architect agent**: After plan.md is written, invoke the architect agent to record architectural decisions:
|
|
420
|
-
```
|
|
421
|
-
Task("ADR: Record architecture decisions for {feature}", subagent_type: "afc:afc-architect",
|
|
422
|
-
prompt: "Review the following plan and record key architecture decisions to your persistent memory.
|
|
423
|
-
|
|
424
|
-
## Plan Summary
|
|
425
|
-
{paste Architecture Decision + File Change Map sections from plan.md}
|
|
426
|
-
|
|
427
|
-
## Instructions
|
|
428
|
-
1. Read your MEMORY.md for prior ADR history
|
|
429
|
-
2. Check for conflicts between new decisions and existing ADRs
|
|
430
|
-
3. If conflicts found: return CONFLICT with details (orchestrator will ESCALATE)
|
|
431
|
-
4. If no conflicts: record new ADRs to your MEMORY.md
|
|
432
|
-
5. Return: { decisions_recorded: N, conflicts: [] }")
|
|
433
|
-
```
|
|
434
|
-
- If architect returns conflicts → **ESCALATE** to user with conflict details
|
|
435
|
-
- If no conflicts → proceed (ADR recorded for future reference)
|
|
436
|
-
8. **Session context preservation**: Write key decisions to `.claude/afc/specs/{feature}/context.md` for compaction resilience:
|
|
176
|
+
2. **Research (ReWOO pattern, if needed)**: extract technical uncertainties. Plan → Execute parallel Tasks → Solve. Record to `.claude/afc/specs/{feature}/research.md`. 1-2 topics → resolve directly.
|
|
177
|
+
3. **Memory loading** (skip if absent):
|
|
178
|
+
- Quality history: most recent 10 files from `.claude/afc/memory/quality-history/` — trend summary
|
|
179
|
+
- Decisions: most recent 30 from `.claude/afc/memory/decisions/` — conflict check
|
|
180
|
+
- Reviews: most recent 15 from `.claude/afc/memory/reviews/` — recurring finding patterns
|
|
181
|
+
4. Create `.claude/afc/specs/{feature}/plan.md`. Include structure-analysis-based estimates for numerical targets.
|
|
182
|
+
5. **Critic Loop until convergence** (safety cap: 5, follow `docs/critic-loop-rules.md`):
|
|
183
|
+
- COMPLETENESS, FEASIBILITY, ARCHITECTURE, CROSS_CONSISTENCY, RISK, PRINCIPLES
|
|
184
|
+
- **CROSS_CONSISTENCY** (check all 5): entity coverage, NFR traceability, terminology consistency, constraint propagation, acceptance anchor alignment
|
|
185
|
+
- **RISK**: enumerate at least 3 `{config.ci}` failure scenarios; check each risk pattern from Project Context
|
|
186
|
+
- **ARCHITECTURE**: describe import paths for moved/created files, pre-validate against `{config.architecture}` rules
|
|
187
|
+
- Each pass must explicitly note what was missed in the previous pass
|
|
188
|
+
6. Persist research to `.claude/afc/memory/research/{feature}.md`
|
|
189
|
+
7. **ADR recording**: invoke `afc-architect` agent to record architectural decisions. If conflicts found → **ESCALATE**
|
|
190
|
+
8. **Session context** — write `.claude/afc/specs/{feature}/context.md`:
|
|
437
191
|
```markdown
|
|
438
192
|
# Session Context: {feature}
|
|
439
193
|
## Goal
|
|
440
194
|
- Original request: $ARGUMENTS
|
|
441
195
|
- Current objective: Implement {feature}
|
|
442
196
|
## Acceptance Criteria (from spec.md)
|
|
443
|
-
{copy ALL FR-*, NFR-*, SC-* items and GWT acceptance scenarios
|
|
197
|
+
{copy ALL FR-*, NFR-*, SC-* items and GWT acceptance scenarios verbatim}
|
|
444
198
|
## Key Decisions
|
|
445
199
|
- {what}: {rationale}
|
|
446
200
|
## Discoveries
|
|
447
201
|
- {file path}: {finding}
|
|
448
202
|
```
|
|
449
|
-
|
|
450
|
-
9. **Checkpoint**: phase transition already recorded by `afc-pipeline-manage.sh phase plan` at phase start
|
|
451
|
-
10. Progress: `✓ 2/5 Plan complete (Critic: converged ({N} passes, {M} fixes, {E} escalations), files: {N}, ADR: {N} recorded, Implementation Context: {W} words)`
|
|
203
|
+
9. Progress: `✓ 2/5 Plan complete (Critic: converged ({N} passes, {M} fixes, {E} escalations), files: {N}, ADR: {N} recorded, Implementation Context: {W} words)`
|
|
452
204
|
|
|
453
|
-
|
|
205
|
+
---
|
|
454
206
|
|
|
455
|
-
|
|
207
|
+
### Skill Advisor Checkpoint C (Post-Plan)
|
|
456
208
|
|
|
457
|
-
|
|
209
|
+
> Evaluate AFTER Phase 2, BEFORE Phase 3. See `skills/auto/skill-advisor.md#checkpoint-c--post-plan` for full invocation patterns. Budget: max 2 skills. Skip if `ADVISOR_COUNT >= 5`.
|
|
458
210
|
|
|
459
|
-
|
|
460
|
-
|---|----------|-----------|---------|-------|------|
|
|
461
|
-
| C1 | Is the **implementation risk high enough** that a dependency pre-analysis would catch problems the plan missed? Consider: are there files in the File Change Map that import each other (potential circular dependency)? Are there shared utility files that many other files depend on (high fan-out risk)? Are the declared `Depends On` relationships complete, or could there be hidden coupling? | 1=isolated changes, 5=deeply interconnected change set | dependency analysis (general-purpose fork) | Observe |
|
|
462
|
-
| C2 | Does the plan contain **unresolved domain uncertainties** — items tagged `[UNCERTAIN]`, open questions in Implementation Context, or design decisions that assume domain knowledge the team may not have? | 1=all decisions are well-grounded, 5=critical domain questions remain open | `consult({domain})` expert agent | Enrich (fork) |
|
|
211
|
+
Signals: C1 (high interconnection risk → dependency analysis Observe), C2 (unresolved domain uncertainties → `consult({domain})` Enrich).
|
|
463
212
|
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
## File Change Map
|
|
471
|
-
{paste File Change Map table from plan.md}
|
|
472
|
-
|
|
473
|
-
## Instructions
|
|
474
|
-
1. For each file in the map, check its imports/dependencies in the codebase (Grep for import/require/source patterns)
|
|
475
|
-
2. Identify:
|
|
476
|
-
- Circular dependencies between planned files
|
|
477
|
-
- High fan-out files (>5 dependents outside the change set)
|
|
478
|
-
- Hidden coupling not captured in the Depends On column
|
|
479
|
-
- Files that are imported by many other files (risk of breakage)
|
|
480
|
-
3. Format your response EXACTLY as:
|
|
481
|
-
## Complexity Analysis
|
|
482
|
-
- [CIRCULAR] {file A} ↔ {file B}: {description}
|
|
483
|
-
- [FAN-OUT] {file} → {N} dependents: {list top 5}
|
|
484
|
-
- [COUPLING] {file A} → {file B}: {not in Depends On column}
|
|
485
|
-
- [HIGH-RISK] {file}: {reason — most impactful if broken}
|
|
486
|
-
## Risk Summary
|
|
487
|
-
Circular: {N}, High fan-out: {N}, Hidden coupling: {N}
|
|
488
|
-
4. If no issues found, return: '## Complexity Analysis\nNo significant risks detected.'")
|
|
489
|
-
```
|
|
490
|
-
2. Store output to `.claude/afc/specs/{feature}/complexity-analysis.md`
|
|
491
|
-
3. Implement phase reads this file → high-risk files get extra verification after modification
|
|
492
|
-
4. If circular dependencies found → **ESCALATE** to user (circular deps in implementation plan are a design flaw)
|
|
493
|
-
5. Increment `ADVISOR_COUNT`
|
|
494
|
-
6. Progress: ` ├─ Skill Advisor [C]: analyze (score: {N}/5, circular: {C}, fan-out: {F}, coupling: {H})`
|
|
495
|
-
|
|
496
|
-
**If C2 >= 3** (Enrich):
|
|
497
|
-
1. Determine which domain expert can best resolve the uncertainties (based on the nature of the open questions, not keywords)
|
|
498
|
-
2. Invoke expert agent (look up the agent-id from the Expert Agent Routing table — do NOT construct from domain name):
|
|
499
|
-
```
|
|
500
|
-
Task("Domain gap resolution: {domain}", subagent_type: "afc:{agent-id-from-routing-table}",
|
|
501
|
-
prompt: "Resolve domain uncertainties found during planning.
|
|
502
|
-
|
|
503
|
-
## Uncertain Items
|
|
504
|
-
{extract all [UNCERTAIN] tagged items and open questions from plan.md}
|
|
505
|
-
|
|
506
|
-
## Plan Context
|
|
507
|
-
{Implementation Context section from plan.md}
|
|
508
|
-
|
|
509
|
-
## Instructions
|
|
510
|
-
1. For each uncertain item, provide a definitive answer with rationale
|
|
511
|
-
2. Format your response EXACTLY as:
|
|
512
|
-
## Domain Resolutions
|
|
513
|
-
- [RESOLVED] {item}: {answer} — {rationale}
|
|
514
|
-
- [NEEDS-USER] {item}: {why this requires human judgment}
|
|
515
|
-
3. Update your MEMORY.md with the resolution context")
|
|
516
|
-
```
|
|
517
|
-
3. Apply resolutions to plan.md Implementation Context (replace `[UNCERTAIN]` with `[RESOLVED: {answer}]`)
|
|
518
|
-
4. `[NEEDS-USER]` items → **ESCALATE** to user via AskUserQuestion
|
|
519
|
-
5. Increment `ADVISOR_COUNT`
|
|
520
|
-
6. Progress: ` ├─ Skill Advisor [C]: consult({domain}) (score: {N}/5, {M} resolved, {K} needs-user)`
|
|
213
|
+
After advisor skill completes, append result summary to `context.md`:
|
|
214
|
+
```
|
|
215
|
+
## Advisor: {skill_name} (Checkpoint C)
|
|
216
|
+
- Insight: {1-line key finding}
|
|
217
|
+
- Action: {1-line required action or "none"}
|
|
218
|
+
```
|
|
521
219
|
|
|
522
|
-
|
|
220
|
+
---
|
|
523
221
|
|
|
524
222
|
### Phase 3: Implement (3/5)
|
|
525
223
|
|
|
526
224
|
`"${CLAUDE_SKILL_DIR}/../../scripts/afc-pipeline-manage.sh" phase implement`
|
|
527
225
|
|
|
528
|
-
**
|
|
529
|
-
|
|
530
|
-
**Advisor context reload**: If Checkpoint C produced `.claude/afc/specs/{feature}/complexity-analysis.md`, read it and flag high-risk files (circular dependencies, high fan-out) for extra verification after modification during task execution.
|
|
226
|
+
**Context optimization**: If extensive exploration occurred in previous phases, consider `/rewind` → Summarize from here to compact investigation-heavy sections while preserving plan/spec context intact.
|
|
531
227
|
|
|
532
|
-
|
|
228
|
+
**Session context reload**: read `.claude/afc/specs/{feature}/context.md`. If `complexity-analysis.md` exists, read it and flag high-risk files for extra verification.
|
|
533
229
|
|
|
534
|
-
|
|
230
|
+
Follow all orchestration rules in `skills/implement/SKILL.md` (mode selection, batch/swarm, failure recovery).
|
|
535
231
|
|
|
536
232
|
#### Step 3.1: Task Generation + Validation
|
|
537
233
|
|
|
538
|
-
|
|
234
|
+
Generate `tasks.md` from plan.md File Change Map. Required format:
|
|
235
|
+
```
|
|
236
|
+
- [ ] T{NNN} {[P]} {[US*]} {description} `{file path}` {depends: [TXXX]}
|
|
237
|
+
```
|
|
238
|
+
Principles: 1 task = 1 file, same file = sequential, different files = [P] candidate. Append Coverage Mapping (every FR-*/NFR-* mapped to at least one task).
|
|
539
239
|
|
|
540
|
-
|
|
541
|
-
```markdown
|
|
542
|
-
- [ ] T{NNN} {[P]} {[US*]} {description} `{file path}` {depends: [TXXX, TXXX]}
|
|
543
|
-
```
|
|
544
|
-
| Component | Required | Description |
|
|
545
|
-
|-----------|----------|-------------|
|
|
546
|
-
| `T{NNN}` | Yes | 3-digit sequential ID (T001, T002, ...) |
|
|
547
|
-
| `[P]` | No | **Mandatory parallel execution** — task MUST run in parallel with other [P] tasks in the same phase. Requires no file overlap. |
|
|
548
|
-
| `[US*]` | No | User Story label from spec.md |
|
|
549
|
-
| description | Yes | Clear task description (start with a verb) |
|
|
550
|
-
| file path | Yes | Primary target file (wrapped in backticks) |
|
|
551
|
-
| `depends:` | No | Explicit dependency list — task cannot start until all listed complete |
|
|
552
|
-
|
|
553
|
-
**Decomposition Principles**:
|
|
554
|
-
- **1 task = 1 file** principle (where possible)
|
|
555
|
-
- **Same file = sequential**, **different files = [P] candidate**
|
|
556
|
-
- **Explicit dependencies**: Use `depends: [T001, T002]` for blocking dependencies
|
|
557
|
-
- **Test tasks**: Include a verification task for each testable unit
|
|
558
|
-
- **Phase gate**: Add a `{config.gate}` validation task at the end of each Phase
|
|
559
|
-
|
|
560
|
-
**Phase Structure**: Group tasks by Phase (Setup → Core → UI → Integration & Polish)
|
|
561
|
-
|
|
562
|
-
**Coverage Mapping** (append after tasks):
|
|
563
|
-
```markdown
|
|
564
|
-
## Coverage Mapping
|
|
565
|
-
| Requirement | Tasks |
|
|
566
|
-
|-------------|-------|
|
|
567
|
-
| FR-001 | T003, T007 |
|
|
568
|
-
```
|
|
569
|
-
Every FR-*/NFR-* must be mapped to at least one task.
|
|
240
|
+
Check retrospective for past [P] conflict patterns. Run DAG and parallel overlap validation scripts — no critic loop, script-based only. Fix conflicts before proceeding.
|
|
570
241
|
|
|
571
|
-
|
|
572
|
-
- Were there previous parallel conflict issues ([P] file overlaps)? Flag similar file patterns.
|
|
573
|
-
- Were there tasks that were over-decomposed or under-decomposed? Adjust granularity.
|
|
574
|
-
3. **Script validation**: Run DAG validation (`afc-dag-validate.sh`) and parallel overlap validation (`afc-parallel-validate.sh`) — no critic loop, script-based only. Fix any conflicts before proceeding.
|
|
575
|
-
4. Progress: ` ├─ Tasks generated: {N} ({P} parallelizable), Coverage: FR {M}%, NFR {K}%`
|
|
242
|
+
Progress: ` ├─ Tasks generated: {N} ({P} parallelizable), Coverage: FR {M}%, NFR {K}%`
|
|
576
243
|
|
|
577
244
|
#### Step 3.2: TDD Pre-Generation (conditional)
|
|
578
245
|
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
**Trigger condition**: tasks.md contains at least 1 task targeting a `.sh` file in `scripts/`.
|
|
246
|
+
**Trigger**: tasks.md contains at least 1 task targeting a `.sh` file in `scripts/`.
|
|
582
247
|
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
```
|
|
588
|
-
2. Review generated skeleton files — verify they are parseable:
|
|
589
|
-
```bash
|
|
590
|
-
{config.test} # should show Pending examples, not errors
|
|
591
|
-
```
|
|
592
|
-
3. Create `.claude/afc/specs/{feature}/tests-pre.md` listing generated test expectations per task
|
|
593
|
-
4. Progress: ` ├─ TDD pre-gen: {N} skeletons generated`
|
|
594
|
-
|
|
595
|
-
**If not triggered** (no `.sh` tasks): skip silently.
|
|
596
|
-
|
|
597
|
-
**Note**: Generated tests contain `Pending` examples — implementation agents replace these with real assertions during implementation.
|
|
248
|
+
```bash
|
|
249
|
+
"${CLAUDE_SKILL_DIR}/../../scripts/afc-test-pre-gen.sh" ".claude/afc/specs/{feature}/tasks.md" "spec/"
|
|
250
|
+
```
|
|
251
|
+
Verify skeletons are parseable: `{config.test}` should show Pending examples. Create `tests-pre.md` listing expectations per task. Progress: ` ├─ TDD pre-gen: {N} skeletons generated`
|
|
598
252
|
|
|
599
253
|
#### Step 3.3: Blast Radius Analysis (conditional)
|
|
600
254
|
|
|
601
|
-
|
|
255
|
+
**Trigger**: plan.md File Change Map lists >= 3 files.
|
|
602
256
|
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
1.
|
|
607
|
-
```bash
|
|
608
|
-
"${CLAUDE_SKILL_DIR}/../../scripts/afc-blast-radius.sh" ".claude/afc/specs/{feature}/plan.md" "${CLAUDE_PROJECT_DIR}"
|
|
609
|
-
```
|
|
610
|
-
2. If exit 1 (cycle detected): **ESCALATE** — present the cycle to user with options:
|
|
611
|
-
- Option 1: Refactor plan to break the cycle
|
|
612
|
-
- Option 2: Acknowledge the cycle and proceed (mark as [DEFERRED])
|
|
613
|
-
3. If high fan-out files detected (>5 dependents): emit warning, add as RISK note in plan.md
|
|
614
|
-
4. Save output to `.claude/afc/specs/{feature}/impact.md`
|
|
615
|
-
5. Progress: ` ├─ Blast radius: {N} planned, {M} dependents`
|
|
616
|
-
|
|
617
|
-
**If not triggered** (< 3 files): skip silently (small changes have bounded blast radius).
|
|
257
|
+
```bash
|
|
258
|
+
"${CLAUDE_SKILL_DIR}/../../scripts/afc-blast-radius.sh" ".claude/afc/specs/{feature}/plan.md" "${CLAUDE_PROJECT_DIR}"
|
|
259
|
+
```
|
|
260
|
+
Exit 1 (cycle) → **ESCALATE**. High fan-out (>5 dependents) → warning + RISK note. Save to `impact.md`. Progress: ` ├─ Blast radius: {N} planned, {M} dependents`
|
|
618
261
|
|
|
619
262
|
#### Step 3.4: Execution
|
|
620
263
|
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
-
|
|
629
|
-
- **On fail: Debug-based RCA** (replaces blind retry):
|
|
630
|
-
1. Execute `/afc:debug` logic inline with the CI error output as input
|
|
631
|
-
2. Debug performs RCA: error trace → data flow → hypothesis → targeted fix
|
|
632
|
-
3. Re-run `{config.ci}` after fix
|
|
633
|
-
4. If debug-fix cycle fails 3 times → **abort** (not a simple fix — requires user intervention)
|
|
634
|
-
5. This replaces the previous "retry max 3 attempts" pattern with intelligent diagnosis
|
|
264
|
+
1. **Baseline test**: run `{config.test}` before task execution. Failure → ask user to proceed/fix/abort.
|
|
265
|
+
2. Execute tasks phase by phase per implement.md orchestration rules (sequential/batch/swarm based on [P] count)
|
|
266
|
+
3. **Implementation Context injection**: every sub-agent prompt includes plan.md `## Implementation Context` **and** relevant FR/AC from spec.md
|
|
267
|
+
4. **Phase gates**: always read `${CLAUDE_SKILL_DIR}/../../docs/phase-gate-protocol.md` first. On gate pass: `"${CLAUDE_SKILL_DIR}/../../scripts/afc-pipeline-manage.sh" phase-tag {phase_number}`
|
|
268
|
+
5. Real-time `[x]` updates in tasks.md
|
|
269
|
+
6. After full completion, run `{config.ci}`:
|
|
270
|
+
- Pass: `"${CLAUDE_SKILL_DIR}/../../scripts/afc-pipeline-manage.sh" ci-pass`
|
|
271
|
+
- Fail: run `/afc:debug` logic inline (RCA → hypothesis → targeted fix → re-run). If debug-fix fails 3× → **abort**
|
|
635
272
|
|
|
636
273
|
#### Step 3.5: Acceptance Test Generation (conditional)
|
|
637
274
|
|
|
638
|
-
**Trigger
|
|
275
|
+
**Trigger**: spec.md has GWT acceptance scenarios AND `{config.test}` is non-empty.
|
|
639
276
|
|
|
640
|
-
|
|
641
|
-
1. Extract all GWT (Given/When/Then) acceptance scenarios from spec.md
|
|
642
|
-
2. Execute `/afc:test` logic inline — generate test cases from acceptance scenarios:
|
|
643
|
-
```
|
|
644
|
-
For each acceptance scenario in spec.md:
|
|
645
|
-
- Map GWT to a test case: Given → Arrange, When → Act, Then → Assert
|
|
646
|
-
- Target file: determined by the component/module referenced in the scenario
|
|
647
|
-
- Test file location: follows project convention (test framework from Project Context)
|
|
648
|
-
```
|
|
649
|
-
3. Run `{config.test}` to verify tests pass against the implementation
|
|
650
|
-
- If tests fail → this reveals a gap between spec and implementation:
|
|
651
|
-
- Fixable implementation issue → apply targeted fix
|
|
652
|
-
- Spec-implementation mismatch → record as SC shortfall for Review phase
|
|
653
|
-
4. Progress: ` ├─ Acceptance tests: {N} generated, {M} passing`
|
|
277
|
+
Map GWT → test cases (Given=Arrange, When=Act, Then=Assert). Run `{config.test}`. Failures reveal spec-implementation gaps — apply targeted fix or record as SC shortfall for Phase 4.
|
|
654
278
|
|
|
655
|
-
|
|
279
|
+
Progress: ` ├─ Acceptance tests: {N} generated, {M} passing`
|
|
656
280
|
|
|
657
281
|
#### Step 3.6: Implement Critic Loop
|
|
658
282
|
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
-
|
|
663
|
-
-
|
|
664
|
-
- **
|
|
665
|
-
-
|
|
666
|
-
- **Adversarial 3-perspective** (mandatory each pass):
|
|
667
|
-
- Skeptic: "Which implementation assumption is most likely wrong?"
|
|
668
|
-
- Devil's Advocate: "How could this implementation be misused or fail unexpectedly?"
|
|
669
|
-
- Edge-case Hunter: "What input would cause this implementation to fail silently?"
|
|
670
|
-
- State one failure scenario per perspective. If realistic → FAIL + fix. If unrealistic → state quantitative rationale.
|
|
671
|
-
- FAIL → auto-fix, re-run `{config.ci}`, and continue. ESCALATE → pause, present options, resume after response. DEFER → record reason, mark clean.
|
|
672
|
-
|
|
673
|
-
6. **Implement retrospective**: if unexpected problems arose that weren't predicted in Plan, record in `.claude/afc/specs/{feature}/retrospective.md` (for memory update in Clean)
|
|
674
|
-
7. **Checkpoint**: phase transition already recorded by `afc-pipeline-manage.sh phase implement` at phase start
|
|
675
|
-
8. Progress: `✓ 3/5 Implement complete ({completed}/{total} tasks, CI: ✓, Critic: converged ({N} passes, {M} fixes, {E} escalations))`
|
|
283
|
+
**Critic Loop until convergence** (safety cap: 5, follow `docs/critic-loop-rules.md`):
|
|
284
|
+
- SCOPE_ADHERENCE: `git diff` changed files vs plan.md File Change Map. "M of N files match" count required.
|
|
285
|
+
- ARCHITECTURE: changed files vs `{config.architecture}` rules. "N of M rules checked" count required.
|
|
286
|
+
- CORRECTNESS: cross-check against spec.md AC. "N of M AC verified" count required.
|
|
287
|
+
- SIDE_EFFECT_SAFETY: for call order/error handling/state flow changes — verify callee behavior compatibility by reading callee implementation directly.
|
|
288
|
+
- **Adversarial 3-perspective** (mandatory each pass): Skeptic / Devil's Advocate / Edge-case Hunter — one failure scenario each.
|
|
289
|
+
- Verdicts: follow `docs/critic-loop-rules.md`
|
|
676
290
|
|
|
677
|
-
|
|
291
|
+
7. If unexpected problems arose not predicted in Plan: record in `.claude/afc/specs/{feature}/retrospective.md`
|
|
292
|
+
8. Progress: `✓ 3/5 Implement complete ({completed}/{total} tasks, CI: ✓, Critic: converged ({N} passes, {M} fixes, {E} escalations))`
|
|
678
293
|
|
|
679
|
-
|
|
294
|
+
---
|
|
680
295
|
|
|
681
|
-
|
|
296
|
+
### Skill Advisor Checkpoint D (Post-Implement)
|
|
682
297
|
|
|
683
|
-
|
|
684
|
-
|---|----------|-----------|---------|-------|------|
|
|
685
|
-
| D1 | Were **testable source files changed without corresponding test coverage**? Look at `git diff --name-only` — for each changed source file, does a test file covering its behavior also appear in the diff? Consider the project's test convention and whether the changed files contain logic that should be tested (skip config files, types-only files, static assets). Only evaluate if `{config.test}` is non-empty. | 1=all changes have test coverage, 5=critical logic changed with zero tests | test generation (general-purpose fork) | Enrich |
|
|
686
|
-
| D2 | Based on **past pipeline quality data**, is there reason to believe this implementation has hidden quality issues? Check `.claude/afc/memory/quality-history/*.json` (if exists) — have recent pipelines shown elevated critical findings? Are there recurring problem categories that this feature's changed files might be susceptible to? | 1=clean history or no history, 5=strong pattern of recurring issues in similar areas | pre-review QA (general-purpose fork) | Observe |
|
|
298
|
+
> Evaluate AFTER Phase 3, BEFORE Phase 4. See `skills/auto/skill-advisor.md#checkpoint-d--post-implement` for full invocation patterns. Budget: max 2 skills. Skip if `ADVISOR_COUNT >= 5`.
|
|
687
299
|
|
|
688
|
-
|
|
689
|
-
1. Identify which changed source files lack test coverage — focus on files with meaningful logic (not config, not types, not assets):
|
|
690
|
-
```
|
|
691
|
-
For each changed source file:
|
|
692
|
-
- Does the project have a test file for it? (check test directory patterns)
|
|
693
|
-
- Was that test file also modified in this diff?
|
|
694
|
-
- Does the source file contain testable exports? (functions, classes, handlers)
|
|
695
|
-
→ List files that have testable logic but no test coverage in this diff
|
|
696
|
-
```
|
|
697
|
-
2. Invoke test generation (fork):
|
|
698
|
-
```
|
|
699
|
-
Task("Coverage boost: {feature}", subagent_type: "general-purpose",
|
|
700
|
-
prompt: "Generate missing tests for recently implemented files.
|
|
701
|
-
|
|
702
|
-
## Uncovered Files (testable logic, no test changes in this diff)
|
|
703
|
-
{list of uncovered source files with their full paths}
|
|
704
|
-
|
|
705
|
-
## Instructions
|
|
706
|
-
1. Read each uncovered file to understand its exports and behavior
|
|
707
|
-
2. Read existing test files in the project for pattern reference
|
|
708
|
-
3. Generate unit tests targeting:
|
|
709
|
-
- Exported functions/classes
|
|
710
|
-
- Edge cases and error paths
|
|
711
|
-
- Integration points (if the file calls other changed files)
|
|
712
|
-
4. Follow the project's test framework: {config.test framework}
|
|
713
|
-
5. Place test files following project convention
|
|
714
|
-
6. Run {config.test} to verify tests pass
|
|
715
|
-
7. Return: files created, test count, pass/fail status")
|
|
716
|
-
```
|
|
717
|
-
3. New test files automatically enter review scope (Phase 4)
|
|
718
|
-
4. Increment `ADVISOR_COUNT`
|
|
719
|
-
5. Progress: ` ├─ Skill Advisor [D]: test (score: {N}/5, {M} uncovered files → {K} test files generated)`
|
|
300
|
+
Signals: D1 (testable files changed without test coverage → test generation Enrich), D2 (historical quality issues → pre-review QA Observe).
|
|
720
301
|
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
## Changed Files
|
|
729
|
-
{git diff --name-only}
|
|
730
|
-
|
|
731
|
-
## Quality History Context
|
|
732
|
-
{summary of patterns from recent quality-history reports — categories, frequencies, affected file types}
|
|
733
|
-
|
|
734
|
-
## Instructions
|
|
735
|
-
1. Focus on the recurring problem categories identified above
|
|
736
|
-
2. Check: error handling completeness, input validation, resource cleanup
|
|
737
|
-
3. Format your response EXACTLY as:
|
|
738
|
-
## Pre-Review QA Findings
|
|
739
|
-
- [{severity}] {file}:{line} — {issue}: {suggested fix}
|
|
740
|
-
## Priority Hints for Review
|
|
741
|
-
- {file}: focus on {area} (historically problematic)
|
|
742
|
-
4. Read-only — do NOT modify any files")
|
|
743
|
-
```
|
|
744
|
-
3. Store output as `QA_FINDINGS` → injected into Phase 4 review context
|
|
745
|
-
4. Review phase uses "Priority Hints" to focus attention
|
|
746
|
-
5. Increment `ADVISOR_COUNT`
|
|
747
|
-
6. Progress: ` ├─ Skill Advisor [D]: qa (score: {N}/5, {M} priority hints for review)`
|
|
302
|
+
After advisor skill completes, append result summary to `context.md`:
|
|
303
|
+
```
|
|
304
|
+
## Advisor: {skill_name} (Checkpoint D)
|
|
305
|
+
- Insight: {1-line key finding}
|
|
306
|
+
- Action: {1-line required action or "none"}
|
|
307
|
+
```
|
|
748
308
|
|
|
749
|
-
|
|
309
|
+
---
|
|
750
310
|
|
|
751
311
|
### Phase 4: Review (4/5)
|
|
752
312
|
|
|
753
313
|
`"${CLAUDE_SKILL_DIR}/../../scripts/afc-pipeline-manage.sh" phase review`
|
|
754
314
|
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
**Context reload**: Re-read `.claude/afc/specs/{feature}/context.md` (contains full AC) and `.claude/afc/specs/{feature}/spec.md` to ensure spec context is available for SPEC_ALIGNMENT validation (these may have been compacted since Phase 1).
|
|
758
|
-
|
|
759
|
-
#### Step 4.1: Collect Review Targets
|
|
760
|
-
|
|
761
|
-
1. Collect changed files via `git diff HEAD`
|
|
762
|
-
2. Read **full content** of each changed file (not just the diff — full context needed for review)
|
|
315
|
+
Follow all review perspectives in `skills/review/SKILL.md` (A through H). **Context reload**: re-read `context.md` and `spec.md` before starting.
|
|
763
316
|
|
|
764
|
-
#### Step 4.2: Reverse Impact Analysis
|
|
765
|
-
|
|
766
|
-
Before reviewing, identify **files affected by the changes** (not just the changed files themselves):
|
|
767
|
-
|
|
768
|
-
1. **For each changed file**, find files that depend on it:
|
|
769
|
-
- **LSP (preferred)**: `LSP(findReferences)` on exported symbols — tracks type references, function calls, re-exports
|
|
770
|
-
- **Grep (fallback)**: `Grep` for `import.*{filename}`, `require.*{filename}`, `source.*{filename}` patterns across the codebase
|
|
771
|
-
- LSP and Grep are complementary — use both when LSP is available
|
|
772
|
-
|
|
773
|
-
2. **Build impact map**:
|
|
774
|
-
```
|
|
775
|
-
Impact Map:
|
|
776
|
-
├─ src/auth/login.ts (changed)
|
|
777
|
-
│ └─ affected: src/pages/LoginPage.tsx, src/middleware/auth.ts
|
|
778
|
-
└─ Total: {N} changed files → {M} affected files
|
|
779
|
-
```
|
|
317
|
+
#### Step 4.1–4.2: Collect Targets + Reverse Impact Analysis
|
|
780
318
|
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
4. **Limitations** (include in review output):
|
|
784
|
-
> ⚠ Dynamic dependencies not covered: runtime dispatch, reflection, cross-language calls, config/env-driven branching.
|
|
319
|
+
Collect changed files via `git diff HEAD` — read **full content** of each (not just diff). For each changed file, find dependents via LSP(findReferences) or Grep fallback. Build Impact Map. Affected files are cross-reference context, not full review targets.
|
|
785
320
|
|
|
786
321
|
#### Step 4.3: Scaled Review Orchestration
|
|
787
322
|
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
**Pre-scan: Call Chain Context** (for Parallel Batch and Review Swarm modes only):
|
|
791
|
-
Before distributing files to review agents, collect cross-boundary context:
|
|
792
|
-
1. For each changed file, identify **outbound calls** to other changed files (imports + function calls)
|
|
793
|
-
2. For each outbound call target, extract: function signature + 1-line side-effect summary
|
|
794
|
-
3. Include the **Impact Map** from Step 4.2 — each agent receives the list of affected files
|
|
795
|
-
4. Include this context in each review agent's prompt as `## Cross-File Context`
|
|
796
|
-
|
|
797
|
-
For Direct review mode (≤5 files): skip pre-scan — orchestrator already has full context.
|
|
323
|
+
**For Parallel Batch and Review Swarm only** — pre-scan: collect outbound call chain context and include Impact Map in each agent's `## Cross-File Context`.
|
|
798
324
|
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
Task("Review: {file3, file4}", subagent_type: "general-purpose")
|
|
805
|
-
```
|
|
806
|
-
|
|
807
|
-
**11+ files**: Review Swarm — group files into batches (2-3 per worker), spawn N review workers in a **single message** (N = min(5, file count / 2)). Review is read-only — no write race conditions.
|
|
325
|
+
| File count | Mode |
|
|
326
|
+
|------------|------|
|
|
327
|
+
| ≤5 | Direct review — no delegation |
|
|
328
|
+
| 6–10 | Parallel Batch — 2–3 files per agent, single message |
|
|
329
|
+
| 11+ | Review Swarm — N workers = min(5, file count / 2), single message |
|
|
808
330
|
|
|
809
331
|
#### Step 4.4: Specialist Agent Delegation (parallel, perspectives B and C)
|
|
810
332
|
|
|
811
|
-
Launch
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
prompt: "Review the following changed files for architecture compliance.
|
|
815
|
-
|
|
816
|
-
## Changed Files
|
|
817
|
-
{list of changed files from git diff}
|
|
818
|
-
|
|
819
|
-
## Architecture Rules
|
|
820
|
-
{config.architecture}
|
|
821
|
-
|
|
822
|
-
## Instructions
|
|
823
|
-
1. Read your MEMORY.md for prior architecture patterns and ADRs
|
|
824
|
-
2. Check each file against architecture rules (layer boundaries, naming, placement)
|
|
825
|
-
3. Cross-reference with ADRs recorded during Plan phase — any violations?
|
|
826
|
-
4. Return findings as: severity (Critical/Warning/Info), file:line, issue, suggested fix
|
|
827
|
-
5. Update your MEMORY.md with any new architecture patterns discovered")
|
|
828
|
-
|
|
829
|
-
Task("Security Review: {feature}", subagent_type: "afc:afc-security",
|
|
830
|
-
prompt: "Scan the following changed files for security vulnerabilities.
|
|
831
|
-
|
|
832
|
-
## Changed Files
|
|
833
|
-
{list of changed files from git diff}
|
|
834
|
-
|
|
835
|
-
## Instructions
|
|
836
|
-
1. Read your MEMORY.md for known vulnerability patterns and false positives
|
|
837
|
-
2. Check for: command injection, path traversal, unvalidated input, sensitive data exposure
|
|
838
|
-
3. Skip patterns recorded as false positives in your memory
|
|
839
|
-
4. Return findings as: severity (Critical/Warning/Info), file:line, issue, suggested fix
|
|
840
|
-
5. Include any new vulnerability patterns or confirmed false positives in your response (orchestrator will record them)")
|
|
841
|
-
```
|
|
842
|
-
- Collect agent outputs and merge into the consolidated review
|
|
843
|
-
- Agent findings inherit their severity classification directly
|
|
333
|
+
Launch in a **single message**:
|
|
334
|
+
- `afc:afc-architect` — architecture compliance vs rules and ADRs, update MEMORY.md
|
|
335
|
+
- `afc:afc-security` — vulnerability scan with false-positive awareness, update MEMORY.md
|
|
844
336
|
|
|
845
337
|
#### Step 4.5: Perform Review (8 perspectives)
|
|
846
338
|
|
|
847
|
-
|
|
848
|
-
- A. Code Quality — `{config.code_style}` compliance (direct review)
|
|
849
|
-
- B. Architecture — **delegated to afc-architect agent** (persistent memory, ADR-aware)
|
|
850
|
-
- C. Security — **delegated to afc-security agent** (persistent memory, false-positive-aware)
|
|
851
|
-
- D. Performance — framework-specific patterns from Project Context (direct review)
|
|
852
|
-
- E. Project Pattern Compliance — conventions and idioms (direct review)
|
|
853
|
-
- **F. Reusability** — DRY, shared utilities, abstraction level (direct review)
|
|
854
|
-
- **G. Maintainability** — AI/human comprehension, naming clarity, self-contained files (direct review)
|
|
855
|
-
- **H. Extensibility** — extension points, OCP, future modification cost (direct review)
|
|
339
|
+
A. Code Quality (`{config.code_style}`, direct), B. Architecture (delegated), C. Security (delegated), D. Performance (direct), E. Pattern Compliance (direct), F. Reusability (direct), G. Maintainability (direct), H. Extensibility (direct).
|
|
856
340
|
|
|
857
341
|
#### Step 4.6: Cross-Boundary Verification (MANDATORY)
|
|
858
342
|
|
|
859
|
-
After
|
|
343
|
+
After all reviews complete, orchestrator MUST verify behavioral findings. **Not optional — skipping is a review defect.**
|
|
860
344
|
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
1. **Filter**: From all collected findings, select those involving:
|
|
866
|
-
- Call order changes (function A now calls B before C)
|
|
867
|
-
- Error handling modifications (try/catch scope changes, error propagation changes)
|
|
868
|
-
- State mutation changes (new writes to shared state, removed cleanup)
|
|
869
|
-
|
|
870
|
-
2. **Verify**: For each behavioral finding rated Critical or Warning:
|
|
871
|
-
- **Read the callee's implementation** (the function/method being called) — this read is mandatory, not optional
|
|
872
|
-
- **Skip external dependencies**: If the callee is in `node_modules/`, `vendor/`, or other third-party directories, verify against type definitions or documented API contract instead. Note: "verified against types/docs, not source"
|
|
873
|
-
- Check: does the callee's internal behavior (side effects, state changes, return values) actually conflict with the change?
|
|
874
|
-
- If no conflict → downgrade: Critical → Info, Warning → Info (append "verified: no cross-boundary impact")
|
|
875
|
-
- If confirmed conflict → keep severity, enrich description with callee behavior details
|
|
876
|
-
|
|
877
|
-
3. **False positive reference** (security-related findings only): Check `afc-security` agent's MEMORY.md `## False Positives` section if it exists. Known false positive patterns should be noted in findings.
|
|
878
|
-
|
|
879
|
-
4. **Output**: Append verification summary before Review Output:
|
|
880
|
-
```
|
|
881
|
-
Cross-Boundary Check: {N} behavioral findings verified
|
|
882
|
-
├─ Confirmed: {M} (severity kept)
|
|
883
|
-
├─ Downgraded: {K} (false positive — callee compatible)
|
|
884
|
-
└─ Skipped: {J} (no behavioral change)
|
|
885
|
-
```
|
|
886
|
-
|
|
887
|
-
This step runs in the orchestrator context (not delegated), as it requires reading code across file boundaries.
|
|
345
|
+
1. Filter findings involving: call order changes, error handling modifications, state mutation changes
|
|
346
|
+
2. For each Critical or Warning behavioral finding: **read the callee implementation** (skip if in `node_modules/`/`vendor/` — verify against types/docs instead)
|
|
347
|
+
3. No conflict → downgrade to Info ("verified: no cross-boundary impact"). Confirmed conflict → keep severity with callee behavior details.
|
|
348
|
+
4. Output cross-boundary check summary before Review Output.
|
|
888
349
|
|
|
889
350
|
#### Step 4.7: Inject Advisor Context
|
|
890
351
|
|
|
891
|
-
If Checkpoint D produced
|
|
892
|
-
- **`QA_FINDINGS`** (from D2): read the stored findings and include as "Priority Hints for Review" — focus review attention on historically problematic areas and pre-identified quality concerns.
|
|
893
|
-
- **New test files** (from D1): include in the review scope alongside implementation changes.
|
|
352
|
+
If Checkpoint D produced `QA_FINDINGS` → include as Priority Hints. New test files (from D1) → include in review scope.
|
|
894
353
|
|
|
895
354
|
#### Step 4.8: Auto-specific Validations
|
|
896
355
|
|
|
897
|
-
1.
|
|
898
|
-
2.
|
|
899
|
-
3.
|
|
900
|
-
- Were there recurring Critical finding categories in past reviews? Prioritize those perspectives.
|
|
901
|
-
- Were there false positives that wasted effort? Reduce sensitivity for those patterns.
|
|
902
|
-
|
|
903
|
-
#### Step 4.9: Critic Loop
|
|
904
|
-
|
|
905
|
-
> **Always** read `${CLAUDE_SKILL_DIR}/../../docs/critic-loop-rules.md` first and follow it.
|
|
906
|
-
|
|
907
|
-
**Critic Loop until convergence** (safety cap: 5, follow Critic Loop rules):
|
|
908
|
-
- COMPLETENESS: were all changed files reviewed across all 8 perspectives (A-H)?
|
|
909
|
-
- SPEC_ALIGNMENT: cross-check implementation against spec.md — (1) every SC verified with `{M}/{N}` count, (2) every acceptance scenario (GWT) has corresponding code path, (3) no spec constraint is violated
|
|
910
|
-
- SIDE_EFFECT_AWARENESS: For findings involving call order changes, error handling modifications, or state mutation changes: did the reviewer verify the callee's internal behavior? If a Critical finding assumes a side effect without reading the target implementation → auto-downgrade to Info with note "cross-boundary unverified". Provide "{M} of {N} behavioral findings verified" count.
|
|
911
|
-
- PRECISION: are there unnecessary changes? Are there out-of-scope modifications? Are findings actual issues, not false positives?
|
|
912
|
-
- FAIL → auto-fix and continue. ESCALATE → pause, present options, resume after response. DEFER → record reason, mark clean.
|
|
913
|
-
|
|
914
|
-
#### Step 4.10: Handling SC shortfalls
|
|
915
|
-
|
|
916
|
-
- Fixable → attempt auto-fix → re-run `{config.ci}` verification
|
|
917
|
-
- Not fixable → state in final report with reason (no post-hoc rationalization; record as Plan-phase target-setting error)
|
|
918
|
-
|
|
919
|
-
#### Step 4.11: Retrospective Entry (if new pattern found)
|
|
920
|
-
|
|
921
|
-
If this review reveals a recurring pattern not previously documented in `.claude/afc/memory/retrospectives/`:
|
|
922
|
-
|
|
923
|
-
Append to `.claude/afc/memory/retrospectives/{YYYY-MM-DD}.md`:
|
|
924
|
-
```markdown
|
|
925
|
-
## Pattern: {category}
|
|
926
|
-
**What happened**: {concrete description}
|
|
927
|
-
**Root cause**: {why this keeps occurring}
|
|
928
|
-
**Prevention rule**: {actionable rule — usable in future plan/implement phases}
|
|
929
|
-
**Severity**: Critical | Warning
|
|
930
|
-
```
|
|
931
|
-
|
|
932
|
-
Only write if the pattern is new and actionable. Generic observations are prohibited.
|
|
933
|
-
|
|
934
|
-
#### Step 4.12: Archive Review Report
|
|
356
|
+
1. Check all `[AUTO-RESOLVED]` items — does implementation match the guess? Mismatches → Critical.
|
|
357
|
+
2. Load most recent 15 `.claude/afc/memory/reviews/` files — scan for recurring finding patterns.
|
|
358
|
+
3. Load most recent 10 `.claude/afc/memory/retrospectives/` files — apply prevention rules.
|
|
935
359
|
|
|
936
|
-
|
|
360
|
+
#### Step 4.9: Review Critic Loop
|
|
937
361
|
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
> Files reviewed: {count}
|
|
944
|
-
> Findings: Critical {N} / Warning {N} / Info {N}
|
|
945
|
-
```
|
|
946
|
-
3. This file is copied to `.claude/afc/memory/reviews/{feature}-{date}.md` during Clean phase before .claude/afc/specs/ deletion.
|
|
362
|
+
**Critic Loop until convergence** (safety cap: 5, follow `docs/critic-loop-rules.md`):
|
|
363
|
+
- COMPLETENESS: all changed files reviewed across A-H?
|
|
364
|
+
- SPEC_ALIGNMENT: every SC verified `{M}/{N}`, every GWT has code path, no spec constraint violated?
|
|
365
|
+
- SIDE_EFFECT_AWARENESS: behavioral findings cross-boundary verified? `{M} of {N} verified` count required.
|
|
366
|
+
- PRECISION: unnecessary changes? out-of-scope modifications? false positives?
|
|
947
367
|
|
|
948
|
-
#### Step 4.12:
|
|
368
|
+
#### Step 4.10–4.12: SC Shortfalls, Retrospective, Archive
|
|
949
369
|
|
|
950
|
-
- **
|
|
370
|
+
- **SC shortfalls**: fixable → auto-fix + re-run CI. Not fixable → state in report as Plan-phase error.
|
|
371
|
+
- **Retrospective**: if new recurring pattern found, append to `.claude/afc/memory/retrospectives/{YYYY-MM-DD}.md` (concrete + root cause + prevention rule + severity).
|
|
372
|
+
- **Archive**: write full review to `review-report.md` (copied to `.claude/afc/memory/reviews/{feature}-{date}.md` in Clean).
|
|
951
373
|
- Progress: `✓ 4/5 Review complete (Critical:{N} Warning:{N} Info:{N}, Cross-boundary: {M} verified, SC shortfalls: {N})`
|
|
952
374
|
|
|
953
|
-
|
|
375
|
+
---
|
|
954
376
|
|
|
955
|
-
|
|
377
|
+
### Skill Advisor Checkpoint E (Post-Review)
|
|
956
378
|
|
|
957
|
-
|
|
379
|
+
> Evaluate AFTER Phase 4, BEFORE Phase 5. See `skills/auto/skill-advisor.md#checkpoint-e--post-review` for full invocation patterns. Budget: max 1 skill. Skip if `ADVISOR_COUNT >= 5`.
|
|
958
380
|
|
|
959
|
-
|
|
960
|
-
|---|----------|-----------|---------|-------|------|
|
|
961
|
-
| E1 | Are there **recurring problem patterns** across this and past pipelines that should be codified as project rules? Check `.claude/afc/memory/retrospectives/` — do the same types of issues (e.g., "missing error handling in hooks", "forgotten spec file updates") keep appearing? Also consider: did this pipeline's review reveal issues that match past retrospective patterns? | 1=no retrospective history or no patterns, 5=same issue type recurred 3+ times and is not yet a project rule | pattern promotion (general-purpose fork, with learner guardrails) | Observe |
|
|
381
|
+
Signal: E1 (recurring problem patterns → learner Observe).
|
|
962
382
|
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
```
|
|
970
|
-
Task("Pattern promotion: {feature}", subagent_type: "general-purpose",
|
|
971
|
-
prompt: "Review recurring patterns for potential promotion to project rules.
|
|
972
|
-
|
|
973
|
-
## Recurring Patterns
|
|
974
|
-
{list each pattern with: category, occurrence count, concrete examples from retrospective entries}
|
|
975
|
-
|
|
976
|
-
## Current Review Findings
|
|
977
|
-
{summary of this pipeline's review findings that match retrospective patterns}
|
|
978
|
-
|
|
979
|
-
## Current Rules
|
|
980
|
-
{read .claude/rules/afc-learned.md if it exists, else 'No learned rules yet'}
|
|
981
|
-
|
|
982
|
-
## Instructions
|
|
983
|
-
1. For each recurring pattern, evaluate:
|
|
984
|
-
- Is it actionable? (specific enough to enforce)
|
|
985
|
-
- Is it already covered by existing rules?
|
|
986
|
-
- Would enforcing it have prevented the recurrence?
|
|
987
|
-
2. For patterns worth promoting, write a rule in this format:
|
|
988
|
-
### {Category}
|
|
989
|
-
- **Rule**: {concise, enforceable statement}
|
|
990
|
-
- **Rationale**: {why — based on {N} occurrences across pipelines}
|
|
991
|
-
- **Enforcement**: {how to check — linter, review criterion, or convention}
|
|
992
|
-
3. **Safety guardrails** (mandatory):
|
|
993
|
-
- Do NOT create rules about: permissions, security policies, hook behavior, tool access
|
|
994
|
-
- Do NOT create rules that contradict existing CLAUDE.md or .claude/rules/ content
|
|
995
|
-
- Each rule must be scoped to code conventions only (naming, style, workflow, testing, architecture)
|
|
996
|
-
- Verify no duplicate or contradictory rule exists before appending
|
|
997
|
-
4. Append new rules to .claude/rules/afc-learned.md (create if absent)
|
|
998
|
-
5. Do NOT duplicate existing rules
|
|
999
|
-
6. Return: {N} patterns evaluated, {M} promoted, {K} already covered")
|
|
1000
|
-
```
|
|
1001
|
-
3. Increment `ADVISOR_COUNT`
|
|
1002
|
-
4. Progress: ` ├─ Skill Advisor [E]: learner (score: {N}/5, {M} patterns evaluated, {K} promoted to rules)`
|
|
383
|
+
After advisor skill completes, append result summary to `context.md`:
|
|
384
|
+
```
|
|
385
|
+
## Advisor: {skill_name} (Checkpoint E)
|
|
386
|
+
- Insight: {1-line key finding}
|
|
387
|
+
- Action: {1-line required action or "none"}
|
|
388
|
+
```
|
|
1003
389
|
|
|
1004
|
-
|
|
390
|
+
---
|
|
1005
391
|
|
|
1006
392
|
### Phase 5: Clean (5/5)
|
|
1007
393
|
|
|
1008
394
|
`"${CLAUDE_SKILL_DIR}/../../scripts/afc-pipeline-manage.sh" phase clean`
|
|
1009
395
|
|
|
1010
|
-
Artifact cleanup
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
-
|
|
1015
|
-
-
|
|
1016
|
-
|
|
1017
|
-
-
|
|
1018
|
-
-
|
|
1019
|
-
-
|
|
1020
|
-
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
- Auto-fix on failure (max 2 attempts)
|
|
1025
|
-
4. **Memory update** (if applicable):
|
|
1026
|
-
- Reusable patterns found during pipeline → record in `.claude/afc/memory/`
|
|
1027
|
-
- If there were `[AUTO-RESOLVED]` items → record decisions in `.claude/afc/memory/decisions/`
|
|
1028
|
-
- **If retrospective.md exists** → record as patterns missed by the Plan phase Critic Loop in `.claude/afc/memory/retrospectives/` (reuse as RISK checklist items in future runs)
|
|
1029
|
-
- **If review-report.md exists** → copy to `.claude/afc/memory/reviews/{feature}-{date}.md` before .claude/afc/specs/ deletion
|
|
1030
|
-
- **If research.md exists** and was not already persisted in Plan phase → copy to `.claude/afc/memory/research/{feature}.md`
|
|
1031
|
-
- **Agent memory consolidation**: Check each agent's MEMORY.md for bloat — if it contains redundant, obsolete, or superseded entries that reduce signal-to-noise ratio, invoke the agent to self-prune:
|
|
1032
|
-
```
|
|
1033
|
-
Task("Memory cleanup: afc-architect", subagent_type: "afc:afc-architect",
|
|
1034
|
-
prompt: "Review your MEMORY.md. Read it, identify and prune old/redundant/obsolete entries, and rewrite it keeping only entries that are still relevant and non-overlapping.")
|
|
1035
|
-
```
|
|
1036
|
-
Use semantic assessment (are entries still relevant? do entries overlap?) rather than a line-count threshold. (Same pattern for afc-security if needed.)
|
|
1037
|
-
- **Memory rotation**: For each memory subdirectory, assess whether the oldest files still provide value. Prune files that are superseded by newer entries, reference features/code that no longer exists, or overlap with other files. As a practical guideline, keep the most recent and relevant entries — if a directory has grown large enough that scanning it would be slow (roughly 30+ files), prioritize pruning the least relevant entries:
|
|
1038
|
-
| Directory | Pruning Intent | Soft Guideline |
|
|
1039
|
-
|-----------|---------------|----------------|
|
|
1040
|
-
| `quality-history/` | Remove superseded or redundant quality records | ~30 files |
|
|
1041
|
-
| `reviews/` | Remove reviews for features no longer in the codebase | ~40 files |
|
|
1042
|
-
| `retrospectives/` | Remove retrospectives whose learnings are already captured elsewhere | ~30 files |
|
|
1043
|
-
| `research/` | Remove research for libraries/patterns no longer used | ~50 files |
|
|
1044
|
-
| `decisions/` | Remove decisions that have been reversed or are no longer relevant | ~60 files |
|
|
1045
|
-
- These numbers are soft guidelines, not hard cutoffs — use judgment based on relevance
|
|
1046
|
-
- Sort by filename ascending (oldest first) when pruning by recency
|
|
1047
|
-
- Log: `"Memory rotation: {dir} pruned {N} files"`
|
|
1048
|
-
- Skip directories that do not exist or clearly do not need pruning
|
|
1049
|
-
5. **Quality report** (structured pipeline metrics):
|
|
1050
|
-
- Generate `.claude/afc/memory/quality-history/{feature}-{date}.json` with the following structure:
|
|
1051
|
-
```json
|
|
1052
|
-
{
|
|
1053
|
-
"feature": "{feature}",
|
|
1054
|
-
"date": "{YYYY-MM-DD}",
|
|
1055
|
-
"phases": {
|
|
1056
|
-
"clarify": { "triggered": true/false, "questions": N, "auto_resolved": N },
|
|
1057
|
-
"spec": { "user_stories": N, "requirements": { "FR": N, "NFR": N }, "researched": N, "auto_resolved": N, "critic_passes": N, "critic_fixes": N, "escalations": N },
|
|
1058
|
-
"plan": { "files_planned": N, "implementation_context_words": N, "adr_recorded": N, "adr_conflicts": N, "research_persisted": true/false, "critic_passes": N, "critic_fixes": N, "escalations": N },
|
|
1059
|
-
"implement": {
|
|
1060
|
-
"tasks": { "total": N, "parallel": N, "phases": N },
|
|
1061
|
-
"test_pre_gen": { "triggered": true/false, "skeletons": N },
|
|
1062
|
-
"blast_radius": { "triggered": true/false, "dependents": N, "high_fan_out": N },
|
|
1063
|
-
"completed": N, "total": N, "ci_passes": N, "ci_failures": N,
|
|
1064
|
-
"acceptance_tests": { "triggered": true/false, "generated": N, "passing": N },
|
|
1065
|
-
"debug_rca": { "triggered": true/false, "cycles": N },
|
|
1066
|
-
"critic_passes": N, "critic_fixes": N, "escalations": N
|
|
1067
|
-
},
|
|
1068
|
-
"review": { "critical": N, "warning": N, "info": N, "sc_shortfalls": N, "auto_resolved_mismatches": N,
|
|
1069
|
-
"architect_agent": { "invoked": true/false, "findings": N },
|
|
1070
|
-
"security_agent": { "invoked": true/false, "findings": N },
|
|
1071
|
-
"critic_passes": N, "critic_fixes": N, "escalations": N }
|
|
1072
|
-
},
|
|
1073
|
-
"totals": { "changed_files": N, "auto_resolved": N, "escalations": N, "totalPromptCount": N }
|
|
1074
|
-
}
|
|
1075
|
-
```
|
|
1076
|
-
- Create `.claude/afc/memory/quality-history/` directory if it does not exist
|
|
1077
|
-
6. **Checkpoint reset**:
|
|
1078
|
-
- Clear `.claude/afc/memory/checkpoint.md` **and** `~/.claude/projects/{ENCODED_PATH}/memory/checkpoint.md` (pipeline complete = session goal achieved, dual-delete prevents stale checkpoint in either location; `ENCODED_PATH` = project path with `/` replaced by `-`)
|
|
1079
|
-
7. **Timeline finalize**:
|
|
396
|
+
1. **Artifact cleanup**: delete only `.claude/afc/specs/{feature}/` (current pipeline). Do not delete other subdirectories.
|
|
397
|
+
2. **Dead code scan**: run `{config.gate}` / `{config.ci}` first (linters detect unused imports/variables). Use dedicated tools (`ts-prune`, `knip`) before LLM-based scan. Remove empty directories.
|
|
398
|
+
3. **Final CI gate**: run `{config.ci}`. Auto-fix on failure (max 2 attempts).
|
|
399
|
+
4. **Memory update**:
|
|
400
|
+
- Reusable patterns → `.claude/afc/memory/`
|
|
401
|
+
- `[AUTO-RESOLVED]` items → `.claude/afc/memory/decisions/`
|
|
402
|
+
- `retrospective.md` → `.claude/afc/memory/retrospectives/`
|
|
403
|
+
- `review-report.md` → `.claude/afc/memory/reviews/{feature}-{date}.md`
|
|
404
|
+
- `research.md` (if not already persisted) → `.claude/afc/memory/research/{feature}.md`
|
|
405
|
+
- **Agent memory consolidation**: if architect/security MEMORY.md has redundant entries, invoke agent for self-pruning
|
|
406
|
+
- **Memory rotation**: prune oldest files when directories grow large (soft guidelines: quality-history ~30, reviews ~40, retrospectives ~30, research ~50, decisions ~60). Use relevance judgment, not hard cutoffs.
|
|
407
|
+
5. **Quality report**: write `.claude/afc/memory/quality-history/{feature}-{date}.json` with full phase metrics (clarify, spec, plan, implement, review, totals).
|
|
408
|
+
6. **Checkpoint reset**: clear `.claude/afc/memory/checkpoint.md` AND `~/.claude/projects/{ENCODED_PATH}/memory/checkpoint.md`
|
|
409
|
+
7. **Timeline finalize + release pipeline flag**:
|
|
1080
410
|
```bash
|
|
1081
411
|
"${CLAUDE_SKILL_DIR}/../../scripts/afc-pipeline-manage.sh" log pipeline-end "Pipeline complete: {feature}"
|
|
1082
|
-
```
|
|
1083
|
-
8. **Release Pipeline Flag** (hook integration):
|
|
1084
|
-
```bash
|
|
1085
412
|
"${CLAUDE_SKILL_DIR}/../../scripts/afc-pipeline-manage.sh" end
|
|
1086
413
|
```
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
- Phase rollback tags removed (handled automatically by pipeline end)
|
|
1091
|
-
9. **Checkpoint**: phase transition already recorded by `afc-pipeline-manage.sh phase clean` at phase start
|
|
1092
|
-
10. Progress: `✓ 5/5 Clean complete (deleted: {N}, dead code: {N}, CI: ✓)`
|
|
414
|
+
8. Progress: `✓ 5/5 Clean complete (deleted: {N}, dead code: {N}, CI: ✓)`
|
|
415
|
+
|
|
416
|
+
---
|
|
1093
417
|
|
|
1094
418
|
### Final Output
|
|
1095
419
|
|
|
@@ -1114,12 +438,13 @@ Auto pipeline complete: {feature}
|
|
|
1114
438
|
└─ .claude/afc/specs/{feature}/ cleaned up
|
|
1115
439
|
```
|
|
1116
440
|
|
|
1117
|
-
|
|
441
|
+
---
|
|
1118
442
|
|
|
1119
|
-
|
|
443
|
+
## Abort Conditions
|
|
1120
444
|
|
|
445
|
+
Abort and report to user when:
|
|
1121
446
|
1. `{config.ci}` fails 3 consecutive times
|
|
1122
|
-
2. File conflict during implementation (overlaps
|
|
447
|
+
2. File conflict during implementation (overlaps from another branch)
|
|
1123
448
|
3. Critical security issue found (cannot auto-fix)
|
|
1124
449
|
|
|
1125
450
|
On abort:
|
|
@@ -1127,30 +452,23 @@ On abort:
|
|
|
1127
452
|
Pipeline aborted (Phase {N}/5)
|
|
1128
453
|
├─ Reason: {abort cause}
|
|
1129
454
|
├─ Completed phases: {completed list}
|
|
1130
|
-
├─ Rollback: git reset --hard afc/pre-auto
|
|
455
|
+
├─ Rollback: git reset --hard afc/pre-auto
|
|
1131
456
|
├─ Checkpoint: .claude/afc/memory/checkpoint.md (last phase gate passed)
|
|
1132
|
-
├─ Artifacts: .claude/afc/specs/{feature}/ (partial
|
|
457
|
+
├─ Artifacts: .claude/afc/specs/{feature}/ (partial — manual deletion needed if Clean did not run)
|
|
1133
458
|
└─ Resume: /afc:resume → /afc:implement (checkpoint-based)
|
|
1134
459
|
```
|
|
1135
460
|
|
|
461
|
+
---
|
|
462
|
+
|
|
1136
463
|
## Notes
|
|
1137
464
|
|
|
1138
|
-
- **Full auto does not mean uncritical**: Phase 0.3 Request Triage may reject
|
|
1139
|
-
- **
|
|
1140
|
-
- **
|
|
1141
|
-
- **
|
|
1142
|
-
- **
|
|
1143
|
-
- **
|
|
1144
|
-
- **
|
|
1145
|
-
- **
|
|
1146
|
-
- **Tasks phase is absorbed**: tasks.md is generated automatically at implement start from plan.md's File Change Map. No separate tasks phase or tasks critic loop. Validation is script-based (DAG + parallel overlap checks).
|
|
1147
|
-
- **[P] parallel is mandatory**: if a [P] marker is assigned in tasks.md, it must be executed in parallel. Orchestration mode (batch vs swarm) is selected automatically based on task count. Sequential substitution is prohibited.
|
|
1148
|
-
- **Swarm mode is automatic**: when a phase has 6+ [P] tasks, the orchestrator pre-assigns tasks to swarm workers. Do not manually batch.
|
|
1149
|
-
- **Implementation Context travels with workers**: every sub-agent prompt includes the Implementation Context section from plan.md, ensuring spec intent propagates to parallel workers.
|
|
1150
|
-
- **Session context resilience**: key decisions are written to `.claude/afc/specs/{feature}/context.md` at Plan completion and read at Implement start, surviving context compaction.
|
|
1151
|
-
- **Specialist agents enhance review**: afc-architect and afc-security agents are invoked during Review to provide persistent-memory-aware analysis. Their findings are merged into the consolidated review. Agent memory updates happen automatically during the agent call.
|
|
1152
|
-
- **Debug-based RCA replaces blind retry**: CI failures trigger `/afc:debug` logic (hypothesis → targeted fix) instead of generic "retry 3 times". This produces better fixes and records patterns via retrospective.
|
|
1153
|
-
- **Acceptance tests close the spec-to-code gap**: When spec contains GWT scenarios and a test framework is configured, acceptance tests are auto-generated after implementation, verifying spec intent is met.
|
|
1154
|
-
- **Research and ADR persist across sessions**: Research findings are saved to `.claude/afc/memory/research/`, ADRs to architect agent memory. Future pipelines can reference these to avoid re-research and detect conflicts.
|
|
1155
|
-
- **No out-of-scope deletion**: do not delete files/directories in Clean that were not created by the current pipeline.
|
|
465
|
+
- **Full auto does not mean uncritical**: Phase 0.3 Request Triage may reject/reduce/redirect before investing resources.
|
|
466
|
+
- **[AUTO-RESOLVED] items**: estimates only — review after the fact is recommended.
|
|
467
|
+
- **Large feature warning**: warn before starting if 5+ User Stories are expected.
|
|
468
|
+
- **Read existing code first**: always read existing files before modifying.
|
|
469
|
+
- **[P] parallel is mandatory**: if a `[P]` marker is assigned in tasks.md, it must execute in parallel. Sequential substitution is prohibited.
|
|
470
|
+
- **Implementation Context travels with workers**: every sub-agent prompt includes plan.md `## Implementation Context`.
|
|
471
|
+
- **Session context resilience**: `context.md` is written at Plan completion and read at Implement start (survives context compaction).
|
|
472
|
+
- **Debug-based RCA replaces blind retry**: CI failures trigger `/afc:debug` logic.
|
|
1156
473
|
- **NEVER use `run_in_background: true` on Task calls**: agents must run in foreground so results are returned before the next step.
|
|
474
|
+
- **Orchestration mode details**: see `docs/orchestration-modes.md` for sequential/batch/swarm specifics.
|