all-for-claudecode 2.13.0 → 2.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/.claude-plugin/marketplace.json +24 -5
  2. package/.claude-plugin/plugin.json +15 -4
  3. package/README.md +12 -0
  4. package/agents/afc-appsec-expert.md +19 -26
  5. package/agents/afc-architect.md +9 -2
  6. package/agents/afc-backend-expert.md +16 -4
  7. package/agents/afc-design-expert.md +17 -7
  8. package/agents/afc-impl-worker.md +7 -1
  9. package/agents/afc-infra-expert.md +16 -6
  10. package/agents/afc-legal-expert.md +16 -18
  11. package/agents/afc-marketing-expert.md +15 -5
  12. package/agents/afc-pm-expert.md +16 -5
  13. package/agents/afc-pr-analyst.md +1 -1
  14. package/agents/afc-security.md +7 -2
  15. package/agents/afc-tech-advisor.md +18 -30
  16. package/docs/agent-authoring-guide.md +144 -0
  17. package/docs/context-management-harness.md +293 -0
  18. package/docs/orchestration-modes.md +228 -0
  19. package/docs/skill-authoring-guide.md +153 -0
  20. package/hooks/hooks.json +27 -2
  21. package/package.json +4 -3
  22. package/schemas/hooks.schema.json +1 -1
  23. package/schemas/marketplace.schema.json +6 -1
  24. package/schemas/plugin.schema.json +0 -4
  25. package/scripts/afc-pipeline-manage.sh +1 -0
  26. package/scripts/afc-post-compact.sh +54 -0
  27. package/scripts/afc-spec-guard.sh +7 -7
  28. package/scripts/afc-stop-failure.sh +46 -0
  29. package/scripts/afc-sync-cache.sh +8 -2
  30. package/scripts/afc-tdd-guard.sh +7 -5
  31. package/scripts/afc-user-prompt-submit.sh +38 -0
  32. package/scripts/pre-compact-checkpoint.sh +10 -0
  33. package/scripts/session-start-context.sh +10 -0
  34. package/skills/architect/SKILL.md +1 -9
  35. package/skills/auto/SKILL.md +228 -910
  36. package/skills/auto/skill-advisor.md +306 -0
  37. package/skills/checkpoint/SKILL.md +7 -1
  38. package/skills/clarify/SKILL.md +3 -2
  39. package/skills/consult/SKILL.md +30 -123
  40. package/skills/consult/peer-mode.md +61 -0
  41. package/skills/debug/SKILL.md +3 -21
  42. package/skills/ideate/SKILL.md +1 -77
  43. package/skills/ideate/brief-template.md +73 -0
  44. package/skills/implement/SKILL.md +68 -260
  45. package/skills/init/SKILL.md +79 -129
  46. package/skills/init/reference.md +55 -0
  47. package/skills/issue/SKILL.md +51 -76
  48. package/skills/launch/SKILL.md +5 -0
  49. package/skills/learner/SKILL.md +1 -25
  50. package/skills/learner/suggestion-format.md +49 -0
  51. package/skills/plan/SKILL.md +1 -5
  52. package/skills/pr-comment/SKILL.md +38 -51
  53. package/skills/principles/SKILL.md +3 -7
  54. package/skills/qa/SKILL.md +3 -14
  55. package/skills/release-notes/SKILL.md +6 -5
  56. package/skills/resolve/SKILL.md +75 -158
  57. package/skills/resolve/graphql.md +48 -0
  58. package/skills/resume/SKILL.md +10 -5
  59. package/skills/review/SKILL.md +56 -202
  60. package/skills/review/perspectives.md +118 -0
  61. package/skills/security/SKILL.md +4 -22
  62. package/skills/security/cross-boundary-verification.md +22 -0
  63. package/skills/setup/SKILL.md +38 -87
  64. package/skills/setup/conflict-detection.md +33 -0
  65. package/skills/spec/SKILL.md +1 -5
  66. package/skills/tasks/SKILL.md +47 -70
  67. package/skills/test/SKILL.md +4 -16
  68. package/skills/triage/SKILL.md +38 -85
  69. package/skills/triage/coupling-detection.md +13 -0
  70. package/skills/triage/pr-analysis-prompt.md +46 -0
  71. package/skills/validate/SKILL.md +24 -62
  72. package/skills/validate/validation-categories.md +39 -0
