all-for-claudecode 2.9.1 → 2.11.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 (42) hide show
  1. package/.claude-plugin/marketplace.json +2 -2
  2. package/.claude-plugin/plugin.json +2 -2
  3. package/MIGRATION.md +1 -1
  4. package/README.md +4 -0
  5. package/package.json +2 -2
  6. package/schemas/plugin.schema.json +2 -2
  7. package/scripts/afc-consistency-check.sh +25 -23
  8. package/scripts/afc-doctor.sh +10 -10
  9. package/scripts/afc-qa-audit.sh +1 -1
  10. package/scripts/afc-sync-cache.sh +1 -1
  11. package/{commands/analyze.md → skills/analyze/SKILL.md} +10 -8
  12. package/{commands/architect.md → skills/architect/SKILL.md} +3 -3
  13. package/skills/auto/SKILL.md +1156 -0
  14. package/{commands/clarify.md → skills/clarify/SKILL.md} +4 -3
  15. package/{commands/clean.md → skills/clean/SKILL.md} +14 -13
  16. package/{commands/consult.md → skills/consult/SKILL.md} +19 -18
  17. package/{commands/implement.md → skills/implement/SKILL.md} +28 -15
  18. package/{commands/init.md → skills/init/SKILL.md} +5 -1
  19. package/{commands/learner.md → skills/learner/SKILL.md} +4 -4
  20. package/{commands/plan.md → skills/plan/SKILL.md} +1 -122
  21. package/skills/plan/plan-template.md +118 -0
  22. package/{commands/pr-comment.md → skills/pr-comment/SKILL.md} +4 -4
  23. package/{commands/principles.md → skills/principles/SKILL.md} +1 -1
  24. package/{commands/qa.md → skills/qa/SKILL.md} +2 -2
  25. package/{commands/release-notes.md → skills/release-notes/SKILL.md} +8 -4
  26. package/{commands/review.md → skills/review/SKILL.md} +11 -11
  27. package/{commands/security.md → skills/security/SKILL.md} +19 -4
  28. package/{commands/spec.md → skills/spec/SKILL.md} +2 -77
  29. package/skills/spec/spec-template.md +72 -0
  30. package/{commands/triage.md → skills/triage/SKILL.md} +6 -7
  31. package/commands/auto.md +0 -585
  32. /package/{commands/checkpoint.md → skills/checkpoint/SKILL.md} +0 -0
  33. /package/{commands/debug.md → skills/debug/SKILL.md} +0 -0
  34. /package/{commands/doctor.md → skills/doctor/SKILL.md} +0 -0
  35. /package/{commands/ideate.md → skills/ideate/SKILL.md} +0 -0
  36. /package/{commands/launch.md → skills/launch/SKILL.md} +0 -0
  37. /package/{commands/research.md → skills/research/SKILL.md} +0 -0
  38. /package/{commands/resume.md → skills/resume/SKILL.md} +0 -0
  39. /package/{docs → skills/spec}/nfr-templates.md +0 -0
  40. /package/{commands/tasks.md → skills/tasks/SKILL.md} +0 -0
  41. /package/{commands/test.md → skills/test/SKILL.md} +0 -0
  42. /package/{commands/validate.md → skills/validate/SKILL.md} +0 -0
@@ -50,10 +50,11 @@ Scan across 10 categories:
50
50
  | 9 | Completion criteria | Success criteria that cannot be measured |
51
51
  | 10 | Residual placeholders | TODO/TBD/??? |
52
52
 
53
+ These categories serve as a comprehensive checklist, not a rigid classification. Adapt to the project's domain — skip categories irrelevant to the project type (e.g., skip 'UX flow' for CLI tools) and add domain-specific categories if needed (e.g., 'regulatory compliance' for healthcare/fintech projects).
54
+
53
55
  ### 3. Generate and Present Questions
54
56
 
55
- - Generate at most **5** questions
56
- - Priority: scope > security/privacy > UX > technical
57
+ - Generate questions ranked by their impact on spec quality — how much would the answer change the spec's direction or completeness? Present the most impactful questions first. The number of questions should match the actual ambiguity level: deeply ambiguous specs may need more questions, while mostly-clear specs need fewer. Do not artificially cap at a fixed number, but keep the set focused and avoid overwhelming the user (aim for the minimum needed to resolve critical ambiguities).
57
58
  - Present **one at a time** via AskUserQuestion:
58
59
  - Use multiple choice when possible (2-4 options)
59
60
  - Include the meaning/impact of each option
@@ -79,7 +80,7 @@ Clarification complete
79
80
 
80
81
  ## Notes
81
82
 
82
- - **5-question limit**: If more than 5 questions arise, select only the most important. Resolve the rest during the plan phase.
83
+ - **Question focus**: Ask only what is needed to resolve critical ambiguities. Defer lower-priority questions to the plan phase rather than overwhelming the user.
83
84
  - **Modify spec only**: Do not touch plan.md or tasks.md.
84
85
  - **Avoid redundancy**: Do not ask about items already clearly stated in spec.
85
86
  - **If `$ARGUMENTS` is provided**: Focus the scan on that area.
@@ -60,23 +60,24 @@ Set `PIPELINE_ARTIFACT_DIR` = `.claude/afc/specs/{feature}/`
60
60
  - **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)
61
61
  - **If review-report.md exists** -> copy to `.claude/afc/memory/reviews/{feature}-{date}.md` before .claude/afc/specs/ deletion
62
62
  - **If research.md exists** and was not already persisted in Plan phase -> copy to `.claude/afc/memory/research/{feature}.md`
