all-for-claudecode 2.2.0 → 2.3.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.
@@ -6,14 +6,14 @@
6
6
  },
7
7
  "metadata": {
8
8
  "description": "Automated pipeline for Claude Code — spec → plan → implement → review → clean",
9
- "version": "2.2.0"
9
+ "version": "2.3.0"
10
10
  },
11
11
  "plugins": [
12
12
  {
13
13
  "name": "afc",
14
14
  "source": "./",
15
15
  "description": "Automated pipeline for Claude Code. Automates the full development cycle: spec → plan → implement → review → clean.",
16
- "version": "2.2.0",
16
+ "version": "2.3.0",
17
17
  "category": "automation",
18
18
  "tags": ["pipeline", "automation", "spec", "plan", "implement", "review", "critic-loop"]
19
19
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "afc",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "description": "Automated pipeline for Claude Code. Automates the full development cycle: spec → plan → implement → review → clean.",
5
5
  "author": { "name": "jhlee0409", "email": "relee6203@gmail.com" },
6
6
  "homepage": "https://github.com/jhlee0409/all-for-claudecode",
package/MIGRATION.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Migration Guide
2
2
 
3
+ ## v2.3.0 — Memory Management + analyze/validate Split
4
+
5
+ ### What Changed
6
+
7
+ | Item | Before (v2.2.x) | After (v2.3.0) |
8
+ |------|-----------------|----------------|
9
+ | `/afc:analyze` | Artifact consistency check (= validate) | General-purpose code analysis (user-invocable, sonnet, context: fork) |
10
+ | `/afc:validate` | Did not exist separately | Artifact consistency check (model-only, haiku) |
11
+ | Agent MEMORY.md | Unbounded size | 100-line limit with auto-pruning |
12
+ | Memory directories | Unbounded file accumulation | Loading limits (most recent N files) + rotation in Clean phase |
13
+ | `/afc:doctor` Category 6 | Hook Health | Memory Health (new); Hook Health → 7, Version Sync → 8 |
14
+ | Checkpoint writes | Single location | Dual-write (project memory + auto-memory) |
15
+
16
+ ### Migration Steps
17
+
18
+ **No action required for most users.** Changes are backwards-compatible and auto-applied.
19
+
20
+ - If you previously used `/afc:analyze` for artifact consistency checking, use `/afc:validate` instead (or let the pipeline invoke it automatically).
21
+ - Agent memory files (`.claude/agent-memory/afc-architect/MEMORY.md`, `.claude/agent-memory/afc-security/MEMORY.md`) exceeding 100 lines will be auto-pruned on next pipeline run.
22
+ - Memory subdirectories exceeding rotation thresholds will be auto-pruned during the Clean phase.
23
+ - Run `/afc:init` to update the `AFC:VERSION` tag in your CLAUDE.md.
24
+
25
+ ---
26
+
3
27
  ## v2.0 — Rebrand: selfish-pipeline → all-for-claudecode
4
28
 
5
29
  > all-for-claudecode v2.0 renames the package, plugin prefix, scripts, agents, and state files from `selfish` to `afc`.
package/README.md CHANGED
@@ -56,6 +56,47 @@ CI failure → debug-based RCA (not blind retry).
56
56
  Critic Loops verify quality at each gate until convergence.
57
57
  ```
58
58
 
59
+ ## Walkthrough: What a Pipeline Run Looks Like
60
+
61
+ Running `/afc:auto "Add password reset flow"` produces this (abbreviated):
62
+
63
+ **Spec (1/5)** — Generates `spec.md` with requirements and acceptance criteria:
64
+ ```
65
+ FR-001: POST /auth/reset sends email with token
66
+ FR-002: GET /auth/reset/:token validates and shows form
67
+ FR-003: Token expires after 1 hour
68
+ Acceptance: Given expired token, When user submits, Then show error
69
+ ```
70
+
71
+ **Plan (2/5)** — Creates `plan.md` with file change map and architecture decisions:
72
+ ```
73
+ File Change Map:
74
+ src/routes/auth.ts — ADD reset endpoint handlers
75
+ src/services/email.ts — ADD sendResetEmail()
76
+ src/middleware/validate.ts — MODIFY add token validation
77
+ tests/auth.test.ts — ADD reset flow tests
78
+ ```
79
+
80
+ **Implement (3/5)** — Auto-decomposes into tasks, executes with CI gates:
81
+ ```
82
+ Tasks: 4 total (2 parallel)
83
+ [1] Add reset endpoint ✓
84
+ [2] Add email service ✓ ← parallel with [1]
85
+ [3] Add token validation ✓ ← depends on [1]
86
+ [4] Add tests ✓
87
+ CI: npm test → passed
88
+ ```
89
+
90
+ **Review (4/5)** — 8-perspective review + specialist agent analysis:
91
+ ```
92
+ Architecture (afc-architect): ✓ layer boundaries respected
93
+ Security (afc-security): ⚠ rate-limit reset endpoint
94
+ Performance: ✓ no N+1 queries
95
+ → Auto-fixed: added rate limiter middleware
96
+ ```
97
+
98
+ **Clean (5/5)** — Removes pipeline artifacts, final CI check.
99
+
59
100
  ## Slash Commands
60
101
 
61
102
  | Command | Description |
@@ -76,9 +117,31 @@ Critic Loops verify quality at each gate until convergence.
76
117
  | `/afc:checkpoint` | Save session state |
77
118
  | `/afc:resume` | Restore session state |
78
119
  | `/afc:tasks` | Task decomposition (auto-generated by implement) |
79
- | `/afc:analyze` | Verify artifact consistency |
120
+ | `/afc:ideate` | Explore and structure a product idea |
121
+ | `/afc:launch` | Generate release artifacts (changelog, tag, publish) |
122
+ | `/afc:validate` | Verify artifact consistency |
123
+ | `/afc:analyze` | General-purpose code and component analysis |
80
124
  | `/afc:clarify` | Resolve spec ambiguities |
81
125
 
126
+ ### Individual Command Examples
127
+
128
+ ```bash
129
+ # Write a spec for a specific feature
130
+ /afc:spec "Add dark mode toggle"
131
+
132
+ # Design a plan from an existing spec
133
+ /afc:plan
134
+
135
+ # Debug a specific error
136
+ /afc:debug "TypeError: Cannot read property 'user' of undefined"
137
+
138
+ # Run code review on current changes
139
+ /afc:review
140
+
141
+ # Explore and structure a product idea
142
+ /afc:ideate "real-time collaboration feature"
143
+ ```
144
+
82
145
  ## Hook Events
83
146
 
84
147
  Every hook fires automatically — no configuration needed after install.
@@ -90,7 +153,7 @@ Every hook fires automatically — no configuration needed after install.
90
153
  | `PreToolUse` | Blocks dangerous commands (`push --force`, `reset --hard`) |
91
154
  | `PostToolUse` | Tracks file changes + auto-formats code |
92
155
  | `SubagentStart` | Injects pipeline context into subagents |
93
- | `Stop` | CI gate (shell) + code completeness check (agent) |
156
+ | `Stop` | CI gate (shell) + code completeness check (shell) |
94
157
  | `SessionEnd` | Warns about unfinished pipeline |
95
158
  | `PostToolUseFailure` | Diagnostic hints for known error patterns |
96
159
  | `Notification` | Desktop alerts (macOS/Linux) |
@@ -103,7 +166,7 @@ Every hook fires automatically — no configuration needed after install.
103
166
  | `WorktreeCreate` | Sets up worktree isolation for parallel workers |
104
167
  | `WorktreeRemove` | Cleans up worktree after worker completion |
105
168
 
106
- Handler types: `command` (shell scripts, all events), `prompt` (LLM single-turn, TaskCompleted), `agent` (subagent with tools, Stop).
169
+ Handler types: `command` (shell scripts, all events), `prompt` (LLM single-turn, TaskCompleted).
107
170
 
108
171
  ## Persistent Memory Agents
109
172
 
@@ -125,31 +188,21 @@ The implement phase automatically selects execution strategy:
125
188
 
126
189
  Dependencies are tracked via DAG. CI gate + Mini-Review + Auto-Checkpoint run at each phase boundary.
127
190
 
128
- ## Project Presets
129
-
130
- | Preset | Stack |
131
- |---|---|
132
- | `template` | Generic (manual config) |
133
- | `nextjs-fsd` | Next.js + FSD + Zustand + React Query |
134
- | `react-spa` | Vite + React 18 + Zustand + Tailwind |
135
- | `express-api` | Express + TypeScript + Prisma + Jest |
136
- | `monorepo` | Turborepo + pnpm workspace |
137
-
138
191
  ## Configuration
139
192
 
140
193
  ```
141
194
  /afc:init
142
195
  ```
143
196
 
144
- Detects your tech stack and generates `.claude/afc.config.md` with CI/lint/test commands, architecture rules, framework settings, and code style conventions.
197
+ Auto-detects your tech stack (package manager, framework, architecture, testing, linting) and generates `.claude/afc.config.md` with CI commands, architecture rules, and code style conventions. No manual preset selection needed — the init command analyzes your project structure directly.
145
198
 
146
199
  ## FAQ
147
200
 
148
201
  ### Does it work with any project?
149
- Yes. Run `/afc:init` to auto-detect your stack, or pick a preset.
202
+ Yes. Run `/afc:init` to auto-detect your stack. Works with JavaScript/TypeScript, Python, Rust, Go, and any project with a CI command.
150
203
 
151
204
  ### Does it require any dependencies?
152
- No. Pure markdown commands + bash hook scripts.
205
+ No. Pure markdown commands + bash hook scripts. No npm packages are imported at runtime.
153
206
 
154
207
  ### What happens if CI fails during the pipeline?
155
208
  Debug-based RCA: traces the error, forms a hypothesis, applies a targeted fix. Halts after 3 failed attempts with full diagnosis.
@@ -158,7 +211,22 @@ Debug-based RCA: traces the error, forms a hypothesis, applies a targeted fix. H
158
211
  Yes. Each phase has its own command (`/afc:spec`, `/afc:plan`, `/afc:implement`, `/afc:review`). `/afc:auto` runs them all.
159
212
 
160
213
  ### What are Critic Loops?
161
- Convergence-based quality checks after each phase. They evaluate output against criteria (completeness, feasibility, architecture compliance) and auto-fix issues until stable. 4 verdicts: PASS, FAIL, ESCALATE (asks user), DEFER.
214
+ Convergence-based quality checks after each phase. They evaluate output against criteria and auto-fix issues until stable. 4 verdicts: PASS, FAIL, ESCALATE (asks user), DEFER.
215
+
216
+ ### How many tokens does a pipeline run use?
217
+ Depends on project size and feature complexity. A typical `/afc:auto` run for a medium feature uses roughly the same as a detailed manual implementation session — the pipeline adds structure, not overhead.
218
+
219
+ ### Can I customize the pipeline behavior?
220
+ Yes. Edit `.claude/afc.config.md` to change CI commands, architecture rules, and code style conventions. The pipeline reads this config at every phase.
221
+
222
+ ### Does it work with monorepos?
223
+ Yes. Run `/afc:init` in the monorepo root. The init command detects workspace structure and configures accordingly.
224
+
225
+ ### Can multiple team members use it on the same repo?
226
+ Yes. Each developer runs their own pipeline independently. The `.claude/afc.config.md` config is shared (commit it to the repo), but pipeline state is local and session-scoped.
227
+
228
+ ### How is this different from Cursor / Copilot / other AI tools?
229
+ All-for-claudecode is not a code completion tool — it is a structured development pipeline. It enforces spec → plan → implement → review flow with quality gates, persistent memory agents, and CI verification at every step.
162
230
 
163
231
  ## License
164
232
 
@@ -11,6 +11,8 @@ tools:
11
11
  - WebSearch
12
12
  model: sonnet
13
13
  memory: project
14
+ # Note: no `isolation: worktree` — architect writes ADR files to project memory
15
+ # which must persist in the main worktree (unlike afc-security which is read-only)
14
16
  skills:
15
17
  - docs/critic-loop-rules.md
16
18
  - docs/phase-gate-protocol.md
@@ -50,6 +52,11 @@ At the end of each analysis:
50
52
  1. Record new ADR decisions, discovered patterns, or architectural insights to MEMORY.md
51
53
  2. Keep entries concise — only stable patterns and confirmed decisions
52
54
  3. Remove outdated entries when architecture evolves
55
+ 4. **Size limit**: MEMORY.md must not exceed **100 lines**. If adding new entries would exceed the limit:
56
+ - Remove the oldest ADR entries (keep the most recent decisions)
57
+ - Merge similar architecture patterns into single entries
58
+ - Remove entries for deleted/refactored code that no longer exists
59
+ - Prioritize: active constraints > recent patterns > historical ADRs
53
60
 
54
61
  ## Memory Format
55
62
 
@@ -45,6 +45,12 @@ At the end of each scan:
45
45
  1. Record newly discovered vulnerability patterns to MEMORY.md
46
46
  2. Record confirmed false positives with reasoning
47
47
  3. Note project-specific security characteristics (e.g., input sanitization patterns, auth flows)
48
+ 4. **Size limit**: MEMORY.md must not exceed **100 lines**. If adding new entries would exceed the limit:
49
+ - Remove the oldest false positive entries (patterns likely already fixed)
50
+ - Merge similar vulnerability patterns into single entries
51
+ - Remove entries for files/paths that no longer exist in the codebase
52
+ - Prioritize: active vulnerability patterns > project security profile > historical false positives
53
+ - Never remove entries for Critical-severity patterns regardless of age
48
54
 
49
55
  ## Memory Format
50
56
 
@@ -1,125 +1,103 @@
1
1
  ---
2
2
  name: afc:analyze
3
- description: "Artifact consistency validation (read-only)"
4
- argument-hint: "[validation scope: spec-plan, tasks-only]"
5
- user-invocable: false
3
+ description: "General-purpose code and component analysis"
4
+ argument-hint: "<analysis target or question>"
5
+ user-invocable: true
6
6
  context: fork
7
7
  allowed-tools:
8
8
  - Read
9
9
  - Grep
10
10
  - Glob
11
- model: haiku
11
+ - WebSearch
12
+ model: sonnet
12
13
  ---
13
14
 
14
- # /afc:analyze — Artifact Consistency Validation
15
+ # /afc:analyze — Code Analysis
15
16
 
16
- > Validates consistency and quality across spec.md, plan.md, and tasks.md.
17
+ > Performs general-purpose codebase exploration and analysis based on a natural-language prompt.
17
18
  > **Read-only** — does not modify any files.
18
19
 
19
20
  ## Arguments
20
21
 
21
- - `$ARGUMENTS` — (optional) limit validation scope (e.g., "spec-plan", "tasks-only")
22
+ - `$ARGUMENTS` — (required) description of what to analyze (e.g., "trace the login flow", "root cause of rendering bug", "how does the hook system work")
22
23
 
23
24
  ## Config Load
24
25
 
25
26
  **Always** read `.claude/afc.config.md` first. This file contains free-form markdown sections:
26
- - `## Architecture` — architecture pattern, layers, import rules (primary reference for this command)
27
+ - `## Architecture` — architecture pattern, layers, import rules (primary reference for structural analysis)
27
28
  - `## Code Style` — language, naming conventions, lint rules
28
29
  - `## Project Context` — framework, state management, testing, etc.
29
30
 
30
- If config file is missing: read `CLAUDE.md` for architecture info. Assume "Layered Architecture" if neither source has it.
31
+ If config file is missing: read `CLAUDE.md` for architecture info. Proceed without config if neither exists.
31
32
 
32
33
  ## Execution Steps
33
34
 
34
- ### 1. Load Artifacts
35
+ ### 1. Parse Analysis Intent
35
36
 
36
- From `.claude/afc/specs/{feature}/`:
37
- - **spec.md** (required)
38
- - **plan.md** (required)
39
- - **tasks.md** (if present)
40
- - **research.md** (if present)
37
+ Classify `$ARGUMENTS` into one of these analysis modes:
41
38
 
42
- Warn about missing files but proceed with what is available.
39
+ | Mode | Trigger Keywords | Focus |
40
+ |------|-----------------|-------|
41
+ | **Root Cause** | "why", "cause", "bug", "error", "broken" | Error trace → data flow → hypothesis |
42
+ | **Structural** | "how", "architecture", "flow", "trace", "structure" | Component relationships, call graphs, data flow |
43
+ | **Exploratory** | "what", "find", "where", "which", "list" | File/function discovery, pattern matching |
44
+ | **Comparative** | "difference", "compare", "vs", "between" | Side-by-side analysis of implementations |
43
45
 
44
- ### 2. Run Validation
46
+ If the intent doesn't clearly match a mode, default to **Exploratory**.
45
47
 
46
- Validate across 6 categories:
48
+ ### 2. Codebase Exploration
47
49
 
48
- #### A. Duplication Detection (DUPLICATION)
49
- - Similar requirements within spec.md
50
- - Overlapping tasks within tasks.md
50
+ Based on the classified mode:
51
51
 
52
- #### B. Ambiguity Detection (AMBIGUITY)
53
- - Unmeasurable adjectives ("appropriate", "fast", "good")
54
- - Residual TODO/TBD/FIXME markers
55
- - Incomplete sentences
52
+ 1. **Identify scope**: determine which files/directories are relevant to `$ARGUMENTS`
53
+ 2. **Read code**: read relevant files using Read tool (prioritize by relevance)
54
+ 3. **Trace connections**: follow imports, function calls, and data flow
55
+ 4. **Gather evidence**: collect specific code references (file:line) for findings
56
56
 
57
- #### C. Coverage Gaps (COVERAGE)
58
- - spec → plan: Are all FR-*/NFR-* reflected in the plan?
59
- - plan → tasks: Are all items in the plan's File Change Map present in tasks?
60
- - spec → tasks: Are all requirements mapped to tasks?
57
+ Exploration should be guided by `{config.architecture}` layer structure when available.
61
58
 
62
- #### D. Inconsistencies (INCONSISTENCY)
63
- - Terminology drift (different names for the same concept)
64
- - Conflicting requirements
65
- - Mismatches between technical decisions in plan and execution in tasks
59
+ ### 3. Analysis
66
60
 
67
- #### E. Principles Compliance (PRINCIPLES)
68
- - Validate against MUST principles in .claude/afc/memory/principles.md if present
69
- - Potential violations of {config.architecture} rules
61
+ Apply the appropriate analysis lens:
70
62
 
71
- #### F. Unidentified Risks (RISK)
72
- - Are there risks not identified in plan.md?
73
- - External dependency risks
74
- - Potential performance bottlenecks
75
-
76
- ### 3. Severity Classification
77
-
78
- | Severity | Criteria |
79
- |----------|----------|
80
- | **CRITICAL** | Principles violation, core feature blocker, security issue |
81
- | **HIGH** | Duplication/conflict, untestable, coverage gap |
82
- | **MEDIUM** | Terminology drift, ambiguous requirements |
83
- | **LOW** | Style improvements, minor duplication |
63
+ - **Root Cause**: build a causal chain from symptom → intermediate causes → root cause
64
+ - **Structural**: map component relationships, identify coupling and cohesion patterns
65
+ - **Exploratory**: enumerate findings with code references
66
+ - **Comparative**: highlight similarities, differences, and tradeoffs
84
67
 
85
68
  ### 4. Output Results (console)
86
69
 
87
70
  ```markdown
88
- ## Consistency Analysis Results: {feature name}
71
+ ## Analysis: {summary of $ARGUMENTS}
72
+
73
+ ### Mode: {Root Cause | Structural | Exploratory | Comparative}
89
74
 
90
75
  ### Findings
91
- | ID | Category | Severity | Location | Summary | Recommended Action |
92
- |----|----------|----------|----------|---------|-------------------|
93
- | A-001 | COVERAGE | HIGH | spec FR-003 | No mapping in tasks | Add task |
94
- | A-002 | AMBIGUITY | MEDIUM | spec NFR-001 | "quickly" is unmeasurable | Add numeric threshold |
95
-
96
- ### Coverage Summary
97
- | Mapping | Coverage |
98
- |---------|----------|
99
- | spec plan | {N}% |
100
- | plan tasks | {N}% |
101
- | spec → tasks | {N}% |
102
-
103
- ### Metrics
104
- - Total requirements: {N}
105
- - Total tasks: {N}
106
- - Issues: CRITICAL {N} / HIGH {N} / MEDIUM {N} / LOW {N}
107
-
108
- ### Next Steps
109
- {Concrete action proposals for CRITICAL/HIGH issues}
76
+ {Numbered findings with code references (file:line)}
77
+
78
+ ### Key Relationships
79
+ {Relevant component/function relationships discovered}
80
+
81
+ ### Summary
82
+ {2-3 sentence conclusion answering the original question}
83
+
84
+ ### Suggested Next Steps
85
+ {1-3 actionable suggestions based on the analysis}
110
86
  ```
111
87
 
112
88
  ### 5. Final Output
113
89
 
114
90
  ```
115
- Analysis complete
116
- ├─ Found: CRITICAL {N} / HIGH {N} / MEDIUM {N} / LOW {N}
117
- ├─ Coverage: spec→plan {N}%, plan→tasks {N}%, spec→tasks {N}%
118
- └─ Recommended: {next action}
91
+ Analysis complete: {short summary}
92
+ ├─ Mode: {mode}
93
+ ├─ Files explored: {N}
94
+ ├─ Findings: {N}
95
+ └─ Suggested next steps: {N}
119
96
  ```
120
97
 
121
98
  ## Notes
122
99
 
123
100
  - **Read-only**: Do not modify any files. Report only.
124
- - **Avoid false positives**: Do not over-flag ambiguity. Consider context.
125
- - **Optional**: Not required in the pipeline. Can proceed plan implement directly.
101
+ - **Scope discipline**: Focus analysis on what was asked. Do not expand scope unnecessarily.
102
+ - **Code references**: Always include `file:line` references so the user can navigate to relevant code.
103
+ - **Not artifact validation**: For spec/plan/tasks consistency checks, use `/afc:validate` instead.
@@ -92,7 +92,7 @@ Structure analysis results and **print to console**:
92
92
 
93
93
  > **Always** read `${CLAUDE_PLUGIN_ROOT}/docs/critic-loop-rules.md` first and follow it.
94
94
 
95
- Run the critic loop until convergence. Safety cap: 7 passes.
95
+ Run the critic loop until convergence. Safety cap: 7 passes (higher than the standard 5 because architecture analysis involves broader exploration across modules and layers).
96
96
 
97
97
  | Criterion | Validation |
98
98
  |-----------|------------|
package/commands/auto.md CHANGED
@@ -170,7 +170,7 @@ Execute `/afc:spec` logic inline:
170
170
  4. `[NEEDS CLARIFICATION]` items: **research first, then auto-resolve remaining** (clarify skipped if Phase 0.5 already ran)
171
171
  - Items answerable via research → resolve with researched facts, tag `[RESEARCHED]`
172
172
  - Items requiring user judgment → auto-resolve with best-guess, tag `[AUTO-RESOLVED]`
173
- 5. **Retrospective check**: if `.claude/afc/memory/retrospectives/` exists, load and check:
173
+ 5. **Retrospective check**: if `.claude/afc/memory/retrospectives/` exists, load the **most recent 10 files** (sorted by filename descending) and check:
174
174
  - Were there previous `[AUTO-RESOLVED]` items that turned out wrong? Flag similar patterns.
175
175
  - Were there scope-related issues in past specs? Warn about similar ambiguities.
176
176
  6. **Critic Loop until convergence** (safety cap: 5, follow Critic Loop rules):
@@ -191,9 +191,9 @@ Execute `/afc:plan` logic inline:
191
191
  1. Load spec.md
192
192
  2. If technical uncertainties exist → auto-resolve via WebSearch/code exploration → create research.md
193
193
  3. **Memory loading** (skip gracefully if directories are empty or absent):
194
- - **Quality history**: if `.claude/afc/memory/quality-history/*.json` exists, load recent entries and display trend summary: "Last {N} pipelines: avg critic_fixes {X}, avg ci_failures {Y}, avg escalations {Z}". Use trends to inform plan risk assessment.
195
- - **Decisions**: if `.claude/afc/memory/decisions/` exists, load ADR entries and check for conflicts with the current feature's design direction. Flag any contradictions.
196
- - **Reviews**: if `.claude/afc/memory/reviews/` exists, scan for recurring finding patterns (same file/category appearing in 2+ reviews). Flag as known risk areas.
194
+ - **Quality history**: if `.claude/afc/memory/quality-history/*.json` exists, load the **most recent 10 files** (sorted by filename descending) and display trend summary: "Last {N} pipelines: avg critic_fixes {X}, avg ci_failures {Y}, avg escalations {Z}". Use trends to inform plan risk assessment.
195
+ - **Decisions**: if `.claude/afc/memory/decisions/` exists, load the **most recent 30 files** (sorted by filename descending) and check for conflicts with the current feature's design direction. Flag any contradictions.
196
+ - **Reviews**: if `.claude/afc/memory/reviews/` exists, load the **most recent 15 files** (sorted by filename descending) and scan for recurring finding patterns (same file/category appearing in 2+ reviews). Flag as known risk areas.
197
197
  4. Create `.claude/afc/specs/{feature}/plan.md`
198
198
  - **If setting numerical targets (line counts etc.), include structure-analysis-based estimates** (e.g., "function A ~50 lines, component B ~80 lines → total ~130 lines")
199
199
  5. **Critic Loop until convergence** (safety cap: 5, follow Critic Loop rules):
@@ -231,14 +231,18 @@ Execute `/afc:plan` logic inline:
231
231
  ```
232
232
  - If architect returns conflicts → **ESCALATE** to user with conflict details
233
233
  - If no conflicts → proceed (ADR recorded for future reference)
234
- 8. **Session context preservation**: Save key decisions and constraints for context compaction resilience:
235
- ```
236
- save_session_context({
237
- goal: { original_request: "$ARGUMENTS", current_objective: "Implement {feature}" },
238
- decisions: [{ what: "{key design decision}", why: "{rationale}" }],
239
- discoveries: [{ file: "{path}", insight: "{finding}" }]
240
- })
234
+ 8. **Session context preservation**: Write key decisions to `.claude/afc/specs/{feature}/context.md` for compaction resilience:
235
+ ```markdown
236
+ # Session Context: {feature}
237
+ ## Goal
238
+ - Original request: $ARGUMENTS
239
+ - Current objective: Implement {feature}
240
+ ## Key Decisions
241
+ - {what}: {rationale}
242
+ ## Discoveries
243
+ - {file path}: {finding}
241
244
  ```
245
+ This file is read at Implement start to restore context after compaction.
242
246
  9. **Checkpoint**: phase transition already recorded by `afc-pipeline-manage.sh phase plan` at phase start
243
247
  10. Progress: `✓ 2/5 Plan complete (Critic: converged ({N} passes, {M} fixes, {E} escalations), files: {N}, ADR: {N} recorded, Implementation Context: {W} words)`
244
248
 
@@ -246,7 +250,7 @@ Execute `/afc:plan` logic inline:
246
250
 
247
251
  `"${CLAUDE_PLUGIN_ROOT}/scripts/afc-pipeline-manage.sh" phase implement`
248
252
 
249
- **Session context reload**: At implement start, call `load_session_context()` to restore key decisions and constraints from Plan phase (resilient to context compaction).
253
+ **Session context reload**: At implement start, read `.claude/afc/specs/{feature}/context.md` if it exists. This restores key decisions and constraints from Plan phase (resilient to context compaction).
250
254
 
251
255
  Execute `/afc:implement` logic inline — **follow all orchestration rules defined in `commands/implement.md`** (task generation, mode selection, batch/swarm execution, failure recovery, task execution pattern). The implement command is the single source of truth for orchestration details.
252
256
 
@@ -255,7 +259,7 @@ Execute `/afc:implement` logic inline — **follow all orchestration rules defin
255
259
  #### Step 3.1: Task Generation + Validation
256
260
 
257
261
  1. Generate tasks.md from plan.md File Change Map (as defined in implement.md Step 1.3)
258
- 2. **Retrospective check**: if `.claude/afc/memory/retrospectives/` exists, load and check:
262
+ 2. **Retrospective check**: if `.claude/afc/memory/retrospectives/` exists, load the **most recent 10 files** (sorted by filename descending) and check:
259
263
  - Were there previous parallel conflict issues ([P] file overlaps)? Flag similar file patterns.
260
264
  - Were there tasks that were over-decomposed or under-decomposed? Adjust granularity.
261
265
  3. Script validation (DAG + parallel overlap) — no critic loop, script-based only
@@ -410,20 +414,20 @@ Execute `/afc:review` logic inline — **follow all review perspectives defined
410
414
  - **G. Maintainability** — AI/human comprehension, naming clarity, self-contained files (direct review)
411
415
  - **H. Extensibility** — extension points, OCP, future modification cost (direct review)
412
416
  4. **Auto-resolved validation**: Check all `[AUTO-RESOLVED]` items from spec phase — does the implementation match the guess? Flag mismatches as Critical.
413
- 5. **Past reviews check**: if `.claude/afc/memory/reviews/` exists, scan for recurring finding patterns across past review reports. Prioritize those areas.
414
- 6. **Retrospective check**: if `.claude/afc/memory/retrospectives/` exists, load and check:
417
+ 5. **Past reviews check**: if `.claude/afc/memory/reviews/` exists, load the **most recent 15 files** (sorted by filename descending) and scan for recurring finding patterns across past review reports. Prioritize those areas.
418
+ 6. **Retrospective check**: if `.claude/afc/memory/retrospectives/` exists, load the **most recent 10 files** (sorted by filename descending) and check:
415
419
  - Were there recurring Critical finding categories in past reviews? Prioritize those perspectives.
416
420
  - Were there false positives that wasted effort? Reduce sensitivity for those patterns.
417
- 6. **Critic Loop until convergence** (safety cap: 5, follow Critic Loop rules):
421
+ 7. **Critic Loop until convergence** (safety cap: 5, follow Critic Loop rules):
418
422
  - COMPLETENESS: were all changed files reviewed across all 8 perspectives (A-H)?
419
423
  - 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
420
424
  - PRECISION: are there unnecessary changes? Are there out-of-scope modifications?
421
425
  - FAIL → auto-fix and continue. ESCALATE → pause, present options, resume after response. DEFER → record reason, mark clean.
422
- 7. **Handling SC shortfalls**:
426
+ 8. **Handling SC shortfalls**:
423
427
  - Fixable → attempt auto-fix → re-run `{config.ci}` verification
424
428
  - Not fixable → state in final report with reason (no post-hoc rationalization; record as Plan-phase target-setting error)
425
- 8. **Checkpoint**: phase transition already recorded by `afc-pipeline-manage.sh phase review` at phase start
426
- 9. Progress: `✓ 4/5 Review complete (Critical:{N} Warning:{N} Info:{N}, SC shortfalls: {N})`
429
+ 9. **Checkpoint**: phase transition already recorded by `afc-pipeline-manage.sh phase review` at phase start
430
+ 10. Progress: `✓ 4/5 Review complete (Critical:{N} Warning:{N} Info:{N}, SC shortfalls: {N})`
427
431
 
428
432
  ### Phase 5: Clean (5/5)
429
433
 
@@ -448,7 +452,23 @@ Artifact cleanup and codebase hygiene check after implementation and review:
448
452
  - **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)
449
453
  - **If review-report.md exists** → copy to `.claude/afc/memory/reviews/{feature}-{date}.md` before .claude/afc/specs/ deletion
450
454
  - **If research.md exists** and was not already persisted in Plan phase → copy to `.claude/afc/memory/research/{feature}.md`
451
- - **Agent memory consolidation**: architect and security agents have already updated their persistent MEMORY.md during Review phase — no additional action needed (agent memory survives across sessions independently)
455
+ - **Agent memory consolidation**: architect and security agents have already updated their persistent MEMORY.md during Review phase. **Size enforcement**: check each agent's MEMORY.md line count if either exceeds 100 lines, invoke the respective agent to self-prune:
456
+ ```
457
+ Task("Memory cleanup: afc-architect", subagent_type: "afc:afc-architect",
458
+ prompt: "Your MEMORY.md exceeds 100 lines. Read it, prune old/redundant entries, and rewrite to under 100 lines following your size limit rules.")
459
+ ```
460
+ (Same pattern for afc-security if needed. Skip if both are under 100 lines.)
461
+ - **Memory rotation**: for each memory subdirectory, check file count and prune oldest files if over threshold:
462
+ | Directory | Threshold | Action |
463
+ |-----------|-----------|--------|
464
+ | `quality-history/` | 30 files | Delete oldest files beyond threshold |
465
+ | `reviews/` | 40 files | Delete oldest files beyond threshold |
466
+ | `retrospectives/` | 30 files | Delete oldest files beyond threshold |
467
+ | `research/` | 50 files | Delete oldest files beyond threshold |
468
+ | `decisions/` | 60 files | Delete oldest files beyond threshold |
469
+ - Sort by filename ascending (oldest first), delete excess
470
+ - Log: `"Memory rotation: {dir} pruned {N} files"`
471
+ - Skip directories that do not exist or are under threshold
452
472
  5. **Quality report** (structured pipeline metrics):
453
473
  - Generate `.claude/afc/memory/quality-history/{feature}-{date}.json` with the following structure:
454
474
  ```json
@@ -478,7 +498,7 @@ Artifact cleanup and codebase hygiene check after implementation and review:
478
498
  ```
479
499
  - Create `.claude/afc/memory/quality-history/` directory if it does not exist
480
500
  6. **Checkpoint reset**:
481
- - Clear `.claude/afc/memory/checkpoint.md` (pipeline complete = session goal achieved)
501
+ - Clear `.claude/afc/memory/checkpoint.md` **and** `~/.claude/projects/{ENCODED_PATH}/auto-memory/checkpoint.md` (pipeline complete = session goal achieved, dual-delete prevents stale checkpoint in either location; `ENCODED_PATH` = project path with `/` replaced by `-`)
482
502
  7. **Timeline finalize**:
483
503
  ```bash
484
504
  "${CLAUDE_PLUGIN_ROOT}/scripts/afc-pipeline-manage.sh" log pipeline-end "Pipeline complete: {feature}"
@@ -548,7 +568,7 @@ Pipeline aborted (Phase {N}/5)
548
568
  - **[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.
549
569
  - **Swarm mode is automatic**: when a phase has 6+ [P] tasks, the orchestrator pre-assigns tasks to swarm workers. Do not manually batch.
550
570
  - **Implementation Context travels with workers**: every sub-agent prompt includes the Implementation Context section from plan.md, ensuring spec intent propagates to parallel workers.
551
- - **Session context resilience**: key decisions are saved via `save_session_context` at Plan completion and restored at Implement start, surviving context compaction.
571
+ - **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.
552
572
  - **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.
553
573
  - **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.
554
574
  - **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.
@@ -84,7 +84,21 @@ Run ALL checks regardless of earlier failures. Do not short-circuit.
84
84
  | No lingering safety tags | `git tag -l 'afc/pre-*'` | No tags, or tags match active pipeline | ⚠ Warning: lingering safety tag `afc/pre-{x}` found. Fix: `git tag -d afc/pre-{x}` |
85
85
  | Checkpoint state | Read `.claude/afc/memory/checkpoint.md` if exists | No checkpoint (clean), or checkpoint is from current session | ⚠ Warning: stale checkpoint from {date}. Fix: run `/afc:resume` to continue or delete `.claude/afc/memory/checkpoint.md` |
86
86
 
87
- ### Category 6: Hook Health
87
+ ### Category 6: Memory Health
88
+
89
+ > Checks `.claude/afc/memory/` subdirectory sizes and agent memory file sizes. If memory directory does not exist, print `✓ No memory directory` and skip this category.
90
+
91
+ | Check | How | Pass | Fail |
92
+ |-------|-----|------|------|
93
+ | quality-history count | Count files in `.claude/afc/memory/quality-history/` | ≤ 30 files | ⚠ Warning: {N} files in quality-history/ (threshold: 30). Oldest files should be pruned. Fix: run a pipeline with `/afc:auto` (Clean phase auto-prunes) or manually delete oldest files |
94
+ | reviews count | Count files in `.claude/afc/memory/reviews/` | ≤ 40 files | ⚠ Warning: {N} files in reviews/ (threshold: 40). Fix: run a pipeline or manually delete oldest files |
95
+ | retrospectives count | Count files in `.claude/afc/memory/retrospectives/` | ≤ 30 files | ⚠ Warning: {N} files in retrospectives/ (threshold: 30). Fix: run a pipeline or manually delete oldest files |
96
+ | research count | Count files in `.claude/afc/memory/research/` | ≤ 50 files | ⚠ Warning: {N} files in research/ (threshold: 50). Fix: run a pipeline or manually delete oldest files |
97
+ | decisions count | Count files in `.claude/afc/memory/decisions/` | ≤ 60 files | ⚠ Warning: {N} files in decisions/ (threshold: 60). Fix: run a pipeline or manually delete oldest files |
98
+ | afc-architect MEMORY.md size | Count lines in `.claude/agent-memory/afc-architect/MEMORY.md` (if exists) | ≤ 100 lines | ⚠ Warning: afc-architect MEMORY.md is {N} lines (limit: 100). Fix: invoke `/afc:architect` to trigger self-pruning, or manually edit the file |
99
+ | afc-security MEMORY.md size | Count lines in `.claude/agent-memory/afc-security/MEMORY.md` (if exists) | ≤ 100 lines | ⚠ Warning: afc-security MEMORY.md is {N} lines (limit: 100). Fix: invoke `/afc:security` to trigger self-pruning, or manually edit the file |
100
+
101
+ ### Category 7: Hook Health
88
102
 
89
103
  | Check | How | Pass | Fail |
90
104
  |-------|-----|------|------|
@@ -92,7 +106,7 @@ Run ALL checks regardless of earlier failures. Do not short-circuit.
92
106
  | All scripts exist | For each script referenced in hooks.json, check file exists | All scripts found | ✗ Fix: reinstall plugin |
93
107
  | Scripts executable | Check execute permission on each script in plugin's scripts/ | All have +x | Fix: `chmod +x` on the missing scripts, or reinstall plugin |
94
108
 
95
- ### Category 7: Version Sync (development only)
109
+ ### Category 8: Version Sync (development only)
96
110
 
97
111
  > Only run if current directory is the all-for-claudecode source repo (check for `package.json` with `"name": "all-for-claudecode"`).
98
112
 
@@ -94,9 +94,9 @@ If tasks.md already exists (e.g., from standalone `/afc:tasks` run): use as-is,
94
94
  - Identify already-completed `[x]` tasks
95
95
  2. Load **Implementation Context** section from plan.md (used in sub-agent prompts)
96
96
 
97
- ### 1.5. Retrospective Check
97
+ ### 1.7. Retrospective Check
98
98
 
99
- If `.claude/afc/memory/retrospectives/` exists, load and check:
99
+ If `.claude/afc/memory/retrospectives/` exists, load the **most recent 10 files** (sorted by filename descending) and check:
100
100
  - Were there implementation issues in past pipelines (e.g., file conflicts, unexpected dependencies, CI failures after parallel execution)?
101
101
  - Flag similar patterns in the current task list. Warn before implementation begins.
102
102
  - Skip gracefully if directory is empty or absent.