@@ -0,0 +1,306 @@
1
+ # Skill Advisor — Reference
2
+
3
+ > Invoked by `/afc:auto` at 5 phase-boundary checkpoints. Each checkpoint uses LLM semantic evaluation (not keyword matching) to determine whether auxiliary skills add value. Budget-controlled: max 5 auxiliary invocations per pipeline.
4
+
5
+ ## Execution Modes
6
+
7
+ | Mode | Description | Context cost |
8
+ |------|-------------|-------------|
9
+ | **Transform** | Skill output replaces/restructures the next phase's input | High (blocking) |
10
+ | **Enrich** | Skill output appends context to the next phase's input | Low (fork/Task) |
11
+ | **Observe** | Skill output is metadata only (logged, flags set) | Low (fork) |
12
+
13
+ **Result recording**: After every advisor skill completes (any mode), append a brief summary to `.claude/afc/specs/{feature}/context.md` using the format defined at each checkpoint. This ensures advisor insights survive context compaction and are available to all subsequent phases.
14
+
15
+ ## Budget Control
16
+
17
+ | Constraint | Limit | Rationale |
18
+ |-----------|-------|-----------|
19
+ | Per checkpoint | max 2 skills | Phase transition delay cap |
20
+ | Pipeline total | max 5 auxiliary invocations | Total execution time cap |
21
+ | Transform mode | max 1 per pipeline | Main context pollution prevention |
22
+ | Concurrent fork | max 3 per checkpoint | Agent resource limit |
23
+
24
+ Track in `ADVISOR_COUNT` (starts 0) and `ADVISOR_TRANSFORM_USED` (boolean). Persist every increment:
25
+ ```bash
26
+ afc_state_write "advisorCount" "$ADVISOR_COUNT"
27
+ afc_state_write "advisorTransformUsed" "true" # when Transform is used
28
+ ```
29
+ On context recovery: `ADVISOR_COUNT = afc_state_read "advisorCount"`.
30
+
31
+ ## Expert Agent Routing
32
+
33
+ Route based on what expertise the feature actually needs (not keyword presence). Verify domain relevance against `{config.architecture}` — skip inapplicable domains (e.g., `design` for CLI, `infra` for no-deployment project).
34
+
35
+ | Domain | Agent ID (subagent_type value) | When to route |
36
+ |--------|-------------------------------|---------------|
37
+ | backend | `afc-backend-expert` | API design, database schema, server architecture, auth flows |
38
+ | infra | `afc-infra-expert` | Deployment, CI/CD, cloud infrastructure, containerization |
39
+ | pm | `afc-pm-expert` | Product decisions, user stories, prioritization, metrics |
40
+ | design | `afc-design-expert` | UI/UX, accessibility, component design, visual hierarchy |
41
+ | marketing | `afc-marketing-expert` | SEO, analytics, growth, conversion optimization |
42
+ | legal | `afc-legal-expert` | Privacy regulations, licensing, compliance, data protection |
43
+ | security | `afc-appsec-expert` | Application security, vulnerability patterns, secure coding |
44
+ | advisor | `afc-tech-advisor` | Technology selection, library comparison, stack decisions |
45
+
46
+ **Important**: Use the Agent ID column as the `subagent_type` value directly (e.g., `subagent_type: "afc:afc-backend-expert"`). `security` → `afc-appsec-expert` (NOT `afc-security-expert`).
47
+
48
+ ---
49
+
50
+ ## Checkpoint A — Pre-Spec
51
+
52
+ > Fire BEFORE Phase 1 (Spec). Skip if `ADVISOR_COUNT >= 5`. Budget: max 2 skills, max 1 Transform.
53
+
54
+ | # | Question | Score 1–5 | If >= 3 | Skill | Mode |
55
+ |---|----------|-----------|---------|-------|------|
56
+ | A1 | Is this request at the **idea/vision level** rather than a concrete feature? (lacks specific file paths, API endpoints, component names) | 1=concrete spec-ready, 5=pure vision | `ideate` | Transform |
57
+ | A2 | Does implementing this feature require **specialized domain knowledge** that a generalist developer wouldn't have? (regulatory, industry-specific patterns, compliance) | 1=general programming, 5=deep domain expertise essential | `consult({domain})` | Enrich (fork) |
58
+
59
+ **If A1 >= 3** (Transform — skip if `ADVISOR_TRANSFORM_USED`):
60
+ 1. Execute `/afc:ideate` inline with `$ARGUMENTS`
61
+ 2. On failure: do NOT set `ADVISOR_TRANSFORM_USED`, proceed with original `$ARGUMENTS`, log: `"Skill Advisor [A]: ideate failed, proceeding with original input"`
62
+ 3. On success: extract `## Problem Statement` + `## Value Proposition` + `## Core Features (MoSCoW)` (Must Have only) from `ideate.md`
63
+ 4. Construct enriched spec input:
64
+ ```
65
+ SPEC_INPUT = "$ARGUMENTS
66
+
67
+ ## Ideation Context (auto-generated)
68
+ {extracted Problem Statement}
69
+ {extracted Value Proposition}
70
+ {extracted Core Features — Must Have only}"
71
+ ```
72
+ 5. Replace `$ARGUMENTS` with `SPEC_INPUT` for Phase 1. Set `ADVISOR_TRANSFORM_USED = true`, increment `ADVISOR_COUNT`, persist both to state.
73
+ 6. Progress: ` ├─ Skill Advisor [A]: ideate (score: {N}/5, input restructured from idea to structured brief)`
74
+
75
+ **If A2 >= 3** (Enrich):
76
+ 1. Determine which domain best matches the actual expertise gap (not keywords). Verify relevance against project tech stack.
77
+ 2. Invoke expert agent:
78
+ ```
79
+ Task("Domain pre-consultation: {domain}", subagent_type: "afc:{agent-id}",
80
+ prompt: "You are being consulted automatically during pipeline spec preparation.
81
+ ## Feature Context
82
+ {$ARGUMENTS}
83
+ ## Why You Were Consulted
84
+ {1-sentence explanation of expertise gap}
85
+ ## Instructions
86
+ 1. Read your MEMORY.md for prior project context
87
+ 2. Read .claude/afc/project-profile.md if it exists
88
+ 3. Provide domain-specific constraints and anti-patterns that MUST be reflected in the spec
89
+ 4. Format EXACTLY as:
90
+ ## Domain Constraints ({domain})
91
+ - [MUST] {constraint}: {rationale}
92
+ - [MUST NOT] {anti-pattern}: {risk}
93
+ - [CONSIDER] {best practice}: {benefit}
94
+ 5. Max 10 items, prioritized by risk severity.
95
+ 6. Update your MEMORY.md with the consultation context")
96
+ ```
97
+ 3. Store as `DOMAIN_CONSTRAINTS` → inject into Phase 1. Spec MUST include `## Domain Constraints` section.
98
+ 4. Increment `ADVISOR_COUNT`. Progress: ` ├─ Skill Advisor [A]: consult({domain}) (score: {N}/5, {M} constraints injected)`
99
+
100
+ ---
101
+
102
+ ## Checkpoint B — Post-Spec
103
+
104
+ > Fire AFTER Phase 1, BEFORE Phase 2 (Plan). Skip if `ADVISOR_COUNT >= 5`. Budget: max 2 skills.
105
+
106
+ | # | Question | Score 1–5 | If >= 3 | Skill | Mode |
107
+ |---|----------|-----------|---------|-------|------|
108
+ | B1 | Does this feature **handle, store, or transmit sensitive data or trust boundaries**? (auth/authz, PII, financial data, external input reaching internal systems, session/token lifecycle) | 1=no trust boundary touched, 5=core security feature | `security` | Enrich (fork) |
109
+ | B2 | Does this feature **cross multiple architectural boundaries** or introduce a new structural pattern? (3+ layers, new component type, coordination across independently-deployable units) | 1=single-layer change, 5=cross-cutting architectural change | `architect` | Enrich (fork) |
110
+
111
+ **If B1 >= 3** (Enrich):
112
+ 1. Invoke security agent for pre-plan threat modeling:
113
+ ```
114
+ Task("Threat Model: {feature}", subagent_type: "afc:afc-security",
115
+ prompt: "Generate a threat model BEFORE implementation planning begins.
116
+ ## Spec Summary
117
+ {spec.md FR/NFR/Key Entities — security-relevant items only}
118
+ ## Why This Was Triggered
119
+ {1-sentence explanation}
120
+ ## Instructions
121
+ 1. Read your MEMORY.md for known vulnerability patterns in this project
122
+ 2. Identify attack surfaces from spec requirements
123
+ 3. Format EXACTLY as:
124
+ ## Threat Model (pre-scan)
125
+ | Threat | Attack Surface | Mitigation Required | Priority |
126
+ |--------|---------------|-------------------|----------|
127
+ 4. Max 8 threats, prioritized by exploitability and impact.")
128
+ ```
129
+ 2. Store as `THREAT_MODEL` → inject into Phase 2. Plan MUST address each mitigation in Risk & Mitigation. Plan Critic RISK criterion MUST verify: `{M}/{N} threat mitigations addressed`.
130
+ 3. Increment `ADVISOR_COUNT`. Progress: ` ├─ Skill Advisor [B]: security (score: {N}/5, threat model: {M} threats identified)`
131
+
132
+ **If B2 >= 3** (Enrich):
133
+ 1. Invoke architect agent for pre-plan guidance:
134
+ ```
135
+ Task("Architecture Advisory: {feature}", subagent_type: "afc:afc-architect",
136
+ prompt: "Provide architecture guidance BEFORE plan creation.
137
+ ## Spec Summary
138
+ {spec.md Key Entities + layer analysis from {config.architecture}}
139
+ ## Why This Was Triggered
140
+ {1-sentence explanation}
141
+ ## Instructions
142
+ 1. Read your MEMORY.md for prior ADRs and architecture patterns
143
+ 2. Recommend: component placement, layer boundaries, interface contracts
144
+ 3. Flag conflicts with existing architecture patterns
145
+ 4. Format EXACTLY as:
146
+ ## Architecture Advisory (pre-plan)
147
+ - [PLACE] {component} → {layer/module}: {rationale}
148
+ - [BOUNDARY] {interface}: {contract description}
149
+ - [CONFLICT] {existing} ↔ {new}: {resolution recommendation}
150
+ - [PATTERN] {recommended pattern}: {why it fits}
151
+ 5. Max 10 items. Update your MEMORY.md if new patterns are identified")
152
+ ```
153
+ 2. Store as `ARCH_ADVISORY` → inject into Phase 2. Plan Critic ARCHITECTURE criterion MUST validate against this advisory.
154
+ 3. Increment `ADVISOR_COUNT`. Progress: ` ├─ Skill Advisor [B]: architect (score: {N}/5, advisory: {M} recommendations, {K} conflicts)`
155
+
156
+ **If both B1 and B2 >= 3**: launch both agents in a **single message** (parallel fork). After both return, apply `THREAT_MODEL` and `ARCH_ADVISORY` to plan. If mitigations conflict with architecture proposals → **ESCALATE** to user with conflict details.
157
+
158
+ ---
159
+
160
+ ## Checkpoint C — Post-Plan
161
+
162
+ > Fire AFTER Phase 2, BEFORE Phase 3 (Implement). Skip if `ADVISOR_COUNT >= 5`. Budget: max 2 skills.
163
+
164
+ | # | Question | Score 1–5 | If >= 3 | Skill | Mode |
165
+ |---|----------|-----------|---------|-------|------|
166
+ | C1 | Is **implementation risk high enough** that dependency pre-analysis would catch problems the plan missed? (files importing each other, high fan-out shared utils, incomplete `Depends On` relationships, hidden coupling) | 1=isolated changes, 5=deeply interconnected change set | dependency analysis (general-purpose fork) | Observe |
167
+ | C2 | Does the plan contain **unresolved domain uncertainties** — items tagged `[UNCERTAIN]`, open questions in Implementation Context, design decisions assuming domain knowledge the team may lack? | 1=all decisions well-grounded, 5=critical domain questions remain open | `consult({domain})` expert agent | Enrich (fork) |
168
+
169
+ **If C1 >= 3** (Observe):
170
+ 1. Invoke analysis in fork context:
171
+ ```
172
+ Task("Complexity Analysis: {feature}", subagent_type: "general-purpose",
173
+ prompt: "Analyze the dependency graph of files listed in the plan's File Change Map.
174
+ ## File Change Map
175
+ {paste File Change Map table from plan.md}
176
+ ## Instructions
177
+ 1. For each file, check imports/dependencies (Grep for import/require/source patterns)
178
+ 2. Identify:
179
+ - Circular dependencies between planned files
180
+ - High fan-out files (>5 dependents outside the change set)
181
+ - Hidden coupling not captured in Depends On column
182
+ - Files imported by many others (risk of breakage)
183
+ 3. Format EXACTLY as:
184
+ ## Complexity Analysis
185
+ - [CIRCULAR] {file A} ↔ {file B}: {description}
186
+ - [FAN-OUT] {file} → {N} dependents: {list top 5}
187
+ - [COUPLING] {file A} → {file B}: {not in Depends On column}
188
+ - [HIGH-RISK] {file}: {reason}
189
+ ## Risk Summary
190
+ Circular: {N}, High fan-out: {N}, Hidden coupling: {N}
191
+ 4. If no issues: '## Complexity Analysis\nNo significant risks detected.'")
192
+ ```
193
+ 2. Store to `.claude/afc/specs/{feature}/complexity-analysis.md`. Implement phase reads this — high-risk files get extra verification after modification. Circular dependencies → **ESCALATE** to user.
194
+ 3. Increment `ADVISOR_COUNT`. Progress: ` ├─ Skill Advisor [C]: analyze (score: {N}/5, circular: {C}, fan-out: {F}, coupling: {H})`
195
+
196
+ **If C2 >= 3** (Enrich):
197
+ 1. Determine which domain expert best resolves the uncertainties. Invoke:
198
+ ```
199
+ Task("Domain gap resolution: {domain}", subagent_type: "afc:{agent-id}",
200
+ prompt: "Resolve domain uncertainties found during planning.
201
+ ## Uncertain Items
202
+ {extract all [UNCERTAIN] tagged items and open questions from plan.md}
203
+ ## Plan Context
204
+ {Implementation Context section from plan.md}
205
+ ## Instructions
206
+ 1. For each uncertain item, provide a definitive answer with rationale
207
+ 2. Format EXACTLY as:
208
+ ## Domain Resolutions
209
+ - [RESOLVED] {item}: {answer} — {rationale}
210
+ - [NEEDS-USER] {item}: {why this requires human judgment}
211
+ 3. Update your MEMORY.md with the resolution context")
212
+ ```
213
+ 2. Apply resolutions to plan.md (replace `[UNCERTAIN]` with `[RESOLVED: {answer}]`). `[NEEDS-USER]` → **ESCALATE** via AskUserQuestion.
214
+ 3. Increment `ADVISOR_COUNT`. Progress: ` ├─ Skill Advisor [C]: consult({domain}) (score: {N}/5, {M} resolved, {K} needs-user)`
215
+
216
+ ---
217
+
218
+ ## Checkpoint D — Post-Implement
219
+
220
+ > Fire AFTER Phase 3, BEFORE Phase 4 (Review). Skip if `ADVISOR_COUNT >= 5`. Budget: max 2 skills.
221
+
222
+ | # | Question | Score 1–5 | If >= 3 | Skill | Mode |
223
+ |---|----------|-----------|---------|-------|------|
224
+ | D1 | Were **testable source files changed without corresponding test coverage**? (check `git diff --name-only` — skip config, types-only, static assets; only evaluate if `{config.test}` is non-empty) | 1=all changes have test coverage, 5=critical logic changed with zero tests | test generation (general-purpose fork) | Enrich |
225
+ | D2 | Based on **past pipeline quality data**, is there reason to believe this implementation has hidden quality issues? (check `.claude/afc/memory/quality-history/*.json` for elevated critical findings or recurring problem categories) | 1=clean history or no history, 5=strong pattern of recurring issues in similar areas | pre-review QA (general-purpose fork) | Observe |
226
+
227
+ **If D1 >= 3 AND `{config.test}` is non-empty** (Enrich):
228
+ 1. For each changed source file: does the project have a test file for it? Was it also modified in this diff? Does it contain testable exports?
229
+ 2. Invoke test generation:
230
+ ```
231
+ Task("Coverage boost: {feature}", subagent_type: "general-purpose",
232
+ prompt: "Generate missing tests for recently implemented files.
233
+ ## Uncovered Files
234
+ {list of source files with testable logic but no test changes in this diff}
235
+ ## Instructions
236
+ 1. Read each uncovered file to understand exports and behavior
237
+ 2. Read existing test files for pattern reference
238
+ 3. Generate unit tests targeting exported functions/classes, edge cases, error paths, integration points
239
+ 4. Follow project test framework: {config.test framework}
240
+ 5. Place test files following project convention
241
+ 6. Run {config.test} to verify tests pass
242
+ 7. Return: files created, test count, pass/fail status")
243
+ ```
244
+ 3. New test files automatically enter review scope. Increment `ADVISOR_COUNT`.
245
+ 4. Progress: ` ├─ Skill Advisor [D]: test (score: {N}/5, {M} uncovered files → {K} test files generated)`
246
+
247
+ **If D2 >= 3** (Observe):
248
+ 1. Load `.claude/afc/memory/quality-history/*.json` (most recent 3 files):
249
+ ```
250
+ Task("Pre-review QA: {feature}", subagent_type: "general-purpose",
251
+ prompt: "Perform a pre-review quality audit focused on historically problematic areas.
252
+ ## Changed Files
253
+ {git diff --name-only}
254
+ ## Quality History Context
255
+ {summary of patterns from recent quality-history reports}
256
+ ## Instructions
257
+ 1. Focus on recurring problem categories
258
+ 2. Check: error handling completeness, input validation, resource cleanup
259
+ 3. Format EXACTLY as:
260
+ ## Pre-Review QA Findings
261
+ - [{severity}] {file}:{line} — {issue}: {suggested fix}
262
+ ## Priority Hints for Review
263
+ - {file}: focus on {area} (historically problematic)
264
+ 4. Read-only — do NOT modify any files")
265
+ ```
266
+ 2. Store as `QA_FINDINGS` → inject into Phase 4 as Priority Hints. Increment `ADVISOR_COUNT`.
267
+ 3. Progress: ` ├─ Skill Advisor [D]: qa (score: {N}/5, {M} priority hints for review)`
268
+
269
+ ---
270
+
271
+ ## Checkpoint E — Post-Review
272
+
273
+ > Fire AFTER Phase 4, BEFORE Phase 5 (Clean). Skip if `ADVISOR_COUNT >= 5`. Budget: max 1 skill.
274
+
275
+ | # | Question | Score 1–5 | If >= 3 | Skill | Mode |
276
+ |---|----------|-----------|---------|-------|------|
277
+ | E1 | Are there **recurring problem patterns** across this and past pipelines that should be codified as project rules? (check `.claude/afc/memory/retrospectives/` — same issue type recurred 3+ times and is not yet a project rule) | 1=no patterns or no history, 5=same issue type recurred 3+ times | pattern promotion (general-purpose fork) | Observe |
278
+
279
+ **If E1 >= 3** (Observe):
280
+ 1. Read retrospective files. Identify recurring patterns. Check against existing `.claude/rules/afc-learned.md`.
281
+ 2. Invoke learner:
282
+ ```
283
+ Task("Pattern promotion: {feature}", subagent_type: "general-purpose",
284
+ prompt: "Review recurring patterns for potential promotion to project rules.
285
+ ## Recurring Patterns
286
+ {each pattern with: category, occurrence count, concrete examples}
287
+ ## Current Review Findings
288
+ {this pipeline's review findings matching retrospective patterns}
289
+ ## Current Rules
290
+ {read .claude/rules/afc-learned.md if exists, else 'No learned rules yet'}
291
+ ## Instructions
292
+ 1. For each pattern, evaluate: is it actionable? already covered? would it have prevented recurrence?
293
+ 2. For patterns worth promoting, write:
294
+ ### {Category}
295
+ - **Rule**: {concise, enforceable statement}
296
+ - **Rationale**: {why — based on {N} occurrences}
297
+ - **Enforcement**: {how to check — linter, review criterion, or convention}
298
+ 3. Safety guardrails (mandatory):
299
+ - Do NOT create rules about permissions, security policies, hook behavior, tool access
300
+ - Do NOT contradict existing CLAUDE.md or .claude/rules/ content
301
+ - Rules must be scoped to code conventions only (naming, style, workflow, testing, architecture)
302
+ - Verify no duplicate or contradictory rule exists before appending
303
+ 4. Append new rules to .claude/rules/afc-learned.md (create if absent)
304
+ 5. Return: {N} evaluated, {M} promoted, {K} already covered")
305
+ ```
306
+ 3. Increment `ADVISOR_COUNT`. Progress: ` ├─ Skill Advisor [E]: learner (score: {N}/5, {M} patterns evaluated, {K} promoted to rules)`
@@ -19,11 +19,17 @@ allowed-tools:
19
19
 
