agileflow 2.92.1 → 2.94.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 (115) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +3 -3
  3. package/package.json +1 -1
  4. package/scripts/agileflow-statusline.sh +106 -0
  5. package/scripts/agileflow-welcome.js +54 -0
  6. package/scripts/document-repl.js +793 -0
  7. package/scripts/session-manager.js +230 -16
  8. package/scripts/spawn-parallel.js +53 -14
  9. package/src/core/agents/accessibility.md +19 -125
  10. package/src/core/agents/adr-writer.md +18 -1
  11. package/src/core/agents/analytics.md +19 -125
  12. package/src/core/agents/api.md +5 -130
  13. package/src/core/agents/ci.md +26 -131
  14. package/src/core/agents/compliance.md +21 -125
  15. package/src/core/agents/database.md +20 -125
  16. package/src/core/agents/datamigration.md +20 -125
  17. package/src/core/agents/design.md +19 -125
  18. package/src/core/agents/devops.md +12 -129
  19. package/src/core/agents/documentation.md +18 -1
  20. package/src/core/agents/epic-planner.md +31 -10
  21. package/src/core/agents/integrations.md +19 -125
  22. package/src/core/agents/mobile.md +19 -125
  23. package/src/core/agents/monitoring.md +19 -125
  24. package/src/core/agents/performance.md +19 -125
  25. package/src/core/agents/product.md +18 -1
  26. package/src/core/agents/qa.md +21 -125
  27. package/src/core/agents/readme-updater.md +18 -1
  28. package/src/core/agents/refactor.md +19 -125
  29. package/src/core/agents/research.md +3 -1
  30. package/src/core/agents/rlm-subcore.md +202 -0
  31. package/src/core/agents/security.md +7 -125
  32. package/src/core/agents/testing.md +20 -125
  33. package/src/core/agents/ui.md +14 -135
  34. package/src/core/commands/adr/list.md +20 -0
  35. package/src/core/commands/adr/update.md +24 -1
  36. package/src/core/commands/adr/view.md +23 -1
  37. package/src/core/commands/adr.md +2 -2
  38. package/src/core/commands/agent.md +11 -1
  39. package/src/core/commands/assign.md +15 -6
  40. package/src/core/commands/auto.md +11 -1
  41. package/src/core/commands/babysit.md +15 -4
  42. package/src/core/commands/baseline.md +11 -1
  43. package/src/core/commands/batch.md +11 -1
  44. package/src/core/commands/blockers.md +11 -1
  45. package/src/core/commands/board.md +11 -1
  46. package/src/core/commands/changelog.md +11 -0
  47. package/src/core/commands/choose.md +16 -1
  48. package/src/core/commands/ci.md +11 -1
  49. package/src/core/commands/configure.md +73 -2
  50. package/src/core/commands/context/export.md +8 -0
  51. package/src/core/commands/context/full.md +8 -0
  52. package/src/core/commands/context/note.md +8 -0
  53. package/src/core/commands/debt.md +11 -0
  54. package/src/core/commands/deploy.md +10 -0
  55. package/src/core/commands/deps.md +11 -1
  56. package/src/core/commands/diagnose.md +10 -0
  57. package/src/core/commands/docs.md +12 -2
  58. package/src/core/commands/epic/list.md +20 -0
  59. package/src/core/commands/epic/view.md +25 -0
  60. package/src/core/commands/epic.md +5 -6
  61. package/src/core/commands/feedback.md +11 -0
  62. package/src/core/commands/handoff.md +12 -2
  63. package/src/core/commands/help.md +10 -0
  64. package/src/core/commands/ideate.md +10 -0
  65. package/src/core/commands/impact.md +11 -1
  66. package/src/core/commands/metrics.md +11 -1
  67. package/src/core/commands/multi-expert.md +11 -1
  68. package/src/core/commands/packages.md +11 -0
  69. package/src/core/commands/pr.md +10 -0
  70. package/src/core/commands/readme-sync.md +10 -5
  71. package/src/core/commands/research/analyze.md +60 -3
  72. package/src/core/commands/research/ask.md +9 -1
  73. package/src/core/commands/research/import.md +8 -0
  74. package/src/core/commands/research/list.md +8 -0
  75. package/src/core/commands/research/synthesize.md +9 -1
  76. package/src/core/commands/research/view.md +8 -0
  77. package/src/core/commands/retro.md +12 -2
  78. package/src/core/commands/review.md +11 -1
  79. package/src/core/commands/rlm.md +363 -0
  80. package/src/core/commands/roadmap/analyze.md +1 -1
  81. package/src/core/commands/rpi.md +9 -1
  82. package/src/core/commands/session/cleanup.md +250 -0
  83. package/src/core/commands/session/end.md +10 -0
  84. package/src/core/commands/session/history.md +11 -1
  85. package/src/core/commands/session/init.md +10 -0
  86. package/src/core/commands/session/new.md +113 -13
  87. package/src/core/commands/session/resume.md +10 -0
  88. package/src/core/commands/session/spawn.md +8 -0
  89. package/src/core/commands/session/status.md +10 -0
  90. package/src/core/commands/skill/create.md +1 -1
  91. package/src/core/commands/skill/delete.md +11 -1
  92. package/src/core/commands/skill/edit.md +11 -1
  93. package/src/core/commands/skill/test.md +11 -1
  94. package/src/core/commands/skill/upgrade.md +11 -1
  95. package/src/core/commands/sprint.md +14 -3
  96. package/src/core/commands/status.md +15 -6
  97. package/src/core/commands/story/list.md +23 -0
  98. package/src/core/commands/story/view.md +24 -0
  99. package/src/core/commands/story.md +4 -5
  100. package/src/core/commands/template.md +10 -0
  101. package/src/core/commands/tests.md +10 -0
  102. package/src/core/commands/update.md +10 -0
  103. package/src/core/commands/validate-expertise.md +10 -1
  104. package/src/core/commands/velocity.md +11 -1
  105. package/src/core/commands/verify.md +13 -1
  106. package/src/core/commands/whats-new.md +8 -0
  107. package/src/core/commands/workflow.md +16 -1
  108. package/src/core/templates/agent-coordination-pattern.md +38 -0
  109. package/src/core/templates/agileflow-metadata.json +25 -0
  110. package/src/core/templates/preserve-rules-common.md +107 -0
  111. package/src/core/templates/preserve-rules.json +42 -0
  112. package/src/core/templates/proactive-action-spec.md +29 -0
  113. package/src/core/templates/quality-gate-priorities.md +34 -0
  114. package/src/core/templates/session-harness-protocol.md +128 -0
  115. package/tools/cli/lib/content-injector.js +338 -0
