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.
- package/.claude-plugin/marketplace.json +4 -4
- package/.claude-plugin/plugin.json +3 -4
- package/MIGRATION.md +10 -7
- package/README.md +68 -119
- package/agents/afc-architect.md +16 -0
- package/agents/afc-impl-worker.md +40 -0
- package/agents/afc-security.md +11 -0
- package/bin/cli.mjs +1 -1
- package/commands/analyze.md +6 -7
- package/commands/architect.md +5 -7
- package/commands/auto.md +355 -102
- package/commands/checkpoint.md +3 -4
- package/commands/clarify.md +8 -1
- package/commands/debug.md +40 -3
- package/commands/doctor.md +12 -13
- package/commands/ideate.md +191 -0
- package/commands/implement.md +211 -66
- package/commands/init.md +76 -61
- package/commands/launch.md +181 -0
- package/commands/plan.md +86 -22
- package/commands/principles.md +6 -2
- package/commands/resume.md +1 -2
- package/commands/review.md +68 -18
- package/commands/security.md +10 -13
- package/commands/spec.md +60 -3
- package/commands/tasks.md +19 -4
- package/commands/test.md +24 -6
- package/docs/phase-gate-protocol.md +6 -6
- package/hooks/hooks.json +29 -3
- package/package.json +19 -11
- package/schemas/hooks.schema.json +75 -0
- package/schemas/marketplace.schema.json +52 -0
- package/schemas/plugin.schema.json +53 -0
- package/scripts/afc-bash-guard.sh +6 -6
- package/scripts/afc-blast-radius.sh +418 -0
- package/scripts/afc-config-change.sh +6 -4
- package/scripts/afc-consistency-check.sh +261 -0
- package/scripts/afc-dag-validate.mjs +94 -0
- package/scripts/afc-dag-validate.sh +142 -0
- package/scripts/afc-failure-hint.sh +6 -4
- package/scripts/afc-parallel-validate.mjs +81 -0
- package/scripts/afc-parallel-validate.sh +33 -45
- package/scripts/afc-permission-request.sh +56 -11
- package/scripts/afc-pipeline-manage.sh +46 -46
- package/scripts/afc-preflight-check.sh +6 -3
- package/scripts/afc-schema-validate.sh +225 -0
- package/scripts/afc-session-end.sh +5 -5
- package/scripts/afc-state.sh +256 -0
- package/scripts/afc-stop-gate.sh +32 -24
- package/scripts/afc-subagent-context.sh +15 -6
- package/scripts/afc-subagent-stop.sh +4 -2
- package/scripts/afc-task-completed-gate.sh +19 -25
- package/scripts/afc-teammate-idle.sh +9 -14
- package/scripts/afc-test-pre-gen.sh +141 -0
- package/scripts/afc-timeline-log.sh +9 -6
- package/scripts/afc-user-prompt-submit.sh +8 -10
- package/scripts/afc-worktree-create.sh +56 -0
- package/scripts/afc-worktree-remove.sh +47 -0
- package/scripts/install-shellspec.sh +38 -0
- package/scripts/pre-compact-checkpoint.sh +6 -4
- package/scripts/session-start-context.sh +9 -8
- package/scripts/track-afc-changes.sh +6 -9
- package/templates/afc.config.template.md +12 -76
- package/templates/afc.config.express-api.md +0 -99
- package/templates/afc.config.monorepo.md +0 -98
- package/templates/afc.config.nextjs-fsd.md +0 -107
- package/templates/afc.config.react-spa.md +0 -96
package/commands/implement.md
CHANGED
|
@@ -6,8 +6,8 @@ argument-hint: "[task ID or phase specification]"
|
|
|
6
6
|
|
|
7
7
|
# /afc:implement — Execute Code Implementation
|
|
8
8
|
|
|
9
|
-
> Executes
|
|
10
|
-
>
|
|
9
|
+
> Executes implementation phase by phase with dependency-aware scheduling.
|
|
10
|
+
> Generates tasks.md automatically from plan.md if absent. Swarm mode activates for >5 parallel tasks per phase.
|
|
11
11
|
|
|
12
12
|
## Arguments
|
|
13
13
|
|
|
@@ -19,7 +19,12 @@ argument-hint: "[task ID or phase specification]"
|
|
|
19
19
|
|
|
20
20
|
## Config Load
|
|
21
21
|
|
|
22
|
-
**Always** read `.claude/afc.config.md` first (read manually if not auto-loaded above).
|
|
22
|
+
**Always** read `.claude/afc.config.md` first (read manually if not auto-loaded above).
|
|
23
|
+
|
|
24
|
+
If config file is missing:
|
|
25
|
+
1. Ask the user: "`.claude/afc.config.md` not found. Run `/afc:init` to set up the project?"
|
|
26
|
+
2. If user accepts → run `/afc:init`, then **restart this command** with the original `$ARGUMENTS`
|
|
27
|
+
3. If user declines → **abort**
|
|
23
28
|
|
|
24
29
|
## Execution Steps
|
|
25
30
|
|
|
@@ -35,23 +40,66 @@ git tag -f afc/pre-implement
|
|
|
35
40
|
- Tag is automatically overwritten on the next `/afc:implement` run
|
|
36
41
|
- Skip if running inside `/afc:auto` pipeline (the `afc/pre-auto` tag already exists)
|
|
37
42
|
|
|
43
|
+
**Standalone safety activation** (skip if inside `/afc:auto`):
|
|
44
|
+
If no active pipeline state exists, activate it for the duration of this command:
|
|
45
|
+
```bash
|
|
46
|
+
"${CLAUDE_PLUGIN_ROOT}/scripts/afc-pipeline-manage.sh" start {feature-name-from-plan.md}
|
|
47
|
+
"${CLAUDE_PLUGIN_ROOT}/scripts/afc-pipeline-manage.sh" phase implement
|
|
48
|
+
```
|
|
49
|
+
This enables Stop Gate and CI Gate hooks during standalone implementation. Release on completion (Step 7) or failure rollback.
|
|
50
|
+
|
|
38
51
|
### 1. Load Context
|
|
39
52
|
|
|
40
53
|
1. **Current branch** → `BRANCH_NAME`
|
|
41
54
|
2. Load the following files from `.claude/afc/specs/{feature}/`:
|
|
42
|
-
- **
|
|
43
|
-
- **plan.md** (required) — abort if missing
|
|
55
|
+
- **plan.md** (required) — abort if missing: "plan.md not found. Run `/afc:plan` first."
|
|
44
56
|
- **spec.md** (for reference)
|
|
45
57
|
- **research.md** (if present)
|
|
46
|
-
|
|
58
|
+
- **tasks.md** (if present — may be generated in Step 1.3)
|
|
59
|
+
3. **Recent changes**: run `git log --oneline -20` to understand what changed recently (context for implementation)
|
|
60
|
+
4. **Smoke test**: run `{config.gate}` before starting implementation:
|
|
61
|
+
- If it fails → diagnose before implementing (existing code is broken — fix first or report to user)
|
|
62
|
+
- If it passes → baseline confirmed, proceed
|
|
63
|
+
|
|
64
|
+
### 1.3. Task List Generation (if tasks.md absent)
|
|
65
|
+
|
|
66
|
+
If `.claude/afc/specs/{feature}/tasks.md` does not exist, generate it from plan.md:
|
|
67
|
+
|
|
68
|
+
1. **Parse plan.md File Change Map**: extract files, actions, descriptions, `Depends On`, `Phase`
|
|
69
|
+
2. **Generate tasks.md**:
|
|
70
|
+
- Convert each row to task format: `- [ ] T{NNN} {[P]} {description} \`{file}\` {depends: [TXXX]}`
|
|
71
|
+
- Assign `[P]` to tasks in the same Phase with no file dependency overlap
|
|
72
|
+
- Map `Depends On` column to `depends: [TXXX]` references
|
|
73
|
+
- Include phase gate validation task per phase
|
|
74
|
+
- Include coverage mapping at the bottom:
|
|
75
|
+
- FR/NFR → tasks (every FR-*/NFR-* maps to at least one task)
|
|
76
|
+
- Entity → tasks (every spec Key Entity maps to at least one task)
|
|
77
|
+
- Constraint → tasks (every spec Constraint is addressed by at least one task)
|
|
78
|
+
3. **Validate** (script-based, no critic loop):
|
|
79
|
+
```bash
|
|
80
|
+
"${CLAUDE_PLUGIN_ROOT}/scripts/afc-dag-validate.sh" .claude/afc/specs/{feature}/tasks.md
|
|
81
|
+
"${CLAUDE_PLUGIN_ROOT}/scripts/afc-parallel-validate.sh" .claude/afc/specs/{feature}/tasks.md
|
|
82
|
+
```
|
|
83
|
+
4. If validation fails → fix tasks.md and re-validate (max 2 attempts)
|
|
84
|
+
5. Save to `.claude/afc/specs/{feature}/tasks.md`
|
|
85
|
+
|
|
86
|
+
If tasks.md already exists (e.g., from standalone `/afc:tasks` run): use as-is, skip generation.
|
|
87
|
+
|
|
88
|
+
### 1.5. Parse Task List
|
|
89
|
+
|
|
90
|
+
1. Parse tasks.md:
|
|
47
91
|
- Extract each task's ID, [P] marker, [US*] label, description, file paths, `depends:` list
|
|
48
92
|
- Group by phase
|
|
49
93
|
- Build dependency graph (validate DAG — abort if circular)
|
|
50
94
|
- Identify already-completed `[x]` tasks
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
95
|
+
2. Load **Implementation Context** section from plan.md (used in sub-agent prompts)
|
|
96
|
+
|
|
97
|
+
### 1.5. Retrospective Check
|
|
98
|
+
|
|
99
|
+
If `.claude/afc/memory/retrospectives/` exists, load and check:
|
|
100
|
+
- Were there implementation issues in past pipelines (e.g., file conflicts, unexpected dependencies, CI failures after parallel execution)?
|
|
101
|
+
- Flag similar patterns in the current task list. Warn before implementation begins.
|
|
102
|
+
- Skip gracefully if directory is empty or absent.
|
|
55
103
|
|
|
56
104
|
### 2. Check Progress
|
|
57
105
|
|
|
@@ -72,7 +120,7 @@ Execute each phase in order. Choose the orchestration mode based on the number o
|
|
|
72
120
|
|---------------------|------|----------|
|
|
73
121
|
| 0 | Sequential | Execute tasks one by one |
|
|
74
122
|
| 1–5 | Parallel Batch | Launch Task() calls in parallel (current batch approach) |
|
|
75
|
-
| 6+ | Swarm | Create task pool →
|
|
123
|
+
| 6+ | Swarm | Create task pool → orchestrator pre-assigns tasks to worker agents |
|
|
76
124
|
|
|
77
125
|
#### Sequential Mode (no P marker)
|
|
78
126
|
|
|
@@ -82,70 +130,136 @@ Execute each phase in order. Choose the orchestration mode based on the number o
|
|
|
82
130
|
|
|
83
131
|
#### Parallel Batch Mode (1–5 [P] tasks)
|
|
84
132
|
|
|
85
|
-
- Verify
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
133
|
+
**Pre-validation**: Verify no file overlap (downgrade to sequential if overlapping).
|
|
134
|
+
|
|
135
|
+
**Step 1 — Register**: Create tasks for the current phase only (phase-locked registration):
|
|
136
|
+
```
|
|
137
|
+
TaskCreate({ subject: "T003: Create UserService", description: "..." })
|
|
138
|
+
TaskCreate({ subject: "T004: Create AuthService", description: "..." })
|
|
139
|
+
TaskUpdate({ taskId: "T004", addBlockedBy: ["T002"] }) // if T004 depends on T002
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Step 2 — Launch unblocked [P] tasks in a single message** (Claude Code executes multiple Task() calls in a single message concurrently, up to ~10):
|
|
143
|
+
```
|
|
144
|
+
Task("T003: Create UserService", subagent_type: "afc:afc-impl-worker",
|
|
145
|
+
isolation: "worktree",
|
|
146
|
+
prompt: "Implement the following task:
|
|
147
|
+
|
|
148
|
+
## Task
|
|
149
|
+
{task ID}: {description} — `{file path}`
|
|
150
|
+
|
|
151
|
+
## Implementation Context
|
|
152
|
+
{paste full ## Implementation Context section from plan.md}
|
|
153
|
+
|
|
154
|
+
## Plan Context
|
|
155
|
+
{relevant Phase section from plan.md for this task}
|
|
156
|
+
|
|
157
|
+
## Rules
|
|
158
|
+
- {config.code_style} and {config.architecture}
|
|
159
|
+
- Follow CLAUDE.md and afc.config.md
|
|
160
|
+
|
|
161
|
+
## Output
|
|
162
|
+
Return a structured summary (max 2000 chars):
|
|
163
|
+
- Files changed: {list}
|
|
164
|
+
- Key decisions: {any design choices made}
|
|
165
|
+
- Issues: {blockers or concerns, if any}
|
|
166
|
+
- Verification: {config.gate} result")
|
|
167
|
+
Task("T004: Create AuthService", subagent_type: "afc:afc-impl-worker", isolation: "worktree", ...)
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**Step 3 — Collect results and advance**: After all parallel agents return:
|
|
171
|
+
1. Read each agent's returned output and verify completion
|
|
172
|
+
2. Mark `TaskUpdate(status: "completed")` for each finished task
|
|
173
|
+
3. **Manually check for newly-unblocked tasks**: Call `TaskList`, inspect `blockedBy` lists — if all blockers are now completed, the task is unblockable. (Note: auto-unblocking is only guaranteed in Agent Teams mode; in sub-agent mode, the orchestrator must poll and check manually.)
|
|
174
|
+
4. If newly-unblockable tasks exist → launch next batch (repeat Step 2)
|
|
175
|
+
5. If no more pending tasks remain → phase complete
|
|
176
|
+
|
|
177
|
+
**Failure Recovery** (per-task, not per-batch):
|
|
178
|
+
1. Identify the failed task from the agent's error return
|
|
179
|
+
2. Reset: `TaskUpdate(taskId, status: "pending")`
|
|
180
|
+
3. Track: `TaskUpdate(taskId, metadata: { retryCount: N })`
|
|
181
|
+
4. If retryCount < 3 → re-launch in the next batch round (not immediately — wait for current batch to finish)
|
|
182
|
+
5. If retryCount >= 3 → mark as failed, report: `"T{ID} failed after 3 attempts: {last error}"`
|
|
183
|
+
6. Continue with remaining tasks — a single failure does not block the entire phase
|
|
104
184
|
|
|
105
185
|
#### Swarm Mode (6+ [P] tasks)
|
|
106
186
|
|
|
107
|
-
When a phase has more than 5 parallelizable tasks, use the **
|
|
187
|
+
When a phase has more than 5 parallelizable tasks, use the **orchestrator-managed swarm pattern**.
|
|
108
188
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
189
|
+
> **Key constraint**: Claude Code's TaskUpdate uses **last-write-wins** with local file locking only. Multiple sub-agents calling TaskUpdate on the same task simultaneously can cause lost writes. The orchestrator must mediate task assignment to prevent collisions.
|
|
190
|
+
|
|
191
|
+
**Step 1 — Register current-phase tasks only** (phase-locked):
|
|
192
|
+
```
|
|
193
|
+
// Register ONLY this phase's tasks — never register future phases
|
|
194
|
+
TaskCreate({ subject: "T007: Create ComponentA", description: "..." })
|
|
195
|
+
TaskCreate({ subject: "T008: Create ComponentB", description: "..." })
|
|
196
|
+
// ... for all tasks in this phase
|
|
197
|
+
TaskUpdate({ taskId: "T008", addBlockedBy: ["T006"] }) // if dependency exists
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
**Step 2 — Orchestrator assigns tasks** (no self-claiming):
|
|
201
|
+
Instead of workers self-claiming (race-prone), the **orchestrator pre-assigns** tasks:
|
|
202
|
+
```
|
|
203
|
+
// Orchestrator assigns: each worker gets a unique, non-overlapping task set
|
|
204
|
+
Task("Worker 1: T007, T009, T011", subagent_type: "afc:afc-impl-worker",
|
|
205
|
+
isolation: "worktree",
|
|
206
|
+
prompt: "Implement these tasks in order:
|
|
207
|
+
1. T007: {description} — `{file path}`
|
|
208
|
+
2. T009: {description} — `{file path}`
|
|
209
|
+
3. T011: {description} — `{file path}`
|
|
210
|
+
|
|
211
|
+
## Implementation Context
|
|
212
|
+
{paste full ## Implementation Context section from plan.md}
|
|
213
|
+
|
|
214
|
+
For each task:
|
|
215
|
+
- Read the target file before modifying
|
|
216
|
+
- Implement following plan.md design
|
|
217
|
+
- Verify with {config.gate} after each task
|
|
218
|
+
|
|
219
|
+
## Rules
|
|
220
|
+
- {config.code_style} and {config.architecture}
|
|
221
|
+
- Follow CLAUDE.md and afc.config.md
|
|
222
|
+
|
|
223
|
+
## Output
|
|
224
|
+
Return a structured summary per task (max 2000 chars total):
|
|
225
|
+
- Files changed, key decisions, issues encountered per task.")
|
|
226
|
+
|
|
227
|
+
Task("Worker 2: T008, T010, T012", subagent_type: "afc:afc-impl-worker", isolation: "worktree", ...)
|
|
228
|
+
```
|
|
130
229
|
|
|
131
|
-
|
|
230
|
+
**Step 3 — Collect and reconcile**:
|
|
231
|
+
1. Wait for all workers to return (foreground execution)
|
|
232
|
+
2. Read results, mark `TaskUpdate(status: "completed")` for each finished task
|
|
233
|
+
3. Call `TaskList` to check for remaining pending/blocked tasks
|
|
234
|
+
4. If unblocked tasks remain → assign to new worker batch (repeat Step 2)
|
|
235
|
+
5. If all tasks complete → phase done
|
|
132
236
|
|
|
133
|
-
|
|
134
|
-
1. Scan TaskList for tasks with status `in_progress` that have no active worker
|
|
135
|
-
2. Reset each orphaned task: `TaskUpdate(taskId, status: "pending", owner: "")`
|
|
136
|
-
3. Track retry count per task (max 2 retries)
|
|
137
|
-
4. If a task fails 3 times → mark as `failed`, report to user: `"T{ID} failed after 3 attempts: {last error}"`
|
|
138
|
-
5. Re-spawn replacement workers for remaining tasks
|
|
237
|
+
**Worker count**: N = min(5, unblocked task count). Max 5 concurrent sub-agents per phase.
|
|
139
238
|
|
|
140
|
-
|
|
239
|
+
**Task assignment strategy**: Round-robin by file path — each worker gets tasks targeting different files to maximize isolation. If a worker has multiple tasks, order them by `depends:` topology.
|
|
141
240
|
|
|
142
|
-
|
|
241
|
+
#### Swarm Failure Recovery
|
|
242
|
+
|
|
243
|
+
When a worker agent returns an error:
|
|
244
|
+
1. Identify which tasks the worker was assigned (from the pre-assigned list)
|
|
245
|
+
2. Check which tasks the worker actually completed (from its result summary)
|
|
246
|
+
3. Reset uncompleted tasks: `TaskUpdate(taskId, status: "pending")`
|
|
247
|
+
4. Track retry count: `TaskUpdate(taskId, metadata: { retryCount: N })`
|
|
248
|
+
5. If retryCount < 3 → reassign to next worker batch
|
|
249
|
+
6. If retryCount >= 3 → mark as failed, report: `"T{ID} failed after 3 attempts: {last error}"`
|
|
250
|
+
7. Continue with remaining tasks
|
|
251
|
+
|
|
252
|
+
> Single task failure does not block the phase. The orchestrator reassigns failed tasks to subsequent batches.
|
|
143
253
|
|
|
144
254
|
#### Dependency Resolution
|
|
145
255
|
|
|
146
|
-
- Tasks with `depends: [T001, T002]` are registered via TaskUpdate(addBlockedBy: ["T001", "T002"])
|
|
147
|
-
-
|
|
148
|
-
|
|
256
|
+
- Tasks with `depends: [T001, T002]` are registered via `TaskUpdate(addBlockedBy: ["T001", "T002"])`
|
|
257
|
+
- **Auto-unblocking is NOT guaranteed in sub-agent mode**. The orchestrator must:
|
|
258
|
+
1. After each batch completes, call `TaskList` to get current state
|
|
259
|
+
2. For each pending task, check if all `blockedBy` tasks are now completed
|
|
260
|
+
3. If all blockers resolved → task is eligible for the next batch
|
|
261
|
+
- **Phase-locked registration**: Only register tasks for the current phase. Never register Phase N+1 tasks until Phase N is fully complete and its gate has passed. This prevents workers from claiming future-phase tasks.
|
|
262
|
+
- **Cross-phase dependencies**: A Phase 2 task may `depends:` on a Phase 1 task. Since Phase 1 must complete before Phase 2 begins, this is always satisfied. Within the same phase, `depends:` creates intra-phase ordering.
|
|
149
263
|
|
|
150
264
|
#### Phase Completion Gate (3 steps)
|
|
151
265
|
|
|
@@ -180,9 +294,37 @@ After all tasks are complete:
|
|
|
180
294
|
```
|
|
181
295
|
|
|
182
296
|
- **Pass**: output final report
|
|
183
|
-
- **Fail**:
|
|
297
|
+
- **Fail**: **Debug-based RCA** (replaces blind retry):
|
|
298
|
+
1. Execute `/afc:debug` logic inline with the CI error output as input
|
|
299
|
+
2. Debug performs RCA: error trace → data flow → hypothesis → targeted fix
|
|
300
|
+
3. Re-run `{config.ci}` after fix
|
|
301
|
+
4. If debug-fix cycle fails 3 times → report to user with diagnosis details (not a simple fix)
|
|
302
|
+
5. This produces targeted fixes instead of blind retries
|
|
303
|
+
|
|
304
|
+
### 6. Implement Critic Loop
|
|
305
|
+
|
|
306
|
+
After CI passes, run a convergence-based Critic Loop to verify design alignment before reporting completion.
|
|
307
|
+
|
|
308
|
+
> **Always** read `${CLAUDE_PLUGIN_ROOT}/docs/critic-loop-rules.md` first and follow it.
|
|
184
309
|
|
|
185
|
-
|
|
310
|
+
**Critic Loop until convergence** (safety cap: 5):
|
|
311
|
+
|
|
312
|
+
- **SCOPE_ADHERENCE**: Compare `git diff` changed files against plan.md File Change List. Flag any file modified that is NOT in the plan. Flag any planned file NOT modified. Provide "M of N files match" count.
|
|
313
|
+
- **ARCHITECTURE**: Validate changed files against `{config.architecture}` rules (layer boundaries, naming conventions, import paths). Provide "N of M rules checked" count.
|
|
314
|
+
- **CORRECTNESS**: Cross-check implemented changes against spec.md acceptance criteria (AC). Verify each AC has corresponding code. Provide "N of M AC verified" count.
|
|
315
|
+
- **Adversarial 3-perspective** (mandatory each pass):
|
|
316
|
+
- Skeptic: "Which implementation assumption is most likely wrong?"
|
|
317
|
+
- Devil's Advocate: "How could this implementation be misused or fail unexpectedly?"
|
|
318
|
+
- Edge-case Hunter: "What input would cause this implementation to fail silently?"
|
|
319
|
+
- State one failure scenario per perspective. If realistic → FAIL + fix. If unrealistic → state quantitative rationale.
|
|
320
|
+
- FAIL → auto-fix, re-run `{config.ci}`, and continue. ESCALATE → pause, present options, resume after response. DEFER → record reason, mark clean.
|
|
321
|
+
|
|
322
|
+
### 7. Final Output
|
|
323
|
+
|
|
324
|
+
**Standalone cleanup** (if pipeline was activated in Step 0):
|
|
325
|
+
```bash
|
|
326
|
+
"${CLAUDE_PLUGIN_ROOT}/scripts/afc-pipeline-manage.sh" end
|
|
327
|
+
```
|
|
186
328
|
|
|
187
329
|
```
|
|
188
330
|
Implementation complete
|
|
@@ -204,3 +346,6 @@ Implementation complete
|
|
|
204
346
|
- **Real-time tasks.md updates**: mark checkbox on each task completion.
|
|
205
347
|
- **Mode selection is automatic**: do not manually override. Sequential for non-[P], batch for ≤5, swarm for 6+.
|
|
206
348
|
- **NEVER use `run_in_background: true` on Task calls**: agents must run in foreground so results are returned before the next step.
|
|
349
|
+
- **No worker self-claiming**: In swarm mode, the orchestrator pre-assigns tasks to workers. Workers do NOT call TaskList/TaskUpdate to claim tasks — this avoids last-write-wins race conditions on TaskUpdate.
|
|
350
|
+
- **Phase-locked registration**: Only register (TaskCreate) the current phase's tasks. Never pre-register future phases. This is the primary mechanism for phase boundary enforcement.
|
|
351
|
+
- **Orchestrator polls for unblocking**: After each batch, the orchestrator calls TaskList and manually checks blockedBy status. Do not rely on automatic unblocking outside Agent Teams mode.
|
package/commands/init.md
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: afc:init
|
|
3
3
|
description: "Project initial setup"
|
|
4
|
-
argument-hint: "[
|
|
5
|
-
|
|
4
|
+
argument-hint: "[additional context]"
|
|
5
|
+
allowed-tools:
|
|
6
|
+
- Read
|
|
7
|
+
- Write
|
|
8
|
+
- Bash
|
|
9
|
+
- Glob
|
|
6
10
|
model: haiku
|
|
7
11
|
---
|
|
8
12
|
|
|
@@ -13,9 +17,7 @@ model: haiku
|
|
|
13
17
|
|
|
14
18
|
## Arguments
|
|
15
19
|
|
|
16
|
-
- `$ARGUMENTS` — (optional)
|
|
17
|
-
- If not specified: analyzes project structure and auto-infers
|
|
18
|
-
- If preset specified: uses `${CLAUDE_PLUGIN_ROOT}/templates/afc.config.{preset}.md`
|
|
20
|
+
- `$ARGUMENTS` — (optional) Additional context or hints for project analysis
|
|
19
21
|
|
|
20
22
|
## Execution Steps
|
|
21
23
|
|
|
@@ -50,74 +52,86 @@ If `.claude/afc.config.md` already exists:
|
|
|
50
52
|
- Ask user: "Config file already exists. Do you want to overwrite it?"
|
|
51
53
|
- If declined: **abort**
|
|
52
54
|
|
|
53
|
-
### 3.
|
|
55
|
+
### 3. Analyze Project Structure
|
|
54
56
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
1. Verify `${CLAUDE_PLUGIN_ROOT}/templates/afc.config.{$ARGUMENTS}.md` exists
|
|
58
|
-
2. If found: copy that file to `.claude/afc.config.md`
|
|
59
|
-
3. If not found: print "Preset `{$ARGUMENTS}` not found. Available: {list}" then **abort**
|
|
60
|
-
|
|
61
|
-
#### B. Auto-Infer (`$ARGUMENTS` not provided)
|
|
62
|
-
|
|
63
|
-
Analyze project structure and auto-infer configuration:
|
|
57
|
+
Analyze the project and auto-infer configuration. Use `$ARGUMENTS` as additional context if provided.
|
|
64
58
|
|
|
65
59
|
**Step 1. Package Manager / Script Detection**
|
|
66
60
|
- Read `package.json` → extract CI-related commands from `scripts` field
|
|
67
|
-
- Determine package manager from lockfile
|
|
68
|
-
|
|
61
|
+
- Determine package manager from lockfile:
|
|
62
|
+
|
|
63
|
+
| Lockfile | Package Manager |
|
|
64
|
+
|----------|----------------|
|
|
65
|
+
| `pnpm-lock.yaml` | pnpm |
|
|
66
|
+
| `yarn.lock` | yarn |
|
|
67
|
+
| `bun.lockb` or `bun.lock` | bun |
|
|
68
|
+
| `package-lock.json` | npm |
|
|
69
|
+
|
|
70
|
+
- If no lockfile: check `packageManager` field in `package.json`
|
|
71
|
+
- Non-JS projects: check `pyproject.toml` (Python), `Cargo.toml` (Rust), `go.mod` (Go)
|
|
69
72
|
|
|
70
73
|
**Step 2. Framework Detection**
|
|
71
74
|
- Determine from `package.json` dependencies/devDependencies:
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
|
|
76
|
+
| Dependency | Framework |
|
|
77
|
+
|-----------|-----------|
|
|
78
|
+
| `next` | Next.js (App Router if `app/` dir exists, else Pages Router) |
|
|
79
|
+
| `nuxt` | Nuxt |
|
|
80
|
+
| `@sveltejs/kit` | SvelteKit |
|
|
81
|
+
| `@remix-run/react` | Remix |
|
|
82
|
+
| `astro` | Astro |
|
|
83
|
+
| `@angular/core` | Angular |
|
|
84
|
+
| `vite` (alone) | Vite SPA |
|
|
85
|
+
| `hono` | Hono |
|
|
86
|
+
| `fastify` | Fastify |
|
|
87
|
+
| `express` | Express |
|
|
88
|
+
|
|
89
|
+
- Non-JS: `pyproject.toml` → Django/FastAPI/Flask, `Cargo.toml` → Rust project, `go.mod` → Go project
|
|
77
90
|
- Presence of `tsconfig.json` → TypeScript indicator
|
|
78
91
|
|
|
79
92
|
**Step 3. Architecture Detection**
|
|
80
93
|
- Analyze directory structure:
|
|
81
|
-
-
|
|
94
|
+
- FSD: requires **at least 3** of `features/`, `entities/`, `shared/`, `widgets/`, `pages/` under `src/`
|
|
82
95
|
- `src/domain/`, `src/application/`, `src/infrastructure/` → Clean Architecture
|
|
83
96
|
- `src/modules/` → Modular
|
|
84
97
|
- Other → Layered
|
|
85
|
-
- `paths` in `tsconfig.json` → extract
|
|
86
|
-
|
|
87
|
-
**Step 4. State
|
|
88
|
-
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
- `
|
|
97
|
-
- `styled-components` → styled-components
|
|
98
|
-
- `jest` / `vitest` / `playwright` → mapped respectively
|
|
99
|
-
|
|
100
|
-
**Step 6. Code Style Detection**
|
|
101
|
-
- Check `.eslintrc*` / `eslint.config.*` → identify lint rules
|
|
102
|
-
- `strict` in `tsconfig.json` → strict_mode
|
|
98
|
+
- `paths` in `tsconfig.json` → extract path alias
|
|
99
|
+
|
|
100
|
+
**Step 4. State / Styling / Testing / DB Detection**
|
|
101
|
+
- State management: `zustand`, `@reduxjs/toolkit`, `@tanstack/react-query`, `swr`, `pinia`, `jotai`, `recoil`
|
|
102
|
+
- Styling: `tailwindcss`, `styled-components`, `@emotion/react`, `sass`, CSS Modules (check for `*.module.css`)
|
|
103
|
+
- Testing: `jest`, `vitest`, `playwright`, `@testing-library/*`, `cypress`
|
|
104
|
+
- Linter: `.eslintrc*` / `eslint.config.*` / `biome.json` / `biome.jsonc`
|
|
105
|
+
- DB/ORM: `prisma` (check `prisma/schema.prisma`), `drizzle-orm`, `typeorm`, `@prisma/client`
|
|
106
|
+
|
|
107
|
+
**Step 5. Code Style Detection**
|
|
108
|
+
- Check linter config → identify key rules
|
|
109
|
+
- `strict` in `tsconfig.json` → strict mode
|
|
103
110
|
- Read 2-3 existing code samples to verify naming patterns
|
|
104
111
|
|
|
105
112
|
### 4. Generate Config File
|
|
106
113
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
114
|
+
Generate `.claude/afc.config.md` in **free-form markdown** format:
|
|
115
|
+
|
|
116
|
+
1. **CI Commands** section: YAML code block with `ci`, `gate`, `test` keys (fixed format, scripts parse these)
|
|
117
|
+
2. **Architecture** section: describe detected architecture style, layers, import rules, path aliases in free-form prose/lists
|
|
118
|
+
3. **Code Style** section: describe detected language, strictness, naming conventions, lint rules in free-form prose/lists
|
|
119
|
+
4. **Project Context** section: describe framework, state management, styling, testing, DB/ORM, risks, and any other relevant project characteristics in free-form prose/lists
|
|
120
|
+
|
|
121
|
+
Reference `${CLAUDE_PLUGIN_ROOT}/templates/afc.config.template.md` for the section structure.
|
|
122
|
+
Write sections as natural descriptions — **no YAML code blocks** except for CI Commands.
|
|
123
|
+
For items that cannot be inferred: note `TODO: Adjust for your project` inline.
|
|
124
|
+
Save to `.claude/afc.config.md`.
|
|
111
125
|
|
|
112
126
|
### 5. Scan Global CLAUDE.md and Detect Conflicts
|
|
113
127
|
|
|
114
128
|
Read `~/.claude/CLAUDE.md` and analyze in the following order.
|
|
115
129
|
|
|
116
|
-
#### Step 1. Check for Existing
|
|
130
|
+
#### Step 1. Check for Existing all-for-claudecode or Legacy SELFISH Block
|
|
117
131
|
|
|
118
132
|
Check for presence of `<!-- AFC:START -->` or `<!-- SELFISH:START -->` marker.
|
|
119
133
|
- If `<!-- AFC:START -->` found: replace with latest version (proceed to Step 3)
|
|
120
|
-
- If `<!-- SELFISH:START -->` found (legacy v1.x): remove the entire `SELFISH:START` ~ `SELFISH:END` block, then proceed to inject new
|
|
134
|
+
- If `<!-- SELFISH:START -->` found (legacy v1.x): remove the entire `SELFISH:START` ~ `SELFISH:END` block, then proceed to inject new all-for-claudecode block at Step 4. Print: `Migrated: SELFISH block → all-for-claudecode block in ~/.claude/CLAUDE.md`
|
|
121
135
|
- If neither found: proceed to Step 2
|
|
122
136
|
|
|
123
137
|
#### Step 2. Conflict Pattern Scan
|
|
@@ -145,8 +159,8 @@ Find these patterns:
|
|
|
145
159
|
|
|
146
160
|
**D. Legacy Block Detection**
|
|
147
161
|
Previous versions without markers or with old branding:
|
|
148
|
-
- `##
|
|
149
|
-
- `##
|
|
162
|
+
- `## all-for-claudecode Auto-Trigger Rules`
|
|
163
|
+
- `## all-for-claudecode Integration`
|
|
150
164
|
- `<!-- SELFISH:START -->` ~ `<!-- SELFISH:END -->` (v1.x block — should have been caught in Step 1, but double-check here)
|
|
151
165
|
- `<selfish-pipeline>` / `</selfish-pipeline>` XML tags
|
|
152
166
|
|
|
@@ -170,25 +184,25 @@ Ask user:
|
|
|
170
184
|
> "Directives overlapping with afc were found. How would you like to proceed?"
|
|
171
185
|
>
|
|
172
186
|
> 1. **afc-exclusive mode** — Adds afc override comments to conflicting agent routing directives.
|
|
173
|
-
> Does not modify other tools' marker block contents; covers them with override rules in the
|
|
187
|
+
> Does not modify other tools' marker block contents; covers them with override rules in the all-for-claudecode block.
|
|
174
188
|
> 2. **coexistence mode** — Ignores conflicts and adds only the afc block.
|
|
175
189
|
> Since it's at the end of the file, afc directives will likely take priority, but may be non-deterministic on conflict.
|
|
176
190
|
> 3. **manual cleanup** — Shows only the current conflict list and stops.
|
|
177
191
|
> User manually cleans up CLAUDE.md then runs init again.
|
|
178
192
|
|
|
179
193
|
Based on choice:
|
|
180
|
-
- **Option 1**:
|
|
181
|
-
- **Option 2**:
|
|
194
|
+
- **Option 1**: all-for-claudecode block includes explicit override rules (activates `<conflict-overrides>` section from base template)
|
|
195
|
+
- **Option 2**: all-for-claudecode block added without overrides (base template as-is)
|
|
182
196
|
- **Option 3**: Print conflict list only and abort without modifying CLAUDE.md
|
|
183
197
|
|
|
184
|
-
#### Step 4. Inject
|
|
198
|
+
#### Step 4. Inject all-for-claudecode Block
|
|
185
199
|
|
|
186
200
|
**Version resolution**: Read `${CLAUDE_PLUGIN_ROOT}/package.json` and extract the `"version"` field. Use this value as `{PLUGIN_VERSION}` in the template below.
|
|
187
201
|
|
|
188
202
|
Add the following block at the **very end** of the file (later-positioned directives have higher priority).
|
|
189
203
|
|
|
190
|
-
Replace existing
|
|
191
|
-
If legacy block (`##
|
|
204
|
+
Replace existing all-for-claudecode block if present, otherwise append.
|
|
205
|
+
If legacy block (`## all-for-claudecode Auto-Trigger Rules` etc.) exists, remove it then append.
|
|
192
206
|
|
|
193
207
|
```markdown
|
|
194
208
|
<!-- AFC:START -->
|
|
@@ -209,10 +223,12 @@ IMPORTANT: For requests matching the afc skill routing table below, always invok
|
|
|
209
223
|
| Spec | `afc:spec` | spec, specification |
|
|
210
224
|
| Tasks | `afc:tasks` | break down tasks, decompose |
|
|
211
225
|
| Research | `afc:research` | research, investigate |
|
|
226
|
+
| Ideate | `afc:ideate` | idea, brainstorm, what to build, product brief |
|
|
212
227
|
| Ambiguous | `afc:clarify` | auto-triggered when requirements are unclear |
|
|
213
228
|
| Full auto | `afc:auto` | do it automatically, auto-run |
|
|
214
229
|
|
|
215
230
|
User-only (not auto-triggered — inform user on request):
|
|
231
|
+
- `afc:launch` — inform user when release artifact generation is requested
|
|
216
232
|
- `afc:doctor` — inform user when health check is requested
|
|
217
233
|
- `afc:architect` — inform user when architecture review is requested
|
|
218
234
|
- `afc:security` — inform user when security scan is requested
|
|
@@ -222,11 +238,11 @@ User-only (not auto-triggered — inform user on request):
|
|
|
222
238
|
|
|
223
239
|
## Pipeline
|
|
224
240
|
|
|
225
|
-
spec → plan →
|
|
241
|
+
spec → plan → implement → review → clean
|
|
226
242
|
|
|
227
243
|
## Override Rules
|
|
228
244
|
|
|
229
|
-
NEVER use executor, deep-executor, debugger, planner, analyst, verifier, test-engineer, code-reviewer, quality-reviewer, style-reviewer, api-reviewer, security-reviewer, performance-reviewer for tasks that
|
|
245
|
+
NEVER use executor, deep-executor, debugger, planner, analyst, verifier, test-engineer, code-reviewer, quality-reviewer, style-reviewer, api-reviewer, security-reviewer, performance-reviewer for tasks that an afc skill covers above. ALWAYS invoke the afc skill instead.
|
|
230
246
|
</afc-pipeline>
|
|
231
247
|
<!-- AFC:END -->
|
|
232
248
|
```
|
|
@@ -247,7 +263,7 @@ The following rules were auto-generated to resolve conflicts:
|
|
|
247
263
|
### 6. Final Output
|
|
248
264
|
|
|
249
265
|
```
|
|
250
|
-
|
|
266
|
+
all-for-claudecode initialization complete
|
|
251
267
|
├─ Config: .claude/afc.config.md
|
|
252
268
|
├─ Framework: {detected framework}
|
|
253
269
|
├─ Architecture: {detected style}
|
|
@@ -263,10 +279,9 @@ All-for-ClaudeCode initialization complete
|
|
|
263
279
|
|
|
264
280
|
- **Overwrite caution**: If config file already exists, always confirm with user.
|
|
265
281
|
- **Inference limits**: Auto-inference is best-effort. User may need to review and adjust.
|
|
266
|
-
- **Preset path**: Presets are loaded from the `templates/` directory inside the plugin.
|
|
267
282
|
- **`.claude/` directory**: Created automatically if it does not exist.
|
|
268
283
|
- **Global CLAUDE.md principles**:
|
|
269
|
-
- Never modify content outside the `<!-- AFC:START/END -->` markers
|
|
284
|
+
- Never modify content outside the `<!-- AFC:START/END -->` markers (the `AFC` prefix in markers is a compact technical identifier)
|
|
270
285
|
- Never modify content inside other tools' marker blocks (`<!-- *:START/END -->`)
|
|
271
|
-
- Always place the
|
|
286
|
+
- Always place the all-for-claudecode block at the very end of the file (ensures priority)
|
|
272
287
|
- Conflict resolution is handled only via override rules (do not delete or modify other blocks)
|