20
20
  - `$ARGUMENTS` — (optional) checkpoint message (e.g., "Phase 2 complete, before starting UI implementation")
21
21
 
22
+ ## Current State (auto-loaded)
23
+
24
+ !`git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "[NO_BRANCH]"`
25
+ !`git log --oneline -1 2>/dev/null || echo "[NO_COMMITS]"`
26
+ !`ls .claude/afc/specs/ 2>/dev/null || echo "[NO_SPECS]"`
27
+
22
28
  ## Execution Steps
23
29
 
24
30
  ### 1. Collect Current State
25
31
 
26
- Collect automatically:
32
+ Collect automatically (use pre-fetched state above when available):
27
33
 
28
34
  1. **Git status**:
29
35
  - Current branch
@@ -20,9 +20,9 @@ model: sonnet
20
20
 
21
21
  - `$ARGUMENTS` — (optional) focus on a specific area (e.g., "security", "performance", "UI flow")
22
22
 
23
- ## Config Load
23
+ ## Project Config (auto-loaded)
24
24
 
25
- **Must** read `.claude/afc.config.md` first. If the config file is not present, print "`.claude/afc.config.md` not found. Run `/afc:init` first." then **abort**.
25
+ !`cat .claude/afc.config.md 2>/dev/null || echo "[CONFIG NOT FOUND] .claude/afc.config.md not found. Run /afc:init first abort if missing."`
26
26
 
