moflo 4.3.1 → 4.6.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 (66) hide show
  1. package/.claude/guidance/agent-bootstrap.md +2 -2
  2. package/.claude/guidance/guidance-memory-strategy.md +262 -0
  3. package/.claude/guidance/memory-strategy.md +204 -0
  4. package/.claude/guidance/moflo.md +594 -0
  5. package/.claude/guidance/task-swarm-integration.md +348 -0
  6. package/.claude/helpers/hook-handler.cjs +83 -1
  7. package/.claude/helpers/metrics-db.mjs +492 -488
  8. package/.claude/helpers/statusline.cjs +85 -16
  9. package/.claude/settings.json +10 -25
  10. package/.claude/settings.local.json +14 -0
  11. package/README.md +279 -181
  12. package/bin/build-embeddings.mjs +2 -2
  13. package/bin/generate-code-map.mjs +1 -1
  14. package/bin/index-guidance.mjs +85 -15
  15. package/bin/semantic-search.mjs +6 -6
  16. package/bin/setup-project.mjs +9 -9
  17. package/package.json +8 -7
  18. package/src/@claude-flow/cli/dist/src/commands/appliance.js +12 -12
  19. package/src/@claude-flow/cli/dist/src/commands/benchmark.js +2 -2
  20. package/src/@claude-flow/cli/dist/src/commands/claims.js +1 -1
  21. package/src/@claude-flow/cli/dist/src/commands/config.js +3 -3
  22. package/src/@claude-flow/cli/dist/src/commands/daemon.js +25 -3
  23. package/src/@claude-flow/cli/dist/src/commands/deployment.js +1 -1
  24. package/src/@claude-flow/cli/dist/src/commands/doctor.js +23 -6
  25. package/src/@claude-flow/cli/dist/src/commands/embeddings.js +1 -1
  26. package/src/@claude-flow/cli/dist/src/commands/gate.d.ts +8 -8
  27. package/src/@claude-flow/cli/dist/src/commands/gate.js +13 -13
  28. package/src/@claude-flow/cli/dist/src/commands/hooks.js +1 -1
  29. package/src/@claude-flow/cli/dist/src/commands/init.js +14 -12
  30. package/src/@claude-flow/cli/dist/src/commands/neural.js +1 -1
  31. package/src/@claude-flow/cli/dist/src/commands/orc.d.ts +6 -6
  32. package/src/@claude-flow/cli/dist/src/commands/orc.js +25 -25
  33. package/src/@claude-flow/cli/dist/src/commands/performance.js +1 -1
  34. package/src/@claude-flow/cli/dist/src/commands/plugins.js +1 -1
  35. package/src/@claude-flow/cli/dist/src/commands/providers.js +1 -1
  36. package/src/@claude-flow/cli/dist/src/commands/security.js +1 -1
  37. package/src/@claude-flow/cli/dist/src/commands/start.js +11 -11
  38. package/src/@claude-flow/cli/dist/src/commands/status.js +3 -3
  39. package/src/@claude-flow/cli/dist/src/commands/transfer-store.js +1 -1
  40. package/src/@claude-flow/cli/dist/src/config/moflo-config.d.ts +30 -0
  41. package/src/@claude-flow/cli/dist/src/config/moflo-config.js +103 -7
  42. package/src/@claude-flow/cli/dist/src/index.d.ts +1 -1
  43. package/src/@claude-flow/cli/dist/src/index.js +3 -3
  44. package/src/@claude-flow/cli/dist/src/init/claudemd-generator.js +1 -1
  45. package/src/@claude-flow/cli/dist/src/init/executor.js +9 -12
  46. package/src/@claude-flow/cli/dist/src/init/helpers-generator.js +640 -640
  47. package/src/@claude-flow/cli/dist/src/init/moflo-init.js +522 -67
  48. package/src/@claude-flow/cli/dist/src/init/settings-generator.js +7 -12
  49. package/src/@claude-flow/cli/dist/src/init/statusline-generator.d.ts +1 -1
  50. package/src/@claude-flow/cli/dist/src/init/statusline-generator.js +784 -784
  51. package/src/@claude-flow/cli/dist/src/mcp-tools/agentdb-tools.js +12 -12
  52. package/src/@claude-flow/cli/dist/src/mcp-tools/hooks-tools.js +122 -66
  53. package/src/@claude-flow/cli/dist/src/memory/intelligence.js +5 -1
  54. package/src/@claude-flow/cli/dist/src/memory/memory-initializer.d.ts +1 -1
  55. package/src/@claude-flow/cli/dist/src/memory/memory-initializer.js +371 -371
  56. package/src/@claude-flow/cli/dist/src/parser.d.ts +10 -0
  57. package/src/@claude-flow/cli/dist/src/parser.js +49 -3
  58. package/src/@claude-flow/cli/dist/src/plugins/store/discovery.js +1 -1
  59. package/src/@claude-flow/cli/dist/src/runtime/headless.js +30 -30
  60. package/src/@claude-flow/cli/dist/src/services/claim-service.js +1 -1
  61. package/src/@claude-flow/cli/dist/src/services/ruvector-training.js +11 -5
  62. package/src/@claude-flow/cli/dist/src/services/workflow-gate.d.ts +13 -3
  63. package/src/@claude-flow/cli/dist/src/services/workflow-gate.js +73 -5
  64. package/src/@claude-flow/cli/dist/src/types.d.ts +1 -1
  65. package/src/@claude-flow/cli/dist/src/types.js +1 -1
  66. package/src/@claude-flow/memory/package.json +44 -42