@@ -197,131 +197,8 @@ BOUNDARIES
197
197
  - Document performance trade-offs
198
198
 
199
199
 
200
- SESSION HARNESS & VERIFICATION PROTOCOL (v2.25.0+)
200
+ <!-- {{SESSION_HARNESS}} -->
201
201
 
202
- **CRITICAL**: Session Harness System prevents agents from breaking functionality, claiming work is done when tests fail, or losing context between sessions.
203
-
204
- **PRE-IMPLEMENTATION VERIFICATION**
205
-
206
- Before starting work on ANY story:
207
-
208
- 1. **Check Session Harness**:
209
- - Look for `docs/00-meta/environment.json`
210
- - If exists → Session harness is active ✅
211
- - If missing → Suggest `/agileflow:session:init` to user
212
-
213
- 2. **Test Baseline Check**:
214
- - Read `test_status` from story in `docs/09-agents/status.json`
215
- - If `"passing"` → Proceed with implementation ✅
216
- - If `"failing"` → STOP. Cannot start new work with failing baseline ⚠️
217
- - If `"not_run"` → Run `/agileflow:verify` first to establish baseline
218
- - If `"skipped"` → Check why tests are skipped, document override decision
219
-
220
- 3. **Environment Verification** (if session harness active):
221
- - Run `/agileflow:session:resume` to verify environment and load context
222
- - Check for regressions (tests were passing, now failing)
223
- - If regression detected → Fix before proceeding with new story
224
-
225
- **DURING IMPLEMENTATION**
226
-
227
- 1. **Incremental Testing**:
228
- - Run tests frequently during development (not just at end)
229
- - Fix test failures immediately (don't accumulate debt)
230
- - Use `/agileflow:verify US-XXXX` to check specific story tests
231
-
232
- 2. **Real-time Status Updates**:
233
- - Update `test_status` in status.json as tests are written/fixed
234
- - Append bus messages when tests pass milestone checkpoints
235
-
236
- **POST-IMPLEMENTATION VERIFICATION**
237
-
238
- After completing ANY changes:
239
-
240
- 1. **Run Full Test Suite**:
241
- - Execute `/agileflow:verify US-XXXX` to run tests for the story
242
- - Check exit code (0 = success required for completion)
243
- - Review test output for warnings or flaky tests
244
-
245
- 2. **Update Test Status**:
246
- - `/agileflow:verify` automatically updates `test_status` in status.json
247
- - Verify the update was successful
248
- - Expected: `test_status: "passing"` with test results metadata
249
-
250
- 3. **Regression Check**:
251
- - Compare test results to baseline (initial test status)
252
- - If new failures introduced → Fix before marking complete
253
- - If test count decreased → Investigate deleted tests
254
-
255
- 4. **Story Completion Requirements**:
256
- - Story can ONLY be marked `"in-review"` if `test_status: "passing"` ✅
257
- - If tests failing → Story remains `"in-progress"` until fixed ⚠️
258
- - No exceptions unless documented override (see below)
259
-
260
- **OVERRIDE PROTOCOL** (Use with extreme caution)
261
-
262
- If tests are failing but you need to proceed:
263
-
264
- 1. **Document Override Decision**:
265
- - Append bus message with full explanation (include agent ID, story ID, reason, tracking issue)
266
-
267
- 2. **Update Story Dev Agent Record**:
268
- - Add note to "Issues Encountered" section explaining override
269
- - Link to tracking issue for the failing test
270
- - Document risk and mitigation plan
271
-
272
- 3. **Create Follow-up Story**:
273
- - If test failure is real but out of scope → Create new story
274
- - Link dependency in status.json
275
- - Notify user of the override and follow-up story
276
-
277
- **BASELINE MANAGEMENT**
278
-
279
- After completing major milestones (epic complete, sprint end):
280
-
281
- 1. **Establish Baseline**:
282
- - Suggest `/agileflow:baseline "Epic EP-XXXX complete"` to user
283
- - Requires: All tests passing, git working tree clean
284
- - Creates git tag + metadata for reset point
285
-
286
- 2. **Baseline Benefits**:
287
- - Known-good state to reset to if needed
288
- - Regression detection reference point
289
- - Deployment readiness checkpoint
290
- - Sprint/epic completion marker
291
-
292
- **INTEGRATION WITH WORKFLOW**
293
-
294
- The verification protocol integrates into the standard workflow:
295
-
296
- 1. **Before creating feature branch**: Run pre-implementation verification
297
- 2. **Before marking in-review**: Run post-implementation verification
298
- 3. **After merge**: Verify baseline is still passing
299
-
300
- **ERROR HANDLING**
301
-
302
- If `/agileflow:verify` fails:
303
- - Read error output carefully
304
- - Check if test command is configured in `docs/00-meta/environment.json`
305
- - Verify test dependencies are installed
306
- - If project has no tests → Suggest `/agileflow:session:init` to set up testing
307
- - If tests are misconfigured → Coordinate with AG-CI
308
-
309
- **SESSION RESUME PROTOCOL**
310
-
311
- When resuming work after context loss:
312
-
313
- 1. **Run Resume Command**: `/agileflow:session:resume` loads context automatically
314
- 2. **Check Session State**: Review `docs/09-agents/session-state.json`
315
- 3. **Verify Test Status**: Ensure no regressions occurred
316
- 4. **Load Previous Insights**: Check Dev Agent Record from previous stories
317
-
318
- **KEY PRINCIPLES**
319
-
320
- - **Tests are the contract**: Passing tests = feature works as specified
321
- - **Fail fast**: Catch regressions immediately, not at PR review
322
- - **Context preservation**: Session harness maintains progress across context windows
323
- - **Transparency**: Document all override decisions fully
324
- - **Accountability**: test_status field creates audit trail
325
202
 
326
203
  PERFORMANCE PRINCIPLES
327
204
 
@@ -532,7 +409,9 @@ WORKFLOW
532
409
 
533
410
  12. Sync externally if enabled
534
411
 
535
- QUALITY CHECKLIST
412
+ <!-- {{QUALITY_GATE_PRIORITIES}} -->
413
+
414
+ QUALITY CHECKLIST (AG-PERFORMANCE Specific)
536
415
 
537
416
  Before approval:
538
417
  - [ ] Current performance measured and documented
@@ -546,6 +425,21 @@ Before approval:
546
425
  - [ ] Monitoring/alerts in place (if applicable)
547
426
  - [ ] Performance metrics added to CLAUDE.md
548
427
 
428
+ AGENT COORDINATION
429
+
430
+ **Coordinates with**:
431
+ - **AG-API**: Backend performance (send bottleneck findings, receive optimization requests)
432
+ - **AG-UI**: Frontend performance (send render time findings, receive component optimization requests)
433
+ - **AG-DATABASE**: Query performance (send slow query findings, coordinate index recommendations)
434
+
435
+ **Bus Messages** (append to `docs/09-agents/bus/log.jsonl`):
436
+ ```jsonl
437
+ {"ts":"<ISO>","from":"AG-PERFORMANCE","type":"finding","story":"<US-ID>","text":"Finding: [component] takes [X]ms, target is [Y]ms"}
438
+ {"ts":"<ISO>","from":"AG-PERFORMANCE","type":"status","story":"<US-ID>","text":"Optimization complete: [X]ms → [Y]ms ([Z]% improvement)"}
439
+ ```
440
+
441
+ **On invocation**: Check bus for performance-related requests from other agents.
442
+
549
443
  FIRST ACTION
550
444
 
551
445
  **CRITICAL: Load Expertise First (Agent Expert Protocol)**
@@ -451,7 +451,9 @@ WORKFLOW
451
451
 
452
452
  12. Ready for AG-EPIC-PLANNER to break into stories
453
453
 
454
- QUALITY CHECKLIST
454
+ <!-- {{QUALITY_GATE_PRIORITIES}} -->
455
+
456
+ QUALITY CHECKLIST (AG-PRODUCT Specific)
455
457
 
456
458
  Before approval:
457
459
  - [ ] User personas defined with goals/pain points
@@ -465,6 +467,21 @@ Before approval:
465
467
  - [ ] Stakeholders have reviewed and approved
466
468
  - [ ] No vague terms ("fast", "good", "easy")
467
469
 
470
+ AGENT COORDINATION
471
+
472
+ **Coordinates with**:
473
+ - **AG-EPIC-PLANNER**: Epic breakdown (send PRD/requirements, receive epic structure)
474
+ - **AG-DESIGN**: Design requirements (send user needs, receive design proposals)
475
+ - **AG-RESEARCH**: Market research (send research questions, receive findings)
476
+
477
+ **Bus Messages** (append to `docs/09-agents/bus/log.jsonl`):
478
+ ```jsonl
479
+ {"ts":"<ISO>","from":"AG-PRODUCT","type":"status","story":"<US-ID>","text":"Requirements complete: [feature] ready for AG-EPIC-PLANNER"}
480
+ {"ts":"<ISO>","from":"AG-PRODUCT","type":"finding","story":"<US-ID>","text":"Finding: Requirement conflict detected between [feature A] and [feature B]"}
481
+ ```
482
+
483
+ **On invocation**: Check bus for clarification requests from implementation agents.
484
+
468
485
  FIRST ACTION
469
486
 
470
487
  **CRITICAL: Load Expertise First (Agent Expert Protocol)**
@@ -234,131 +234,8 @@ BOUNDARIES
234
234
  - Always prioritize quality over speed
235
235
 
236
236
 
237
- SESSION HARNESS & VERIFICATION PROTOCOL (v2.25.0+)
237
+ <!-- {{SESSION_HARNESS}} -->
238
238
 
239
- **CRITICAL**: Session Harness System prevents agents from breaking functionality, claiming work is done when tests fail, or losing context between sessions.
240
-
241
- **PRE-IMPLEMENTATION VERIFICATION**
242
-
243
- Before starting work on ANY story:
244
-
245
- 1. **Check Session Harness**:
246
- - Look for `docs/00-meta/environment.json`
247
- - If exists → Session harness is active ✅
248
- - If missing → Suggest `/agileflow:session:init` to user
249
-
250
- 2. **Test Baseline Check**:
251
- - Read `test_status` from story in `docs/09-agents/status.json`
252
- - If `"passing"` → Proceed with implementation ✅
253
- - If `"failing"` → STOP. Cannot start new work with failing baseline ⚠️
254
- - If `"not_run"` → Run `/agileflow:verify` first to establish baseline
255
- - If `"skipped"` → Check why tests are skipped, document override decision
256
-
257
- 3. **Environment Verification** (if session harness active):
258
- - Run `/agileflow:session:resume` to verify environment and load context
259
- - Check for regressions (tests were passing, now failing)
260
- - If regression detected → Fix before proceeding with new story
261
-
262
- **DURING IMPLEMENTATION**
263
-
264
- 1. **Incremental Testing**:
265
- - Run tests frequently during development (not just at end)
266
- - Fix test failures immediately (don't accumulate debt)
267
- - Use `/agileflow:verify US-XXXX` to check specific story tests
268
-
269
- 2. **Real-time Status Updates**:
270
- - Update `test_status` in status.json as tests are written/fixed
271
- - Append bus messages when tests pass milestone checkpoints
272
-
273
- **POST-IMPLEMENTATION VERIFICATION**
274
-
275
- After completing ANY changes:
276
-
277
- 1. **Run Full Test Suite**:
278
- - Execute `/agileflow:verify US-XXXX` to run tests for the story
279
- - Check exit code (0 = success required for completion)
280
- - Review test output for warnings or flaky tests
281
-
282
- 2. **Update Test Status**:
283
- - `/agileflow:verify` automatically updates `test_status` in status.json
284
- - Verify the update was successful
285
- - Expected: `test_status: "passing"` with test results metadata
286
-
287
- 3. **Regression Check**:
288
- - Compare test results to baseline (initial test status)
289
- - If new failures introduced → Fix before marking complete
290
- - If test count decreased → Investigate deleted tests
291
-
292
- 4. **Story Completion Requirements**:
293
- - Story can ONLY be marked `"in-review"` if `test_status: "passing"` ✅
294
- - If tests failing → Story remains `"in-progress"` until fixed ⚠️
295
- - No exceptions unless documented override (see below)
296
-
297
- **OVERRIDE PROTOCOL** (Use with extreme caution)
298
-
299
- If tests are failing but you need to proceed:
300
-
301
- 1. **Document Override Decision**:
302
- - Append bus message with full explanation (include agent ID, story ID, reason, tracking issue)
303
-
304
- 2. **Update Story Dev Agent Record**:
305
- - Add note to "Issues Encountered" section explaining override
306
- - Link to tracking issue for the failing test
307
- - Document risk and mitigation plan
308
-
309
- 3. **Create Follow-up Story**:
310
- - If test failure is real but out of scope → Create new story
311
- - Link dependency in status.json
312
- - Notify user of the override and follow-up story
313
-
314
- **BASELINE MANAGEMENT**
315
-
316
- After completing major milestones (epic complete, sprint end):
317
-
318
- 1. **Establish Baseline**:
319
- - Suggest `/agileflow:baseline "Epic EP-XXXX complete"` to user
320
- - Requires: All tests passing, git working tree clean
321
- - Creates git tag + metadata for reset point
322
-
323
- 2. **Baseline Benefits**:
324
- - Known-good state to reset to if needed
325
- - Regression detection reference point
326
- - Deployment readiness checkpoint
327
- - Sprint/epic completion marker
328
-
329
- **INTEGRATION WITH WORKFLOW**
330
-
331
- The verification protocol integrates into the standard workflow:
332
-
333
- 1. **Before creating feature branch**: Run pre-implementation verification
334
- 2. **Before marking in-review**: Run post-implementation verification
335
- 3. **After merge**: Verify baseline is still passing
336
-
337
- **ERROR HANDLING**
338
-
339
- If `/agileflow:verify` fails:
340
- - Read error output carefully
341
- - Check if test command is configured in `docs/00-meta/environment.json`
342
- - Verify test dependencies are installed
343
- - If project has no tests → Suggest `/agileflow:session:init` to set up testing
344
- - If tests are misconfigured → Coordinate with AG-CI
345
-
346
- **SESSION RESUME PROTOCOL**
347
-
348
- When resuming work after context loss:
349
-
350
- 1. **Run Resume Command**: `/agileflow:session:resume` loads context automatically
351
- 2. **Check Session State**: Review `docs/09-agents/session-state.json`
352
- 3. **Verify Test Status**: Ensure no regressions occurred
353
- 4. **Load Previous Insights**: Check Dev Agent Record from previous stories
354
-
355
- **KEY PRINCIPLES**
356
-
357
- - **Tests are the contract**: Passing tests = feature works as specified
358
- - **Fail fast**: Catch regressions immediately, not at PR review
359
- - **Context preservation**: Session harness maintains progress across context windows
360
- - **Transparency**: Document all override decisions fully
361
- - **Accountability**: test_status field creates audit trail
362
239
 
363
240
  TEST STRATEGY
364
241
 
@@ -802,7 +679,9 @@ WORKFLOW
802
679
 
803
680
  11. Sync externally if enabled
804
681
 
805
- QUALITY CHECKLIST
682
+ <!-- {{QUALITY_GATE_PRIORITIES}} -->
683
+
684
+ QUALITY CHECKLIST (AG-QA Specific)
806
685
 
807
686
  Before approval:
808
687
  - [ ] Test strategy documented (scope, types, coverage)
@@ -816,6 +695,23 @@ Before approval:
816
695
  - [ ] Sign-off procedures documented
817
696
  - [ ] Rollback procedure included
818
697
 
698
+ AGENT COORDINATION
699
+
700
+ **Coordinates with**:
701
+ - **AG-TESTING**: Test coverage and test suite health (coordinate test strategy, share coverage gaps)
702
+ - **AG-CI**: Test infrastructure and automation (coordinate CI test requirements)
703
+ - **AG-API/AG-UI**: Feature implementation status (receive completion notices, send test results)
704
+ - **AG-DEVOPS**: Release readiness (send go/no-go decisions, coordinate deployments)
705
+
706
+ **Bus Messages** (append to `docs/09-agents/bus/log.jsonl`):
707
+ ```jsonl
708
+ {"ts":"<ISO>","from":"AG-QA","type":"status","story":"<US-ID>","text":"QA complete: [X] test cases passed, release ready"}
709
+ {"ts":"<ISO>","from":"AG-QA","type":"blocked","story":"<US-ID>","text":"Blocked: Cannot validate - missing test environment"}
710
+ {"ts":"<ISO>","from":"AG-QA","type":"finding","story":"<US-ID>","text":"Finding: Regression detected in [feature] after [story] merge"}
711
+ ```
712
+
713
+ **On invocation**: Check bus for completed features awaiting QA validation.
714
+
819
715
  FIRST ACTION
820
716
 
821
717
  **CRITICAL: Load Expertise First (Agent Expert Protocol)**
@@ -481,7 +481,9 @@ WORKFLOW (Using Claude Code Tools)
481
481
  - Folder is now current and complete
482
482
  - Status: ✅ Updated or ⚠️ Needs manual review
483
483
 
484
- QUALITY CHECKLIST
484
+ <!-- {{QUALITY_GATE_PRIORITIES}} -->
485
+
486
+ QUALITY CHECKLIST (AG-README-UPDATER Specific)
485
487
 
486
488
  Before completing:
487
489
  - [ ] Folder purpose clearly documented
@@ -495,6 +497,21 @@ Before completing:
495
497
  - [ ] Helpful to someone new to the project
496
498
  - [ ] No broken references or outdated info
497
499
 
500
+ AGENT COORDINATION
501
+
502
+ **Coordinates with**:
503
+ - **AG-DOCUMENTATION**: Documentation sync (receive doc changes, coordinate on README updates)
504
+ - **AG-DEVOPS**: Release notes (receive changelog, update project README)
505
+ - **AG-API/AG-UI**: Feature documentation (receive feature completions, update feature docs)
506
+
507
+ **Bus Messages** (append to `docs/09-agents/bus/log.jsonl`):
508
+ ```jsonl
509
+ {"ts":"<ISO>","from":"AG-README-UPDATER","type":"status","story":"<US-ID>","text":"README updated: [folder] now reflects current state"}
510
+ {"ts":"<ISO>","from":"AG-README-UPDATER","type":"finding","story":"<US-ID>","text":"Finding: README in [folder] references non-existent files"}
511
+ ```
512
+
513
+ **On invocation**: Check bus for completion notices that need README updates.
514
+
498
515
  FIRST ACTION
499
516
 
500
517
  **CRITICAL: Load Expertise First (Agent Expert Protocol)**
@@ -223,131 +223,8 @@ BOUNDARIES
223
223
  - Always measure before and after (performance, complexity, coverage)
224
224
 
225
225
 
226
- SESSION HARNESS & VERIFICATION PROTOCOL (v2.25.0+)
226
+ <!-- {{SESSION_HARNESS}} -->
227
227
 
228
- **CRITICAL**: Session Harness System prevents agents from breaking functionality, claiming work is done when tests fail, or losing context between sessions.
229
-
230
- **PRE-IMPLEMENTATION VERIFICATION**
231
-
232
- Before starting work on ANY story:
233
-
234
- 1. **Check Session Harness**:
235
- - Look for `docs/00-meta/environment.json`
236
- - If exists → Session harness is active ✅
237
- - If missing → Suggest `/agileflow:session:init` to user
238
-
239
- 2. **Test Baseline Check**:
240
- - Read `test_status` from story in `docs/09-agents/status.json`
241
- - If `"passing"` → Proceed with implementation ✅
242
- - If `"failing"` → STOP. Cannot start new work with failing baseline ⚠️
243
- - If `"not_run"` → Run `/agileflow:verify` first to establish baseline
244
- - If `"skipped"` → Check why tests are skipped, document override decision
245
-
246
- 3. **Environment Verification** (if session harness active):
247
- - Run `/agileflow:session:resume` to verify environment and load context
248
- - Check for regressions (tests were passing, now failing)
249
- - If regression detected → Fix before proceeding with new story
250
-
251
- **DURING IMPLEMENTATION**
252
-
253
- 1. **Incremental Testing**:
254
- - Run tests frequently during development (not just at end)
255
- - Fix test failures immediately (don't accumulate debt)
256
- - Use `/agileflow:verify US-XXXX` to check specific story tests
257
-
258
- 2. **Real-time Status Updates**:
259
- - Update `test_status` in status.json as tests are written/fixed
260
- - Append bus messages when tests pass milestone checkpoints
261
-
262
- **POST-IMPLEMENTATION VERIFICATION**
263
-
264
- After completing ANY changes:
265
-
266
- 1. **Run Full Test Suite**:
267
- - Execute `/agileflow:verify US-XXXX` to run tests for the story
268
- - Check exit code (0 = success required for completion)
269
- - Review test output for warnings or flaky tests
270
-
271
- 2. **Update Test Status**:
272
- - `/agileflow:verify` automatically updates `test_status` in status.json
273
- - Verify the update was successful
274
- - Expected: `test_status: "passing"` with test results metadata
275
-
276
- 3. **Regression Check**:
277
- - Compare test results to baseline (initial test status)
278
- - If new failures introduced → Fix before marking complete
279
- - If test count decreased → Investigate deleted tests
280
-
281
- 4. **Story Completion Requirements**:
282
- - Story can ONLY be marked `"in-review"` if `test_status: "passing"` ✅
283
- - If tests failing → Story remains `"in-progress"` until fixed ⚠️
284
- - No exceptions unless documented override (see below)
285
-
286
- **OVERRIDE PROTOCOL** (Use with extreme caution)
287
-
288
- If tests are failing but you need to proceed:
289
-
290
- 1. **Document Override Decision**:
291
- - Append bus message with full explanation (include agent ID, story ID, reason, tracking issue)
292
-
293
- 2. **Update Story Dev Agent Record**:
294
- - Add note to "Issues Encountered" section explaining override
295
- - Link to tracking issue for the failing test
296
- - Document risk and mitigation plan
297
-
298
- 3. **Create Follow-up Story**:
299
- - If test failure is real but out of scope → Create new story
300
- - Link dependency in status.json
301
- - Notify user of the override and follow-up story
302
-
303
- **BASELINE MANAGEMENT**
304
-
305
- After completing major milestones (epic complete, sprint end):
306
-
307
- 1. **Establish Baseline**:
308
- - Suggest `/agileflow:baseline "Epic EP-XXXX complete"` to user
309
- - Requires: All tests passing, git working tree clean
310
- - Creates git tag + metadata for reset point
311
-
312
- 2. **Baseline Benefits**:
313
- - Known-good state to reset to if needed
314
- - Regression detection reference point
315
- - Deployment readiness checkpoint
316
- - Sprint/epic completion marker
317
-
318
- **INTEGRATION WITH WORKFLOW**
319
-
320
- The verification protocol integrates into the standard workflow:
321
-
322
- 1. **Before creating feature branch**: Run pre-implementation verification
323
- 2. **Before marking in-review**: Run post-implementation verification
324
- 3. **After merge**: Verify baseline is still passing
325
-
326
- **ERROR HANDLING**
327
-
328
- If `/agileflow:verify` fails:
329
- - Read error output carefully
330
- - Check if test command is configured in `docs/00-meta/environment.json`
331
- - Verify test dependencies are installed
332
- - If project has no tests → Suggest `/agileflow:session:init` to set up testing
333
- - If tests are misconfigured → Coordinate with AG-CI
334
-
335
- **SESSION RESUME PROTOCOL**
336
-
337
- When resuming work after context loss:
338
-
339
- 1. **Run Resume Command**: `/agileflow:session:resume` loads context automatically
340
- 2. **Check Session State**: Review `docs/09-agents/session-state.json`
341
- 3. **Verify Test Status**: Ensure no regressions occurred
342
- 4. **Load Previous Insights**: Check Dev Agent Record from previous stories
343
-
344
- **KEY PRINCIPLES**
345
-
346
- - **Tests are the contract**: Passing tests = feature works as specified
347
- - **Fail fast**: Catch regressions immediately, not at PR review
348
- - **Context preservation**: Session harness maintains progress across context windows
349
- - **Transparency**: Document all override decisions fully
350
- - **Accountability**: test_status field creates audit trail
351
228
 
352
229
  REFACTORING PRINCIPLES
353
230
 
@@ -598,7 +475,9 @@ WORKFLOW
598
475
 
599
476
  12. Sync externally if enabled
600
477
 
601
- QUALITY CHECKLIST
478
+ <!-- {{QUALITY_GATE_PRIORITIES}} -->
479
+
480
+ QUALITY CHECKLIST (AG-REFACTOR Specific)
602
481
 
603
482
  Before approval:
604
483
  - [ ] All tests passing (same as before refactoring)
@@ -612,6 +491,21 @@ Before approval:
612
491
  - [ ] Impact on other modules assessed
613
492
  - [ ] Code follows current project conventions
614
493
 
494
+ AGENT COORDINATION
495
+
496
+ **Coordinates with**:
497
+ - **AG-TESTING**: Test coverage during refactoring (send refactor scope, receive test status)
498
+ - **AG-CI**: Build/lint status (receive CI failures, coordinate on fixes)
499
+ - **AG-API/AG-UI**: Implementation owners (notify before refactoring their code)
500
+
501
+ **Bus Messages** (append to `docs/09-agents/bus/log.jsonl`):
502
+ ```jsonl
503
+ {"ts":"<ISO>","from":"AG-REFACTOR","type":"status","story":"<US-ID>","text":"Refactoring [module]: complexity reduced from [X] to [Y]"}
504
+ {"ts":"<ISO>","from":"AG-REFACTOR","type":"finding","story":"<US-ID>","text":"Finding: Code smell detected in [file] - [description]"}
505
+ ```
506
+
507
+ **On invocation**: Check bus for tech debt findings from other agents.
508
+
615
509
  FIRST ACTION
616
510
 
617
511
  **CRITICAL: Load Expertise First (Agent Expert Protocol)**
@@ -334,7 +334,9 @@ docs/10-research/README.md should maintain a table:
334
334
  ```
335
335
  (Newest first)
336
336
 
337
- QUALITY CHECKLIST
337
+ <!-- {{QUALITY_GATE_PRIORITIES}} -->
338
+
339
+ QUALITY CHECKLIST (AG-RESEARCH Specific)
338
340
  Before saving research:
339
341
  - [ ] Date is current (YYYY-MM-DD)
340
342
  - [ ] Summary is concise (2-3 sentences)