27
27
  ## Execution Steps
28
28
 
@@ -81,6 +81,7 @@ Clarification complete
81
81
  ## Notes
82
82
 
83
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.
84
+ - **Verify after update**: After updating spec.md, re-read the modified sections to confirm changes are consistent and no new `[NEEDS CLARIFICATION]` tags were introduced by the edit itself.
84
85
  - **Modify spec only**: Do not touch plan.md or tasks.md.
85
86
  - **Avoid redundancy**: Do not ask about items already clearly stated in spec.
86
87
  - **If `$ARGUMENTS` is provided**: Focus the scan on that area.
@@ -35,30 +35,24 @@ If `$ARGUMENTS` is empty → go to Step 2 (domain selection).
35
35
 
36
36
  **B. No domain, but question provided** → intent-based evaluation:
37
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
38
  | Domain | When to route |
41
39
  |--------|---------------|
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?
55
-
56
- **C. No domain, no question, or no keyword match** → ask user:
57
-
58
- Use AskUserQuestion:
40
+ | backend | Server-side logic, data modeling, API design, authentication flows, database decisions |
41
+ | infra | Deployment, CI/CD pipelines, cloud services, scaling, reliability, monitoring |
42
+ | pm | What to build, for whom, when, how to measure success, prioritization, scope |
43
+ | design | Visual hierarchy, interaction patterns, accessibility, component design, user flow |
44
+ | marketing | SEO, content strategy, acquisition funnels, analytics tracking, growth tactics |
45
+ | legal | Regulatory obligations, license compatibility, privacy requirements |
46
+ | security | Threats, vulnerabilities, attack surfaces, threat modeling, compliance |
47
+ | advisor | Choosing between technologies, frameworks, libraries, or architectural approaches |
48
+ | peer | Think through a problem collaboratively, explore directions, weigh trade-offs |
49
+
50
+ Identify the PRIMARY expertise gap — what specialized knowledge does the user need most?
51
+
52
+ **C. No domain, no question** ask user:
53
+
59
54
  ```
60
55
  "Which expert would you like to consult?"
61
- Options:
62
56
  1. Backend — API design, database, authentication, server architecture
63
57
  2. Infra — deployment, CI/CD, cloud, monitoring, scaling
64
58
  3. PM — product strategy, prioritization, user stories, metrics
@@ -66,83 +60,22 @@ Options:
66
60
  5. Marketing — SEO, analytics, growth, content strategy
67
61
  6. Legal — GDPR, privacy, licenses, compliance, terms of service
68
62
  7. Security — application security, OWASP, threat modeling, secure coding
69
- 8. Advisor — technology/library/framework selection, ecosystem navigation, stack decisions
70
- 9. Peer — think together, brainstorm, discuss ideas, explore directions as equals
63
+ 8. Advisor — technology/library/framework selection, stack decisions
64
+ 9. Peer — think together, brainstorm, explore directions as equals
71
65
  ```
