claude-flow-novice 2.14.19 → 2.14.21

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.
@@ -1,495 +0,0 @@
1
- # CFN Loop Task Mode - Quick Reference
2
-
3
- **Version:** 1.0.0 | **Date:** 2025-10-28 | **Status:** Production Ready
4
-
5
- ---
6
-
7
- ## Overview
8
-
9
- Task Mode: Main Chat acts as coordinator and spawns agents directly via Task() tool with full context injection and visibility.
10
-
11
- | Aspect | Task Mode | CLI Mode |
12
- |--------|-----------|----------|
13
- | **Spawning** | Main Chat spawns agents directly via Task() | Coordinator spawns agents via npx CLI |
14
- | **Visibility** | Full transparency in Main Chat | Background, Redis logs |
15
- | **Provider** | All Anthropic | CLI uses Z.ai routing |
16
- | **Cost** | ~$0.150/iteration | ~$0.054/iteration (64% savings) |
17
- | **Use Case** | Debugging, prototyping, learning | Production, cost optimization |
18
- | **ACE Reflection** | Optional via `--ace-reflect` flag | Always enabled |
19
-
20
- ### ACE Reflection Flag
21
-
22
- ```bash
23
- # Enable ACE reflection after each sprint (captures lessons learned)
24
- /cfn-loop "Task description" --spawn-mode=task --ace-reflect
25
-
26
- # Without ACE reflection (default for backwards compatibility)
27
- /cfn-loop "Task description" --spawn-mode=task
28
- ```
29
-
30
- **When to use `--ace-reflect`:**
31
- - Long-running epics (3+ sprints) where learning accumulates
32
- - Complex tasks with multiple iterations
33
- - Teams building organizational knowledge
34
- - Post-mortem analysis and continuous improvement
35
-
36
- ---
37
-
38
- ## Task Mode Execution Pattern
39
-
40
- **Key Principle: Main Chat IS the coordinator**
41
-
42
- In Task Mode, Main Chat directly spawns all agents via Task() tool. No coordinator agent is used.
43
-
44
- ### Example: Zone A React Router Migration
45
-
46
- ```javascript
47
- // ✅ CORRECT - Main Chat spawns agents directly
48
- Task("backend-developer", `
49
- Migrate React Router from v4 to v6 in Zone A components
50
- Deliverables: Updated Routes, component fixes, tests
51
- Directory: frontend/src/zone-a/
52
- `);
53
-
54
- Task("react-frontend-engineer", `
55
- Review and fix any component issues after router migration
56
- Focus on route parameters, navigation, and component integration
57
- `);
58
-
59
- Task("tester", `
60
- Test React Router v6 migration in Zone A
61
- Verify all routes work, navigation functions, no regressions
62
- `);
63
-
64
- // Later: Process outputs, collect confidence, decide next iteration
65
- ```
66
-
67
- ### What NOT to Do in Task Mode
68
-
69
- ```javascript
70
- // ❌ INCORRECT - Don't spawn coordinator agent
71
- Task("cfn-v3-coordinator", "Coordinate React Router migration");
72
-
73
- // ❌ INCORRECT - Don't use CLI commands in Task Mode
74
- Bash("npx claude-flow-novice swarm 'task description'");
75
-
76
- // ❌ INCORRECT - Don't nest CFN Loop calls
77
- Task("reviewer", "/cfn-loop 'review this code'"); // Causes infinite loops
78
- ```
79
-
80
- ---
81
-
82
- ## Agent Specialization
83
-
84
- ### Loop 3 (Implementation)
85
-
86
- | Task Type | Agents | Count |
87
- |-----------|--------|-------|
88
- | Backend API | backend-dev, researcher, devops | 3 |
89
- | Full-Stack | backend-dev, react-frontend-engineer, devops | 3 |
90
- | Mobile | mobile-dev, backend-dev, researcher | 3 |
91
- | Infrastructure | devops, rust-developer, researcher | 2-3 |
92
- | NPM Package | npm-package-specialist, backend-dev, researcher | 3 |
93
- | Documentation | api-documentation, researcher | 2 |
94
-
95
- **Available Implementers:** backend-dev, react-frontend-engineer, devops, rust-developer, researcher, mobile-dev, npm-package-specialist, base-template-generator, api-documentation
96
-
97
- ### Loop 2 (Validation)
98
-
99
- | Complexity | Files | LOC | Validators | Agents | Threshold |
100
- |------------|-------|-----|------------|--------|-----------|
101
- | Simple | 1-2 | <200 | 2 | reviewer, tester | 0.85 |
102
- | Standard | 3-5 | 200-500 | 4 | +architect, +security-specialist | 0.90 |
103
- | Complex/Enterprise | >5 | >500 | 5 | +code-analyzer, +perf/ada* | 0.92-0.95 |
104
-
105
- *Add performance-benchmarker if perf-critical, accessibility-advocate-persona if frontend
106
-
107
- **Adaptive Scaling Logic:**
108
- ```javascript
109
- let validators = ['reviewer', 'tester']; // Base (Simple)
110
- // Standard: 3-5 files or 200-500 LOC
111
- if (files >= 3 || LOC >= 200) {
112
- validators.push('architect', 'security-specialist');
113
- }
114
- // Complex/Enterprise: >5 files or >500 LOC
115
- if (files > 5 || LOC > 500) {
116
- validators.push('code-analyzer');
117
- if (keywords.match(/performance|cache|optimization/i)) validators.push('performance-benchmarker');
118
- if (keywords.match(/frontend|ui|react|vue|angular/i)) validators.push('accessibility-advocate-persona');
119
- }
120
- return validators.slice(0, 6); // Max 6
121
- ```
122
-
123
- **Available Validators:** reviewer, tester, architect, security-specialist, performance-benchmarker, code-analyzer, accessibility-advocate-persona, playwright-tester, interaction-tester
124
-
125
- ### Loop 4 (Product Owner)
126
-
127
- - **product-owner**: GOAP decision-making, scope enforcement (PROCEED/ITERATE/ABORT)
128
- - **cto-agent**: Epic-level planning, resource allocation, technology decisions
129
-
130
- ---
131
-
132
- ## Sprint Completion Workflow
133
-
134
- **Key Difference in Task Mode:**
135
- - Product Owner spawned via `Task()` by Main Chat acting as coordinator (NOT via `execute-decision.sh`)
136
- - Use helper scripts for parsing/validation: `parse-decision.sh`, `validate-deliverables.sh`
137
- - CLI Mode uses `execute-decision.sh` which handles spawning + all logic
138
-
139
- ### 1. Consensus Validation
140
-
141
- **Task Mode** - Main Chat (as coordinator) spawns Product Owner via Task():
142
- ```javascript
143
- // Main Chat (as coordinator) builds context and spawns PO
144
- const poContext = `
145
- CFN Loop iteration ${iteration} complete.
146
- Loop 2 Consensus: ${consensus} (threshold: ${threshold})
147
-
148
- Decision Framework:
149
- - PROCEED: Consensus >= ${threshold} AND deliverables verified
150
- - ITERATE: Consensus < ${threshold} AND iteration < ${maxIterations}
151
- - ABORT: Max iterations reached
152
-
153
- Output format: Decision: [PROCEED|ITERATE|ABORT]
154
- `;
155
-
156
- const poOutput = Task("product-owner", poContext);
157
-
158
- // Parse decision using helper
159
- const decision = exec(`parse-decision.sh --output "${poOutput}"`);
160
- // Output: PROCEED | ITERATE | ABORT
161
- ```
162
-
163
- **Note:** Do NOT call `execute-decision.sh` in Task Mode - it spawns PO via CLI, causing duplicate agents.
164
-
165
- ### 2. Deliverable Verification
166
- ```bash
167
- # Verify deliverables exist (prevents "consensus on vapor")
168
- ./.claude/skills/cfn-product-owner-decision/validate-deliverables.sh \
169
- --task-id "$TASK_ID" \
170
- --expected-files "src/auth.ts,tests/auth.test.ts"
171
-
172
- # Returns: SUCCESS | FAILED
173
- # If FAILED + implementation task → override PROCEED to ITERATE
174
- ```
175
-
176
- ### 3. Git Commit & Push
177
- ```bash
178
- git add .
179
- git commit -m "$(cat <<'EOF'
180
- feat(sprint-X): [feature name]
181
-
182
- Deliverables:
183
- - [files created/modified]
184
-
185
- Validation:
186
- - Consensus: [0.XX]
187
- - Tests: [status]
188
-
189
- 🤖 Generated with [Claude Code](https://claude.com/claude-code)
190
- Co-Authored-By: Claude <noreply@anthropic.com>
191
- EOF
192
- )"
193
- git push origin main
194
- ```
195
-
196
- ### 4. Sprint Summary
197
- ```bash
198
- cat > "docs/SPRINT_${SPRINT_NUM}_COMPLETE.md" <<EOF
199
- # Sprint ${SPRINT_NUM} Complete
200
- **Date:** $(date +%Y-%m-%d) | **Consensus:** ${CONSENSUS}
201
- ## Deliverables
202
- $(git diff HEAD~1 --name-status | awk '{print "- "$2}')
203
- ## Validation
204
- Iterations: Loop 3: ${L3}, Loop 2: ${L2} | Decision: PROCEED
205
- EOF
206
- ```
207
-
208
- ### 5. Execute Product Owner Suggested Next Steps
209
-
210
- **After PROCEED Decision:**
211
- Product Owner may suggest follow-up tasks (documentation, testing, refactoring). Main Chat (as coordinator) must proceed by spawning specialized agents to execute these tasks:
212
-
213
- ```javascript
214
- // Parse PO feedback for suggested next steps
215
- const nextSteps = parseFeedback(poOutput, ["documentation", "integration test", "performance optimization"]);
216
-
217
- // Spawn agents for each next step
218
- for (const step of nextSteps) {
219
- if (step.complexity === "simple" && !step.requiresValidation) {
220
- // Use backlog background worker for simple tasks
221
- Bash(`
222
- ./.claude/skills/epic-management/add-backlog-item.sh \
223
- --epic-id "${EPIC_ID}" \
224
- --title "${step.title}" \
225
- --priority "P3" \
226
- --reason "Post-sprint cleanup - low validation needs"
227
- `, "Defer to background worker");
228
- } else {
229
- // Spawn specialist agents for complex tasks
230
- Task(step.agent, `
231
- Execute post-sprint task: ${step.description}
232
-
233
- Context: Sprint ${SPRINT_NUM} completed. ${step.context}
234
-
235
- Deliverables: ${step.deliverables.join(", ")}
236
-
237
- Acceptance: ${step.acceptance}
238
- `);
239
- }
240
- }
241
- ```
242
-
243
- **Strategic Backlog Worker Usage:**
244
- - **Use background worker when:**
245
- - No overlap with main sprint work (independent tasks)
246
- - Simple tasks requiring little validation (linting, formatting, simple docs)
247
- - Tasks validatable via compilation/linting (type fixes, import cleanup)
248
- - Avoids holding up main CFN Loop (P3 priority items)
249
-
250
- - **Use Task() agents when:**
251
- - Complex tasks requiring validation (API changes, security updates)
252
- - Tasks with dependencies on sprint deliverables
253
- - Tasks needing consensus (architectural decisions, breaking changes)
254
-
255
- ### 6. ACE Reflection (Optional - If `--ace-reflect` flag enabled)
256
- ```bash
257
- # Only run if --ace-reflect flag was passed to /cfn-loop command
258
- if [[ "$ACE_REFLECT_ENABLED" == "true" ]]; then
259
- echo "📊 Capturing ACE reflection..."
260
- ./.claude/skills/cfn-ace-system/invoke-context-reflect.sh \
261
- --task-id "${TASK_ID}" \
262
- --sprint-id "${SPRINT_NUM}" \
263
- --consensus "${CONSENSUS}" \
264
- --iterations-loop3 "${L3}" \
265
- --iterations-loop2 "${L2}" \
266
- --deliverables "$(git diff HEAD~1 --name-only | tr '\n' ',')"
267
-
268
- # Output: Stores reflection in SQLite with tags, confidence, priority
269
- # Categories: PATTERN, STRAT, ANTI, EDGE
270
- # Automatic tag extraction and deduplication
271
- echo "✅ ACE reflection captured: $(sqlite3 .claude/cfn-data/cfn-loop.db 'SELECT COUNT(*) FROM context_reflections WHERE task_id = \"'${TASK_ID}'\"') bullets"
272
- fi
273
- ```
274
-
275
- **Checklist:**
276
- - [ ] Consensus ≥ threshold | [ ] Product Owner approved | [ ] Deliverables verified
277
- - [ ] Tests passing | [ ] Next steps executed or deferred | [ ] Git committed | [ ] Git pushed
278
- - [ ] Summary generated | [ ] ACE reflection captured (if `--ace-reflect` enabled)
279
-
280
- ---
281
-
282
- ## Backlog Mechanism
283
-
284
- ### Epic Config Structure
285
- ```json
286
- {
287
- "epic_id": "epic-auth-001",
288
- "phases": [...],
289
- "backlog": [
290
- {
291
- "backlog_id": "backlog-001",
292
- "title": "Implement OAuth",
293
- "reason": "Out of scope - deferred by PO",
294
- "priority": "P2",
295
- "estimated_complexity": "medium"
296
- }
297
- ]
298
- }
299
- ```
300
-
301
- ### Adding Backlog Items
302
-
303
- **Manual:**
304
- ```bash
305
- ./.claude/skills/epic-management/add-backlog-item.sh \
306
- --epic-id "epic-auth-001" --title "OAuth" --priority "P2"
307
- ```
308
-
309
- **Auto-Deferral (Product Owner):**
310
- ```bash
311
- # CLI Mode: execute-decision.sh handles this automatically
312
- # Task Mode: Coordinator should implement this logic after PO decision
313
- if [[ "$FEEDBACK" == *"out of scope"* ]]; then
314
- add-backlog-item.sh --epic-id "$EPIC_ID" --title "$ITEM" --auto-deferred
315
- fi
316
- ```
317
-
318
- ### Prioritization
319
- - **P1**: Critical, blocks progress → process immediately by launching agents for loop 3
320
- - **P2**: High value → next sprint
321
- - **P3**: Nice to have → background worker
322
-
323
- ---
324
-
325
- ## Adaptive Validator Scaling
326
-
327
- ### Complexity Scoring
328
- ```javascript
329
- let score = 0;
330
- score += (files <= 2) ? 10 : (files <= 5) ? 30 : 60;
331
- score += (LOC <= 200) ? 10 : (LOC <= 500) ? 30 : 60;
332
- if (task.match(/auth|payment|token/i)) score += 40; // Security
333
- if (task.match(/performance|cache/i)) score += 30; // Performance
334
- if (task.match(/frontend|ui|react|vue|angular/i)) score += 20; // ADA compliance
335
-
336
- // Category: simple (≤50), standard (≤100), complex/enterprise (>100)
337
- // Validators: simple=2, standard=4 (arch+sec), complex=5+ (code-analyzer+perf/ada*)
338
- ```
339
-
340
- ### Dynamic Thresholds
341
- ```javascript
342
- const base = {simple: 0.85, standard: 0.90, complex: 0.92};
343
- threshold = base[category] + (iteration - 1) * 0.02; // Stricter on retries
344
- threshold = Math.min(threshold, 0.98); // Cap at 0.98
345
- ```
346
-
347
- ---
348
-
349
- ## Background Backlog Worker
350
-
351
- ### Architecture
352
- - **Main Chat (as coordinator)**: Spawns Task() agents directly for Sprint N (foreground)
353
- - **Background CLI**: Processes P3 backlog items (detached process)
354
-
355
- ### Launch Background Worker
356
- ```bash
357
- npx claude-flow-novice agent backlog-worker \
358
- --epic-id "epic-auth-001" --priority "P3" --background \
359
- --log-file "/tmp/backlog-worker-$(date +%s).log" > /dev/null 2>&1 &
360
- echo $! > /tmp/backlog-worker.pid
361
- ```
362
-
363
- ### Worker Logic
364
- 1. Fetch P3 items: `redis-cli SMEMBERS "epic:${EPIC_ID}:backlog:P3"`
365
- 2. For each item:
366
- - Mark in_progress: `redis-cli HSET "backlog:${ID}" status "in_progress"`
367
- - Spawn CFN Loop: `npx claude-flow-novice swarm "$DESC" --mode mvp --background`
368
- - Monitor: `redis-cli BLPOP "swarm:${TASK_ID}:complete" 300`
369
- - Mark complete: `redis-cli HSET "backlog:${ID}" status "complete"`
370
- 3. Update Redis every 5 min: `redis-cli HSET "backlog:worker:status" processed "$N"`
371
-
372
- ### Monitor Progress
373
- ```bash
374
- redis-cli HGETALL "backlog:worker:status" # Check status
375
- tail -f /tmp/backlog-worker-*.log # View logs
376
- kill $(cat /tmp/backlog-worker.pid) # Stop worker
377
- ```
378
-
379
- ### Safety Mechanisms
380
- - Max 3 concurrent items, 10-min timeout per item, 2-hour max runtime
381
- - Redis locks: `redis-cli SET "backlog:${ID}:lock" "worker-$$" EX 600 NX`
382
- - Manual recovery: Reset stuck items to "pending"
383
-
384
- ---
385
-
386
- ### Background Backlog Example
387
-
388
- ```javascript
389
- // Background: Process P3 backlog
390
- Bash(`
391
- npx claude-flow-novice agent backlog-worker \
392
- --epic-id "epic-auth-001" --priority "P3" --background \
393
- > /dev/null 2>&1 & echo $! > /tmp/backlog-worker.pid
394
- `, "Launch backlog worker")
395
-
396
- // Check progress anytime
397
- Bash(`redis-cli HGETALL "backlog:worker:status"`, "Check progress")
398
- ```
399
-
400
- ---
401
-
402
- ## Quick Reference
403
-
404
- ### Validator Selection Heuristics
405
- ```
406
- Simple (1-2 files, <200 LOC): reviewer, tester
407
- Standard (3-5 files, 200-500 LOC): +architect, +security-specialist
408
- Complex/Enterprise (>5 files, >500 LOC): +code-analyzer
409
- IF performance-critical → +performance-benchmarker
410
- IF frontend (react/vue/angular/ui) → +accessibility-advocate-persona
411
- ```
412
-
413
- ### Troubleshooting
414
-
415
- | Issue | Solution |
416
- |-------|----------|
417
- | Low consensus | Add specialized validator or stricter acceptance criteria |
418
- | Git push fails | Check remote: `git remote -v && git fetch origin` |
419
- | Backlog worker stuck | Reset items: `redis-cli HSET "backlog:${ID}" status "pending"`, restart worker |
420
- | Too many validators | Reduce count to 3-4 or lower threshold by 0.02-0.04 |
421
-
422
- ### Complexity Analysis CLI
423
- ```bash
424
- ./.claude/skills/task-complexity/analyze.sh --task "$DESC" --files "$LIST"
425
- # Output: {"score": 85, "category": "standard", "validators": ["reviewer","tester","architect","security-specialist"], "threshold": 0.90}
426
- ```
427
-
428
- ---
429
-
430
- ## ACE System Integration
431
-
432
- ### Reflection After Sprint
433
- After each sprint completion, Task Mode should capture lessons learned:
434
-
435
- ```bash
436
- # Automatic reflection capture (called after git push)
437
- ./.claude/skills/cfn-ace-system/invoke-context-reflect.sh \
438
- --task-id "${TASK_ID}" \
439
- --sprint-id "${SPRINT_NUM}" \
440
- --consensus "${CONSENSUS}" \
441
- --iterations-loop3 "${L3}" \
442
- --iterations-loop2 "${L2}" \
443
- --deliverables "$(git diff HEAD~1 --name-only | tr '\n' ',')"
444
- ```
445
-
446
- **What Gets Captured:**
447
- - Patterns that worked well (consensus ≥0.90, low iterations)
448
- - Anti-patterns that caused issues (high iterations, deliverable failures)
449
- - Strategy patterns (agent selection, validator scaling effectiveness)
450
- - Edge cases (timeout scenarios, race conditions, blocking issues)
451
-
452
- **Storage:**
453
- - SQLite database: `.claude/cfn-data/cfn-loop.db`
454
- - Table: `context_reflections`
455
- - Automatic tagging, deduplication, confidence scoring
456
-
457
- **Benefits:**
458
- - Future sprints learn from past mistakes
459
- - Adaptive validator scaling improves over time
460
- - Pattern recognition across projects
461
- - Knowledge accumulation (not lost between sessions)
462
-
463
- ### Optional: Context Injection (Future Enhancement)
464
- Before spawning agents, inject relevant lessons:
465
- ```bash
466
- # Not yet implemented in Task Mode, but available:
467
- ./.claude/skills/cfn-ace-system/invoke-context-inject.sh \
468
- --task "${TASK_DESCRIPTION}" \
469
- --phase "${PHASE_NAME}" \
470
- --tags "validation,consensus,deliverables"
471
- # Returns: Top N relevant bullets from past reflections
472
- ```
473
-
474
- ### Optional: Context Curation (Periodic Maintenance)
475
- Merge and deduplicate reflection data:
476
- ```bash
477
- # Run monthly or after major epics:
478
- ./.claude/skills/cfn-ace-system/invoke-context-curate.sh \
479
- --confidence-threshold 0.85 \
480
- --merge-similar-patterns
481
- ```
482
-
483
- ---
484
-
485
- ## Related Documentation
486
-
487
- - **CFN Coordinator Parameters**: `.claude/commands/cfn/CFN_COORDINATOR_PARAMETERS.md`
488
- - **Redis Coordination**: `.claude/skills/cfn-redis-coordination/SKILL.md`
489
- - **Product Owner Decision**: `.claude/skills/cfn-product-owner-decision/SKILL.md`
490
- - **Agent Output Standards**: `docs/AGENT_OUTPUT_STANDARDS.md`
491
- - **ACE System**: `.claude/skills/cfn-ace-system/SKILL.md`
492
-
493
- ---
494
-
495
- **Version:** 1.0.0 (2025-10-28) - Task mode guide: agent specialization, sprint workflow, backlog, adaptive scaling, background processing