63
- - **Agent memory consolidation**: check each agent's MEMORY.md line count -- if either exceeds 100 lines, invoke the respective agent to self-prune:
63
+ - **Agent memory consolidation**: Check each agent's MEMORY.md for bloat if it contains redundant, obsolete, or superseded entries that reduce signal-to-noise ratio, invoke the agent to self-prune:
64
64
  ```
65
65
  Task("Memory cleanup: afc-architect", subagent_type: "afc:afc-architect",
66
- prompt: "Your MEMORY.md exceeds 100 lines. Read it, prune old/redundant entries, and rewrite to under 100 lines following your size limit rules.")
66
+ prompt: "Review your MEMORY.md. Read it, identify and prune old/redundant/obsolete entries, and rewrite it keeping only entries that are still relevant and non-overlapping.")
67
67
  ```
68
- (Same pattern for afc-security if needed. Skip if both are under 100 lines.)
69
- - **Memory rotation**: for each memory subdirectory, check file count and prune oldest files if over threshold:
70
- | Directory | Threshold | Action |
71
- |-----------|-----------|--------|
72
- | `quality-history/` | 30 files | Delete oldest files beyond threshold |
73
- | `reviews/` | 40 files | Delete oldest files beyond threshold |
74
- | `retrospectives/` | 30 files | Delete oldest files beyond threshold |
75
- | `research/` | 50 files | Delete oldest files beyond threshold |
76
- | `decisions/` | 60 files | Delete oldest files beyond threshold |
77
- - Sort by filename ascending (oldest first), delete excess
68
+ Use semantic assessment (are entries still relevant? do entries overlap?) rather than a line-count threshold. (Same pattern for afc-security if needed.)
69
+ - **Memory rotation**: For each memory subdirectory, assess whether the oldest files still provide value. Prune files that are superseded by newer entries, reference features/code that no longer exists, or overlap with other files. As a practical guideline, keep the most recent and relevant entries — if a directory has grown large enough that scanning it would be slow (roughly 30+ files), prioritize pruning the least relevant entries:
70
+ | Directory | Pruning Intent | Soft Guideline |
71
+ |-----------|---------------|----------------|
72
+ | `quality-history/` | Remove superseded or redundant quality records | ~30 files |
73
+ | `reviews/` | Remove reviews for features no longer in the codebase | ~40 files |
74
+ | `retrospectives/` | Remove retrospectives whose learnings are already captured elsewhere | ~30 files |
75
+ | `research/` | Remove research for libraries/patterns no longer used | ~50 files |
76
+ | `decisions/` | Remove decisions that have been reversed or are no longer relevant | ~60 files |
77
+ - These numbers are soft guidelines, not hard cutoffs — use judgment based on relevance
78
+ - Sort by filename ascending (oldest first) when pruning by recency
78
79
  - Log: `"Memory rotation: {dir} pruned {N} files"`
79
- - Skip directories that do not exist or are under threshold
80
+ - Skip directories that do not exist or clearly do not need pruning
80
81
 
81
82
  ### 6. Quality Report
82
83
 
@@ -33,24 +33,25 @@ If `$ARGUMENTS` is empty → go to Step 2 (domain selection).
33
33
 
34
34
  **A. Explicit domain provided** → use it directly.
35
35
 
36
- **B. No domain, but question provided** → keyword matching:
37
-
38
- | Domain | Keywords |
39
- |--------|----------|
40
- | backend | API, database, schema, query, server, auth, JWT, REST, GraphQL, ORM, migration, endpoint, middleware, validation, session, cookie, token |
41
- | infra | deploy, Docker, CI/CD, cloud, monitoring, k8s, pipeline, Kubernetes, terraform, AWS, GCP, Azure, nginx, SSL, DNS, CDN, container, scaling |
42
- | pm | feature, user story, priority, roadmap, PRD, MVP, backlog, metric, KPI, retention, churn, persona, requirement, scope |
43
- | design | UI, UX, accessibility, component, layout, color, animation, responsive, wireframe, prototype, typography, spacing, contrast, WCAG |
44
- | marketing | SEO, analytics, content, growth, conversion, funnel, GA4, acquisition, retention, landing page, Open Graph, meta tag, social media |
45
- | legal | GDPR, CCPA, privacy, cookie, consent, license, GPL, MIT, compliance, terms of service, data protection, PII, HIPAA, regulation, policy |
46
- | security | XSS, CSRF, injection, OWASP, vulnerability, attack, exploit, encryption, secret, credential, CORS, CSP, rate limit, brute force, penetration |
47
- | advisor | library, framework, stack, tool, package, which to use, alternative, compare, choose, select, recommend, what exists, ecosystem, best option, switch to |
48
- | peer | think together, brainstorm, discuss, explore idea, talk through, figure out, pros and cons, what if, should I, direction, approach, trade-off, opinion, weigh options |
49
-
50
- Match rules:
51
- - Case-insensitive keyword matching against the question
52
- - If multiple domains match: pick the one with the most keyword hits
53
- - If tie: pick the first domain in the table order above
36
+ **B. No domain, but question provided** → intent-based evaluation:
37
+
38
+ Read the user's question and determine which domain's expertise would provide the most value. Consider the actual intent, not keyword presence.
39
+
40
+ | Domain | When to route |
41
+ |--------|---------------|
42
+ | backend | User needs help with server-side logic, data modeling, API design, authentication flows, database decisions, or how application code processes and stores data |
43
+ | infra | User needs help with how the application is deployed, operated, or monitored — infrastructure topology, CI/CD pipelines, cloud services, scaling, reliability |
44
+ | pm | User needs help with product decisions: what to build, for whom, when, how to measure success, how to prioritize competing features, or how to define scope |
45
+ | design | User needs help with how something looks or feels to a user visual hierarchy, interaction patterns, accessibility, component design, or user flow |
46
+ | marketing | User needs help reaching or retaining users outside the product: SEO, content strategy, acquisition funnels, analytics tracking, or growth tactics |
47
+ | legal | User needs help understanding regulatory obligations, license compatibility, privacy requirements, or the legal implications of a design or data practice |
48
+ | security | User needs help identifying or mitigating threats, vulnerabilities, or attack surfaces secure coding, threat modeling, or compliance with security standards |
49
+ | advisor | User is choosing between technologies, frameworks, libraries, or architectural approaches and wants an informed recommendation with trade-off analysis |
50
+ | peer | User wants to think through a problem collaboratively, explore directions, weigh trade-offs, or have a structured dialogue rather than receive an answer |
51
+
52
+ Evaluation rules:
53
+ - Identify what specialized knowledge the user actually needs, not which domain's jargon appears in the text
54
+ - If multiple domains seem relevant, identify the PRIMARY expertise gap — what specialized knowledge does the user need most?
54
55
 