72
66
 
73
67
  ### 3. Peer Mode (if domain is `peer`)
74
68
 
75
- If the detected domain is `peer`, **do not delegate to a subagent**. Run the dialogue directly in the main context.
76
-
77
- #### Behavior Principles
78
-
79
- You are a thinking partner, not an expert giving answers. Follow these rules:
80
-
81
- 1. **Ask before answering.** Default to questions that deepen the user's thinking, not solutions. "What would happen if...?", "What are you optimizing for?"
82
- 2. **Challenge, don't agree.** Apply the Anti-Sycophancy Rules from `expert-protocol.md`. When the user states a direction, probe its weaknesses before supporting it.
83
- 3. **Present the strongest counter-argument.** Steel-man the opposing view: "The best case for NOT doing this is..."
84
- 4. **Name what's been decided and what hasn't.** Periodically summarize: "So far we've landed on X. Still open: Y and Z."
85
- 5. **Suggest convergence, don't force it.** When the discussion feels circular or key decisions are made, say so: "I think we have enough to move forward. Want to wrap up?"
86
-
87
- #### Coaching Techniques
88
-
89
- Use these as appropriate — not all at once, not in order:
90
-
91
- - **5 Whys** — repeat "why?" to reach the root motivation
92
- - **Pre-mortem** — "If this fails in 6 months, what went wrong?"
93
- - **Constraint flip** — "What if you had half the time?" / "What if cost didn't matter?"
94
- - **Steel-manning** — present the strongest version of the opposing view
95
- - **Bisection** — "Is the core question A or B?" to narrow scope
96
-
97
- #### Codebase Context
98
-
99
- If the discussion involves the current project:
100
- - Read relevant files (Read/Glob/Grep) to ground the conversation in reality
101
- - Reference actual code, not hypothetical structures
102
- - Note existing patterns that constrain or enable options
103
-
104
- #### Wrapping Up
105
-
106
- When the user signals completion (or agrees to your convergence suggestion):
107
-
108
- 1. Write `.claude/afc/discuss.md` with:
109
-
110
- ```markdown
111
- # Discussion: {topic}
112
-
113
- > Date: {YYYY-MM-DD}
114
- > Seed: {original question/topic}
69
+ Do not delegate to a subagent. Run dialogue directly in the main context.
115
70
 
116
- ## Key Decisions
117
- - [DECIDED] {decision} — {rationale}
71
+ See [peer-mode.md](peer-mode.md) for full behavior, coaching techniques, and wrap-up protocol.
118
72
 
119
- ## Open Questions
120
- - [OPEN] {unresolved item}
121
-
122
- ## Summary
123
- {3-5 sentence synthesis of what was discussed and concluded}
124
-
125
- ## Next Steps
126
- - {recommended action, e.g., → /afc:spec "...", → /afc:plan "...", → /afc:research "..."}
127
- ```
128
-
129
- 2. Output:
130
- ```
131
- Discussion complete
132
- ├─ .claude/afc/discuss.md
133
- ├─ Decisions: {count}
134
- ├─ Open questions: {count}
135
- └─ Suggested next: {command}
136
- ```
137
-
138
- **Skip Steps 4-6 and end here.**
73
+ **Skip Steps 3b–6 and end here.**
139
74
 
