all-for-claudecode 2.0.0 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (67) hide show
  1. package/.claude-plugin/marketplace.json +4 -4
  2. package/.claude-plugin/plugin.json +3 -4
  3. package/MIGRATION.md +10 -7
  4. package/README.md +68 -119
  5. package/agents/afc-architect.md +16 -0
  6. package/agents/afc-impl-worker.md +40 -0
  7. package/agents/afc-security.md +11 -0
  8. package/bin/cli.mjs +1 -1
  9. package/commands/analyze.md +6 -7
  10. package/commands/architect.md +5 -7
  11. package/commands/auto.md +355 -102
  12. package/commands/checkpoint.md +3 -4
  13. package/commands/clarify.md +8 -1
  14. package/commands/debug.md +40 -3
  15. package/commands/doctor.md +12 -13
  16. package/commands/ideate.md +191 -0
  17. package/commands/implement.md +211 -66
  18. package/commands/init.md +76 -61
  19. package/commands/launch.md +181 -0
  20. package/commands/plan.md +86 -22
  21. package/commands/principles.md +6 -2
  22. package/commands/resume.md +1 -2
  23. package/commands/review.md +68 -18
  24. package/commands/security.md +10 -13
  25. package/commands/spec.md +60 -3
  26. package/commands/tasks.md +19 -4
  27. package/commands/test.md +24 -6
  28. package/docs/phase-gate-protocol.md +6 -6
  29. package/hooks/hooks.json +29 -3
  30. package/package.json +19 -11
  31. package/schemas/hooks.schema.json +75 -0
  32. package/schemas/marketplace.schema.json +52 -0
  33. package/schemas/plugin.schema.json +53 -0
  34. package/scripts/afc-bash-guard.sh +6 -6
  35. package/scripts/afc-blast-radius.sh +418 -0
  36. package/scripts/afc-config-change.sh +6 -4
  37. package/scripts/afc-consistency-check.sh +261 -0
  38. package/scripts/afc-dag-validate.mjs +94 -0
  39. package/scripts/afc-dag-validate.sh +142 -0
  40. package/scripts/afc-failure-hint.sh +6 -4
  41. package/scripts/afc-parallel-validate.mjs +81 -0
  42. package/scripts/afc-parallel-validate.sh +33 -45
  43. package/scripts/afc-permission-request.sh +56 -11
  44. package/scripts/afc-pipeline-manage.sh +46 -46
  45. package/scripts/afc-preflight-check.sh +6 -3
  46. package/scripts/afc-schema-validate.sh +225 -0
  47. package/scripts/afc-session-end.sh +5 -5
  48. package/scripts/afc-state.sh +256 -0
  49. package/scripts/afc-stop-gate.sh +32 -24
  50. package/scripts/afc-subagent-context.sh +15 -6
  51. package/scripts/afc-subagent-stop.sh +4 -2
  52. package/scripts/afc-task-completed-gate.sh +19 -25
  53. package/scripts/afc-teammate-idle.sh +9 -14
  54. package/scripts/afc-test-pre-gen.sh +141 -0
  55. package/scripts/afc-timeline-log.sh +9 -6
  56. package/scripts/afc-user-prompt-submit.sh +8 -10
  57. package/scripts/afc-worktree-create.sh +56 -0
  58. package/scripts/afc-worktree-remove.sh +47 -0
  59. package/scripts/install-shellspec.sh +38 -0
  60. package/scripts/pre-compact-checkpoint.sh +6 -4
  61. package/scripts/session-start-context.sh +9 -8
  62. package/scripts/track-afc-changes.sh +6 -9
  63. package/templates/afc.config.template.md +12 -76
  64. package/templates/afc.config.express-api.md +0 -99
  65. package/templates/afc.config.monorepo.md +0 -98
  66. package/templates/afc.config.nextjs-fsd.md +0 -107
  67. package/templates/afc.config.react-spa.md +0 -96