55
56
  **C. No domain, no question, or no keyword match** → ask user:
56
57
 
@@ -116,7 +116,7 @@ If `.claude/afc/memory/retrospectives/` exists, load the **most recent 10 files*
116
116
 
117
117
  ### 3. Phase-by-Phase Execution
118
118
 
119
- Execute each phase in order. Choose the orchestration mode based on the number of [P] tasks in the phase:
119
+ Execute each phase in order. Choose the orchestration mode by evaluating whether multi-agent coordination overhead would be justified given the tasks' characteristics:
120
120
 
121
121
  #### Mode Selection
122
122
 
@@ -126,12 +126,17 @@ Execute each phase in order. Choose the orchestration mode based on the number o
126
126
  |-----------|------|----------|
127
127
  | No [P] markers | Sequential | Main agent executes tasks one by one |
128
128
  | [P] tasks but delegation criteria NOT met | Sequential | Main agent executes directly (preserves full context) |
129
- | [P] tasks, delegation criteria ALL met, 3–5 [P] | Parallel Batch | Launch Task() calls in parallel |
130
- | [P] tasks, delegation criteria ALL met, 6+ [P] | Swarm | Create task pool → orchestrator pre-assigns tasks to worker agents |
129
+ | [P] tasks, delegation criteria ALL met, coordination overhead justified, moderate parallelism | Parallel Batch | Launch Task() calls in parallel |
130
+ | [P] tasks, delegation criteria ALL met, coordination overhead clearly justified, high parallelism | Swarm | Create task pool → orchestrator pre-assigns tasks to worker agents |
131
+
132
+ **Mode judgment**: Ask — "Given these N tasks with their complexity, file scope, and interdependencies, would spawning multiple agents and merging their results be faster and safer than executing sequentially?" If the answer is not clearly yes, default to Sequential.
133
+
134
+ - **Parallel Batch** is appropriate when there are enough independent tasks that parallel execution provides meaningful speed gain, but the total count is manageable enough that a single orchestrator round-trip suffices.
135
+ - **Swarm** is appropriate when the number of independent tasks is large enough that a single batch of Task() calls would saturate the concurrent agent limit, requiring multiple orchestrator rounds.
131
136
 
132
137
  **Parallel delegation criteria** (ALL must be satisfied):
133
138
  1. Tasks have **no `depends:` edges** between them in the DAG (no ordering constraint)
134
- 2. **≥ 3 parallelizable tasks** in the phase (2 tasks → sequential is cheaper)
139
+ 2. **Enough parallelizable tasks** that multi-agent overhead is worth it (a very small number of short tasks → sequential is cheaper)
135
140
  3. Each task is **self-contained** (does not require runtime results from other tasks in the same batch)
136
141
  4. Each task's **target files do not overlap** with any other task in the batch (no shared file writes)
137
142
 