140
75
  ---
141
76
 
142
77
  ### 3b. Construct Expert Prompt (non-peer domains)
143
78
 
144
- Build the prompt for the expert agent:
145
-
146
79
  ```
147
80
  You are being consulted via /afc:consult.
148
81
 
@@ -161,8 +94,6 @@ You are being consulted via /afc:consult.
161
94
 
162
95
  ### 4. Delegate to Expert Agent
163
96
 
164
- Invoke the expert agent via Task(). Map the detected domain to the corresponding agent:
165
-
166
97
  | Domain | subagent_type |
167
98
  |--------|---------------|
168
99
  | backend | `afc:afc-backend-expert` |
@@ -174,28 +105,18 @@ Invoke the expert agent via Task(). Map the detected domain to the corresponding
174
105
  | security | `afc:afc-appsec-expert` |
175
106
  | advisor | `afc:afc-tech-advisor` |
176
107
 
177
- Example for each domain:
178
108
  ```
179
- Task("backend consultation", subagent_type: "afc:afc-backend-expert", prompt: "...")
180
- Task("infra consultation", subagent_type: "afc:afc-infra-expert", prompt: "...")
181
- Task("pm consultation", subagent_type: "afc:afc-pm-expert", prompt: "...")
182
- Task("design consultation", subagent_type: "afc:afc-design-expert", prompt: "...")
183
- Task("marketing consultation", subagent_type: "afc:afc-marketing-expert", prompt: "...")
184
- Task("legal consultation", subagent_type: "afc:afc-legal-expert", prompt: "...")
185
- Task("security consultation", subagent_type: "afc:afc-appsec-expert", prompt: "...")
186
- Task("advisor consultation", subagent_type: "afc:afc-tech-advisor", prompt: "...")
109
+ Task("{domain} consultation", subagent_type: "afc:afc-{domain}-expert", prompt: "...")
187
110
  ```
188
111
 
189
112
  The agent runs in foreground (never `run_in_background`).
190
113
 
191
114
  ### 5. Relay Response
192
115
 
193
- Return the agent's response to the user as-is. Do not summarize or filter the expert's output.
116
+ Return the agent's response to the user as-is. Do not summarize or filter.
194
117
 
195
118
  ### 6. Follow-up Prompt
196
119
 
197
- After relaying the response, suggest:
198
-
199
120
  ```
