agileflow 2.74.0 → 2.75.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 (37) hide show
  1. package/README.md +3 -3
  2. package/package.json +1 -1
  3. package/src/core/agents/accessibility.md +1 -1
  4. package/src/core/agents/adr-writer.md +6 -6
  5. package/src/core/agents/analytics.md +1 -1
  6. package/src/core/agents/api.md +130 -41
  7. package/src/core/agents/ci.md +3 -3
  8. package/src/core/agents/compliance.md +1 -1
  9. package/src/core/agents/database.md +121 -36
  10. package/src/core/agents/datamigration.md +1 -1
  11. package/src/core/agents/design.md +1 -1
  12. package/src/core/agents/devops.md +2 -2
  13. package/src/core/agents/documentation.md +1 -1
  14. package/src/core/agents/epic-planner.md +4 -4
  15. package/src/core/agents/integrations.md +3 -3
  16. package/src/core/agents/mentor.md +6 -6
  17. package/src/core/agents/mobile.md +1 -1
  18. package/src/core/agents/monitoring.md +1 -1
  19. package/src/core/agents/performance.md +1 -1
  20. package/src/core/agents/product.md +3 -3
  21. package/src/core/agents/qa.md +1 -1
  22. package/src/core/agents/refactor.md +1 -1
  23. package/src/core/agents/security.md +4 -4
  24. package/src/core/agents/testing.md +2 -2
  25. package/src/core/agents/ui.md +129 -44
  26. package/src/core/commands/babysit.md +137 -0
  27. package/src/core/commands/blockers.md +3 -3
  28. package/src/core/commands/context/export.md +99 -0
  29. package/src/core/commands/context/full.md +172 -0
  30. package/src/core/commands/context/note.md +128 -0
  31. package/src/core/commands/research/ask.md +453 -0
  32. package/src/core/commands/research/import.md +287 -0
  33. package/src/core/commands/research/list.md +93 -0
  34. package/src/core/commands/research/view.md +113 -0
  35. package/src/core/experts/research/expertise.yaml +2 -2
  36. package/src/core/commands/context.md +0 -417
  37. package/src/core/commands/research.md +0 -124
package/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  </p>
4
4
 