@@ -0,0 +1,181 @@
1
+ ---
2
+ name: afc:launch
3
+ description: "Generate release artifacts"
4
+ argument-hint: "[version tag or 'auto']"
5
+ allowed-tools:
6
+ - Read
7
+ - Write
8
+ - Edit
9
+ - Bash
10
+ - Glob
11
+ - Grep
12
+ model: sonnet
13
+ ---
14
+
15
+ # /afc:launch — Generate Release Artifacts
16
+
17
+ > Generates release artifacts (CHANGELOG entry, README updates, GitHub Release notes) from git history and optional spec context.
18
+ > This is a **standalone utility** — not part of the auto pipeline.
19
+ > Works with or without a prior afc pipeline run.
20
+
21
+ ## Arguments
22
+
23
+ - `$ARGUMENTS` — (optional) One of:
24
+ - Version tag: `"v2.2.0"` — uses this as the release version
25
+ - `"auto"` — auto-detects version from package.json/Cargo.toml/pyproject.toml
26
+ - Not specified: prompts for version
27
+
28
+ ## Execution Steps
29
+
30
+ ### 1. Detect Project Context
31
+
32
+ 1. **Version detection**:
33
+ - If `$ARGUMENTS` is a version string (matches `v?\d+\.\d+\.\d+`): use it
34
+ - If `$ARGUMENTS` = `"auto"`: read version from package.json → Cargo.toml → pyproject.toml → setup.py (first found)
35
+ - If not specified: check package.json etc. for current version, present to user, confirm or override
36
+
37
+ 2. **Previous version detection**:
38
+ ```bash
39
+ git describe --tags --abbrev=0 2>/dev/null || echo "none"
40
+ ```
41
+ - If a previous tag exists: diff range = `{previous_tag}..HEAD`
42
+ - If no tags: diff range = all commits (warn user: "No previous release tag found. Including all history.")
43
+
44
+ 3. **Changelog detection**:
45
+ - Check for existing: `CHANGELOG.md` → `CHANGES.md` → `HISTORY.md`
46
+ - If found: will prepend new entry
47
+ - If not found: will create `CHANGELOG.md`
48
+
49
+ ### 2. Gather Change Context
50
+
51
+ Collect all available context for high-quality release notes:
52
+
53
+ 1. **Git history** (required):
54
+ ```bash
55
+ git log {previous_tag}..HEAD --pretty=format:"%h %s" --no-merges
56
+ ```
57
+
58
+ 2. **Changed files summary** (required):
59
+ ```bash
60
+ git diff --stat {previous_tag}..HEAD
61
+ ```
62
+
63
+ 3. **Spec context** (optional — enhances quality):
64
+ - Glob `.claude/afc/specs/*/spec.md` — if any exist, read Overview and User Stories sections
65
+ - This provides **intent context** that raw commit messages lack
66
+ - If no specs found: rely on git history only (still produces good output)
67
+
68
+ 4. **Review context** (optional):
69
+ - Glob `.claude/afc/memory/reviews/*` — if any exist from this version cycle, note key findings
70
+ - Skip if not found
71
+
72
+ 5. **Breaking change detection**:
73
+ - Grep commit messages for: `BREAKING`, `breaking change`, `!:` (conventional commits)
74
+ - Grep diffs for: deleted public exports, renamed public APIs, changed function signatures
75
+ - Flag any findings as breaking changes in the output
76
+
77
+ ### 3. Generate CHANGELOG Entry
78
+
79
+ Prepend a new entry to the changelog file:
80
+
81
+ 1. **Duplicate check**: Grep the changelog for `## [{version}]`. If an entry for this version already exists:
82
+ - Ask user: "CHANGELOG already has an entry for {version}. (1) Overwrite (2) Abort"
83
+ - If overwrite: replace the existing entry (from `## [{version}]` to the next `## [` line)
84
+ - If abort: skip CHANGELOG generation
85
+
86
+ 2. Follow the existing format if one exists; otherwise use [Keep a Changelog](https://keepachangelog.com/) format:
87
+
88
+ ```markdown
89
+ ## [{version}] - {YYYY-MM-DD}
90
+
91
+ ### Added
92
+ - {new features, described from user perspective}
93
+
94
+ ### Changed
95
+ - {modifications to existing functionality}
96
+
97
+ ### Fixed
98
+ - {bug fixes}
99
+
100
+ ### Removed
101
+ - {removed features or deprecated items}
102
+
103
+ ### Breaking Changes
104
+ - {if any — empty section omitted}
105
+ ```
106
+
107
+ **Quality rules**:
108
+ - Write from **user perspective**, not developer perspective ("Add dark mode support" not "Add ThemeProvider component")
109
+ - Group related changes into single entries (don't list every file)
110
+ - If spec context is available: use feature names from specs, not commit message fragments
111
+ - Omit empty sections (if no fixes, don't include "### Fixed")
112
+
113
+ ### 4. Update README (conditional)
114
+
115
+ Only update README if meaningful changes warrant it:
116
+
117
+ 1. **Check triggers**:
118
+ - New CLI commands or API endpoints added?
119
+ - Installation process changed?
120
+ - New dependencies or requirements?
121
+ - Feature that users need to know about?
122
+
123
+ 2. **If no triggers match**: skip README update entirely (print: "README: no updates needed")
124
+
125
+ 3. **If triggers match**: read current README, identify the relevant section, apply minimal targeted edit
126
+ - Do NOT rewrite the entire README
127
+ - Do NOT add badges, shields, or decorative elements
128
+ - Only update sections directly affected by changes
129
+
130
+ ### 5. Generate GitHub Release Notes
131
+
132
+ Create `.claude/afc/release-notes.md` (draft for `gh release create`):
133
+
134
+ ```markdown
135
+ # {version}
136
+
137
+ {2-3 sentence summary of this release — what's the headline?}
138
+
139
+ ## Highlights
140
+
141
+ - {top 1-3 user-facing changes, expanded with context}
142
+
143
+ ## What's Changed
144
+
145
+ {CHANGELOG entry content, reformatted for GitHub}
146
+
147
+ ## Breaking Changes
148
+
149
+ {if any — clear migration instructions}
150
+
151
+ **Full Changelog**: {previous_tag}...{version}
152
+ ```
153
+
154
+ ### 6. Present Summary and Next Steps
155
+
156
+ ```
157
+ Release artifacts generated: {version}
158
+ ├─ CHANGELOG.md: entry prepended ({N} items across {M} categories)
159
+ ├─ README.md: {updated section / no updates needed}
160
+ ├─ .claude/afc/release-notes.md: draft created
161
+ ├─ Breaking changes: {count or "none"}
162
+ ├─ Commits included: {N} (since {previous_tag})
163
+ └─ Specs referenced: {N or "none (git-only mode)"}
164
+
165
+ Next steps:
166
+ git add CHANGELOG.md README.md
167
+ git commit -m "docs: prepare release {version}"
168
+ git tag {version}
169
+ gh release create {version} --notes-file .claude/afc/release-notes.md
170
+ ```
171
+
172
+ **Do NOT execute these commands automatically.** Present them for the user to review and run.
173
+
174
+ ## Notes
175
+
176
+ - **Not part of the auto pipeline**. Launch is a standalone utility invoked when you're ready to release, not after every feature.
177
+ - **Non-destructive**: only creates/edits CHANGELOG and README (conditionally). Does not push, tag, or create releases automatically.
178
+ - **Git history is the source of truth**. Spec context enhances quality but is never required.
179
+ - **Conventional Commits awareness**: if the project uses conventional commits (`feat:`, `fix:`, `chore:`), the generated CHANGELOG respects those categories.
180
+ - **Idempotent**: running launch twice with the same version overwrites the release-notes.md draft and re-generates the CHANGELOG entry (warns before overwriting).
181
+ - **No scope for `clean`**: release-notes.md in `.claude/afc/` is a draft file. The user decides whether to keep or delete it after the release.
package/commands/plan.md CHANGED
@@ -2,6 +2,13 @@
2
2
  name: afc:plan
3
3
  description: "Implementation design"
4
4
  argument-hint: "[additional context or constraints]"
5
+ allowed-tools:
6
+ - Read
7
+ - Glob
8
+ - Grep
9
+ - Write
10
+ - WebSearch
11
+ - WebFetch
5
12
  model: sonnet
6
13
  ---
7
14
  # /afc:plan — Implementation Design
@@ -19,7 +26,12 @@ model: sonnet
19
26
 
20
27
  ## Config Load
21
28
 
22
- **Always** read `.claude/afc.config.md` first (read manually if not auto-loaded above). Abort if config file is missing.
29
+ **Always** read `.claude/afc.config.md` first (read manually if not auto-loaded above).
30
+
31
+ If config file is missing:
32
+ 1. Ask the user: "`.claude/afc.config.md` not found. Run `/afc:init` to set up the project?"
33
+ 2. If user accepts → run `/afc:init`, then **restart this command** with the original `$ARGUMENTS`
34
+ 3. If user declines → **abort**
23
35
 
24
36
  ## Execution Steps
25
37
 
@@ -32,6 +44,10 @@ model: sonnet
32
44
  3. Read full **spec.md**
33
45
  4. Read **.claude/afc/memory/principles.md** (if present)
34
46
  5. Read **CLAUDE.md** project context
47
+ 6. **Memory loading** (skip gracefully if directories are empty or absent):
48
+ - **Quality history**: if `.claude/afc/memory/quality-history/*.json` exists, load recent entries and display trend: "Last {N} pipelines: avg critic_fixes {X}, avg ci_failures {Y}". Use trends to inform risk assessment.
49
+ - **Decisions**: if `.claude/afc/memory/decisions/` exists, load ADR entries and check for conflicts with the current feature's design direction.
50
+ - **Reviews**: if `.claude/afc/memory/reviews/` exists, scan for recurring finding patterns (same file/category appearing in 2+ reviews). Flag as known risk areas.
35
51
 
36
52
  ### 2. Clarification Check
37
53
 
@@ -78,6 +94,10 @@ Collect all results and record in `.claude/afc/specs/{feature}/research.md`:
78
94
  **Source**: {URL or file path}
79
95
  ```
80
96
 
97
+ #### Step 4: Persist (long-term memory)
98
+ Copy research findings to `.claude/afc/memory/research/{feature}.md` for cross-session reuse.
99
+ Future pipelines can reference prior research to avoid redundant investigation.
100
+
81
101
  ### 4. Phase 1 — Write Design
82
102
 
83
103
  Create `.claude/afc/specs/{feature}/plan.md`. **Must** follow the structure below:
@@ -89,13 +109,7 @@ Create `.claude/afc/specs/{feature}/plan.md`. **Must** follow the structure belo
89
109
  {summary of core requirements from spec + technical approach, 3-5 sentences}
90
110
 
91
111
  ## Technical Context
92
- {summary of project settings loaded from afc.config.md}
93
- - **Language**: {config.code_style.language}
94
- - **Framework**: {config.framework.name}
95
- - **State**: {config.state_management summary}
96
- - **Architecture**: {config.architecture.style}
97
- - **Styling**: {config.styling.framework}
98
- - **Testing**: {config.testing.framework}
112
+ {Summarize key project settings from afc.config.md — Architecture, Code Style, and Project Context sections}
99
113
  - **Constraints**: {constraints extracted from spec}
100
114
 
101
115
  ## Principles Check
@@ -111,17 +125,32 @@ Create `.claude/afc/specs/{feature}/plan.md`. **Must** follow the structure belo
111
125
  |-------|------|------|
112
126
  | {entities/features/widgets/shared} | {path} | {description} |
113
127
 
114
- ### State Management Strategy
128
+ ### State Management Strategy (omit if not applicable)
115
129
  {what combination of Zustand store / React Query / Context is used where}
116
130
 
117
- ### API Design
131
+ ### API Design (omit if not applicable)
118
132
  {plan for new API endpoints or use of existing APIs}
119
133
 
120
134
  ## File Change Map
121
- {list of files to change/create. for each file:}
122
- | File | Action | Description |
123
- |------|--------|-------------|
124
- | {path} | create/modify/delete | {summary of change} |
135
+
136
+ | File | Action | Description | Depends On | Phase |
137
+ |------|--------|-------------|------------|-------|
138
+ | {path} | create/modify/delete | {summary} | {file(s) or "—"} | {1-N} |
139
+
140
+ > - **Depends On**: list file(s) that must be created/modified first (enables dependency-aware task generation in /afc:implement).
141
+ > - **Phase**: implementation phase number. Same-phase + no dependency + different file = parallelizable.
142
+
143
+ ## Implementation Context
144
+
145
+ > Auto-generated section for implementation agents. Compress to under 500 words.
146
+ > This section travels with every sub-agent prompt during /afc:implement.
147
+
148
+ - **Objective**: {1-sentence feature purpose from spec Overview}
149
+ - **Key Constraints**: {NFR summaries + spec Constraints section, compressed}
150
+ - **Critical Edge Cases**: {top 3 edge cases from spec, 1 line each}
151
+ - **Risk Watchpoints**: {top risks from Risk & Mitigation table}
152
+ - **Must NOT**: {explicit prohibitions — from spec constraints, principles.md, or CLAUDE.md}
153
+ - **Acceptance Anchors**: {key acceptance criteria from spec that implementation must satisfy}
125
154
 
126
155
  ## Risk & Mitigation
127
156
  | Risk | Impact | Mitigation |
@@ -129,19 +158,26 @@ Create `.claude/afc/specs/{feature}/plan.md`. **Must** follow the structure belo
129
158
  | {risk} | {H/M/L} | {approach} |
130
159
 
131
160
  ## Alternative Design
161
+ ### Approach 0: No Change (status quo)
162
+ {Why might the current state be sufficient? What is the cost of doing nothing?}
163
+ {If no change is clearly inferior: state specific reason — "Status quo lacks X, which is required by FR-001"}
164
+ {If no change is viable: recommend it — avoid implementing for the sake of implementing}
165
+
132
166
  ### Approach A: {chosen approach name}
133
167
  {Brief description — this is the approach detailed above}
134
168
 
135
169
  ### Approach B: {alternative approach name}
136
170
  {Brief description of a meaningfully different approach}
137
171
 
138
- | Criterion | Approach A | Approach B |
139
- |-----------|-----------|-----------|
140
- | Complexity | {evaluation} | {evaluation} |
141
- | Risk | {evaluation} | {evaluation} |
142
- | Maintainability | {evaluation} | {evaluation} |
172
+ | Criterion | No Change | Approach A | Approach B |
173
+ |-----------|-----------|-----------|-----------|
174
+ | Complexity | None | {evaluation} | {evaluation} |
175
+ | Risk | None | {evaluation} | {evaluation} |
176
+ | Maintainability | Current | {evaluation} | {evaluation} |
177
+ | Justification | {why not enough} | {why this} | {why this} |
143
178
 
144
- **Decision**: Approach {A/B} — {1-sentence rationale}
179
+ **Decision**: Approach {0/A/B} — {1-sentence rationale}
180
+ {If Approach 0 chosen: abort plan, report: "No implementation needed — current state satisfies requirements."}
145
181
 
146
182
  ## Phase Breakdown
147
183
  ### Phase 1: Setup
@@ -161,34 +197,62 @@ Create `.claude/afc/specs/{feature}/plan.md`. **Must** follow the structure belo
161
197
 
162
198
  > **Always** read `${CLAUDE_PLUGIN_ROOT}/docs/critic-loop-rules.md` first and follow it.
163
199
 
164
- Run the critic loop until convergence. Safety cap: 7 passes.
200
+ Run the critic loop until convergence. Safety cap: 5 passes.
165
201
 
166
202
  | Criterion | Validation |
167
203
  |-----------|------------|
168
204
  | **COMPLETENESS** | Are all requirements (FR-*) from spec.md reflected in the plan? |
169
205
  | **FEASIBILITY** | Is it compatible with the existing codebase? Are dependencies available? |
170
206
  | **ARCHITECTURE** | Does it comply with {config.architecture} rules? |
207
+ | **CROSS_CONSISTENCY** | Spec↔Plan cross-artifact validation (see checklist below) |
171
208
  | **RISK** | Are there any unidentified risks? Additionally, if `.claude/afc/memory/retrospectives/` directory contains files from previous pipeline runs, load each file and check whether the current plan addresses the patterns recorded there. Tag matched patterns with `[RETRO-CHECKED]`. |
172
209
  | **PRINCIPLES** | Does it not violate the MUST principles in principles.md? |
173
210
 
211
+ **CROSS_CONSISTENCY checklist** (mandatory, check all 5):
212
+ 1. **Entity coverage**: every entity in spec.md `Key Entities` table appears in at least one File Change Map row. Report: `{M}/{N} entities covered`.
213
+ 2. **NFR traceability**: every NFR-* in spec.md has a corresponding Architecture Decision, Risk mitigation, or Implementation Context entry. Report: `{M}/{N} NFRs traced`.
214
+ 3. **Terminology consistency**: same concept uses the same name in spec and plan. Flag any drift (e.g., spec says "user profile", plan says "account settings").
215
+ 4. **Constraint propagation**: every item in spec.md `Constraints` section is addressed in Risk & Mitigation or Implementation Context `Must NOT`. Report: `{M}/{N} constraints propagated`.
216
+ 5. **Acceptance anchor alignment**: Implementation Context `Acceptance Anchors` faithfully reflect spec.md's acceptance scenarios (no omissions, no misinterpretations).
217
+
174
218
  **On FAIL**: auto-fix and continue to next pass.
175
219
  **On ESCALATE**: pause, present options to user, apply choice, resume.
176
220
  **On DEFER**: record reason, mark criterion clean, continue.
177
221
  **On CONVERGE**: `✓ Critic converged ({N} passes, {M} fixes, {E} escalations)`
178
222
  **On SAFETY CAP**: `⚠ Critic safety cap ({N} passes). Review recommended.`
179
223
 
224
+ ### 5.5. ADR Recording (optional)
225
+
226
+ When the `afc-architect` agent is available, invoke it to record architecture decisions:
227
+ ```
228
+ Task("ADR: Record decisions for {feature}", subagent_type: "afc:afc-architect",
229
+ prompt: "Review the plan and record key architecture decisions to your persistent memory.
230
+ Plan sections: Architecture Decision + File Change Map.
231
+ Check for conflicts with existing ADRs. Return: { decisions_recorded: N, conflicts: [] }")
232
+ ```
233
+ - If conflicts detected → warn user
234
+ - If agent unavailable → skip (decisions still exist in plan.md for reference)
235
+
236
+ ### 5.6. Auto-Checkpoint (standalone only)
237
+
238
+ When not running inside `/afc:auto`, save progress for `/afc:resume`:
239
+ - Write/update `.claude/afc/memory/checkpoint.md` with: branch, last commit, feature name, current phase (plan complete), next step (`/afc:implement`)
240
+ - Skip if running inside auto pipeline (auto manages its own checkpoints via phase transitions)
241
+
180
242
  ### 6. Final Output
181
243
 
182
244
  ```
183
245
  Plan generated
184
246
  ├─ .claude/afc/specs/{feature}/plan.md
185
247
  ├─ .claude/afc/specs/{feature}/research.md (if research was performed)
248
+ ├─ Implementation Context: generated ({W} words)
186
249
  ├─ Critic: converged ({N} passes, {M} fixes, {E} escalations)
187
- └─ Next step: /afc:tasks
250
+ └─ Next step: /afc:implement (tasks generated automatically at implement start)
188
251
  ```
189
252
 
190
253
  ## Notes
191
254
 
255
+ - **"No Change" is a valid outcome**: If Approach 0 (status quo) is the best option, recommend it. Do not implement for the sake of implementing.
192
256
  - Write plan.md to an **actionable level**. Vague expressions like "handle appropriately" are prohibited.
193
257
  - File paths in the File Change Map must be based on the **actual project structure** (no guessing).
194
258
  - Place files according to {config.architecture} rules; verify by checking existing codebase patterns.
@@ -2,7 +2,6 @@
2
2
  name: afc:principles
3
3
  description: "Manage project principles"
4
4
  argument-hint: "[action: add, remove, init]"
5
- disable-model-invocation: true
6
5
  allowed-tools:
7
6
  - Read
8
7
  - Write
@@ -26,7 +25,12 @@ model: haiku
26
25
 
27
26
  ## Config Load
28
27
 
29
- **Must** read `.claude/afc.config.md` first. Stop if the config file is not present.
28
+ **Always** read `.claude/afc.config.md` first.
29
+
30
+ If config file is missing:
31
+ 1. Ask the user: "`.claude/afc.config.md` not found. Run `/afc:init` to set up the project?"
32
+ 2. If user accepts → run `/afc:init`, then **restart this command** with the original `$ARGUMENTS`
33
+ 3. If user declines → **abort**
30
34
 
31
35
  ## Execution Steps
32
36
 
@@ -2,7 +2,6 @@
2
2
  name: afc:resume
3
3
  description: "Restore session"
4
4
  argument-hint: "[no arguments]"
5
- disable-model-invocation: true
6
5
  model: haiku
7
6
  allowed-tools:
8
7
  - Read
@@ -60,7 +59,7 @@ Compare the checkpoint state against the current environment:
60
59
  ### Recommended Next Steps
61
60
  {recommended commands based on state}
62
61
  - Tasks in progress → resume `/afc:implement`
63
- - Plan complete → `/afc:tasks`
62
+ - Plan complete → `/afc:implement` (tasks generated automatically at start)
64
63
  - Spec only → `/afc:plan`
65
64
  ```
66
65
 
@@ -28,7 +28,12 @@ model: sonnet
28
28
 
29
29
  ## Config Load
30
30
 
31
- **Always** read `.claude/afc.config.md` first (read manually if not auto-loaded above). Abort if config file is missing.
31
+ **Always** read `.claude/afc.config.md` first (read manually if not auto-loaded above).
32
+
33
+ If config file is missing:
34
+ 1. Ask the user: "`.claude/afc.config.md` not found. Run `/afc:init` to set up the project?"
35
+ 2. If user accepts → run `/afc:init`, then **restart this command** with the original `$ARGUMENTS`
36
+ 3. If user declines → **abort**
32
37
 
33
38
  ## Execution Steps
34
39
 
@@ -58,21 +63,44 @@ Task("Review: {file3, file4}", subagent_type: "general-purpose")
58
63
  Read each agent's returned output, then write consolidated review.
59
64
 
60
65
  #### 11+ files: Review Swarm
61
- Create a review task pool and spawn self-organizing review workers:
62
- ```
63
- // 1. Register each file as a review task via TaskCreate
64
- TaskCreate({ subject: "Review: src/auth/login.ts", description: "Review for quality, security, architecture, performance..." })
65
- TaskCreate({ subject: "Review: src/auth/session.ts", ... })
66
- // ... for all changed files
66
+ Create a review task pool and spawn pre-assigned review workers:
67
+
68
+ > **Note**: Unlike implement swarm (which prohibits self-claiming due to write conflicts), review workers use orchestrator pre-assignment by file group. This is safe because review is read-only — no write race conditions.
67
69
 
70
+ ```
71
+ // 1. Group files into batches (2-3 files per worker)
68
72
  // 2. Spawn N review workers in a single message (N = min(5, file count / 2))
69
- Task("Review Worker 1", subagent_type: "general-purpose",
70
- prompt: "You are a review worker. Loop: TaskList claim pending → read file + diff → review → record findings → repeat until empty.
73
+ Task("Review Worker 1: src/auth/login.ts, src/auth/session.ts", subagent_type: "general-purpose",
74
+ prompt: "Review the following files for quality, security, architecture, performance.
75
+ Files: src/auth/login.ts, src/auth/session.ts
71
76
  Review criteria: {config.code_style}, {config.architecture}, security, performance.
72
77
  Output findings as: severity (Critical/Warning/Info), file:line, issue, suggested fix.")
78
+ Task("Review Worker 2: src/api/routes.ts, src/api/middleware.ts", subagent_type: "general-purpose", ...)
73
79
  ```
74
80
  Collect all worker outputs, then write consolidated review.
75
81
 
82
+ ### 2.5. Specialist Agent Delegation (optional, parallel)
83
+
84
+ When the `afc-architect` and `afc-security` agents are available, delegate perspectives B and C for deeper analysis:
85
+
86
+ ```
87
+ Task("Architecture Review", subagent_type: "afc:afc-architect",
88
+ prompt: "Review changed files for architecture compliance.
89
+ Files: {changed file list}
90
+ Rules: {config.architecture}
91
+ Return findings as: severity, file:line, issue, suggested fix.")
92
+
93
+ Task("Security Review", subagent_type: "afc:afc-security",
94
+ prompt: "Scan changed files for security vulnerabilities.
95
+ Files: {changed file list}
96
+ Return findings as: severity, file:line, issue, suggested fix.")
97
+ ```
98
+
99
+ - Launch both in a **single message** (parallel execution)
100
+ - Merge agent findings into the consolidated review (Step 4)
101
+ - Agents update their persistent memory automatically (ADR patterns, vulnerability patterns, false positives)
102
+ - If agents are unavailable (e.g., standalone mode without plugin): fall back to direct review for B and C
103
+
76
104
  ### 3. Perform Review
77
105
 
78
106
  For each changed file, examine from the following perspectives:
@@ -83,25 +111,46 @@ For each changed file, examine from the following perspectives:
83
111
  - Duplicate code
84
112
  - Unnecessary complexity
85
113
 
86
- #### B. {config.architecture}
114
+ #### B. {config.architecture} (agent-enhanced when available)
87
115
  - Layer dependency direction violations (lower→upper imports)
88
116
  - Segment rules (api/, model/, ui/, lib/)
89
117
  - Appropriate layer placement
118
+ - **Agent bonus**: ADR conflict detection, cross-session pattern recognition
90
119
 
91
- #### C. Security
120
+ #### C. Security (agent-enhanced when available)
92
121
  - XSS vulnerabilities (dangerouslySetInnerHTML, unvalidated user input)
93
122
  - Sensitive data exposure
94
123
  - SQL/Command injection
124
+ - **Agent bonus**: false positive filtering, known vulnerability pattern matching
95
125
 
96
126
  #### D. Performance
97
- - Unnecessary re-renders (missing useCallback/useMemo)
98
- - Infinite loop potential (useEffect dependencies)
99
- - Large data processing
127
+ - Startup/response latency concerns
128
+ - Unnecessary computation or redundant operations
129
+ - Resource management (memory, file handles, connections, subprocesses)
130
+ - Framework-specific performance patterns (from Project Context)
100
131
 
101
132
  #### E. Project Pattern Compliance
102
- - {config.state_management} usage patterns
103
- - Server/client state management patterns (see {config.state_management})
104
- - Component structure (Props type location, hook order)
133
+ - {config.code_style} naming and structure conventions
134
+ - {config.architecture} layer rules and boundaries
135
+ - Framework-specific idioms and best practices (from Project Context)
136
+
137
+ #### F. Reusability
138
+ - Duplicate or near-duplicate logic across files
139
+ - Opportunities to extract shared utilities or helpers
140
+ - DRY principle adherence (same logic repeated in multiple places)
141
+ - Appropriate abstraction level (not premature, not missing)
142
+
143
+ #### G. Maintainability
144
+ - Function/file size — can a developer or LLM understand each unit in isolation?
145
+ - Naming clarity — do names reveal intent without requiring surrounding context?
146
+ - Self-contained files — minimal cross-file dependencies for comprehension
147
+ - Comments where logic is non-obvious (present where needed, absent where redundant)
148
+
149
+ #### H. Extensibility
150
+ - Can new variants or features be added without modifying existing code?
151
+ - Are there clear extension points (configuration, plugin hooks, strategy patterns)?
152
+ - Open/Closed principle adherence where applicable
153
+ - Future modification cost — would a reasonable feature request require rewriting or only extending?
105
154
 
106
155
  ### 4. Review Output
107
156
 
@@ -146,7 +195,8 @@ Run the critic loop until convergence. Safety cap: 5 passes.
146
195
 
147
196
  | Criterion | Validation |
148
197
  |-----------|------------|
149
- | **COMPLETENESS** | Were all changed files reviewed? Are there any missed perspectives? |
198
+ | **COMPLETENESS** | Were all changed files reviewed? Are there any missed perspectives (A through H)? |
199
+ | **SPEC_ALIGNMENT** | Cross-check implementation against spec.md: (1) every SC (success criterion) is satisfied — provide `{M}/{N} SC verified` count, (2) every acceptance scenario (GWT) has corresponding code path, (3) no spec constraint is violated by the implementation |
150
200
  | **PRECISION** | Are the findings actual issues, not false positives? |
151
201
 
152
202
  **On FAIL**: auto-fix and continue to next pass.
@@ -2,7 +2,6 @@
2
2
  name: afc:security
3
3
  description: "Security scan (read-only)"
4
4
  argument-hint: "[scan scope: file/directory path or full]"
5
- disable-model-invocation: true
6
5
  context: fork
7
6
  agent: afc-security
8
7
  allowed-tools:
@@ -27,16 +26,14 @@ model: sonnet
27
26
 
28
27
  ## Config Load
29
28
 
30
- Read the following settings from `CLAUDE.md` or `.claude/CLAUDE.md` at the project root and assign to the `config` variable:
29
+ **Always** read `.claude/afc.config.md` first. This file contains free-form markdown sections:
30
+ - `## Project Context` — framework, state management, testing, etc. (primary source for framework info)
31
+ - `## Architecture` — architecture pattern, layers, import rules
32
+ - `## Code Style` — language, naming conventions, lint rules
31
33
 
32
- ```
33
- config.framework = the framework used in the project
34
- (e.g., "Next.js", "Nuxt", "SvelteKit", "Express", "NestJS")
35
- → Framework specified in CLAUDE.md. Assume "unknown" if not present.
36
- config.auditCmd = dependency audit command
37
- (e.g., "yarn audit", "npm audit", "pnpm audit")
38
- → Infer from the packageManager field in package.json or the lockfile.
39
- ```
34
+ If config file is missing: read `CLAUDE.md` for framework info. Assume "unknown" if neither source has it.
35
+
36
+ For dependency audit command: infer from `packageManager` field in `package.json` or the lockfile (e.g., `npm audit`, `yarn audit`, `pnpm audit`).
40
37
 
41
38
  ## Execution Steps
42
39
 
@@ -67,7 +64,7 @@ Task("Security scan: src/shared/api/", subagent_type: general-purpose)
67
64
  - Session management vulnerabilities
68
65
 
69
66
  #### C. Sensitive Data Exposure (A02:2021)
70
- - `.env` values exposed to the client (check framework-specific public env variables for {config.framework})
67
+ - `.env` values exposed to the client (check framework-specific public env variables from Project Context)
71
68
  - Sensitive information printed via console.log
72
69
  - Internal details exposed in error messages
73
70
 
@@ -108,7 +105,7 @@ Task("Security scan: src/shared/api/", subagent_type: general-purpose)
108
105
  - **Mitigation**: {how to fix}
109
106
 
110
107
  ### Dependency Audit
111
- {config.auditCmd} result summary — if executable
108
+ {dependency audit command result summary — if executable}
112
109
 
113
110
  ### Recommended Actions
114
111
  {prioritized fix suggestions}
@@ -128,4 +125,4 @@ Security scan complete
128
125
  - **Read-only**: Does not modify code. Reports security issues only.
129
126
  - **Minimize false positives**: Account for React's default XSS defenses. Report only genuinely dangerous patterns.
130
127
  - **Handle sensitive data carefully**: Do not include actual token or password values in scan results.
131
- - **Consider context**: Reflect security specifics for the {config.framework} environment.
128
+ - **Consider context**: Reflect security specifics for the project's framework environment (from Project Context).