200
121
  Follow-up options:
201
122
  - Ask a deeper question on this topic
@@ -206,34 +127,20 @@ Follow-up options:
206
127
  ## Examples
207
128
 
208
129
  ```bash
209
- # Specific domain + question
210
130
  /afc:consult backend "Should I use JWT or session cookies for auth?"
211
-
212
- # Auto-detect domain from question
213
- /afc:consult "My API is slow when loading the dashboard"
214
-
215
- # Exploratory mode (Socratic diagnostic)
216
- /afc:consult backend
217
-
218
- # With depth hint
131
+ /afc:consult "My API is slow when loading the dashboard" # auto-detect
132
+ /afc:consult backend # exploratory mode
219
133
  /afc:consult infra "How should I set up CI/CD?" deep
220
-
221
- # Peer mode — think together (explicit)
222
- /afc:consult peer "Should we split this into a monorepo or keep it separate?"
223
-
224
- # Peer mode — auto-detected from keywords
134
+ /afc:consult peer "Should we split this into a monorepo?"
225
135
  /afc:consult "Let's think through the onboarding flow together"
226
-
227
- # No arguments (domain selection prompt)
228
- /afc:consult
136
+ /afc:consult # domain selection prompt
229
137
  ```
230
138
 
231
139
  ## Notes