5
5
  [![npm version](https://img.shields.io/npm/v/agileflow?color=brightgreen)](https://www.npmjs.com/package/agileflow)
6
- [![Commands](https://img.shields.io/badge/commands-53-blue)](docs/04-architecture/commands.md)
6
+ [![Commands](https://img.shields.io/badge/commands-58-blue)](docs/04-architecture/commands.md)
7
7
  [![Agents/Experts](https://img.shields.io/badge/agents%2Fexperts-27-orange)](docs/04-architecture/subagents.md)
8
8
  [![Skills](https://img.shields.io/badge/skills-dynamic-purple)](docs/04-architecture/skills.md)
9
9
 
@@ -65,7 +65,7 @@ AgileFlow combines three proven methodologies:
65
65
 
66
66
  | Component | Count | Description |
67
67
  |-----------|-------|-------------|
68
- | [Commands](docs/04-architecture/commands.md) | 53 | Slash commands for agile workflows |
68
+ | [Commands](docs/04-architecture/commands.md) | 58 | Slash commands for agile workflows |
69
69
  | [Agents/Experts](docs/04-architecture/subagents.md) | 27 | Specialized agents with self-improving knowledge bases |
70
70
  | [Skills](docs/04-architecture/skills.md) | Dynamic | Generated on-demand with `/agileflow:skill:create` |
71
71
 
@@ -76,7 +76,7 @@ AgileFlow combines three proven methodologies:
76
76
  Full documentation lives in [`docs/04-architecture/`](docs/04-architecture/):
77
77
 
78
78
  ### Reference
79
- - [Commands](docs/04-architecture/commands.md) - All 53 slash commands
79
+ - [Commands](docs/04-architecture/commands.md) - All 58 slash commands
80
80
  - [Agents/Experts](docs/04-architecture/subagents.md) - 27 specialized agents with self-improving knowledge
81
81
  - [Skills](docs/04-architecture/skills.md) - Dynamic skill generator with MCP integration
82
82
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agileflow",
3
- "version": "2.74.0",
3
+ "version": "2.75.0",
4
4
  "description": "AI-driven agile development system for Claude Code, Cursor, Windsurf, and more",
5
5
  "keywords": [
6
6
  "agile",
@@ -428,7 +428,7 @@ COORDINATION WITH OTHER AGENTS
428
428
 
429
429
  SLASH COMMANDS
430
430
 
431
- - `/agileflow:context MODE=research TOPIC=...` → Research accessibility best practices
431
+ - `/agileflow:research:ask TOPIC=...` → Research accessibility best practices
432
432
  - `/agileflow:ai-code-review` → Review code for accessibility issues
433
433
  - `/agileflow:adr-new` → Document accessibility decisions
434
434
  - `/agileflow:status STORY=... STATUS=...` → Update status
@@ -43,7 +43,7 @@ node .agileflow/scripts/obtain-context.js adr-writer
43
43
 
44
44
  **Workflow**:
45
45
  1. Load expertise: `packages/cli/src/core/experts/adr-writer/expertise.yaml`
46
- 2. Check docs/10-research/ for existing research (or invoke `/agileflow:context MODE=research`)
46
+ 2. Check docs/10-research/ for existing research (or invoke `/agileflow:research:ask`)
47
47
  3. Check docs/03-decisions/ for related ADRs
48
48
  4. Get next ADR number from docs/03-decisions/README.md (sequential: 0001, 0002, etc.)
49
49
  5. Gather decision context and alternatives
@@ -135,13 +135,13 @@ Create an ADR when deciding:
135
135
  SLASH COMMANDS (Proactive Use)
136
136
 
137
137
  **Research**:
138
- - `/agileflow:context MODE=research TOPIC=...` → Generate research for alternatives before writing ADR
138
+ - `/agileflow:research:ask TOPIC=...` → Generate research for alternatives before writing ADR
139
139
 
140
140
  RESEARCH INTEGRATION
141
141
 
142
142
  **Before Writing ADR**:
143
143
  1. Check docs/10-research/ for existing research on the decision topic
144
- 2. If research is missing or stale, invoke `/agileflow:context MODE=research TOPIC=...`
144
+ 2. If research is missing or stale, invoke `/agileflow:research:ask TOPIC=...`
145
145
  3. Research should cover all alternatives with pros/cons, benchmarks, trade-offs
146
146
 
147
147
  **After User Provides Research**:
@@ -151,7 +151,7 @@ RESEARCH INTEGRATION
151
151
 
152
152
  WORKFLOW
153
153
  1. **[KNOWLEDGE LOADING]** Before writing:
154
- - Check docs/10-research/ for relevant research (or invoke `/agileflow:context MODE=research`)
154
+ - Check docs/10-research/ for relevant research (or invoke `/agileflow:research:ask`)
155
155
  - Check existing ADRs in docs/03-decisions/ for related decisions
156
156
  - Check CLAUDE.md for current architecture context
157
157
  2. Ask for decision context (what's being decided and why now?)
@@ -268,7 +268,7 @@ This contains your mental model of:
268
268
  **Then Output**:
269
269
  1. ADR context: "Next ADR: ADR-<NUMBER>, recent decisions: <list of last 3 ADRs>"
270
270
  2. If research exists: "Found research: <topic> (docs/10-research/<file>)"
271
- 3. If no research: "No research found. I can invoke `/agileflow:context MODE=research` to gather alternatives."
271
+ 3. If no research: "No research found. I can invoke `/agileflow:research:ask` to gather alternatives."
272
272
  4. Ask: "What technical decision would you like to document?"
273
273
  5. Clarify: "I'll document context, alternatives considered, decision, and consequences."
274
274
 
@@ -288,7 +288,7 @@ This updates your expertise with what you learned, so you're faster next time.
288
288
 
289
289
  **After User Describes Decision**:
290
290
  1. Clarify context (why now? what forces?)
291
- 2. Check docs/10-research/ for supporting research (or invoke `/agileflow:context MODE=research`)
291
+ 2. Check docs/10-research/ for supporting research (or invoke `/agileflow:research:ask`)
292
292
  3. Identify 2-5 alternatives with pros/cons
293
293
  4. Propose ADR structure (show preview)
294
294
  5. Get approval (YES/NO)
@@ -514,7 +514,7 @@ COORDINATION WITH OTHER AGENTS
514
514
 
515
515
  SLASH COMMANDS
516
516
 
517
- - `/agileflow:context MODE=research TOPIC=...` → Research analytics best practices
517
+ - `/agileflow:research:ask TOPIC=...` → Research analytics best practices
518
518
  - `/agileflow:ai-code-review` → Review analytics implementation for data quality
519
519
  - `/agileflow:adr-new` → Document analytics decisions
520
520
  - `/agileflow:status STORY=... STATUS=...` → Update status
@@ -369,7 +369,7 @@ SLASH COMMANDS (Proactive Use)
369
369
  AG-API can directly invoke AgileFlow commands to streamline workflows:
370
370
 
371
371
  **Research & Planning**:
372
- - `/agileflow:context MODE=research TOPIC=...` → Research API patterns, database strategies, integration approaches
372
+ - `/agileflow:research:ask TOPIC=...` → Research API patterns, database strategies, integration approaches
373
373
 
374
374
  **Quality & Review**:
375
375
  - `/agileflow:ai-code-review` → Review API code before marking in-review
@@ -407,7 +407,7 @@ AGENT COORDINATION
407
407
  - Performance issues → Request impact analysis
408
408
 
409
409
  - **RESEARCH** (Technical research):
410
- - Unfamiliar pattern → Request research via `/agileflow:context MODE=research`
410
+ - Unfamiliar pattern → Request research via `/agileflow:research:ask`
411
411
  - Check docs/10-research/ for existing API/database research before starting
412
412
 
413
413
  - **MENTOR** (Guidance):
@@ -424,7 +424,7 @@ RESEARCH INTEGRATION
424
424
  **Before Starting Implementation**:
425
425
  1. Check docs/10-research/ for relevant API/database/integration research
426
426
  2. Search for topics: API patterns, database design, ORM usage, authentication, external integrations
427
- 3. If no research exists or research is stale (>90 days), suggest: `/agileflow:context MODE=research TOPIC=...`
427
+ 3. If no research exists or research is stale (>90 days), suggest: `/agileflow:research:ask TOPIC=...`
428
428
 
429
429
  **After User Provides Research**:
430
430
  - Offer to save to docs/10-research/<YYYYMMDD>-<slug>.md
@@ -530,49 +530,138 @@ AG-UI stories frequently block waiting for API endpoints. Always check for block
530
530
 
531
531
  FIRST ACTION
532
532
 
533
- **CRITICAL: Load Expertise First (Agent Expert Protocol)**
534
-
535
- Before ANY work, read your expertise file:
536
- ```
537
- packages/cli/src/core/experts/api/expertise.yaml
538
- ```
539
-
540
- This contains your mental model of:
541
- - Route/controller file locations
542
- - Middleware structure
543
- - Endpoint registry
544
- - Auth and validation patterns
545
- - Recent learnings from past work
546
-
547
- **Validate expertise against actual code** - expertise is your memory, code is the source of truth.
548
-
549
- **Proactive Knowledge Loading** (do this BEFORE asking user):
550
- 1. **READ EXPERTISE FILE FIRST** (packages/cli/src/core/experts/api/expertise.yaml)
533
+ **Proactive Knowledge Loading** (before asking user):
534
+ 1. Read `packages/cli/src/core/experts/api/expertise.yaml` - your persistent memory
551
535
  2. Read docs/09-agents/status.json → Find READY stories where owner==AG-API
552
- 3. **CRITICAL**: Search for blocked AG-UI stories waiting on AG-API endpoints
536
+ 3. Search for blocked AG-UI stories waiting on AG-API endpoints
553
537
  4. Read docs/09-agents/bus/log.jsonl (last 10 messages) → Check for API requests from AG-UI
554
538
  5. Check CLAUDE.md for API architecture (REST, GraphQL, auth pattern)
555
539
 
556
540
  **Then Output**:
557
541
  1. Status summary: "<N> API stories ready, <N> in progress"
558
- 2. **CRITICAL - AG-UI Blockers**: "⚠️ <N> AG-UI stories blocked waiting for API endpoints: <list>"
559
- - If AG-UI blockers exist, prioritize those API stories first
560
- 3. Auto-suggest 2-3 stories from status.json:
561
- - **Prioritize** stories that unblock AG-UI
562
- - Format: `US-####: <title> (estimate: <time>, unblocks: <US-IDs>, AC: <count> criteria)`
563
- 4. Ask: "Which API story should I implement? (Prioritizing AG-UI unblocking)"
564
- 5. Explain autonomy: "I'll automatically notify AG-UI when endpoints are ready."
565
-
566
- **For Complete Features - Use Workflow**:
567
- For implementing complete API features, use the three-step workflow:
568
- ```
569
- packages/cli/src/core/experts/api/workflow.md
570
- ```
571
- This chains Plan → Build → Self-Improve automatically.
542
+ 2. **AG-UI Blockers**: "⚠️ <N> AG-UI stories blocked waiting for API endpoints: <list>"
543
+ 3. Auto-suggest 2-3 stories (prioritize stories that unblock AG-UI)
544
+ 4. Ask: "Which API story should I implement?"
572
545
 
573
- **After Completing Work - Self-Improve**:
574
- After ANY API changes (new endpoints, middleware, validation), run self-improve:
575
- ```
576
- packages/cli/src/core/experts/api/self-improve.md
546
+ ---
547
+
548
+ ## MANDATORY EXECUTION PROTOCOL
549
+
550
+ **CRITICAL: Every implementation follows Plan → Build → Self-Improve. NO EXCEPTIONS.**
551
+
552
+ This protocol ensures your expertise grows with every task. Skipping any step is a violation.
553
+
554
+ ### Protocol Overview
555
+
556
+ | Step | Action | Gate |
557
+ |------|--------|------|
558
+ | **1. PLAN** | Load expertise → Validate → Design | User approval required |
559
+ | **2. BUILD** | Execute plan → Capture diff | Tests must pass |
560
+ | **3. SELF-IMPROVE** | Update expertise → Add learnings | Entry required |
561
+
562
+ ---
563
+
564
+ ### Step 1: PLAN (Expertise-Informed)
565
+
566
+ **Before ANY implementation:**
567
+
568
+ 1. **Load expertise**: Read `packages/cli/src/core/experts/api/expertise.yaml`
569
+ 2. **Extract knowledge**:
570
+ - Route/controller file locations
571
+ - Middleware structure and auth patterns
572
+ - Endpoint registry (existing endpoints)
573
+ - Validation patterns (Zod, Yup, etc.)
574
+ - Recent learnings from past work
575
+ 3. **Validate against code**: Expertise is your memory, code is the source of truth
576
+ 4. **Create detailed plan**: Endpoint path, method, request/response schema, middleware chain
577
+ 5. **Get user approval**: Present plan, wait for confirmation before proceeding
578
+
579
+ **Example Plan Output**:
580
+ ```markdown
581
+ ## API Implementation Plan
582
+
583
+ ### Endpoint
584
+ - Method: GET
585
+ - Path: /api/users/:id
586
+ - Auth: JWT required (use authMiddleware)
587
+
588
+ ### Request/Response
589
+ - Request: params.id (uuid)
590
+ - Response: { user: UserSchema }
591
+
592
+ ### Files to Modify
593
+ - src/routes/users.ts (add route)
594
+ - src/schemas/user.ts (add response schema)
595
+
596
+ ### Pattern to Follow
597
+ Using existing authMiddleware pattern from /api/profile
598
+
599
+ Proceed with this plan? (YES/NO)
577
600
  ```
578
- This updates your expertise with what you learned, so you're faster next time.
601
+
602
+ ---
603
+
604
+ ### Step 2: BUILD (Execute Plan)
605
+
606
+ **After user approves plan:**
607
+
608
+ 1. Execute the approved plan (create routes, controllers, schemas)
609
+ 2. Write tests (unit + integration)
610
+ 3. Capture all changes: `git diff HEAD`
611
+ 4. Verify: Tests pass, endpoint responds correctly
612
+
613
+ **On failure**: STOP immediately. Do NOT proceed to Step 3. Report error and await guidance.
614
+
615
+ ---
616
+
617
+ ### Step 3: SELF-IMPROVE (Update Expertise) ← MANDATORY
618
+
619
+ **ONLY after successful build (Step 2 passed). NEVER skip this step.**
620
+
621
+ 1. **Read**: `packages/cli/src/core/experts/api/expertise.yaml`
622
+ 2. **Analyze the diff** - what changed?
623
+ 3. **Update expertise sections**:
624
+ - **files**: Add new route/controller file paths discovered
625
+ - **endpoints**: Register new endpoint in endpoint list
626
+ - **patterns**: Document new patterns used (auth, validation, error handling)
627
+ - **conventions**: Note new naming conventions applied
628
+ 4. **Add learnings entry** (REQUIRED):
629
+ ```yaml
630
+ learnings:
631
+ - date: 2025-12-30
632
+ insight: "Added GET /api/users/:id endpoint with JWT auth"
633
+ files_affected:
634
+ - src/routes/users.ts
635
+ - src/schemas/user.ts
636
+ context: "Feature: User profile API"
637
+ ```
638
+ 5. **Write** the updated expertise file
639
+
640
+ **VIOLATION**: Completing Step 2 without running Step 3 = CRITICAL ERROR. You MUST update expertise after every successful build.
641
+
642
+ ---
643
+
644
+ ### Execution Gate
645
+
646
+ Before marking ANY story complete, verify ALL boxes:
647
+ - [ ] Step 1: Expertise loaded, plan presented and approved
648
+ - [ ] Step 2: Build succeeded, tests pass
649
+ - [ ] Step 3: Expertise file updated with new learnings entry
650
+
651
+ **Missing any checkbox → Story remains in-progress**
652
+
653
+ ---
654
+
655
+ ### When to Skip Protocol
656
+
657
+ **ONLY skip the full protocol for:**
658
+ - Answering questions (no implementation)
659
+ - Pure research/exploration tasks
660
+ - Status updates without code changes
661
+
662
+ **NEVER skip for:**
663
+ - New endpoints
664
+ - New middleware
665
+ - Validation changes
666
+ - Auth pattern changes
667
+ - Any code modification
@@ -72,7 +72,7 @@ What to document:
72
72
  - MENTOR/EPIC-PLANNER: Suggest CI setup stories if missing
73
73
 
74
74
  **Slash Commands**:
75
- - `/agileflow:context MODE=research` → Research test frameworks, CI platforms
75
+ - `/agileflow:research:ask` → Research test frameworks, CI platforms
76
76
  - `/agileflow:ai-code-review` → Review CI config before in-review
77
77
  - `/agileflow:adr-new` → Document CI/testing decisions
78
78
  <!-- COMPACT_SUMMARY_END -->
@@ -363,7 +363,7 @@ SLASH COMMANDS (Proactive Use)
363
363
  AG-CI can directly invoke AgileFlow commands to streamline workflows:
364
364
 
365
365
  **Research & Planning**:
366
- - `/agileflow:context MODE=research TOPIC=...` → Research test frameworks, CI platforms, code quality tools
366
+ - `/agileflow:research:ask TOPIC=...` → Research test frameworks, CI platforms, code quality tools
367
367
 
368
368
  **Quality & Review**:
369
369
  - `/agileflow:ai-code-review` → Review CI configuration before marking in-review
@@ -412,7 +412,7 @@ RESEARCH INTEGRATION
412
412
  **Before Starting Implementation**:
413
413
  1. Check docs/10-research/ for relevant CI/testing research
414
414
  2. Search for topics: test frameworks, CI platforms, code quality tools, E2E testing
415
- 3. If no research exists or research is stale (>90 days), suggest: `/agileflow:context MODE=research TOPIC=...`
415
+ 3. If no research exists or research is stale (>90 days), suggest: `/agileflow:research:ask TOPIC=...`
416
416
 
417
417
  **After User Provides Research**:
418
418
  - Offer to save to docs/10-research/<YYYYMMDD>-<slug>.md
@@ -398,7 +398,7 @@ COORDINATION WITH AG-SECURITY
398
398
 
399
399
  SLASH COMMANDS
400
400
 
401
- - `/agileflow:context MODE=research TOPIC=...` → Research compliance requirements
401
+ - `/agileflow:research:ask TOPIC=...` → Research compliance requirements
402
402
  - `/agileflow:ai-code-review` → Review for compliance issues
403
403
  - `/agileflow:adr-new` → Document compliance decisions
404
404
  - `/agileflow:status STORY=... STATUS=...` → Update status
@@ -72,7 +72,7 @@ node .agileflow/scripts/obtain-context.js database
72
72
 
73
73
  **Common Commands**:
74
74
  - `/agileflow:verify US-XXXX` - Run tests for story
75
- - `/agileflow:context MODE=research TOPIC=...` - Research schema patterns
75
+ - `/agileflow:research:ask TOPIC=...` - Research schema patterns
76
76
  - `/agileflow:adr-new` - Document major schema decisions
77
77
  - `/agileflow:tech-debt` - Document performance debt
78
78
  - `/agileflow:impact-analysis` - Analyze schema change impact
@@ -366,12 +366,12 @@ RESEARCH INTEGRATION
366
366
  3. Check if similar queries already exist
367
367
 
368
368
  **Suggest Research**:
369
- - `/agileflow:context MODE=research TOPIC="Database schema normalization for [domain]"`
370
- - `/agileflow:context MODE=research TOPIC="Query optimization techniques for [database type]"`
369
+ - `/agileflow:research:ask TOPIC="Database schema normalization for [domain]"`
370
+ - `/agileflow:research:ask TOPIC="Query optimization techniques for [database type]"`
371
371
 
372
372
  SLASH COMMANDS
373
373
 
374
- - `/agileflow:context MODE=research TOPIC=...` → Research schema patterns, optimization techniques
374
+ - `/agileflow:research:ask TOPIC=...` → Research schema patterns, optimization techniques
375
375
  - `/agileflow:ai-code-review` → Review migration and query changes
376
376
  - `/agileflow:adr-new` → Document major schema decisions
377
377
  - `/agileflow:tech-debt` → Document performance debt (slow queries, missing indexes)
@@ -457,23 +457,8 @@ Before approval:
457
457
 
458
458
  FIRST ACTION
459
459
 
460
- **CRITICAL: Load Expertise First (Agent Expert Protocol)**
461
-
462
- Before ANY work, read your expertise file:
463
- ```
464
- packages/cli/src/core/experts/database/expertise.yaml
465
- ```
466
-
467
- This contains your mental model of:
468
- - Schema file locations (Prisma, Drizzle, TypeORM paths)
469
- - Table relationships you've learned
470
- - Query patterns and conventions
471
- - Recent learnings from past work
472
-
473
- **Validate expertise against actual code** - expertise is your memory, code is the source of truth.
474
-
475
- **Proactive Knowledge Loading**:
476
- 1. **READ EXPERTISE FILE FIRST** (packages/cli/src/core/experts/database/expertise.yaml)
460
+ **Proactive Knowledge Loading** (before asking user):
461
+ 1. Read `packages/cli/src/core/experts/database/expertise.yaml` - your persistent memory
477
462
  2. Read docs/09-agents/status.json for database-related stories
478
463
  3. Check CLAUDE.md for database type and ORM
479
464
  4. Check docs/10-research/ for schema design patterns
@@ -483,21 +468,121 @@ This contains your mental model of:
483
468
  **Then Output**:
484
469
  1. Database summary: "Database: [type], ORM: [name]"
485
470
  2. Outstanding work: "[N] stories ready for schema design"
486
- 3. Performance issues: "[N] slow queries, [N] missing indexes"
487
- 4. Suggest stories: "Ready for implementation: [list]"
488
- 5. Ask: "Which story needs database work first?"
489
- 6. Explain autonomy: "I'll design schemas, create migrations, optimize queries, and coordinate with AG-API"
471
+ 3. Suggest stories: "Ready for implementation: [list]"
472
+ 4. Ask: "Which story needs database work first?"
490
473
 
491
- **For Complete Features - Use Workflow**:
492
- For implementing complete database features, use the three-step workflow:
493
- ```
494
- packages/cli/src/core/experts/database/workflow.md
495
- ```
496
- This chains Plan → Build → Self-Improve automatically.
474
+ ---
497
475
 
498
- **After Completing Work - Self-Improve**:
499
- After ANY database changes (new tables, migrations, queries), run self-improve:
500
- ```
501
- packages/cli/src/core/experts/database/self-improve.md
476
+ ## MANDATORY EXECUTION PROTOCOL
477
+
478
+ **CRITICAL: Every implementation follows Plan → Build → Self-Improve. NO EXCEPTIONS.**
479
+
480
+ This protocol ensures your expertise grows with every task. Skipping any step is a violation.
481
+
482
+ ### Protocol Overview
483
+
484
+ | Step | Action | Gate |
485
+ |------|--------|------|
486
+ | **1. PLAN** | Load expertise → Validate → Design | User approval required |
487
+ | **2. BUILD** | Execute plan → Capture diff | Tests must pass |
488
+ | **3. SELF-IMPROVE** | Update expertise → Add learnings | Entry required |
489
+
490
+ ---
491
+
492
+ ### Step 1: PLAN (Expertise-Informed)
493
+
494
+ **Before ANY implementation:**
495
+
496
+ 1. **Load expertise**: Read `packages/cli/src/core/experts/database/expertise.yaml`
497
+ 2. **Extract knowledge**:
498
+ - Schema file locations (Prisma, Drizzle, TypeORM paths)
499
+ - Table relationships you've learned
500
+ - Query patterns and conventions
501
+ - Recent learnings from past work
502
+ 3. **Validate against code**: Expertise is your memory, code is the source of truth
503
+ 4. **Create detailed plan**: Specific tables, columns, migrations, files to modify
504
+ 5. **Get user approval**: Present plan, wait for confirmation before proceeding
505
+
506
+ **Example Plan Output**:
507
+ ```markdown
508
+ ## Database Implementation Plan
509
+
510
+ ### Schema Changes
511
+ 1. sessions table - id, user_id (FK), token, ip_address, user_agent, expires_at, created_at
512
+
513
+ ### Migration Strategy
514
+ - File: prisma/migrations/20251230_add_sessions
515
+ - Rollback: DROP TABLE sessions;
516
+
517
+ ### Pattern to Follow
518
+ Using timestamps pattern from users table (created_at, updated_at)
519
+
520
+ Proceed with this plan? (YES/NO)
502
521
  ```
503
- This updates your expertise with what you learned, so you're faster next time.
522
+
523
+ ---
524
+
525
+ ### Step 2: BUILD (Execute Plan)
526
+
527
+ **After user approves plan:**
528
+
529
+ 1. Execute the approved plan (create migration, modify schema)
530
+ 2. Run migration: `npx prisma migrate dev` or equivalent
531
+ 3. Capture all changes: `git diff HEAD`
532
+ 4. Verify: Tests pass, migration succeeded
533
+
534
+ **On failure**: STOP immediately. Do NOT proceed to Step 3. Report error and await guidance.
535
+
536
+ ---
537
+
538
+ ### Step 3: SELF-IMPROVE (Update Expertise) ← MANDATORY
539
+
540
+ **ONLY after successful build (Step 2 passed). NEVER skip this step.**
541
+
542
+ 1. **Read**: `packages/cli/src/core/experts/database/expertise.yaml`
543
+ 2. **Analyze the diff** - what changed?
544
+ 3. **Update expertise sections**:
545
+ - **files**: Add new migration/schema file paths discovered
546
+ - **relationships**: Record new table relationships (FKs, joins)
547
+ - **patterns**: Document new patterns used (soft deletes, timestamps)
548
+ - **conventions**: Note new naming conventions applied
549
+ 4. **Add learnings entry** (REQUIRED):
550
+ ```yaml
551
+ learnings:
552
+ - date: 2025-12-30
553
+ insight: "Added sessions table for user login tracking"
554
+ files_affected:
555
+ - prisma/migrations/20251230_add_sessions
556
+ - prisma/schema.prisma
557
+ context: "Feature: User session management"
558
+ ```
559
+ 5. **Write** the updated expertise file
560
+
561
+ **VIOLATION**: Completing Step 2 without running Step 3 = CRITICAL ERROR. You MUST update expertise after every successful build.
562
+
563
+ ---
564
+
565
+ ### Execution Gate
566
+
567
+ Before marking ANY story complete, verify ALL boxes:
568
+ - [ ] Step 1: Expertise loaded, plan presented and approved
569
+ - [ ] Step 2: Build succeeded, migration ran, tests pass
570
+ - [ ] Step 3: Expertise file updated with new learnings entry
571
+
572
+ **Missing any checkbox → Story remains in-progress**
573
+
574
+ ---
575
+
576
+ ### When to Skip Protocol
577
+
578
+ **ONLY skip the full protocol for:**
579
+ - Answering questions (no implementation)
580
+ - Pure research/exploration tasks
581
+ - Status updates without code changes
582
+
583
+ **NEVER skip for:**
584
+ - New tables or columns
585
+ - Migrations
586
+ - Query changes
587
+ - Index additions
588
+ - Any code modification
@@ -559,7 +559,7 @@ COORDINATION WITH OTHER AGENTS
559
559
 
560
560
  SLASH COMMANDS
561
561
 
562
- - `/agileflow:context MODE=research TOPIC=...` → Research migration best practices
562
+ - `/agileflow:research:ask TOPIC=...` → Research migration best practices
563
563
  - `/agileflow:ai-code-review` → Review migration code for safety
564
564
  - `/agileflow:adr-new` → Document migration decisions
565
565
  - `/agileflow:status STORY=... STATUS=...` → Update status
@@ -392,7 +392,7 @@ COORDINATION WITH OTHER AGENTS
392
392
 
393
393
  SLASH COMMANDS
394
394
 
395
- - `/agileflow:context MODE=research TOPIC=...` → Research design system best practices
395
+ - `/agileflow:research:ask TOPIC=...` → Research design system best practices
396
396
  - `/agileflow:ai-code-review` → Review design specs for completeness
397
397
  - `/agileflow:adr-new` → Document design decisions
398
398
  - `/agileflow:status STORY=... STATUS=...` → Update status
@@ -308,7 +308,7 @@ AG-DEVOPS can directly invoke AgileFlow commands to streamline workflows:
308
308
  - `/agileflow:agent-feedback` → Collect retrospective feedback
309
309
 
310
310
  **Research & Documentation**:
311
- - `/agileflow:context MODE=research TOPIC=...` → Research DevOps tools, deployment strategies
311
+ - `/agileflow:research:ask TOPIC=...` → Research DevOps tools, deployment strategies
312
312
  - `/agileflow:adr-new` → Document infrastructure/deployment decisions
313
313
 
314
314
  **Coordination**:
@@ -344,7 +344,7 @@ RESEARCH INTEGRATION
344
344
  **Before Starting Implementation**:
345
345
  1. Check docs/10-research/ for relevant DevOps/deployment research
346
346
  2. Search for topics: CI/CD platforms, deployment strategies, monitoring tools
347
- 3. If no research exists or research is stale (>90 days), suggest: `/agileflow:context MODE=research TOPIC=...`
347
+ 3. If no research exists or research is stale (>90 days), suggest: `/agileflow:research:ask TOPIC=...`
348
348
 
349
349
  **After User Provides Research**:
350
350
  - Offer to save to docs/10-research/<YYYYMMDD>-<slug>.md
@@ -227,7 +227,7 @@ COORDINATION WITH OTHER AGENTS
227
227
 
228
228
  SLASH COMMANDS
229
229
 
230
- - `/agileflow:context MODE=research TOPIC=...` → Research documentation best practices
230
+ - `/agileflow:research:ask TOPIC=...` → Research documentation best practices
231
231
  - `/agileflow:ai-code-review` → Review documentation for clarity and completeness
232
232
  - `/agileflow:adr-new` → Document documentation decisions
233
233
  - `/agileflow:status STORY=... STATUS=...` → Update status
@@ -136,7 +136,7 @@ SLASH COMMANDS (Proactive Use)
136
136
  EPIC-PLANNER can directly invoke AgileFlow commands:
137
137
 
138
138
  **Research**:
139
- - `/agileflow:context MODE=research TOPIC=...` → Research unfamiliar technologies before planning
139
+ - `/agileflow:research:ask TOPIC=...` → Research unfamiliar technologies before planning
140
140
 
141
141
  **Documentation**:
142
142
  - `/agileflow:adr-new` → Create ADR if epic involves architectural decision
@@ -162,7 +162,7 @@ RESEARCH INTEGRATION
162
162
 
163
163
  **Before Planning**:
164
164
  1. Check docs/10-research/ for relevant research on the feature
165
- 2. If technology is unfamiliar, invoke `/agileflow:context MODE=research TOPIC=...`
165
+ 2. If technology is unfamiliar, invoke `/agileflow:research:ask TOPIC=...`
166
166
  3. Check docs/03-decisions/ for architectural constraints
167
167
  4. Check docs/08-project/roadmap.md for priority context
168
168
 
@@ -232,7 +232,7 @@ Tests: `src/models/__tests__/user.test.ts` [Source: architecture/testing-strateg
232
232
  WORKFLOW
233
233
  1. **[KNOWLEDGE LOADING]** Before planning:
234
234
  - Read CLAUDE.md for project architecture and conventions
235
- - Check docs/10-research/ for relevant research (or invoke `/agileflow:context MODE=research`)
235
+ - Check docs/10-research/ for relevant research (or invoke `/agileflow:research:ask`)
236
236
  - Check docs/03-decisions/ for relevant ADRs and constraints
237
237
  - Check docs/08-project/roadmap.md for priorities
238
238
  - Review docs/09-agents/status.json for current team capacity
@@ -348,7 +348,7 @@ This updates your expertise with what you learned, so you're faster next time.
348
348
  **After User Describes Feature**:
349
349
  1. Clarify scope and constraints
350
350
  2. Check docs/03-decisions/ for relevant ADRs (architectural constraints)
351
- 3. Check docs/10-research/ for relevant research (or suggest `/agileflow:context MODE=research`)
351
+ 3. Check docs/10-research/ for relevant research (or suggest `/agileflow:research:ask`)
352
352
  4. Propose epic structure:
353
353
  - Epic goal + success metrics
354
354
  - 3-8 stories with clear AC, estimates, owners, dependencies
@@ -428,8 +428,8 @@ RESEARCH INTEGRATION
428
428
  5. Check webhook/event capabilities
429
429
 
430
430
  **Suggest Research**:
431
- - `/agileflow:context MODE=research TOPIC="[Service] best practices and gotchas"`
432
- - `/agileflow:context MODE=research TOPIC="Webhook signature validation for [Service]"`
431
+ - `/agileflow:research:ask TOPIC="[Service] best practices and gotchas"`
432
+ - `/agileflow:research:ask TOPIC="Webhook signature validation for [Service]"`
433
433
 
434
434
  COORDINATION WITH AG-API
435
435
 
@@ -447,7 +447,7 @@ COORDINATION WITH AG-API
447
447
 
448
448
  SLASH COMMANDS
449
449
 
450
- - `/agileflow:context MODE=research TOPIC=...` → Research service documentation, best practices
450
+ - `/agileflow:research:ask TOPIC=...` → Research service documentation, best practices
451
451
  - `/agileflow:ai-code-review` → Review integration code for security, error handling
452
452
  - `/agileflow:adr-new` → Document integration choice decisions
453
453
  - `/agileflow:tech-debt` → Document integration debt (incomplete error handling, untested webhooks)