@@ -4,7 +4,7 @@
4
4
  * One-stop setup that makes MoFlo work out of the box:
5
5
  * 1. Generate moflo.yaml (project config)
6
6
  * 2. Set up .claude/settings.json hooks
7
- * 3. Create .claude/skills/mf/ skill
7
+ * 3. Create .claude/skills/flo/ skill (with /fl alias)
8
8
  * 4. Append MoFlo section to CLAUDE.md
9
9
  * 5. Initialize memory DB
10
10
  * 6. Auto-index guidance + code map
@@ -96,7 +96,7 @@ export async function initMoflo(options) {
96
96
  steps.push(generateConfig(projectRoot, force, answers));
97
97
  // Step 2: .claude/settings.json hooks
98
98
  steps.push(generateHooks(projectRoot, force, answers));
99
- // Step 3: .claude/skills/mf/
99
+ // Step 3: .claude/skills/flo/ (with /fl alias)
100
100
  steps.push(generateSkill(projectRoot, force));
101
101
  // Step 4: CLAUDE.md MoFlo section
102
102
  steps.push(generateClaudeMd(projectRoot, force));
@@ -168,17 +168,37 @@ memory:
168
168
  embedding_model: Xenova/all-MiniLM-L6-v2
169
169
  namespace: default
170
170
 
171
- # Hook toggles
171
+ # Hook toggles (all on by default — disable to slim down)
172
172
  hooks:
173
- pre_edit: true
174
- gate: ${gatesEnabled}
175
- stop_hook: ${answers?.stopHook ?? true}
176
- session_restore: true
177
-
178
- # Model preferences
173
+ pre_edit: true # Track file edits for learning
174
+ post_edit: true # Record edit outcomes, train neural patterns
175
+ pre_task: true # Get agent routing before task spawn
176
+ post_task: true # Record task results for learning
177
+ gate: ${gatesEnabled} # Workflow gate enforcement (memory-first, task-create-first)
178
+ route: true # Intelligent task routing on each prompt
179
+ stop_hook: ${answers?.stopHook ?? true} # Session-end persistence and metric export
180
+ session_restore: true # Restore session state on start
181
+ notification: true # Hook into Claude Code notifications
182
+
183
+ # Model preferences (haiku, sonnet, opus)
179
184
  models:
180
- default: opus
181
- review: opus
185
+ default: opus # Model for general tasks
186
+ research: sonnet # Model for research/exploration agents
187
+ review: opus # Model for code review agents
188
+ test: sonnet # Model for test-writing agents
189
+
190
+ # Intelligent model routing (auto-selects haiku/sonnet/opus per task)
191
+ # When enabled, overrides the static model preferences above
192
+ # by analyzing task complexity and routing to the cheapest capable model.
193
+ model_routing:
194
+ enabled: false # Set to true to enable dynamic routing
195
+ confidence_threshold: 0.85 # Min confidence before escalating to a more capable model
196
+ cost_optimization: true # Prefer cheaper models when confidence is high
197
+ circuit_breaker: true # Penalize models that fail repeatedly
198
+ # Per-agent overrides (set to "inherit" to use routing, or a specific model to pin)
199
+ # agent_overrides:
200
+ # security-architect: opus # Always use opus for security
201
+ # researcher: sonnet # Pin research to sonnet
182
202
  `;
183
203
  fs.writeFileSync(configPath, yaml, 'utf-8');
184
204
  return { name: 'moflo.yaml', status: 'created', detail: `Detected: ${srcDirs.join(', ')} | ${detectedExts.join(', ')}` };
@@ -215,64 +235,139 @@ function generateHooks(root, force, answers) {
215
235
  }
216
236
  catch { /* start fresh */ }
217
237
  // Check if MoFlo hooks already set up
218
- const hasGateHooks = JSON.stringify(existing).includes('moflo gate');
238
+ const settingsStr = JSON.stringify(existing);
239
+ const hasGateHooks = settingsStr.includes('flo gate') || settingsStr.includes('moflo gate');
219
240
  if (hasGateHooks && !force) {
220
241
  return { name: '.claude/settings.json', status: 'skipped', detail: 'MoFlo hooks already configured' };
221
242
  }
222
243
  }
223
- // Build hooks config
244
+ // Build hooks config — all on by default (opinionated pit-of-success)
224
245
  const hooks = {
225
246
  "PreToolUse": [
226
247
  {
227
- "matcher": "Glob|Grep",
248
+ "matcher": "^(Write|Edit|MultiEdit)$",
228
249
  "hooks": [{
229
250
  "type": "command",
230
- "command": "npx moflo gate check-before-scan"
251
+ "command": "npx flo hooks pre-edit",
252
+ "timeout": 5000
231
253
  }]
232
254
  },
233
255
  {
234
- "matcher": "Read",
256
+ "matcher": "^(Glob|Grep)$",
235
257
  "hooks": [{
236
258
  "type": "command",
237
- "command": "npx moflo gate check-before-read"
259
+ "command": "npx flo gate check-before-scan",
260
+ "timeout": 3000
238
261
  }]
239
262
  },
240
263
  {
241
- "matcher": "Agent",
264
+ "matcher": "^Read$",
242
265
  "hooks": [{
243
266
  "type": "command",
244
- "command": "npx moflo gate check-before-agent"
267
+ "command": "npx flo gate check-before-read",
268
+ "timeout": 3000
245
269
  }]
270
+ },
271
+ {
272
+ "matcher": "^Task$",
273
+ "hooks": [
274
+ {
275
+ "type": "command",
276
+ "command": "npx flo gate check-before-agent",
277
+ "timeout": 3000
278
+ },
279
+ {
280
+ "type": "command",
281
+ "command": "npx flo hooks pre-task",
282
+ "timeout": 5000
283
+ }
284
+ ]
246
285
  }
247
286
  ],
248
287
  "PostToolUse": [
249
288
  {
250
- "matcher": "TaskCreate",
289
+ "matcher": "^(Write|Edit|MultiEdit)$",
290
+ "hooks": [{
291
+ "type": "command",
292
+ "command": "npx flo hooks post-edit",
293
+ "timeout": 5000
294
+ }]
295
+ },
296
+ {
297
+ "matcher": "^Task$",
251
298
  "hooks": [{
252
299
  "type": "command",
253
- "command": "npx moflo gate record-task-created"
300
+ "command": "npx flo hooks post-task",
301
+ "timeout": 5000
254
302
  }]
255
303
  },
256
304
  {
257
- "matcher": "Bash",
305
+ "matcher": "^TaskCreate$",
258
306
  "hooks": [{
259
307
  "type": "command",
260
- "command": "npx moflo gate check-bash-memory"
308
+ "command": "npx flo gate record-task-created",
309
+ "timeout": 2000
261
310
  }]
262
311
  },
263
312
  {
264
- "matcher": "mcp__claude-flow__memory_search",
313
+ "matcher": "^Bash$",
265
314
  "hooks": [{
266
315
  "type": "command",
267
- "command": "npx moflo gate record-memory-searched"
316
+ "command": "npx flo gate check-bash-memory",
317
+ "timeout": 2000
318
+ }]
319
+ },
320
+ {
321
+ "matcher": "^mcp__claude-flow__memory_(search|retrieve)$",
322
+ "hooks": [{
323
+ "type": "command",
324
+ "command": "npx flo gate record-memory-searched",
325
+ "timeout": 2000
268
326
  }]
269
327
  }
270
328
  ],
271
329
  "UserPromptSubmit": [
330
+ {
331
+ "hooks": [
332
+ {
333
+ "type": "command",
334
+ "command": "npx flo gate prompt-reminder",
335
+ "timeout": 2000
336
+ },
337
+ {
338
+ "type": "command",
339
+ "command": "npx flo hooks route",
340
+ "timeout": 5000
341
+ }
342
+ ]
343
+ }
344
+ ],
345
+ "SessionStart": [
346
+ {
347
+ "hooks": [
348
+ {
349
+ "type": "command",
350
+ "command": "node \"$CLAUDE_PROJECT_DIR/.claude/scripts/session-start-launcher.mjs\"",
351
+ "timeout": 3000
352
+ }
353
+ ]
354
+ }
355
+ ],
356
+ "Stop": [
272
357
  {
273
358
  "hooks": [{
274
359
  "type": "command",
275
- "command": "npx moflo gate prompt-reminder"
360
+ "command": "npx flo hooks session-end",
361
+ "timeout": 5000
362
+ }]
363
+ }
364
+ ],
365
+ "Notification": [
366
+ {
367
+ "hooks": [{
368
+ "type": "command",
369
+ "command": "npx flo hooks notification",
370
+ "timeout": 3000
276
371
  }]
277
372
  }
278
373
  ]
@@ -280,87 +375,447 @@ function generateHooks(root, force, answers) {
280
375
  // Merge: preserve existing non-MoFlo hooks, add MoFlo hooks
281
376
  existing.hooks = hooks;
282
377
  fs.writeFileSync(settingsPath, JSON.stringify(existing, null, 2), 'utf-8');
283
- return { name: '.claude/settings.json', status: existing.hooks ? 'updated' : 'created', detail: '7 workflow gate hooks configured' };
378
+ return { name: '.claude/settings.json', status: existing.hooks ? 'updated' : 'created', detail: '14 hooks configured (gates, lifecycle, routing, session)' };
284
379
  }
285
380
  // ============================================================================
286
- // Step 3: .claude/skills/mf/ skill
381
+ // Step 3: .claude/skills/flo/ skill (with /fl alias)
287
382
  // ============================================================================
288
383
  function generateSkill(root, force) {
289
- const skillDir = path.join(root, '.claude', 'skills', 'mf');
384
+ const skillDir = path.join(root, '.claude', 'skills', 'flo');
290
385
  const skillFile = path.join(skillDir, 'SKILL.md');
386
+ const aliasDir = path.join(root, '.claude', 'skills', 'fl');
387
+ const aliasFile = path.join(aliasDir, 'SKILL.md');
291
388
  if (fs.existsSync(skillFile) && !force) {
292
- return { name: '.claude/skills/mf/', status: 'skipped', detail: 'Already exists' };
389
+ return { name: '.claude/skills/flo/', status: 'skipped', detail: 'Already exists' };
293
390
  }
294
391
  if (!fs.existsSync(skillDir)) {
295
392
  fs.mkdirSync(skillDir, { recursive: true });
296
393
  }
297
394
  const skillContent = `---
298
- name: mf
395
+ name: flo
299
396
  description: MoFlo ticket workflow - analyze and execute GitHub issues
300
397
  arguments: "[options] <issue-number>"
301
398
  ---
302
399
 
303
- # /mf - MoFlo Ticket Workflow
400
+ # /flo - MoFlo Ticket Workflow
304
401
 
305
- Execute GitHub issues through a full automated workflow.
402
+ Research, enhance, and execute GitHub issues automatically.
306
403
 
307
404
  **Arguments:** $ARGUMENTS
308
405
 
309
406
  ## Usage
310
407
 
311
408
  \`\`\`
312
- /mf <issue-number> # Full workflow (default: swarm mode)
313
- /mf -e <issue-number> # Enhance only: research and update ticket
314
- /mf -r <issue-number> # Research only: analyze issue
315
- /mf -n <issue-number> # Naked mode: single Claude, no agents
316
- /mf -sw <issue-number> # Swarm mode (explicit, default)
409
+ /flo <issue-number> # Full workflow with SWARM (default)
410
+ /flo -e <issue-number> # Enhance only: research and update ticket, then STOP
411
+ /flo --enhance <issue-number> # Same as -e
412
+ /flo -r <issue-number> # Research only: analyze issue, output findings
413
+ /flo --research <issue-number> # Same as -r
414
+ \`\`\`
415
+
416
+ Also available as \`/fl\` (shorthand alias).
417
+
418
+ ### Execution Mode (how work is done)
419
+
420
+ \`\`\`
421
+ /flo 123 # SWARM mode (default) - multi-agent coordination
422
+ /flo -sw 123 # SWARM mode (explicit)
423
+ /flo --swarm 123 # Same as -sw
424
+ /flo -hv 123 # HIVE-MIND mode - consensus-based coordination
425
+ /flo --hive 123 # Same as -hv
426
+ /flo -n 123 # NAKED mode - single Claude, no agents
427
+ /flo --naked 123 # Same as -n
428
+ \`\`\`
429
+
430
+ ### Epic Handling
431
+
432
+ \`\`\`
433
+ /flo 42 # If #42 is an epic, processes all stories sequentially
434
+ \`\`\`
435
+
436
+ **Epic Detection:** Issues with \`epic\` label or containing \`## Stories\` / \`## Tasks\` sections are automatically detected as epics.
437
+
438
+ **Sequential Processing:** When an epic is selected:
439
+ 1. List all child stories/tasks (from checklist or linked issues)
440
+ 2. Process each story **one at a time** in order
441
+ 3. Each story goes through the full workflow (research -> enhance -> implement -> test -> PR)
442
+ 4. After each story's PR is created, move to the next story
443
+ 5. Continue until all stories are complete
444
+
445
+ ### Combined Examples
446
+
447
+ \`\`\`
448
+ /flo 123 # Swarm + full workflow (default) - includes ALL tests
449
+ /flo 42 # If #42 is epic, processes stories sequentially
450
+ /flo -e 123 # Swarm + enhance only (no implementation)
451
+ /flo -hv -e 123 # Hive-mind + enhance only
452
+ /flo -n -r 123 # Naked + research only
453
+ /flo --swarm --enhance 123 # Explicit swarm + enhance only
454
+ /flo -n 123 # Naked + full workflow (still runs all tests)
455
+ \`\`\`
456
+
457
+ ## SWARM IS MANDATORY BY DEFAULT
458
+
459
+ Even if a task "looks simple", you MUST use swarm coordination unless
460
+ the user explicitly passes -n/--naked. "Simple" is a trap. Tasks have
461
+ hidden complexity. Swarm catches it.
462
+
463
+ THE ONLY WAY TO SKIP SWARM: User passes -n or --naked explicitly.
464
+
465
+ ## COMPREHENSIVE TESTING REQUIREMENT
466
+
467
+ ALL tests MUST pass BEFORE PR creation - NO EXCEPTIONS.
468
+ - Unit Tests: MANDATORY for all new/modified code
469
+ - Integration Tests: MANDATORY for API endpoints and services
470
+ - E2E Tests: MANDATORY for user-facing features
471
+ PR CANNOT BE CREATED until all relevant tests pass.
472
+
473
+ ## Workflow Overview
474
+
475
+ \`\`\`
476
+ Research -> Enhance -> Execute -> Testing -> Simplify -> PR+Done
477
+
478
+ Research: Fetch issue, search memory, read guidance, find files
479
+ Enhance: Update GitHub issue with tech analysis, affected files, impl plan
480
+ Execute: Assign self, create branch, implement changes
481
+ Testing: Unit + Integration + E2E tests (ALL MUST PASS - gate)
482
+ Simplify: Run /simplify on changed code (gate - must run before PR)
483
+ PR+Done: Create PR, update issue status, store learnings
484
+ \`\`\`
485
+
486
+ ### Workflow Gates
487
+
488
+ | Gate | Requirement | Blocked Action |
489
+ |------|-------------|----------------|
490
+ | **Testing Gate** | Unit + Integration + E2E must pass | PR creation |
491
+ | **Simplification Gate** | /simplify must run on changed files | PR creation |
492
+
493
+ ### Execution Mode (applies to all phases)
494
+
495
+ | Mode | Description |
496
+ |------|-------------|
497
+ | **SWARM** (default) | Multi-agent via Task tool: researcher, coder, tester, reviewer |
498
+ | **HIVE-MIND** (-hv) | Consensus-based coordination for architecture decisions |
499
+ | **NAKED** (-n) | Single Claude, no agent spawning. Only when user explicitly requests. |
500
+
501
+ ## Phase 1: Research (-r or default first step)
502
+
503
+ ### 1.1 Fetch Issue Details
504
+ \`\`\`bash
505
+ gh issue view <issue-number> --json number,title,body,labels,state,assignees,comments,milestone
506
+ \`\`\`
507
+
508
+ ### 1.2 Check Enhancement Status
509
+ Look for \`## Implementation Plan\` marker in issue body.
510
+ - **If present**: Issue already enhanced, skip to execute or confirm
511
+ - **If absent**: Proceed with research and enhancement
512
+
513
+ ### 1.3 Search Memory FIRST
514
+ ALWAYS search memory BEFORE reading guidance or docs files.
515
+ Memory has file paths, context, and patterns - often all you need.
516
+ Only read guidance files if memory search returns zero relevant results.
517
+
518
+ \`\`\`bash
519
+ npx flo memory search --query "<issue title keywords>" --namespace patterns
520
+ npx flo memory search --query "<domain keywords>" --namespace guidance
521
+ \`\`\`
522
+
523
+ Or via MCP: \`mcp__claude-flow__memory_search\`
524
+
525
+ ### 1.4 Read Guidance Docs (ONLY if memory insufficient)
526
+ **Only if memory search returned < 3 relevant results**, read guidance files:
527
+ - Bug -> testing patterns, error handling
528
+ - Feature -> domain model, architecture
529
+ - UI -> frontend patterns, components
530
+
531
+ ### 1.5 Research Codebase
532
+ Use Task tool with Explore agent to find:
533
+ - Affected files and their current state
534
+ - Related code and dependencies
535
+ - Existing patterns to follow
536
+ - Test coverage gaps
537
+
538
+ ## Phase 2: Enhance (-e includes research + enhancement)
539
+
540
+ ### 2.1 Build Enhancement
541
+ Compile research into structured enhancement:
542
+
543
+ **Technical Analysis** - Root cause (bugs) or approach (features), impact, risk factors
544
+
545
+ **Affected Files** - Files to modify (with line numbers), new files, deletions
546
+
547
+ **Implementation Plan** - Numbered steps with clear actions, dependencies, decision points
548
+
549
+ **Test Plan** - Unit tests to add/update, integration tests needed, manual testing checklist
550
+
551
+ **Estimates** - Complexity (Low/Medium/High), scope (# files, # new tests)
552
+
553
+ ### 2.2 Update GitHub Issue
554
+ \`\`\`bash
555
+ gh issue edit <issue-number> --body "<original body + Technical Analysis + Affected Files + Implementation Plan + Test Plan + Estimates>"
556
+ \`\`\`
557
+
558
+ ### 2.3 Add Enhancement Comment
559
+ \`\`\`bash
560
+ gh issue comment <issue-number> --body "Issue enhanced with implementation plan. Ready for execution."
561
+ \`\`\`
562
+
563
+ ## Phase 3: Execute (default, runs automatically after enhance)
564
+
565
+ ### 3.1 Assign Issue and Update Status
566
+ \`\`\`bash
567
+ gh issue edit <issue-number> --add-assignee @me
568
+ gh issue edit <issue-number> --add-label "in-progress"
569
+ \`\`\`
570
+
571
+ ### 3.2 Create Branch
572
+ \`\`\`bash
573
+ git checkout main && git pull origin main
574
+ git checkout -b <type>/<issue-number>-<short-desc>
317
575
  \`\`\`
576
+ Types: \`feature/\`, \`fix/\`, \`refactor/\`, \`docs/\`
577
+
578
+ ### 3.3 Implement
579
+ Follow the implementation plan from the enhanced issue. No prompts - execute all steps.
580
+
581
+ ## Phase 4: Testing (MANDATORY GATE)
582
+
583
+ This is NOT optional. ALL applicable test types must pass for the change type.
584
+ WORKFLOW STOPS HERE until tests pass. No shortcuts. No exceptions.
585
+
586
+ ### 4.1 Write and Run Tests
587
+ Write unit, integration, and E2E tests as appropriate for the change type.
588
+ Use the project's existing test runner and patterns.
589
+
590
+ ### 4.2 Test Auto-Fix Loop
591
+ If any tests fail, enter the auto-fix loop (max 3 retries OR 10 minutes):
592
+ 1. Run all tests
593
+ 2. If ALL pass -> proceed to simplification
594
+ 3. If ANY fail: analyze failure, fix test or implementation code, retry
595
+ 4. If retries exhausted -> STOP and report to user
596
+
597
+ ## Phase 4.5: Code Simplification (MANDATORY)
598
+
599
+ The built-in /simplify command reviews ALL changed code for:
600
+ - Reuse opportunities and code quality
601
+ - Efficiency improvements
602
+ - Consistency with existing codebase patterns
603
+ - Preserves ALL functionality - no behavior changes
604
+
605
+ If /simplify makes changes -> re-run tests to confirm nothing broke.
606
+ If re-tests fail -> revert changes, proceed with original code.
607
+
608
+ ## Phase 5: Commit and PR (only after tests pass)
609
+
610
+ ### 5.1 Commit
611
+ \`\`\`bash
612
+ git add <specific files>
613
+ git commit -m "type(scope): description
614
+
615
+ Closes #<issue-number>
616
+
617
+ Co-Authored-By: Claude <noreply@anthropic.com>"
618
+ \`\`\`
619
+
620
+ ### 5.2 Create PR
621
+ \`\`\`bash
622
+ git push -u origin <branch-name>
623
+ gh pr create --title "type(scope): description" --body "## Summary
624
+ <brief description>
625
+
626
+ ## Changes
627
+ <bullet list>
628
+
629
+ ## Testing
630
+ - [x] Unit tests pass
631
+ - [x] Integration tests pass
632
+ - [x] E2E tests pass
633
+ - [ ] Manual testing done
634
+
635
+ Closes #<issue-number>"
636
+ \`\`\`
637
+
638
+ ### 5.3 Update Issue Status
639
+ \`\`\`bash
640
+ gh issue edit <issue-number> --remove-label "in-progress" --add-label "ready-for-review"
641
+ gh issue comment <issue-number> --body "PR created: <pr-url>"
642
+ \`\`\`
643
+
644
+ ## Epic Handling
318
645
 
319
- ## Workflow
646
+ ### Detecting Epics
320
647
 
321
- 1. **Research** — Fetch issue, search memory, read guidance, explore codebase
322
- 2. **Enhance** Update issue with implementation plan, affected files, test plan
323
- 3. **Implement** Create branch, implement changes following the plan
324
- 4. **Test** Write and run unit/integration/E2E tests (ALL must pass)
325
- 5. **Simplify** — Run /simplify on changed code for quality review
326
- 6. **PR** Commit, create PR, update issue status, store learnings
648
+ An issue is an **epic** if:
649
+ 1. It has the \`epic\` label, OR
650
+ 2. Its body contains \`## Stories\` or \`## Tasks\` sections, OR
651
+ 3. It has linked child issues (via \`- [ ] #123\` checklist format)
652
+
653
+ ### Epic Processing Flow
654
+
655
+ 1. DETECT EPIC - Check labels, parse body for ## Stories / ## Tasks, extract issue references
656
+ 2. LIST ALL STORIES - Extract from checklist, order top-to-bottom as listed
657
+ 3. SEQUENTIAL PROCESSING - For each story: run full /flo workflow, wait for PR, update checklist
658
+ 4. COMPLETION - All stories have PRs, epic marked as ready-for-review
659
+
660
+ ONE STORY AT A TIME - NO PARALLEL STORY EXECUTION.
661
+ Each story must complete (PR created) before starting next.
662
+
663
+ ### Epic Detection Code
664
+
665
+ \`\`\`javascript
666
+ function isEpic(issue) {
667
+ if (issue.labels?.some(l => l.name === 'epic')) return true;
668
+ if (issue.body?.includes('## Stories') || issue.body?.includes('## Tasks')) return true;
669
+ const linkedIssuePattern = /- \\[[ x]\\] #\\d+/;
670
+ if (linkedIssuePattern.test(issue.body)) return true;
671
+ return false;
672
+ }
673
+
674
+ function extractStories(epicBody) {
675
+ const stories = [];
676
+ const pattern = /- \\[[ ]\\] #(\\d+)/g;
677
+ let match;
678
+ while ((match = pattern.exec(epicBody)) !== null) {
679
+ stories.push(parseInt(match[1]));
680
+ }
681
+ return stories;
682
+ }
683
+ \`\`\`
327
684
 
328
685
  ## Parse Arguments
329
686
 
330
687
  \`\`\`javascript
331
688
  const args = "$ARGUMENTS".trim().split(/\\s+/);
332
- let workflowMode = "full";
333
- let execMode = "swarm";
689
+ let workflowMode = "full"; // full, enhance, research
690
+ let execMode = "swarm"; // swarm (default), hive, naked
334
691
  let issueNumber = null;
335
692
 
336
693
  for (let i = 0; i < args.length; i++) {
337
694
  const arg = args[i];
338
- if (arg === "-e" || arg === "--enhance") workflowMode = "enhance";
339
- else if (arg === "-r" || arg === "--research") workflowMode = "research";
340
- else if (arg === "-sw" || arg === "--swarm") execMode = "swarm";
341
- else if (arg === "-n" || arg === "--naked") execMode = "naked";
342
- else if (/^\\d+$/.test(arg)) issueNumber = arg;
695
+
696
+ // Workflow mode (what to do)
697
+ if (arg === "-e" || arg === "--enhance") {
698
+ workflowMode = "enhance";
699
+ } else if (arg === "-r" || arg === "--research") {
700
+ workflowMode = "research";
701
+ }
702
+
703
+ // Execution mode (how to do it)
704
+ else if (arg === "-sw" || arg === "--swarm") {
705
+ execMode = "swarm";
706
+ } else if (arg === "-hv" || arg === "--hive") {
707
+ execMode = "hive";
708
+ } else if (arg === "-n" || arg === "--naked") {
709
+ execMode = "naked";
710
+ }
711
+
712
+ // Issue number
713
+ else if (/^\\d+$/.test(arg)) {
714
+ issueNumber = arg;
715
+ }
343
716
  }
344
717
 
345
- if (!issueNumber) throw new Error("Issue number required. Usage: /mf <issue-number>");
718
+ if (!issueNumber) {
719
+ throw new Error("Issue number required. Usage: /flo <issue-number>");
720
+ }
721
+
722
+ // Log execution mode to prevent silent skipping
723
+ console.log("Execution mode: " + execMode.toUpperCase());
724
+ if (execMode === "swarm") {
725
+ console.log("SWARM MODE: Will spawn agents via Task tool. Do NOT skip this.");
726
+ }
727
+ console.log("TESTING: Unit + Integration + E2E tests REQUIRED before PR.");
728
+ console.log("SIMPLIFY: /simplify command runs on changed code before PR.");
346
729
  \`\`\`
347
730
 
348
- ## Execution
731
+ ## Execution Flow
732
+
733
+ ### Workflow Modes (what to do)
734
+
735
+ | Mode | Command | Steps | Stops After |
736
+ |------|---------|-------|-------------|
737
+ | **Full** (default) | \`/flo 123\` | Research -> Enhance -> Implement -> Test -> Simplify -> PR | PR created |
738
+ | **Epic** | \`/flo 42\` (epic) | For each story: Full workflow sequentially | All story PRs created |
739
+ | **Enhance** | \`/flo -e 123\` | Research -> Enhance | Issue updated |
740
+ | **Research** | \`/flo -r 123\` | Research | Findings output |
741
+
742
+ ### Execution Modes (how to do it)
743
+
744
+ | Mode | Flag | Description | When to Use |
745
+ |------|------|-------------|-------------|
746
+ | **Swarm** (DEFAULT) | \`-sw\`, \`--swarm\` | Multi-agent via Task tool | Always, unless explicitly overridden |
747
+ | **Hive-Mind** | \`-hv\`, \`--hive\` | Consensus-based coordination | Architecture decisions, tradeoffs |
748
+ | **Naked** | \`-n\`, \`--naked\` | Single Claude, no agents | User explicitly wants simple mode |
349
749
 
350
- Full mode executes without prompts:
351
- 1. Fetch issue via \`gh issue view\`
352
- 2. Search memory for relevant patterns
353
- 3. Research codebase with Explore agents
354
- 4. Enhance issue with implementation plan
355
- 5. Create branch, assign issue, implement
356
- 6. Run tests (unit + integration + E2E)
357
- 7. Run /simplify on changed code
358
- 8. Create PR, update issue, store learnings
750
+ ## Execution Mode Details
359
751
 
360
- All testing, linting, and quality gates are mandatory. PR cannot be created until all tests pass.
752
+ ### SWARM Mode (Default) - ALWAYS USE UNLESS TOLD OTHERWISE
753
+
754
+ You MUST use the Task tool to spawn agents. No exceptions.
755
+
756
+ **Swarm spawns these agents via Task tool:**
757
+ - \`researcher\` - Analyzes issue, searches memory, finds patterns
758
+ - \`coder\` - Implements changes following plan
759
+ - \`tester\` - Writes and runs tests
760
+ - \`/simplify\` - Built-in command that reviews changed code before PR
761
+ - \`reviewer\` - Reviews code before PR
762
+
763
+ **Swarm execution pattern:**
764
+ \`\`\`javascript
765
+ // 1. Create task list FIRST
766
+ TaskCreate({ subject: "Research issue #123", ... })
767
+ TaskCreate({ subject: "Implement changes", ... })
768
+ TaskCreate({ subject: "Test implementation", ... })
769
+ TaskCreate({ subject: "Run /simplify on changed files", ... })
770
+ TaskCreate({ subject: "Review and PR", ... })
771
+
772
+ // 2. Init swarm
773
+ Bash("npx flo swarm init --topology hierarchical --max-agents 8 --strategy specialized")
774
+
775
+ // 3. Spawn agents with Task tool (run_in_background: true)
776
+ Task({ prompt: "...", subagent_type: "researcher", run_in_background: true })
777
+ Task({ prompt: "...", subagent_type: "coder", run_in_background: true })
778
+
779
+ // 4. Wait for results, synthesize, continue
780
+ \`\`\`
781
+
782
+ ### HIVE-MIND Mode (-hv, --hive)
783
+
784
+ Use for consensus-based decisions:
785
+ - Architecture choices
786
+ - Approach tradeoffs
787
+ - Design decisions with multiple valid options
788
+
789
+ ### NAKED Mode (-n, --naked)
790
+
791
+ **Only when user explicitly requests.** Single Claude execution without agents.
792
+ - Still uses Task tool for tracking
793
+ - Still creates tasks for visibility
794
+ - Just doesn't spawn multiple agents
795
+
796
+ ---
797
+
798
+ **Full mode executes without prompts.** It will:
799
+ 1. Research the issue and codebase
800
+ 2. Enhance the GitHub issue with implementation plan
801
+ 3. Assign issue to self, add "in-progress" label
802
+ 4. Create branch, implement, test
803
+ 5. Run /simplify on changed code, re-test if changes made
804
+ 6. Commit, create PR, update issue status
805
+ 7. Store learnings
361
806
  `;
362
807
  fs.writeFileSync(skillFile, skillContent, 'utf-8');
363
- return { name: '.claude/skills/mf/', status: 'created', detail: '/mf skill ready' };
808
+ // Create /fl alias (same content)
809
+ if (!fs.existsSync(aliasDir)) {
810
+ fs.mkdirSync(aliasDir, { recursive: true });
811
+ }
812
+ fs.writeFileSync(aliasFile, skillContent.replace('name: flo', 'name: fl'), 'utf-8');
813
+ // Clean up old /mf skill directory if it exists
814
+ const oldSkillDir = path.join(root, '.claude', 'skills', 'mf');
815
+ if (fs.existsSync(oldSkillDir)) {
816
+ fs.rmSync(oldSkillDir, { recursive: true });
817
+ }
818
+ return { name: '.claude/skills/flo/', status: 'created', detail: '/flo skill ready (alias: /fl)' };
364
819
  }
365
820
  // ============================================================================
366
821
  // Step 4: CLAUDE.md MoFlo section
@@ -408,9 +863,9 @@ These are enforced by hooks — you cannot bypass them:
408
863
  - **TaskCreate-first**: Must call TaskCreate before spawning Agent tool
409
864
  - **Context tracking**: Session tracked as FRESH → MODERATE → DEPLETED → CRITICAL
410
865
 
411
- ### /mf Skill — Issue Execution
866
+ ### /flo Skill — Issue Execution
412
867
 
413
- Use \`/mf <issue-number>\` to execute GitHub issues through the full workflow:
868
+ Use \`/flo <issue-number>\` (or \`/fl\`) to execute GitHub issues through the full workflow:
414
869
  Research → Enhance → Implement → Test → Simplify → PR
415
870
 
416
871
  ### MCP Tools Reference