232
140
 
233
- - **Limited write scope**: Expert agents MUST only write to pipeline and memory paths (`.claude/afc/` and `.claude/agent-memory/`). Writing to application source code is prohibited. If an expert recommends code changes, they return the recommendation as text — the user or orchestrator applies it.
234
- - **Persistent memory**: Each expert remembers your project's decisions across sessions (stored in `.claude/agent-memory/afc-{domain}-expert/MEMORY.md`).
235
- - **Project profile**: Shared context at `.claude/afc/project-profile.md` — auto-created on first consultation, review and adjust as needed.
141
+ - **Limited write scope**: Expert agents MUST only write to `.claude/afc/` and `.claude/agent-memory/`. Writing to application source code is prohibited.
142
+ - **Persistent memory**: Stored in `.claude/agent-memory/afc-{domain}-expert/MEMORY.md`.
143
+ - **Project profile**: Shared context at `.claude/afc/project-profile.md` — auto-created on first consultation.
236
144
  - **Domain adapters**: Industry-specific guardrails (fintech, ecommerce, healthcare) auto-loaded based on project profile.
237
- - **Pipeline-independent**: Works anytime, no active pipeline required. If a pipeline is active, experts consider the current phase context.
238
- - **Cross-referral**: Experts may suggest consulting another domain expert when a question crosses boundaries.
239
- - **Peer mode**: Unlike other domains, `peer` runs directly in the main context (no subagent). It produces `.claude/afc/discuss.md` on wrap-up. Overwritten on each new peer session — rename to preserve.
145
+ - **Cross-referral**: Experts may suggest consulting another domain when a question crosses boundaries.
146
+ - **Peer mode**: Runs in main context, not subagent. Produces `.claude/afc/discuss.md` on wrap-up. See [peer-mode.md](peer-mode.md).
@@ -0,0 +1,61 @@
1
+ # Peer Mode
2
+
3
+ > Think together, not receive answers. Run directly in main context (no subagent).
4
+
5
+ ## Behavior Principles
6
+
7
+ 1. **Ask before answering.** Default to questions that deepen the user's thinking. "What would you optimize for?", "What would happen if...?"
8
+ 2. **Challenge, don't agree.** Apply Anti-Sycophancy Rules from `docs/expert-protocol.md`. Probe weaknesses before supporting a direction.
9
+ 3. **Steel-man the opposition.** "The best case for NOT doing this is..."
10
+ 4. **Name what's settled and what isn't.** Periodically: "Decided: X. Still open: Y, Z."
11
+ 5. **Suggest convergence, don't force it.** "I think we have enough to move forward. Want to wrap up?"
12
+
13
+ ## Coaching Techniques (use as appropriate, not all at once)
14
+
15
+ | Technique | When to use |
16
+ |-----------|-------------|
17
+ | **5 Whys** | Root motivation unclear |
18
+ | **Pre-mortem** | "If this fails in 6 months, what went wrong?" |
19
+ | **Constraint flip** | "What if you had half the time?" / "What if cost didn't matter?" |
20
+ | **Steel-manning** | User is committed to one direction — surface strongest counter |
21
+ | **Bisection** | "Is the core question A or B?" to narrow scope |
22
+
23
+ ## Codebase Grounding
24
+
25
+ If the discussion involves the current project, use Read/Glob/Grep to reference actual code. Hypothetical structures are a last resort.
26
+
27
+ ## Wrap-up
28
+
29
+ When user signals completion (or agrees to convergence):
30
+
31
+ 1. Write `.claude/afc/discuss.md`:
32
+
33
+ ```markdown
34
+ # Discussion: {topic}
35
+
36
+ > Date: {YYYY-MM-DD}
37
+ > Seed: {original question/topic}
38
+
39
+ ## Key Decisions
40
+ - [DECIDED] {decision} — {rationale}
41
+
42
+ ## Open Questions
43
+ - [OPEN] {unresolved item}
44
+
45
+ ## Summary
46
+ {3-5 sentence synthesis}
47
+
48
+ ## Next Steps
49
+ - {recommended action, e.g., → /afc:spec "...", → /afc:plan "..."}
50
+ ```
51
+
52
+ 2. Output:
53
+ ```
54
+ Discussion complete
55
+ ├─ .claude/afc/discuss.md
56
+ ├─ Decisions: {count}
57
+ ├─ Open questions: {count}
58
+ └─ Suggested next: {command}
59
+ ```
60
+
61
+ > Note: `discuss.md` is overwritten on each new peer session — rename to preserve.