@@ -143,7 +148,7 @@ If ANY criterion fails → main agent sequential execution (context preservation
143
148
  - On task start: `▶ {ID}: {description}`
144
149
  - On completion: `✓ {ID} complete`
145
150
 
146
- #### Parallel Batch Mode (3–5 [P] tasks)
151
+ #### Parallel Batch Mode (moderate [P] tasks)
147
152
 
148
153
  **Pre-validation**: Verify no file overlap (downgrade to sequential if overlapping).
149
154
 
@@ -203,14 +208,18 @@ Task("T004: Create AuthService", subagent_type: "afc:afc-impl-worker", isolation
203
208
  2. Capture the `agentId` from the failed agent's result (returned in Task tool output)
204
209
  3. Reset: `TaskUpdate(taskId, status: "pending")`
205
210
  4. Track: `TaskUpdate(taskId, metadata: { retryCount: N, lastAgentId: agentId })`
206
- 5. If retryCount < 3 → re-launch with `resume: lastAgentId` in the next batch round. The resumed agent retains full context from the previous attempt (what it tried, what failed, partial progress), enabling more targeted retry instead of starting from scratch.
211
+ 5. **Classify the error before deciding to retry**:
212
+ - **First failure** (no `metadata.lastError` exists): store `metadata.lastError = {current error message}`. Classify as transient (no prior error to compare) and proceed with retry.
213
+ - **Subsequent failures** (`metadata.lastError` exists): Compare the current error with `metadata.lastError`. If the error is **the same** (deterministic failure — same message, same stack location) → stop immediately and mark as failed. Retrying a deterministic failure wastes cycles.
214
+ - If the error **differs** from the previous attempt (transient/flaky — different message, network blip, lock contention) → re-launch with `resume: lastAgentId`. The resumed agent retains full context from the previous attempt (what it tried, what failed, partial progress), enabling more targeted retry.
207
215
  - **Worktree caveat**: if the failed worker made no file changes, its worktree is auto-cleaned and `resume` will fail. In this case, fall back to a fresh launch (omit `resume`) for the retry.
208
- 6. If retryCount >= 3 mark as failed, report: `"T{ID} failed after 3 attempts: {last error}"`
216
+ - Update `metadata.lastError` with the current error on each attempt.
217
+ 6. If retryCount >= 5 (absolute safety cap) → mark as failed, report: `"T{ID} failed after {retryCount} attempts: {last error}"`
209
218
  7. Continue with remaining tasks — a single failure does not block the entire phase
210
219
 
211
- #### Swarm Mode (6+ [P] tasks)
220
+ #### Swarm Mode (high [P] task count)
212
221
 
213
- When a phase has more than 5 parallelizable tasks, use the **orchestrator-managed swarm pattern**.
222
+ When a phase has enough parallelizable tasks that a single batch of Task() calls would saturate the concurrent agent limit and require multiple orchestrator rounds, use the **orchestrator-managed swarm pattern**.
214
223
 
215
224
  > **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.
216
225
 
@@ -268,7 +277,7 @@ Task("Worker 2: T008, T010, T012", subagent_type: "afc:afc-impl-worker", isolati
268
277
  5. If unblocked tasks remain → assign to new worker batch (repeat Step 2)
269
278
  6. If all tasks complete → phase done
270
279
 
271
- **Worker count**: N = min(5, unblocked task count). Max 5 concurrent sub-agents per phase.
280
+ **Worker count**: N = min(5, unblocked task count). Max 5 concurrent sub-agents per phase (5 is the Claude Code platform limit for concurrent agents — not a semantic preference).
272
281
 
273
282
  **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.
274
283
 
@@ -280,9 +289,13 @@ When a worker agent returns an error:
280
289
  3. Capture the `agentId` from the failed worker's result
281
290
  4. Reset uncompleted tasks: `TaskUpdate(taskId, status: "pending")`
282
291
  5. Track retry count: `TaskUpdate(taskId, metadata: { retryCount: N, lastAgentId: agentId })`
283
- 6. If retryCount < 3 re-launch with `resume: lastAgentId` to preserve context from the previous attempt. The resumed agent retains its full conversation history (files read, changes attempted, errors encountered), enabling targeted retry.
292
+ 6. **Classify the error before deciding to retry**:
293
+ - **First failure** (no `metadata.lastError` exists): store `metadata.lastError = {current error message}`. Classify as transient (no prior error to compare) and proceed with retry.
294
+ - **Subsequent failures** (`metadata.lastError` exists): Compare the current error with `metadata.lastError`. If the error is **the same** (deterministic failure — same message, same stack location) → stop immediately and mark as failed. Retrying a deterministic failure wastes cycles.
295
+ - If the error **differs** from the previous attempt (transient/flaky — different message, network blip, lock contention) → re-launch with `resume: lastAgentId`. The resumed agent retains its full conversation history (files read, changes attempted, errors encountered), enabling targeted retry.
284
296
  - **Worktree caveat**: if the failed worker made no file changes, its worktree is auto-cleaned and `resume` will fail. In this case, fall back to a fresh launch (omit `resume`) for the retry.
285
- 7. If retryCount >= 3 mark as failed, report: `"T{ID} failed after 3 attempts: {last error}"`
297
+ - Update `metadata.lastError` with the current error on each attempt.
298
+ 7. If retryCount >= 5 (absolute safety cap) → mark as failed, report: `"T{ID} failed after {retryCount} attempts: {last error}"`
286
299
  8. Continue with remaining tasks
287
300
 
288
301
  > Single task failure does not block the phase. The orchestrator reassigns failed tasks to subsequent batches.
@@ -350,7 +363,7 @@ After CI passes, run a convergence-based Critic Loop to verify design alignment
350
363
 
351
364
  **Critic Loop until convergence** (safety cap: 5):
352
365
 
353
- - **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.
366
+ - **SCOPE_ADHERENCE**: Compare `git diff` changed files against plan.md File Change Map. Flag any file modified that is NOT in the plan. Flag any planned file NOT modified. Provide "M of N files match" count.
354
367
  - **ARCHITECTURE**: Validate changed files against `{config.architecture}` rules (layer boundaries, naming conventions, import paths). Provide "N of M rules checked" count.
355
368
  - **CORRECTNESS**: Cross-check implemented changes against spec.md acceptance criteria (AC). Verify each AC has corresponding code. Provide "N of M AC verified" count.
356
369
  - **SIDE_EFFECT_SAFETY**: For tasks that changed call order, error handling, or state flow: verify that callee behavior is compatible with the new call pattern. Provide "{M} of {N} behavioral changes verified" count.
@@ -384,10 +397,10 @@ Implementation complete
384
397
  - **Architecture compliance**: follow {config.architecture} rules.
385
398
  - **{config.ci} gate**: must pass on phase completion. Do not bypass.
386
399
  - **Swarm workers**: max 5 concurrent. File overlap is strictly prohibited between parallel tasks.
387
- - **On error**: prevent infinite loops. Report to user after 3 attempts.
400
+ - **On error**: classify errors before retrying. Stop immediately on deterministic (same) errors. Allow additional attempts for transient (different) errors. Hard cap at 5 retries total.
388
401
  - **Real-time tasks.md updates**: mark checkbox on each task completion.
389
402
  - **Default is direct execution**: main agent executes tasks directly unless all 4 parallel delegation criteria are met. This preserves full context and avoids multi-agent context loss.
390
- - **Mode selection is automatic**: do not manually override. Sequential (default), batch for 3–5 qualifying [P], swarm for 6+ qualifying [P].
403
+ - **Mode selection is automatic**: do not manually override. Sequential (default), batch when moderate independent parallelism justifies coordination overhead, swarm when high task count requires multiple orchestrator rounds.
391
404
  - **NEVER use `run_in_background: true` on Task calls**: agents must run in foreground so results are returned before the next step.
392
405
  - **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.
393
406
  - **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.
@@ -72,6 +72,8 @@ Analyze the project and auto-infer configuration. Use `$ARGUMENTS` as additional
72
72
  - If no lockfile: check `packageManager` field in `package.json`
73
73
  - Non-JS projects: check `pyproject.toml` (Python), `Cargo.toml` (Rust), `go.mod` (Go)
74
74
 
75
+ > These detection rules are starting-point heuristics, not definitive. If a project uses a tool not listed here, the model should still detect it from context (e.g., `bun.lockb` for Bun, `deno.lock` for Deno). Always confirm the detected setup with the user before proceeding.
76
+
75
77
  **Step 2. Framework Detection**
76
78
  - Determine from `package.json` dependencies/devDependencies:
77
79
 
@@ -91,9 +93,11 @@ Analyze the project and auto-infer configuration. Use `$ARGUMENTS` as additional
91
93
  - Non-JS: `pyproject.toml` → Django/FastAPI/Flask, `Cargo.toml` → Rust project, `go.mod` → Go project
92
94
  - Presence of `tsconfig.json` → TypeScript indicator
93
95
 
96
+ > This list covers common frameworks but is not exhaustive. For unlisted frameworks, infer from package.json dependencies, project structure, and configuration files. Present the detection result to the user for confirmation.
97
+
94
98
  **Step 3. Architecture Detection**
95
99
  - Analyze directory structure:
96
- - FSD: requires **at least 3** of `features/`, `entities/`, `shared/`, `widgets/`, `pages/` under `src/`
100
+ - FSD: If the project's src/ directory contains a combination of FSD-characteristic directories (`features/`, `entities/`, `shared/`, `widgets/`, `pages/`, `processes/`, `app/`), assess whether the project follows FSD principles. Variant FSD structures (e.g., using `processes/` instead of `pages/`) should also be detected. Confirm with the user if the detection is uncertain.
97
101
  - `src/domain/`, `src/application/`, `src/infrastructure/` → Clean Architecture
98
102
  - `src/modules/` → Modular
99
103
  - Other → Layered
@@ -53,7 +53,7 @@ Analyze ALL queue entries together as a batch. For each entry, you receive struc
53
53
  **Classification rules:**
54
54
  1. Group semantically similar entries into clusters (e.g., "use const not let" + "always use const" = 1 cluster)
55
55
  2. For each cluster, determine:
56
- - **Confidence**: high (explicit preference, ≥2 occurrences) / medium (single clear correction) / low (ambiguous excerpt)
56
+ - **Confidence**: Assess based on the strength and clarity of the signal, not occurrence count. A single explicit user correction ("never do X") is high confidence. Two ambiguous occurrences may still be medium. Consider: was the feedback direct and clear? Does it apply broadly or only to a specific case? Use high / medium / low accordingly.
57
57
  - **Rule type**: naming, style, workflow, testing, architecture
58
58
  - **Scope**: universal (all files) or file-type-specific (e.g., "In TypeScript files...")
59
59
 
@@ -73,7 +73,7 @@ For each candidate rule:
73
73
 
74
74
  ### 4. Present Suggestions
75
75
 
76
- Show clustered suggestions to user. Cap at **5 suggestions per review** (highest confidence first).
76
+ Show clustered suggestions to user, most impactful first. Present the most impactful suggestions first. If there are many high-confidence patterns, present them all rather than artificially capping. If most are low-confidence, present fewer. Let relevance and confidence drive the count, not a fixed limit.
77
77
 
78
78
  ```markdown
79
79
  ## Learned Patterns ({N} pending, showing top {M})
@@ -125,7 +125,7 @@ For each approved rule:
125
125
 
126
126
  3. **Remove consumed entries** from `.claude/.afc-learner-queue.jsonl` (entries that were approved, skipped, or rejected — only keep entries not yet reviewed)
127
127
 
128
- 4. **Rule count check**: If `afc-learned.md` now has ≥30 rules (count `<!-- afc:learned` markers), suggest consolidation:
128
+ 4. **Rule count check**: Suggest consolidation when the rules file becomes unwieldy — when rules overlap, contradict each other, or are too numerous to effectively guide behavior. Use judgment rather than a fixed count:
129
129
  ```
130
130
  afc-learned.md has {N} rules. Consider reviewing and consolidating related rules
131
131
  to keep context budget efficient. You can edit the file directly.
@@ -147,6 +147,6 @@ Learner review complete
147
147
  - **Opt-in only**: Learner signal collection requires `.claude/afc/learner.json` to exist. Run `/afc:learner enable` to start.
148
148
  - **Project-scoped rules**: All rules write to `.claude/rules/afc-learned.md` (git-tracked, team-visible). Never writes to root `CLAUDE.md`, `~/.claude/CLAUDE.md`, or auto memory.
149
149
  - **No raw prompts stored**: The signal queue contains only structured metadata (type, category, 80-char redacted excerpt, timestamp). Full prompt text is never persisted.
150
- - **Queue limits**: Max 50 entries, 7-day TTL. Stale entries are pruned at session start.
150
+ - **Queue limits**: Manage queue size to prevent unbounded growth. Remove entries that have been reviewed, are no longer relevant (the code they reference has changed significantly), or are duplicates of already-processed patterns. As a practical guideline, keep the queue focused on recent, actionable items. Stale entries are pruned at session start.
151
151
  - **Safe by design**: Anti-injection guardrails prevent propagation of harmful instructions. Category blocklist prevents rules about permissions/security/hooks.
152
152
  - **Editable output**: `afc-learned.md` is a regular markdown file. Edit, delete, or reorganize rules at any time.
@@ -101,128 +101,7 @@ Future pipelines can reference prior research to avoid redundant investigation.
101
101
 
102
102
  ### 4. Phase 1 — Write Design
103
103
 
104
- Create `.claude/afc/specs/{feature}/plan.md`. **Must** follow the structure below:
105
-
106
- ```markdown
107
- # Implementation Plan: {feature name}
108
-
109
- ## Summary
110
- {summary of core requirements from spec + technical approach, 3-5 sentences}
111
-
112
- ## Technical Context
113
- {Summarize key project settings from .claude/rules/afc-project.md (auto-loaded) and afc.config.md}
114
- - **Constraints**: {constraints extracted from spec}
115
-
116
- ## Principles Check
117
- {if .claude/afc/memory/principles.md exists: validation results against MUST principles}
118
- {if violations possible: state explicitly + justification}
119
-
120
- ## Architecture Decision
121
- ### Approach
122
- {core idea of the chosen design}
123
-
124
- ### Architecture Placement
125
- | Layer | Path | Role |
126
- |-------|------|------|
127
- | {entities/features/widgets/shared} | {path} | {description} |
128
-
129
- ### State Management Strategy (omit if not applicable)
130
- {what combination of Zustand store / React Query / Context is used where}
131
-
132
- ### API Design (omit if not applicable)
133
- {plan for new API endpoints or use of existing APIs}
134
-
135
- ## Test Strategy
136
-
137
- > Written alongside the File Change Map. Classify each implementation file and decide test coverage level.
138
- > Determines which files need test coverage and at what level.
139
-
140
- ### Code Classification
141
-
142
- | File | Code Type | Test Need | Reason |
143
- |------|-----------|:---------:|--------|
144
- | {path} | {business-logic / pure-function / side-effect / framework / config / UI} | {required / optional / unnecessary} | {brief justification} |
145
-
146
- > Classification guide:
147
- > - **business-logic / pure-function**: Required — unit tests (AAA pattern)
148
- > - **side-effect code** (external API, DB, file I/O): Required — integration tests with mocks
149
- > - **framework / config / getter-setter / boilerplate**: Unnecessary — no test
150
- > - **UI rendering** (no state logic): Optional — minimal snapshot or skip
151
-
152
- ### Test Pyramid
153
-
154
- - **Unit tests**: {count} files ({which files})
155
- - **Integration tests**: {count} files ({which files}, if applicable)
156
- - **E2E tests**: {count} (if applicable, only for critical user flows)
157
-
158
- ### Required Test Cases (derived from spec EARS requirements)
159
-
160
- {For each spec EARS requirement with `→ TC:` mapping, list the test case here}
161
- - `should_{behavior}_when_{trigger}` → covers FR-{NNN}
162
- - `should_{behavior}_while_{state}` → covers FR-{NNN}
163
-
164
- ## File Change Map
165
-
166
- | File | Action | Description | Depends On | Phase |
167
- |------|--------|-------------|------------|-------|
168
- | {path} | create/modify/delete | {summary} | {file(s) or "—"} | {1-N} |
169
-
170
- > - **Depends On**: list file(s) that must be created/modified first (enables dependency-aware task generation in /afc:implement).
171
- > - **Phase**: implementation phase number. Same-phase + no dependency + different file = parallelizable.
172
- > - **Test files**: For each implementation file classified as "required" in Code Classification, include a corresponding test file in the same Phase. Test files are first-class citizens in the File Change Map.
173
-
174
- ## Implementation Context
175
-
176
- > Auto-generated section for implementation agents. Compress to under 500 words.
177
- > This section travels with every sub-agent prompt during /afc:implement.
178
-
179
- - **Objective**: {1-sentence feature purpose from spec Overview}
180
- - **Key Constraints**: {NFR summaries + spec Constraints section, compressed}
181
- - **Critical Edge Cases**: {top 3 edge cases from spec, 1 line each}
182
- - **Risk Watchpoints**: {top risks from Risk & Mitigation table}
183
- - **Must NOT**: {explicit prohibitions — from spec constraints, principles.md, or CLAUDE.md}
184
- - **Acceptance Anchors**: {key acceptance criteria from spec that implementation must satisfy}
185
-
186
- ## Risk & Mitigation
187
- | Risk | Impact | Mitigation |
188
- |------|--------|------------|
189
- | {risk} | {H/M/L} | {approach} |
190
-
191
- ## Alternative Design
192
- ### Approach 0: No Change (status quo)
193
- {Why might the current state be sufficient? What is the cost of doing nothing?}
194
- {If no change is clearly inferior: state specific reason — "Status quo lacks X, which is required by FR-001"}
195
- {If no change is viable: recommend it — avoid implementing for the sake of implementing}
196
-
197
- ### Approach A: {chosen approach name}
198
- {Brief description — this is the approach detailed above}
199
-
200
- ### Approach B: {alternative approach name}
201
- {Brief description of a meaningfully different approach}
202
-
203
- | Criterion | No Change | Approach A | Approach B |
204
- |-----------|-----------|-----------|-----------|
205
- | Complexity | None | {evaluation} | {evaluation} |
206
- | Risk | None | {evaluation} | {evaluation} |
207
- | Maintainability | Current | {evaluation} | {evaluation} |
208
- | Justification | {why not enough} | {why this} | {why this} |
209
-
210
- **Decision**: Approach {0/A/B} — {1-sentence rationale}
211
- {If Approach 0 chosen: abort plan, report: "No implementation needed — current state satisfies requirements."}
212
-
213
- ## Phase Breakdown
214
- ### Phase 1: Setup
215
- {project structure, type definitions, configuration}
216
-
217
- ### Phase 2: Core Implementation
218
- {core business logic, state management}
219
-
220
- ### Phase 3: UI & Integration
221
- {UI components, API integration}
222
-
223
- ### Phase 4: Polish
224
- {error handling, performance optimization, tests}
225
- ```
104
+ Create `.claude/afc/specs/{feature}/plan.md` following the template in `${CLAUDE_SKILL_DIR}/plan-template.md`. Read it first, then generate the plan using that structure. **All sections are mandatory** unless marked "(omit if not applicable)".
226
105
 
227
106
  ### 4.5. File Path Verification
228
107
 
@@ -0,0 +1,118 @@
1
+ # Implementation Plan: {feature name}
2
+
3
+ ## Summary
4
+ {summary of core requirements from spec + technical approach, 3-5 sentences}
5
+
6
+ ## Technical Context
7
+ {Summarize key project settings from .claude/rules/afc-project.md (auto-loaded) and afc.config.md}
8
+ - **Constraints**: {constraints extracted from spec}
9
+
10
+ ## Principles Check
11
+ {if .claude/afc/memory/principles.md exists: validation results against MUST principles}
12
+ {if violations possible: state explicitly + justification}
13
+
14
+ ## Architecture Decision
15
+ ### Approach
16
+ {core idea of the chosen design}
17
+
18
+ ### Architecture Placement
19
+ | Layer | Path | Role |
20
+ |-------|------|------|
21
+ | {entities/features/widgets/shared} | {path} | {description} |
22
+
23
+ ### State Management Strategy (omit if not applicable)
24
+ {what combination of Zustand store / React Query / Context is used where}
25
+
26
+ ### API Design (omit if not applicable)
27
+ {plan for new API endpoints or use of existing APIs}
28
+
29
+ ## Test Strategy
30
+
31
+ > Written alongside the File Change Map. Classify each implementation file and decide test coverage level.
32
+ > Determines which files need test coverage and at what level.
33
+
34
+ ### Code Classification
35
+
36
+ | File | Code Type | Test Need | Reason |
37
+ |------|-----------|:---------:|--------|
38
+ | {path} | {business-logic / pure-function / side-effect / framework / config / UI} | {required / optional / unnecessary} | {brief justification} |
39
+
40
+ > Classification guide:
41
+ > - **business-logic / pure-function**: Required — unit tests (AAA pattern)
42
+ > - **side-effect code** (external API, DB, file I/O): Required — integration tests with mocks
43
+ > - **framework / config / getter-setter / boilerplate**: Unnecessary — no test
44
+ > - **UI rendering** (no state logic): Optional — minimal snapshot or skip
45
+
46
+ ### Test Pyramid
47
+
48
+ - **Unit tests**: {count} files ({which files})
49
+ - **Integration tests**: {count} files ({which files}, if applicable)
50
+ - **E2E tests**: {count} (if applicable, only for critical user flows)
51
+
52
+ ### Required Test Cases (derived from spec EARS requirements)
53
+
54
+ {For each spec EARS requirement with `→ TC:` mapping, list the test case here}
55
+ - `should_{behavior}_when_{trigger}` → covers FR-{NNN}
56
+ - `should_{behavior}_while_{state}` → covers FR-{NNN}
57
+
58
+ ## File Change Map
59
+
60
+ | File | Action | Description | Depends On | Phase |
61
+ |------|--------|-------------|------------|-------|
62
+ | {path} | create/modify/delete | {summary} | {file(s) or "—"} | {1-N} |
63
+
64
+ > - **Depends On**: list file(s) that must be created/modified first (enables dependency-aware task generation in /afc:implement).
65
+ > - **Phase**: implementation phase number. Same-phase + no dependency + different file = parallelizable.
66
+ > - **Test files**: For each implementation file classified as "required" in Code Classification, include a corresponding test file in the same Phase. Test files are first-class citizens in the File Change Map.
67
+
68
+ ## Implementation Context
69
+
70
+ > Auto-generated section for implementation agents. Compress to under 500 words.
71
+ > This section travels with every sub-agent prompt during /afc:implement.
72
+
73
+ - **Objective**: {1-sentence feature purpose from spec Overview}
74
+ - **Key Constraints**: {NFR summaries + spec Constraints section, compressed}
75
+ - **Critical Edge Cases**: {top 3 edge cases from spec, 1 line each}
76
+ - **Risk Watchpoints**: {top risks from Risk & Mitigation table}
77
+ - **Must NOT**: {explicit prohibitions — from spec constraints, principles.md, or CLAUDE.md}
78
+ - **Acceptance Anchors**: {key acceptance criteria from spec that implementation must satisfy}
79
+
80
+ ## Risk & Mitigation
81
+ | Risk | Impact | Mitigation |
82
+ |------|--------|------------|
83
+ | {risk} | {H/M/L} | {approach} |
84
+
85
+ ## Alternative Design
86
+ ### Approach 0: No Change (status quo)
87
+ {Why might the current state be sufficient? What is the cost of doing nothing?}
88
+ {If no change is clearly inferior: state specific reason — "Status quo lacks X, which is required by FR-001"}
89
+ {If no change is viable: recommend it — avoid implementing for the sake of implementing}
90
+
91
+ ### Approach A: {chosen approach name}
92
+ {Brief description — this is the approach detailed above}
93
+
94
+ ### Approach B: {alternative approach name}
95
+ {Brief description of a meaningfully different approach}
96
+
97
+ | Criterion | No Change | Approach A | Approach B |
98
+ |-----------|-----------|-----------|-----------|
99
+ | Complexity | None | {evaluation} | {evaluation} |
100
+ | Risk | None | {evaluation} | {evaluation} |
101
+ | Maintainability | Current | {evaluation} | {evaluation} |
102
+ | Justification | {why not enough} | {why this} | {why this} |
103
+
104
+ **Decision**: Approach {0/A/B} — {1-sentence rationale}
105
+ {If Approach 0 chosen: abort plan, report: "No implementation needed — current state satisfies requirements."}
106
+
107
+ ## Phase Breakdown
108
+ ### Phase 1: Setup
109
+ {project structure, type definitions, configuration}
110
+
111
+ ### Phase 2: Core Implementation
112
+ {core business logic, state management}
113
+
114
+ ### Phase 3: UI & Integration
115
+ {UI components, API integration}
116
+
117
+ ### Phase 4: Polish
118
+ {error handling, performance optimization, tests}
@@ -134,10 +134,10 @@ No issues found. Code looks good!
134
134
 
135
135
  Display the full review comment to the user in the console.
136
136
 
137
- Then determine the review event type:
138
- - **Critical findings exist** `REQUEST_CHANGES`
139
- - **Only Warning/Info findings** `COMMENT`
140
- - **No findings** `APPROVE`
137
+ Then determine the review event based on the actual severity and context of findings:
138
+ - **REQUEST_CHANGES**: Use when findings indicate genuine risk to production code — bugs that would affect users, security vulnerabilities, or architectural violations that would be costly to fix later. A Critical finding in test code or documentation alone does not warrant blocking the PR.
139
+ - **COMMENT**: Use when findings are improvements or concerns that the author should consider but that don't pose immediate risk. Also appropriate when Critical findings are in non-production code (tests, docs, config) or when the author has already acknowledged the concern in PR discussion.
140
+ - **APPROVE**: Use when no findings exist, or when all findings are informational and the code is ready to merge.
141
141
 
142
142
  Tell the user:
143
143
  ```
@@ -107,5 +107,5 @@ Collect principles interactively:
107
107
 
108
108
  - **Persistent storage**: Saved to .claude/afc/memory/principles.md and maintained across sessions.
109
109
  - **Auto-referenced**: Automatically loaded and validated by /afc:plan and /afc:architect.
110
- - **Keep it concise**: Maintain no more than 10 principles. Too many reduces effectiveness.
110
+ - **Keep it concise**: Keep principles concise and actionable. If the list grows long enough that principles start overlapping or becoming too granular, suggest consolidation. The goal is a set of principles that can be held in working memory — typically under 15, but the right number depends on the project's complexity.
111
111
  - **Avoid duplication with CLAUDE.md**: Do not re-register rules already present in CLAUDE.md as principles.
@@ -82,7 +82,7 @@ Checks:
82
82
  Evaluate general code quality indicators.
83
83
 
84
84
  Checks:
85
- - **Complexity hotspots**: deeply nested logic, functions exceeding ~50 LOC
85
+ - **Complexity hotspots**: deeply nested logic, functions with high cognitive complexity (many branches, side effects, or state mutations). Line count alone is not a reliable indicator — a 30-line function with nested conditionals and side effects may be more complex than a 60-line function with simple sequential logic.
86
86
  - **Duplication**: near-identical code blocks across files
87
87
  - **Magic numbers/strings**: unexplained literals in logic
88
88
  - **TODO/FIXME accumulation**: stale markers (count, age if git history available)
@@ -128,7 +128,7 @@ For each active category:
128
128
 
129
129
  ### 5. Critic Loop
130
130
 
131
- Apply `docs/critic-loop-rules.md` with **safety cap: 3 rounds**.
131
+ **Always** read `${CLAUDE_PLUGIN_ROOT}/docs/critic-loop-rules.md` first and follow it. Safety cap: **5 passes**.
132
132
 
133
133
  Focus the critic on:
134
134
  - Are the findings actionable or just noise?
@@ -75,13 +75,17 @@ Flag any matches for the Breaking Changes section.
75
75
 
76
76
  Categorize each commit/PR into one of:
77
77
 
78
- | Category | Conventional Commit Prefixes | Fallback Heuristics |
79
- |----------|------------------------------|---------------------|
78
+ | Category | Conventional Commit Prefixes | Fallback (no prefix) |
79
+ |----------|------------------------------|----------------------|
80
80
  | Breaking Changes | `!:` suffix, `BREAKING` | Label: `breaking` |
81
- | New Features | `feat:` | "add", "new", "implement", "support" |
82
- | Bug Fixes | `fix:` | "fix", "resolve", "correct", "patch" |
81
+ | New Features | `feat:` | Commit introduces new user-facing functionality |
82
+ | Bug Fixes | `fix:` | Commit fixes broken or incorrect behavior |
83
83
  | Other Changes | `chore:`, `docs:`, `ci:`, `refactor:`, `perf:`, `test:`, `style:`, `build:` | Everything else |
84
84
 
85
+ **Fallback classification rule** — For commits without conventional prefixes, read the commit message semantically. Classify based on what the commit actually does: did it introduce new user-facing functionality (New Features)? Did it fix broken behavior (Bug Fixes)? Or is it a maintenance/improvement change (Other Changes)? Do not match individual words — understand the commit's purpose.
86
+
87
+ The word "add" in "add a new API endpoint" indicates a feature. The same word in "add missing test coverage" indicates a test (Other Changes). Context determines classification.
88
+
85
89
  **Rewriting rules** — transform each entry from developer-speak to user-facing language:
86
90
 
87
91
  1. Remove conventional commit prefixes (`feat:`, `fix(scope):`, etc.)