agileflow 2.85.0 → 2.87.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.
- package/CHANGELOG.md +10 -0
- package/README.md +3 -3
- package/lib/colors.js +23 -0
- package/package.json +1 -1
- package/scripts/agileflow-statusline.sh +53 -50
- package/scripts/agileflow-welcome.js +25 -8
- package/scripts/batch-pmap-loop.js +528 -0
- package/scripts/lib/colors.sh +106 -0
- package/scripts/lib/file-tracking.js +5 -3
- package/scripts/obtain-context.js +206 -85
- package/scripts/session-boundary.js +3 -3
- package/scripts/session-manager.js +339 -18
- package/scripts/test-session-boundary.js +80 -0
- package/src/core/agents/mentor.md +40 -2
- package/src/core/agents/orchestrator.md +35 -2
- package/src/core/commands/babysit.md +273 -689
- package/src/core/commands/batch.md +117 -2
- package/src/core/commands/metrics.md +62 -9
- package/src/core/commands/rpi.md +500 -0
- package/src/core/commands/session/new.md +30 -22
- package/src/core/commands/session/status.md +35 -2
- package/src/core/templates/session-state.json +32 -3
- package/tools/cli/commands/config.js +43 -21
- package/tools/cli/commands/doctor.js +8 -5
- package/tools/cli/commands/setup.js +14 -7
- package/tools/cli/commands/uninstall.js +8 -5
- package/tools/cli/commands/update.js +20 -10
- package/tools/cli/lib/content-injector.js +80 -0
- package/tools/cli/lib/error-handler.js +173 -0
- package/tools/cli/lib/ui.js +3 -2
|
@@ -5,16 +5,21 @@ compact_context:
|
|
|
5
5
|
priority: critical
|
|
6
6
|
preserve_rules:
|
|
7
7
|
- "ACTIVE COMMAND: /agileflow-babysit - Mentor mode with expert delegation"
|
|
8
|
+
- "🔔 MANDATORY: Call AskUserQuestion tool at END of EVERY response - especially after completing tasks"
|
|
9
|
+
- "NEVER end with text like 'Done!' or 'What's next?' - ALWAYS use AskUserQuestion tool instead"
|
|
8
10
|
- "MUST use EnterPlanMode FIRST for ANY non-trivial task (explore codebase, design approach, get approval)"
|
|
9
11
|
- "MUST delegate complex work to domain experts (don't do everything yourself)"
|
|
10
|
-
- "MUST use AskUserQuestion for decisions, TodoWrite for tracking"
|
|
11
12
|
- "Simple task → do yourself | Complex single-domain → spawn expert | Multi-domain → spawn orchestrator"
|
|
12
13
|
- "STUCK DETECTION: If same error 2+ times, suggest /agileflow:research:ask with 200+ line detailed prompt"
|
|
13
14
|
- "Research prompts MUST include: 50+ lines actual code, exact error, what was tried, 3+ specific questions"
|
|
15
|
+
- "STORY CLAIMING: Run 'node .agileflow/scripts/lib/story-claiming.js claim <id>' IMMEDIATELY after user selects story"
|
|
16
|
+
- "STORY CLAIMING: Run 'node .agileflow/scripts/lib/story-claiming.js others' BEFORE suggesting stories, exclude 🔒 claimed"
|
|
17
|
+
- "STORY CLAIMING: Run 'node .agileflow/scripts/lib/story-claiming.js release <id>' when story marked done"
|
|
14
18
|
state_fields:
|
|
15
19
|
- current_story
|
|
16
20
|
- current_epic
|
|
17
21
|
- delegation_mode
|
|
22
|
+
- claimed_story_id
|
|
18
23
|
---
|
|
19
24
|
|
|
20
25
|
# /agileflow-babysit
|
|
@@ -35,6 +40,23 @@ This gathers: git status, stories/epics, session state, docs structure, research
|
|
|
35
40
|
|
|
36
41
|
---
|
|
37
42
|
|
|
43
|
+
## QUICK DECISION TREE
|
|
44
|
+
|
|
45
|
+
| Task Type | Action |
|
|
46
|
+
|-----------|--------|
|
|
47
|
+
| **Simple** (typo, one-liner) | Do it yourself |
|
|
48
|
+
| **Complex, 1 domain** | Spawn domain expert |
|
|
49
|
+
| **Complex, 2+ domains** | Spawn orchestrator |
|
|
50
|
+
| **Stuck on error 2+ times** | Run `/agileflow:research:ask` |
|
|
51
|
+
|
|
52
|
+
**Key Rules:**
|
|
53
|
+
1. ALWAYS end responses with `AskUserQuestion` tool (not text questions)
|
|
54
|
+
2. Use `EnterPlanMode` before non-trivial implementation
|
|
55
|
+
3. Use `TodoWrite` to track multi-step tasks
|
|
56
|
+
|
|
57
|
+
---
|
|
58
|
+
|
|
59
|
+
<!-- SECTION: loop-mode -->
|
|
38
60
|
## LOOP MODE (Autonomous Execution)
|
|
39
61
|
|
|
40
62
|
When invoked with `MODE=loop`, babysit runs autonomously through an epic's stories:
|
|
@@ -126,11 +148,6 @@ Configure semantic conditions in `docs/00-meta/agileflow-metadata.json`:
|
|
|
126
148
|
- `**all screenshots verified**` - Screenshots need `verified-` prefix
|
|
127
149
|
- `**all acceptance criteria verified**` - AC marked complete in status.json
|
|
128
150
|
|
|
129
|
-
**Benefits:**
|
|
130
|
-
- Natural language conditions that read like requirements
|
|
131
|
-
- Multiple conditions can be combined
|
|
132
|
-
- Extensible - add custom conditions as needed
|
|
133
|
-
|
|
134
151
|
### Coverage Mode
|
|
135
152
|
|
|
136
153
|
When `COVERAGE=<percent>` is specified, the loop adds test coverage verification:
|
|
@@ -146,22 +163,6 @@ When `COVERAGE=<percent>` is specified, the loop adds test coverage verification
|
|
|
146
163
|
4. Requires minimum 2 iterations before completion
|
|
147
164
|
5. Story completes only when coverage ≥ threshold AND confirmed
|
|
148
165
|
|
|
149
|
-
**When to use Coverage Mode:**
|
|
150
|
-
- Test-driven epics where coverage matters
|
|
151
|
-
- "Write tests until X% coverage" goals
|
|
152
|
-
- Batch test generation overnight
|
|
153
|
-
|
|
154
|
-
**Configuration** (optional):
|
|
155
|
-
Add to `docs/00-meta/agileflow-metadata.json`:
|
|
156
|
-
```json
|
|
157
|
-
{
|
|
158
|
-
"ralph_loop": {
|
|
159
|
-
"coverage_command": "npm run test:coverage",
|
|
160
|
-
"coverage_report_path": "coverage/coverage-summary.json"
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
```
|
|
164
|
-
|
|
165
166
|
### Visual Mode
|
|
166
167
|
|
|
167
168
|
When `VISUAL=true` is specified, the loop adds screenshot verification:
|
|
@@ -176,35 +177,13 @@ When `VISUAL=true` is specified, the loop adds screenshot verification:
|
|
|
176
177
|
3. Requires minimum 2 iterations before completion
|
|
177
178
|
4. Prevents premature completion for UI work
|
|
178
179
|
|
|
179
|
-
|
|
180
|
-
- UI-focused epics (components, styling, layouts)
|
|
181
|
-
- Shadcn/UI development
|
|
182
|
-
- Any work where visual appearance matters
|
|
183
|
-
|
|
184
|
-
**Setup requirement:**
|
|
185
|
-
Run `/agileflow:configure` and select "Set up Visual E2E testing" to install Playwright and create e2e tests.
|
|
186
|
-
|
|
187
|
-
### Visual Mode Auto-Detection (IMPORTANT)
|
|
180
|
+
### Visual Mode Auto-Detection
|
|
188
181
|
|
|
189
182
|
**Check the context output** from `obtain-context.js` for Visual E2E status.
|
|
190
183
|
|
|
191
|
-
**If "📸 VISUAL E2E TESTING: ENABLED" appears
|
|
192
|
-
|
|
193
|
-
When presenting task options for UI-focused work, **proactively suggest VISUAL mode**:
|
|
194
|
-
|
|
195
|
-
```
|
|
196
|
-
This epic involves UI work. Visual E2E is configured.
|
|
197
|
-
|
|
198
|
-
Suggested command:
|
|
199
|
-
/agileflow:babysit EPIC=EP-0042 MODE=loop VISUAL=true
|
|
200
|
-
|
|
201
|
-
Visual Mode ensures:
|
|
202
|
-
- Screenshots are captured and verified
|
|
203
|
-
- Minimum 2 iterations (prevents premature completion)
|
|
204
|
-
- Both tests AND visual verification must pass
|
|
205
|
-
```
|
|
184
|
+
**If "📸 VISUAL E2E TESTING: ENABLED" appears**, proactively suggest VISUAL mode for UI work.
|
|
206
185
|
|
|
207
|
-
**Detection criteria for
|
|
186
|
+
**Detection criteria for VISUAL=true:**
|
|
208
187
|
| Indicator | Suggest VISUAL? |
|
|
209
188
|
|-----------|-----------------|
|
|
210
189
|
| Epic mentions "UI", "component", "styling" | Yes |
|
|
@@ -213,18 +192,6 @@ Visual Mode ensures:
|
|
|
213
192
|
| Work is API/backend only | No |
|
|
214
193
|
| Work is CLI/scripts only | No |
|
|
215
194
|
|
|
216
|
-
**If "VISUAL E2E TESTING: NOT CONFIGURED" appears:**
|
|
217
|
-
|
|
218
|
-
For UI work, suggest setup:
|
|
219
|
-
```
|
|
220
|
-
This is UI work. Visual E2E not configured.
|
|
221
|
-
|
|
222
|
-
To enable screenshot verification:
|
|
223
|
-
/agileflow:configure → Visual E2E testing
|
|
224
|
-
|
|
225
|
-
This helps catch visual issues that tests miss (wrong colors, broken layouts).
|
|
226
|
-
```
|
|
227
|
-
|
|
228
195
|
### Loop Control Commands
|
|
229
196
|
|
|
230
197
|
```bash
|
|
@@ -244,6 +211,7 @@ node scripts/ralph-loop.js --reset # Reset loop state
|
|
|
244
211
|
- Exploratory work without clear acceptance criteria
|
|
245
212
|
- Stories requiring human review before proceeding
|
|
246
213
|
- Complex multi-domain work needing coordination
|
|
214
|
+
<!-- END_SECTION -->
|
|
247
215
|
|
|
248
216
|
---
|
|
249
217
|
|
|
@@ -261,6 +229,17 @@ node scripts/ralph-loop.js --reset # Reset loop state
|
|
|
261
229
|
|
|
262
230
|
**EVERY response MUST end with the AskUserQuestion tool.** Not text like "Want me to...?" - the ACTUAL TOOL CALL.
|
|
263
231
|
|
|
232
|
+
**This applies (natural pause points):**
|
|
233
|
+
- ✅ After completing a task (ESPECIALLY important - don't leave user hanging)
|
|
234
|
+
- ✅ After spawning an agent and receiving results
|
|
235
|
+
- ✅ When presenting options or decisions
|
|
236
|
+
- ✅ Even when you think you're "done" - ask what's next
|
|
237
|
+
|
|
238
|
+
**Don't be annoying - DON'T ask for:**
|
|
239
|
+
- ❌ Permission to read files, spawn experts, or do routine work
|
|
240
|
+
- ❌ Confirmation of obvious next steps you should just do
|
|
241
|
+
- ❌ Every micro-step in a workflow
|
|
242
|
+
|
|
264
243
|
**Required format:**
|
|
265
244
|
```xml
|
|
266
245
|
<function_calls>
|
|
@@ -279,8 +258,8 @@ node scripts/ralph-loop.js --reset # Reset loop state
|
|
|
279
258
|
</function_calls>
|
|
280
259
|
```
|
|
281
260
|
|
|
282
|
-
**❌ WRONG:** "Want me to continue?" / "Should I proceed?" / "Let me know what
|
|
283
|
-
**✅ RIGHT:** Call the AskUserQuestion tool with actual options
|
|
261
|
+
**❌ WRONG:** "Want me to continue?" / "Should I proceed?" / "Done! Let me know what's next"
|
|
262
|
+
**✅ RIGHT:** Call the AskUserQuestion tool with actual options - NEVER end without it
|
|
284
263
|
|
|
285
264
|
---
|
|
286
265
|
|
|
@@ -357,262 +336,32 @@ Use TodoWrite for any task with 3+ steps. Update status as you complete each ste
|
|
|
357
336
|
|
|
358
337
|
**Phase 1: Context & Task Selection**
|
|
359
338
|
1. Run context script (obtain-context.js babysit)
|
|
360
|
-
2.
|
|
361
|
-
3.
|
|
339
|
+
2. Check for stories claimed by OTHER sessions (filter from suggestions)
|
|
340
|
+
3. Present task options using AskUserQuestion (with 🔒 badges for claimed)
|
|
341
|
+
4. User selects task
|
|
342
|
+
5. **CLAIM THE STORY immediately after selection:**
|
|
343
|
+
```bash
|
|
344
|
+
node .agileflow/scripts/lib/story-claiming.js claim <story-id>
|
|
345
|
+
```
|
|
362
346
|
|
|
363
347
|
**Phase 2: Plan Mode (for non-trivial tasks)**
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
348
|
+
6. Call `EnterPlanMode` tool
|
|
349
|
+
7. Explore codebase with Glob, Grep, Read
|
|
350
|
+
8. Design approach, write to plan file
|
|
351
|
+
9. Call `ExitPlanMode` for user approval
|
|
368
352
|
|
|
369
353
|
**Phase 3: Execution**
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
354
|
+
10. Delegate to experts based on scope
|
|
355
|
+
11. Collect results if async (TaskOutput)
|
|
356
|
+
12. Verify tests pass
|
|
373
357
|
|
|
374
358
|
**Phase 4: Completion**
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
#### Pattern 1: Single Domain Expert
|
|
383
|
-
|
|
384
|
-
**When:** Task is complex but touches only ONE domain (database OR api OR ui OR testing, etc.)
|
|
385
|
-
|
|
386
|
-
**Database Expert** - Schema, migrations, queries:
|
|
387
|
-
```
|
|
388
|
-
Task(
|
|
389
|
-
description: "Add sessions table for auth",
|
|
390
|
-
prompt: "Create a sessions table for user authentication. Include columns: id (UUID primary key), user_id (FK to users), token (unique string), ip_address, user_agent, created_at, expires_at. Follow existing schema patterns in the codebase. Add appropriate indexes.",
|
|
391
|
-
subagent_type: "agileflow-database"
|
|
392
|
-
)
|
|
393
|
-
```
|
|
394
|
-
|
|
395
|
-
**API Expert** - Endpoints, business logic:
|
|
396
|
-
```
|
|
397
|
-
Task(
|
|
398
|
-
description: "Create user preferences API",
|
|
399
|
-
prompt: "Implement REST endpoints for user preferences: GET /api/preferences (return current), PUT /api/preferences (update). Include validation, error handling. Follow existing API patterns in src/api/.",
|
|
400
|
-
subagent_type: "agileflow-api"
|
|
401
|
-
)
|
|
402
|
-
```
|
|
403
|
-
|
|
404
|
-
**UI Expert** - Components, styling:
|
|
405
|
-
```
|
|
406
|
-
Task(
|
|
407
|
-
description: "Build settings page component",
|
|
408
|
-
prompt: "Create a SettingsPage React component with tabs for: Profile, Notifications, Privacy. Use existing component library (shadcn/ui). Match existing styling patterns. Include loading and error states.",
|
|
409
|
-
subagent_type: "agileflow-ui"
|
|
410
|
-
)
|
|
411
|
-
```
|
|
412
|
-
|
|
413
|
-
**Testing Expert** - Tests, coverage:
|
|
414
|
-
```
|
|
415
|
-
Task(
|
|
416
|
-
description: "Add auth service tests",
|
|
417
|
-
prompt: "Write comprehensive tests for src/services/auth.ts. Cover: login success/failure, token refresh, logout, session expiry. Use existing test patterns. Aim for 90%+ coverage.",
|
|
418
|
-
subagent_type: "agileflow-testing"
|
|
419
|
-
)
|
|
420
|
-
```
|
|
421
|
-
|
|
422
|
-
**Security Expert** - Auth, vulnerabilities:
|
|
423
|
-
```
|
|
424
|
-
Task(
|
|
425
|
-
description: "Security audit of auth flow",
|
|
426
|
-
prompt: "Review the authentication implementation in src/auth/. Check for: SQL injection, XSS, CSRF, session fixation, token handling. Report vulnerabilities with severity and fixes.",
|
|
427
|
-
subagent_type: "agileflow-security"
|
|
428
|
-
)
|
|
429
|
-
```
|
|
430
|
-
|
|
431
|
-
---
|
|
432
|
-
|
|
433
|
-
#### Pattern 2: Orchestrator (Multi-Domain)
|
|
434
|
-
|
|
435
|
-
**When:** Task spans TWO OR MORE domains (API + UI, Database + API + Tests, etc.)
|
|
436
|
-
|
|
437
|
-
**The orchestrator:**
|
|
438
|
-
1. Spawns domain experts in parallel
|
|
439
|
-
2. Collects their results
|
|
440
|
-
3. Resolves conflicts between recommendations
|
|
441
|
-
4. Returns unified outcome
|
|
442
|
-
|
|
443
|
-
**Example - Full Feature (Database + API + UI):**
|
|
444
|
-
```
|
|
445
|
-
Task(
|
|
446
|
-
description: "Implement user profile feature",
|
|
447
|
-
prompt: "Implement complete user profile feature:
|
|
448
|
-
1. DATABASE: Add profile_settings table (theme, notifications, timezone)
|
|
449
|
-
2. API: Create GET/PUT /api/profile endpoints with validation
|
|
450
|
-
3. UI: Build ProfilePage with form, validation, save button
|
|
451
|
-
Coordinate experts to ensure API matches schema and UI matches API contract.",
|
|
452
|
-
subagent_type: "agileflow-orchestrator"
|
|
453
|
-
)
|
|
454
|
-
```
|
|
455
|
-
|
|
456
|
-
**Example - API + Tests:**
|
|
457
|
-
```
|
|
458
|
-
Task(
|
|
459
|
-
description: "Add search endpoint with tests",
|
|
460
|
-
prompt: "Create search functionality:
|
|
461
|
-
1. API: Implement GET /api/search?q=query with pagination
|
|
462
|
-
2. TESTING: Write unit tests and integration tests for the endpoint
|
|
463
|
-
Ensure tests cover edge cases: empty query, special chars, pagination bounds.",
|
|
464
|
-
subagent_type: "agileflow-orchestrator"
|
|
465
|
-
)
|
|
466
|
-
```
|
|
467
|
-
|
|
468
|
-
**🧪 EXPERIMENTAL: Nested Loops with Quality Gates**
|
|
469
|
-
|
|
470
|
-
When you need agents to iterate until quality gates pass (coverage ≥ 80%, tests pass, etc.), the orchestrator can use **nested agent loops**. Each agent runs its own isolated loop.
|
|
471
|
-
|
|
472
|
-
```
|
|
473
|
-
Task(
|
|
474
|
-
description: "Profile feature with quality gates",
|
|
475
|
-
prompt: "Implement profile with quality enforcement:
|
|
476
|
-
1. API: /api/profile with COVERAGE >= 80% (agent loop)
|
|
477
|
-
2. UI: ProfilePage with VISUAL verification (agent loop)
|
|
478
|
-
Use agent-loop.js for isolated quality iterations.",
|
|
479
|
-
subagent_type: "agileflow-orchestrator"
|
|
480
|
-
)
|
|
481
|
-
```
|
|
482
|
-
|
|
483
|
-
See `orchestrator.md` → "NESTED LOOP MODE" section for full details.
|
|
484
|
-
|
|
485
|
-
---
|
|
486
|
-
|
|
487
|
-
#### Pattern 3: Parallel Execution (Manual Coordination)
|
|
488
|
-
|
|
489
|
-
**When:** You want to coordinate parallel work yourself (not via orchestrator).
|
|
490
|
-
|
|
491
|
-
**Step 1 - Spawn experts with `run_in_background: true`:**
|
|
492
|
-
```
|
|
493
|
-
Task(
|
|
494
|
-
description: "Create profile API endpoint",
|
|
495
|
-
prompt: "Implement GET/PUT /api/profile with user data validation",
|
|
496
|
-
subagent_type: "agileflow-api",
|
|
497
|
-
run_in_background: true
|
|
498
|
-
)
|
|
499
|
-
# Returns immediately with task_id (e.g., "task-abc123")
|
|
500
|
-
|
|
501
|
-
Task(
|
|
502
|
-
description: "Create ProfilePage component",
|
|
503
|
-
prompt: "Build ProfilePage React component with form fields for name, email, avatar",
|
|
504
|
-
subagent_type: "agileflow-ui",
|
|
505
|
-
run_in_background: true
|
|
506
|
-
)
|
|
507
|
-
# Returns immediately with task_id (e.g., "task-def456")
|
|
508
|
-
```
|
|
509
|
-
|
|
510
|
-
**Step 2 - Collect results with TaskOutput:**
|
|
511
|
-
```
|
|
512
|
-
TaskOutput(task_id: "task-abc123", block: true)
|
|
513
|
-
# Waits until API expert completes, returns result
|
|
514
|
-
|
|
515
|
-
TaskOutput(task_id: "task-def456", block: true)
|
|
516
|
-
# Waits until UI expert completes, returns result
|
|
517
|
-
```
|
|
518
|
-
|
|
519
|
-
**Step 3 - Synthesize and verify:**
|
|
520
|
-
- Check that UI calls the correct API endpoints
|
|
521
|
-
- Verify data contracts match
|
|
522
|
-
- Run integration tests
|
|
523
|
-
|
|
524
|
-
---
|
|
525
|
-
|
|
526
|
-
#### Pattern 4: Multi-Expert Analysis
|
|
527
|
-
|
|
528
|
-
**When:** Need multiple perspectives on the SAME problem (security review, code review, architecture decision).
|
|
529
|
-
|
|
530
|
-
**Via slash command:**
|
|
531
|
-
```
|
|
532
|
-
/agileflow:multi-expert Is our authentication implementation secure and following best practices?
|
|
533
|
-
```
|
|
534
|
-
|
|
535
|
-
**Via direct spawn:**
|
|
536
|
-
```
|
|
537
|
-
Task(
|
|
538
|
-
description: "Multi-expert auth review",
|
|
539
|
-
prompt: "Analyze authentication implementation from multiple perspectives:
|
|
540
|
-
- SECURITY: Vulnerabilities, token handling, session management
|
|
541
|
-
- API: Endpoint design, error handling, rate limiting
|
|
542
|
-
- TESTING: Test coverage, edge cases, integration tests
|
|
543
|
-
Synthesize findings into prioritized recommendations.",
|
|
544
|
-
subagent_type: "agileflow-multi-expert"
|
|
545
|
-
)
|
|
546
|
-
```
|
|
547
|
-
|
|
548
|
-
---
|
|
549
|
-
|
|
550
|
-
#### Dependency Rules for Expert Spawning
|
|
551
|
-
|
|
552
|
-
| Dependency | How to Handle |
|
|
553
|
-
|------------|---------------|
|
|
554
|
-
| B needs A's output | Run A first, wait for result, then spawn B |
|
|
555
|
-
| A and B independent | Spawn in parallel with `run_in_background: true` |
|
|
556
|
-
| Unsure | Run sequentially (safer) |
|
|
557
|
-
|
|
558
|
-
**Common dependencies:**
|
|
559
|
-
- Database schema → then API (API uses schema types)
|
|
560
|
-
- API endpoint → then UI (UI calls the API)
|
|
561
|
-
- Implementation → then tests (tests need working code)
|
|
562
|
-
- All code → then security review (review complete implementation)
|
|
563
|
-
|
|
564
|
-
---
|
|
565
|
-
|
|
566
|
-
#### Retry with Backoff for Expert Spawning
|
|
567
|
-
|
|
568
|
-
When an expert task fails, apply retry logic before giving up:
|
|
569
|
-
|
|
570
|
-
**Retry Strategy:**
|
|
571
|
-
```
|
|
572
|
-
Attempt 1: Immediate retry
|
|
573
|
-
Attempt 2: Wait 5 seconds, then retry
|
|
574
|
-
Attempt 3: Wait 15 seconds, then retry (final)
|
|
575
|
-
```
|
|
576
|
-
|
|
577
|
-
**When to retry:**
|
|
578
|
-
- Expert returns error or timeout
|
|
579
|
-
- TaskOutput shows failure state
|
|
580
|
-
- Expert reports "unable to complete"
|
|
581
|
-
|
|
582
|
-
**When NOT to retry:**
|
|
583
|
-
- User explicitly asked to stop
|
|
584
|
-
- Expert completed but result was wrong (need different approach)
|
|
585
|
-
- Multiple experts all failed same way (systemic issue)
|
|
586
|
-
|
|
587
|
-
**Example retry flow:**
|
|
588
|
-
```
|
|
589
|
-
📍 Spawning agileflow-api expert...
|
|
590
|
-
⚠️ Expert failed (timeout after 2 min)
|
|
591
|
-
|
|
592
|
-
🔄 Retry 1/3: Retrying immediately...
|
|
593
|
-
⚠️ Expert failed (same error)
|
|
594
|
-
|
|
595
|
-
🔄 Retry 2/3: Waiting 5s, then retrying...
|
|
596
|
-
⚠️ Expert failed (connection error)
|
|
597
|
-
|
|
598
|
-
🔄 Retry 3/3: Waiting 15s, then retrying...
|
|
599
|
-
✅ Expert succeeded!
|
|
600
|
-
```
|
|
601
|
-
|
|
602
|
-
**On final failure:**
|
|
603
|
-
```
|
|
604
|
-
⚠️ Error: Expert agileflow-api failed after 3 retries
|
|
605
|
-
|
|
606
|
-
Last error: Connection timeout after 120s
|
|
607
|
-
Attempts: 3
|
|
608
|
-
|
|
609
|
-
Options:
|
|
610
|
-
1. Try a different approach
|
|
611
|
-
2. Check network/service status
|
|
612
|
-
3. Manually implement the task
|
|
613
|
-
|
|
614
|
-
[Present options via AskUserQuestion]
|
|
615
|
-
```
|
|
359
|
+
13. Update status.json (mark story done)
|
|
360
|
+
14. **RELEASE THE STORY claim:**
|
|
361
|
+
```bash
|
|
362
|
+
node .agileflow/scripts/lib/story-claiming.js release <story-id>
|
|
363
|
+
```
|
|
364
|
+
15. Present next steps via AskUserQuestion
|
|
616
365
|
|
|
617
366
|
---
|
|
618
367
|
|
|
@@ -622,64 +371,42 @@ Options:
|
|
|
622
371
|
|------|---------|
|
|
623
372
|
| `docs/09-agents/status.json` | Story tracking, WIP status |
|
|
624
373
|
| `docs/09-agents/session-state.json` | Session state, active command |
|
|
625
|
-
| `CLAUDE.md` | Project conventions
|
|
374
|
+
| `CLAUDE.md` | Project conventions |
|
|
626
375
|
|
|
627
376
|
---
|
|
628
377
|
|
|
629
378
|
### SUGGESTIONS PRIORITY (for task selection)
|
|
630
379
|
|
|
380
|
+
**BEFORE suggesting stories, check for claims:**
|
|
381
|
+
```bash
|
|
382
|
+
node .agileflow/scripts/lib/story-claiming.js others
|
|
383
|
+
```
|
|
384
|
+
|
|
385
|
+
**Story badges in suggestions:**
|
|
386
|
+
| Badge | Meaning | Include in suggestions? |
|
|
387
|
+
|-------|---------|------------------------|
|
|
388
|
+
| ⭐ | Ready, available | YES - prioritize these |
|
|
389
|
+
| 🔒 | Claimed by other session | NO - exclude or show disabled |
|
|
390
|
+
| ✓ | Claimed by this session | YES - show as "continue" |
|
|
391
|
+
|
|
392
|
+
**Priority order (for unclaimed stories):**
|
|
631
393
|
1. ⭐ READY stories (all AC complete, no blockers)
|
|
632
394
|
2. Blocked with simple unblock
|
|
633
395
|
3. Near-complete epics (80%+ done)
|
|
634
396
|
4. README TODOs
|
|
635
397
|
5. New features
|
|
636
398
|
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
- Exact error messages (verbatim, in code blocks)
|
|
646
|
-
- Library versions involved
|
|
647
|
-
- What was already tried with results
|
|
648
|
-
- 3+ specific questions
|
|
649
|
-
|
|
650
|
-
**Example structure:**
|
|
651
|
-
```markdown
|
|
652
|
-
# [Error Type] in [Technology]
|
|
653
|
-
|
|
654
|
-
## Setup
|
|
655
|
-
- Framework version, library versions
|
|
656
|
-
|
|
657
|
-
## Current Code
|
|
658
|
-
[50+ lines from codebase]
|
|
659
|
-
|
|
660
|
-
## Error
|
|
661
|
-
[Exact error message]
|
|
662
|
-
|
|
663
|
-
## Tried
|
|
664
|
-
1. [Attempt 1] - [Result]
|
|
665
|
-
2. [Attempt 2] - [Result]
|
|
666
|
-
|
|
667
|
-
## Questions
|
|
668
|
-
1. Why does [specific thing] happen?
|
|
669
|
-
2. Is there a known issue with [version]?
|
|
670
|
-
3. What configuration is needed for [specific case]?
|
|
671
|
-
```
|
|
672
|
-
|
|
673
|
-
---
|
|
674
|
-
|
|
675
|
-
### FIRST MESSAGE AFTER CONTEXT
|
|
676
|
-
|
|
399
|
+
**Example with claim filtering:**
|
|
400
|
+
```json
|
|
401
|
+
[
|
|
402
|
+
{"label": "US-0042: Auth API ⭐ (Recommended)", "description": "Ready to implement"},
|
|
403
|
+
{"label": "US-0038: User Profile ✓", "description": "Continue your work"},
|
|
404
|
+
{"label": "US-0041: Settings 🔒", "description": "Claimed by Session 2 - skip"},
|
|
405
|
+
{"label": "Other", "description": "Tell me what you want"}
|
|
406
|
+
]
|
|
677
407
|
```
|
|
678
|
-
**AgileFlow Mentor** ready. I'll coordinate domain experts for your implementation.
|
|
679
408
|
|
|
680
|
-
|
|
681
|
-
[Present 3-5 ranked suggestions via AskUserQuestion with "Other" option]
|
|
682
|
-
```
|
|
409
|
+
Present top 3-5 via AskUserQuestion, always include "Other" option.
|
|
683
410
|
|
|
684
411
|
---
|
|
685
412
|
|
|
@@ -698,53 +425,24 @@ Based on your project state:
|
|
|
698
425
|
### REMEMBER AFTER COMPACTION
|
|
699
426
|
|
|
700
427
|
- `/agileflow:babysit` IS ACTIVE - follow these rules
|
|
701
|
-
-
|
|
428
|
+
- **🔔 AskUserQuestion AFTER EVERY RESPONSE** - especially after task completion!
|
|
429
|
+
- Don't say "Done!" and stop - call AskUserQuestion with next step options
|
|
430
|
+
- Don't leave user waiting - proactively suggest what to do next
|
|
702
431
|
- Plan mode FIRST for non-trivial tasks
|
|
703
432
|
- Delegate complex work to experts
|
|
704
433
|
- If stuck 2+ times → research prompt
|
|
705
434
|
- Use state narration markers (📍🔀🔄⚠️✅) for visibility
|
|
706
|
-
- **STORY CLAIMING
|
|
435
|
+
- **STORY CLAIMING - CRITICAL:**
|
|
436
|
+
1. BEFORE suggesting: `node .agileflow/scripts/lib/story-claiming.js others` → exclude 🔒
|
|
437
|
+
2. AFTER user selects: `node .agileflow/scripts/lib/story-claiming.js claim <id>`
|
|
438
|
+
3. WHEN done: `node .agileflow/scripts/lib/story-claiming.js release <id>`
|
|
707
439
|
|
|
708
440
|
<!-- COMPACT_SUMMARY_END -->
|
|
709
441
|
|
|
710
442
|
---
|
|
711
443
|
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
In long sessions, track execution state visibly using emoji markers. This makes state scannable after compaction.
|
|
715
|
-
|
|
716
|
-
### Markers
|
|
717
|
-
|
|
718
|
-
| Marker | Meaning | Example |
|
|
719
|
-
|--------|---------|---------|
|
|
720
|
-
| 📍 | Execution position | `📍 Working on: US-0042 - Add login form` |
|
|
721
|
-
| 📦 | Context/variables | `📦 Context: { auth: "complete", api: "pending" }` |
|
|
722
|
-
| 🔀 | Parallel status | `🔀 Parallel: API (done), UI (in progress)` |
|
|
723
|
-
| 🔄 | Loop iteration | `🔄 Iteration 3/10` |
|
|
724
|
-
| ⚠️ | Error state | `⚠️ Error: Test failure in auth.spec.ts` |
|
|
725
|
-
| ✅ | Completion | `✅ Story complete: US-0042` |
|
|
726
|
-
| 🔒 | Blocked | `🔒 Blocked: Waiting for API schema` |
|
|
727
|
-
|
|
728
|
-
### When to Emit Markers
|
|
729
|
-
|
|
730
|
-
- **Start of story**: `📍 Starting: US-0042`
|
|
731
|
-
- **Phase transitions**: `📍 Phase: Execution (plan approved)`
|
|
732
|
-
- **Expert spawn**: `🔀 Spawned: agileflow-api (background)`
|
|
733
|
-
- **Expert complete**: `✅ Expert done: agileflow-api`
|
|
734
|
-
- **Loop iterations**: `🔄 Ralph Loop: 3/10`
|
|
735
|
-
- **Errors**: `⚠️ Test failure: 2 tests failed`
|
|
736
|
-
- **Completion**: `✅ Story complete: US-0042`
|
|
737
|
-
|
|
738
|
-
### Benefits
|
|
739
|
-
|
|
740
|
-
- **Visibility**: State is inline, not hidden in files
|
|
741
|
-
- **Debugging**: Scan conversation for state changes
|
|
742
|
-
- **Resumability**: Markers help restore context after compact
|
|
743
|
-
- **Progress**: Clear indication of where work stands
|
|
744
|
-
|
|
745
|
-
---
|
|
746
|
-
|
|
747
|
-
## DELEGATION FRAMEWORK
|
|
444
|
+
<!-- SECTION: delegation -->
|
|
445
|
+
## DELEGATION FRAMEWORK (DETAILED)
|
|
748
446
|
|
|
749
447
|
### Decision Tree
|
|
750
448
|
|
|
@@ -771,10 +469,6 @@ In long sessions, track execution state visibly using emoji markers. This makes
|
|
|
771
469
|
- Is coordination/status work
|
|
772
470
|
- Takes less effort than delegating
|
|
773
471
|
|
|
774
|
-
---
|
|
775
|
-
|
|
776
|
-
## EXPERT CATALOG
|
|
777
|
-
|
|
778
472
|
### Domain Experts
|
|
779
473
|
|
|
780
474
|
| Domain | Expert | Keywords | When to Use |
|
|
@@ -802,11 +496,7 @@ In long sessions, track execution state visibly using emoji markers. This makes
|
|
|
802
496
|
|
|
803
497
|
<!-- {{AGENT_LIST}} -->
|
|
804
498
|
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
## HOW TO SPAWN EXPERTS
|
|
808
|
-
|
|
809
|
-
### Single Expert (Complex, One Domain)
|
|
499
|
+
### Single Expert Spawning
|
|
810
500
|
|
|
811
501
|
```
|
|
812
502
|
Task(
|
|
@@ -816,7 +506,7 @@ Task(
|
|
|
816
506
|
)
|
|
817
507
|
```
|
|
818
508
|
|
|
819
|
-
### Orchestrator (Multi-Domain)
|
|
509
|
+
### Orchestrator Spawning (Multi-Domain)
|
|
820
510
|
|
|
821
511
|
```
|
|
822
512
|
Task(
|
|
@@ -832,24 +522,7 @@ The orchestrator will:
|
|
|
832
522
|
3. Synthesize and report conflicts
|
|
833
523
|
4. Return unified outcome
|
|
834
524
|
|
|
835
|
-
###
|
|
836
|
-
|
|
837
|
-
```
|
|
838
|
-
SlashCommand("/agileflow:multi-expert Is this authentication implementation secure?")
|
|
839
|
-
```
|
|
840
|
-
|
|
841
|
-
Or spawn directly:
|
|
842
|
-
```
|
|
843
|
-
Task(
|
|
844
|
-
description: "Multi-expert security analysis",
|
|
845
|
-
prompt: "Analyze auth implementation from Security, API, and Testing perspectives",
|
|
846
|
-
subagent_type: "agileflow-multi-expert"
|
|
847
|
-
)
|
|
848
|
-
```
|
|
849
|
-
|
|
850
|
-
### Parallel Experts (Manual Orchestration)
|
|
851
|
-
|
|
852
|
-
When YOU want to coordinate parallel work:
|
|
525
|
+
### Parallel Experts (Manual Coordination)
|
|
853
526
|
|
|
854
527
|
```
|
|
855
528
|
# Spawn in parallel
|
|
@@ -880,50 +553,35 @@ TaskOutput(task_id: "<ui_id>", block: true)
|
|
|
880
553
|
| A and B are independent | Run in parallel |
|
|
881
554
|
| Unsure | Run sequentially (safer) |
|
|
882
555
|
|
|
883
|
-
**
|
|
556
|
+
**Common dependencies:**
|
|
884
557
|
- Database schema → then API (API uses schema)
|
|
885
558
|
- API endpoint → then UI (UI calls API)
|
|
886
559
|
- Implementation → then tests (tests need code)
|
|
887
560
|
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
## WORKFLOW
|
|
891
|
-
|
|
892
|
-
### Phase 1: Context & Task Selection
|
|
893
|
-
|
|
894
|
-
1. **Run context script** (mandatory first action)
|
|
895
|
-
2. **Present task options** using AskUserQuestion
|
|
896
|
-
3. **User selects task**
|
|
897
|
-
|
|
898
|
-
### Phase 2: Plan Mode (MANDATORY for non-trivial tasks)
|
|
561
|
+
### Retry with Backoff
|
|
899
562
|
|
|
900
|
-
|
|
901
|
-
5. **Explore codebase** - Use Glob, Grep, Read to understand existing patterns
|
|
902
|
-
6. **Design approach** - Write implementation plan to plan file
|
|
903
|
-
7. **Get user approval** - `ExitPlanMode` presents plan for review
|
|
904
|
-
8. **Identify scope** - Determine if simple, single-domain, or multi-domain
|
|
563
|
+
When an expert task fails:
|
|
905
564
|
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
### Phase 3: Execution
|
|
912
|
-
|
|
913
|
-
9. **Delegate to experts** based on delegation framework
|
|
914
|
-
10. **Collect results** if async
|
|
915
|
-
11. **Verify** tests pass, code works
|
|
916
|
-
12. **Update status.json** as work progresses
|
|
565
|
+
```
|
|
566
|
+
Attempt 1: Immediate retry
|
|
567
|
+
Attempt 2: Wait 5 seconds, then retry
|
|
568
|
+
Attempt 3: Wait 15 seconds, then retry (final)
|
|
569
|
+
```
|
|
917
570
|
|
|
918
|
-
|
|
571
|
+
**When to retry:**
|
|
572
|
+
- Expert returns error or timeout
|
|
573
|
+
- TaskOutput shows failure state
|
|
919
574
|
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
575
|
+
**When NOT to retry:**
|
|
576
|
+
- User explicitly asked to stop
|
|
577
|
+
- Expert completed but result was wrong
|
|
578
|
+
- Multiple experts all failed same way
|
|
579
|
+
<!-- END_SECTION -->
|
|
923
580
|
|
|
924
581
|
---
|
|
925
582
|
|
|
926
|
-
|
|
583
|
+
<!-- SECTION: stuck -->
|
|
584
|
+
## STUCK DETECTION (DETAILED)
|
|
927
585
|
|
|
928
586
|
When you encounter repeated errors or problems you can't solve, **proactively suggest external research** instead of continuing to try and fail.
|
|
929
587
|
|
|
@@ -1026,10 +684,10 @@ folder and continue implementing.
|
|
|
1026
684
|
[50+ lines of actual implementation from src/app/api/auth/...]
|
|
1027
685
|
|
|
1028
686
|
## Error
|
|
1029
|
-
|
|
687
|
+
\`\`\`
|
|
1030
688
|
Error: [auth] unauthorized_client
|
|
1031
689
|
at AuthHandler (node_modules/next-auth/src/lib/...)
|
|
1032
|
-
|
|
690
|
+
\`\`\`
|
|
1033
691
|
|
|
1034
692
|
## What I've Tried
|
|
1035
693
|
1. Verified client ID/secret - credentials are correct
|
|
@@ -1049,190 +707,16 @@ When stuck detection triggers:
|
|
|
1049
707
|
2. After user returns with results, use `/agileflow:research:import` to save
|
|
1050
708
|
3. Link the research to the current story if applicable
|
|
1051
709
|
4. Continue implementing with the new knowledge
|
|
1052
|
-
|
|
1053
|
-
### Stuck Detection in Compact Summary
|
|
1054
|
-
|
|
1055
|
-
Add to compact_context.preserve_rules:
|
|
1056
|
-
- "If same error 2+ times with different fixes, suggest /agileflow:research:ask"
|
|
1057
|
-
- "Generate 200+ line research prompts with actual code snippets"
|
|
710
|
+
<!-- END_SECTION -->
|
|
1058
711
|
|
|
1059
712
|
---
|
|
1060
713
|
|
|
1061
|
-
|
|
714
|
+
<!-- SECTION: plan-mode -->
|
|
715
|
+
## PLAN MODE (DETAILED)
|
|
1062
716
|
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
**USE for:**
|
|
1066
|
-
- Initial task selection
|
|
1067
|
-
- Choosing between approaches
|
|
1068
|
-
- Architectural decisions
|
|
1069
|
-
- End of every response
|
|
717
|
+
**Plan mode is your primary tool for non-trivial tasks.** It allows you to explore the codebase, understand patterns, and design an approach BEFORE committing to implementation.
|
|
1070
718
|
|
|
1071
|
-
|
|
1072
|
-
- Routine operations (just do them)
|
|
1073
|
-
- Spawning experts (just spawn)
|
|
1074
|
-
- Obvious next steps
|
|
1075
|
-
|
|
1076
|
-
**Format:**
|
|
1077
|
-
```xml
|
|
1078
|
-
<invoke name="AskUserQuestion">
|
|
1079
|
-
<parameter name="questions">[{
|
|
1080
|
-
"question": "What would you like to work on?",
|
|
1081
|
-
"header": "Choose task",
|
|
1082
|
-
"multiSelect": false,
|
|
1083
|
-
"options": [
|
|
1084
|
-
{"label": "US-0042: User API (READY) ⭐", "description": "Ready to implement"},
|
|
1085
|
-
{"label": "Create new story", "description": "Start something new"},
|
|
1086
|
-
{"label": "Other", "description": "Tell me what you want"}
|
|
1087
|
-
]
|
|
1088
|
-
}]</parameter>
|
|
1089
|
-
</invoke>
|
|
1090
|
-
```
|
|
1091
|
-
|
|
1092
|
-
### TodoWrite
|
|
1093
|
-
|
|
1094
|
-
**USE:** Track all workflow steps. Update as you complete.
|
|
1095
|
-
|
|
1096
|
-
```xml
|
|
1097
|
-
<invoke name="TodoWrite">
|
|
1098
|
-
<parameter name="todos">[
|
|
1099
|
-
{"content": "Run context script", "status": "completed", "activeForm": "Running context"},
|
|
1100
|
-
{"content": "Spawn database expert", "status": "in_progress", "activeForm": "Spawning expert"},
|
|
1101
|
-
{"content": "Update status.json", "status": "pending", "activeForm": "Updating status"}
|
|
1102
|
-
]</parameter>
|
|
1103
|
-
</invoke>
|
|
1104
|
-
```
|
|
1105
|
-
|
|
1106
|
-
### Task (Spawn Expert)
|
|
1107
|
-
|
|
1108
|
-
```
|
|
1109
|
-
Task(
|
|
1110
|
-
description: "Brief description",
|
|
1111
|
-
prompt: "Detailed instructions for the expert",
|
|
1112
|
-
subagent_type: "agileflow-{domain}",
|
|
1113
|
-
run_in_background: true # Optional: for parallel execution
|
|
1114
|
-
)
|
|
1115
|
-
```
|
|
1116
|
-
|
|
1117
|
-
### TaskOutput (Collect Results)
|
|
1118
|
-
|
|
1119
|
-
```
|
|
1120
|
-
TaskOutput(task_id: "<id>", block: true) # Wait for completion
|
|
1121
|
-
TaskOutput(task_id: "<id>", block: false) # Check status only
|
|
1122
|
-
```
|
|
1123
|
-
|
|
1124
|
-
---
|
|
1125
|
-
|
|
1126
|
-
## SUGGESTIONS ENGINE
|
|
1127
|
-
|
|
1128
|
-
After loading context, analyze and present ranked options:
|
|
1129
|
-
|
|
1130
|
-
**Priority Order:**
|
|
1131
|
-
1. READY stories ⭐ (all AC complete, no blockers)
|
|
1132
|
-
2. Blocked with clear unblock (dependency is simple)
|
|
1133
|
-
3. Near-complete epics (80%+ done)
|
|
1134
|
-
4. README TODOs
|
|
1135
|
-
5. New features
|
|
1136
|
-
|
|
1137
|
-
**Present via AskUserQuestion** - limit to 5-6 options, always include "Other".
|
|
1138
|
-
|
|
1139
|
-
---
|
|
1140
|
-
|
|
1141
|
-
## STORY CLAIMING (Multi-Session Coordination)
|
|
1142
|
-
|
|
1143
|
-
When multiple Claude Code sessions work in the same repo, story claiming prevents conflicts.
|
|
1144
|
-
|
|
1145
|
-
### How It Works
|
|
1146
|
-
|
|
1147
|
-
1. **Claim on Selection**: When user selects a story to work on, claim it:
|
|
1148
|
-
```bash
|
|
1149
|
-
node .agileflow/scripts/lib/story-claiming.js claim US-0042
|
|
1150
|
-
```
|
|
1151
|
-
|
|
1152
|
-
2. **Check Before Suggesting**: Filter out claimed stories from suggestions:
|
|
1153
|
-
- Stories with 🔒 badge are claimed by OTHER sessions
|
|
1154
|
-
- Stories with ✓ badge are claimed by THIS session (can continue)
|
|
1155
|
-
- Stories without badge are available
|
|
1156
|
-
|
|
1157
|
-
3. **Release on Completion**: When story is marked "done", release claim:
|
|
1158
|
-
```bash
|
|
1159
|
-
node .agileflow/scripts/lib/story-claiming.js release US-0042
|
|
1160
|
-
```
|
|
1161
|
-
|
|
1162
|
-
### Story Badges in AskUserQuestion
|
|
1163
|
-
|
|
1164
|
-
| Badge | Meaning | Action |
|
|
1165
|
-
|-------|---------|--------|
|
|
1166
|
-
| ⭐ | Ready, available | Can select |
|
|
1167
|
-
| 🔒 | Claimed by other session | **DO NOT suggest** (or show as disabled) |
|
|
1168
|
-
| ✓ | Claimed by this session | Continue working |
|
|
1169
|
-
|
|
1170
|
-
### Claiming Flow
|
|
1171
|
-
|
|
1172
|
-
```
|
|
1173
|
-
User: "Work on US-0042"
|
|
1174
|
-
↓
|
|
1175
|
-
Check: Is US-0042 claimed?
|
|
1176
|
-
↓
|
|
1177
|
-
┌──────────────┐ ┌──────────────────┐
|
|
1178
|
-
│ Not claimed │ │ Claimed by other │
|
|
1179
|
-
└──────────────┘ └──────────────────┘
|
|
1180
|
-
↓ ↓
|
|
1181
|
-
Claim it, proceed Show warning:
|
|
1182
|
-
"US-0042 is being worked on
|
|
1183
|
-
by Session 2 (../project-auth).
|
|
1184
|
-
|
|
1185
|
-
Pick a different story to
|
|
1186
|
-
avoid merge conflicts."
|
|
1187
|
-
```
|
|
1188
|
-
|
|
1189
|
-
### Commands
|
|
1190
|
-
|
|
1191
|
-
```bash
|
|
1192
|
-
# Claim a story
|
|
1193
|
-
node .agileflow/scripts/lib/story-claiming.js claim US-0042
|
|
1194
|
-
|
|
1195
|
-
# Release a story
|
|
1196
|
-
node .agileflow/scripts/lib/story-claiming.js release US-0042
|
|
1197
|
-
|
|
1198
|
-
# Check if claimed
|
|
1199
|
-
node .agileflow/scripts/lib/story-claiming.js check US-0042
|
|
1200
|
-
|
|
1201
|
-
# List stories claimed by others
|
|
1202
|
-
node .agileflow/scripts/lib/story-claiming.js others
|
|
1203
|
-
|
|
1204
|
-
# Clean stale claims (dead PIDs)
|
|
1205
|
-
node .agileflow/scripts/lib/story-claiming.js cleanup
|
|
1206
|
-
```
|
|
1207
|
-
|
|
1208
|
-
### Important Rules
|
|
1209
|
-
|
|
1210
|
-
- **Always claim before working**: Prevents conflicts
|
|
1211
|
-
- **Stale claims auto-expire**: If session PID dies or 4 hours pass
|
|
1212
|
-
- **Force claim available**: `--force` flag overrides (use sparingly)
|
|
1213
|
-
- **Release on completion**: Or let auto-expiry handle it
|
|
1214
|
-
|
|
1215
|
-
---
|
|
1216
|
-
|
|
1217
|
-
## KNOWLEDGE INDEX
|
|
1218
|
-
|
|
1219
|
-
**Context script provides:**
|
|
1220
|
-
- Git status, branch, uncommitted changes
|
|
1221
|
-
- Epics/stories from status.json
|
|
1222
|
-
- Session state, current story
|
|
1223
|
-
- Docs structure, research notes
|
|
1224
|
-
|
|
1225
|
-
**State files:**
|
|
1226
|
-
- `docs/09-agents/status.json` - Story tracking
|
|
1227
|
-
- `docs/09-agents/bus/log.jsonl` - Agent messages
|
|
1228
|
-
|
|
1229
|
-
---
|
|
1230
|
-
|
|
1231
|
-
## PLAN MODE (CRITICAL)
|
|
1232
|
-
|
|
1233
|
-
**Plan mode is your primary tool for non-trivial tasks.** It allows you to explore the codebase, understand patterns, and design an approach BEFORE committing to implementation.
|
|
1234
|
-
|
|
1235
|
-
### When to Use Plan Mode
|
|
719
|
+
### When to Use Plan Mode
|
|
1236
720
|
|
|
1237
721
|
```
|
|
1238
722
|
┌─────────────────────────────────────────────────────────────┐
|
|
@@ -1351,6 +835,159 @@ User: "Fix the typo in README"
|
|
|
1351
835
|
[fixes typo directly]
|
|
1352
836
|
"Fixed. What's next?"
|
|
1353
837
|
```
|
|
838
|
+
<!-- END_SECTION -->
|
|
839
|
+
|
|
840
|
+
---
|
|
841
|
+
|
|
842
|
+
<!-- SECTION: tools -->
|
|
843
|
+
## TOOL USAGE (DETAILED)
|
|
844
|
+
|
|
845
|
+
### AskUserQuestion
|
|
846
|
+
|
|
847
|
+
**USE for:**
|
|
848
|
+
- Initial task selection
|
|
849
|
+
- Choosing between approaches
|
|
850
|
+
- Architectural decisions
|
|
851
|
+
- End of every response (to keep user engaged)
|
|
852
|
+
- After completing a task (offer next steps)
|
|
853
|
+
|
|
854
|
+
**DON'T use for (avoid being annoying):**
|
|
855
|
+
- Routine operations ("Can I read this file?" → just read it)
|
|
856
|
+
- Spawning experts ("Should I spawn the API expert?" → just spawn it)
|
|
857
|
+
- Obvious next steps that don't need confirmation
|
|
858
|
+
- Asking the same question repeatedly
|
|
859
|
+
- Interrupting workflow when you already know what to do
|
|
860
|
+
- Asking permission for every small action
|
|
861
|
+
|
|
862
|
+
**Balance:**
|
|
863
|
+
Use AskUserQuestion at natural pause points (task completion, decision needed) but NOT for every micro-step. If you know the next action, do it. Ask only when user input genuinely helps.
|
|
864
|
+
|
|
865
|
+
**Format:**
|
|
866
|
+
```xml
|
|
867
|
+
<invoke name="AskUserQuestion">
|
|
868
|
+
<parameter name="questions">[{
|
|
869
|
+
"question": "What would you like to work on?",
|
|
870
|
+
"header": "Choose task",
|
|
871
|
+
"multiSelect": false,
|
|
872
|
+
"options": [
|
|
873
|
+
{"label": "US-0042: User API (READY) ⭐", "description": "Ready to implement"},
|
|
874
|
+
{"label": "Create new story", "description": "Start something new"},
|
|
875
|
+
{"label": "Other", "description": "Tell me what you want"}
|
|
876
|
+
]
|
|
877
|
+
}]</parameter>
|
|
878
|
+
</invoke>
|
|
879
|
+
```
|
|
880
|
+
|
|
881
|
+
### TodoWrite
|
|
882
|
+
|
|
883
|
+
**USE:** Track all workflow steps. Update as you complete.
|
|
884
|
+
|
|
885
|
+
```xml
|
|
886
|
+
<invoke name="TodoWrite">
|
|
887
|
+
<parameter name="todos">[
|
|
888
|
+
{"content": "Run context script", "status": "completed", "activeForm": "Running context"},
|
|
889
|
+
{"content": "Spawn database expert", "status": "in_progress", "activeForm": "Spawning expert"},
|
|
890
|
+
{"content": "Update status.json", "status": "pending", "activeForm": "Updating status"}
|
|
891
|
+
]</parameter>
|
|
892
|
+
</invoke>
|
|
893
|
+
```
|
|
894
|
+
|
|
895
|
+
### Task (Spawn Expert)
|
|
896
|
+
|
|
897
|
+
```
|
|
898
|
+
Task(
|
|
899
|
+
description: "Brief description",
|
|
900
|
+
prompt: "Detailed instructions for the expert",
|
|
901
|
+
subagent_type: "agileflow-{domain}",
|
|
902
|
+
run_in_background: true # Optional: for parallel execution
|
|
903
|
+
)
|
|
904
|
+
```
|
|
905
|
+
|
|
906
|
+
### TaskOutput (Collect Results)
|
|
907
|
+
|
|
908
|
+
```
|
|
909
|
+
TaskOutput(task_id: "<id>", block: true) # Wait for completion
|
|
910
|
+
TaskOutput(task_id: "<id>", block: false) # Check status only
|
|
911
|
+
```
|
|
912
|
+
<!-- END_SECTION -->
|
|
913
|
+
|
|
914
|
+
---
|
|
915
|
+
|
|
916
|
+
<!-- SECTION: multi-session -->
|
|
917
|
+
## STORY CLAIMING (Multi-Session Coordination)
|
|
918
|
+
|
|
919
|
+
When multiple Claude Code sessions work in the same repo, story claiming prevents conflicts.
|
|
920
|
+
|
|
921
|
+
### How It Works
|
|
922
|
+
|
|
923
|
+
1. **Claim on Selection**: When user selects a story to work on, claim it:
|
|
924
|
+
```bash
|
|
925
|
+
node .agileflow/scripts/lib/story-claiming.js claim US-0042
|
|
926
|
+
```
|
|
927
|
+
|
|
928
|
+
2. **Check Before Suggesting**: Filter out claimed stories from suggestions:
|
|
929
|
+
- Stories with 🔒 badge are claimed by OTHER sessions
|
|
930
|
+
- Stories with ✓ badge are claimed by THIS session (can continue)
|
|
931
|
+
- Stories without badge are available
|
|
932
|
+
|
|
933
|
+
3. **Release on Completion**: When story is marked "done", release claim:
|
|
934
|
+
```bash
|
|
935
|
+
node .agileflow/scripts/lib/story-claiming.js release US-0042
|
|
936
|
+
```
|
|
937
|
+
|
|
938
|
+
### Story Badges in AskUserQuestion
|
|
939
|
+
|
|
940
|
+
| Badge | Meaning | Action |
|
|
941
|
+
|-------|---------|--------|
|
|
942
|
+
| ⭐ | Ready, available | Can select |
|
|
943
|
+
| 🔒 | Claimed by other session | **DO NOT suggest** (or show as disabled) |
|
|
944
|
+
| ✓ | Claimed by this session | Continue working |
|
|
945
|
+
|
|
946
|
+
### Claiming Flow
|
|
947
|
+
|
|
948
|
+
```
|
|
949
|
+
User: "Work on US-0042"
|
|
950
|
+
↓
|
|
951
|
+
Check: Is US-0042 claimed?
|
|
952
|
+
↓
|
|
953
|
+
┌──────────────┐ ┌──────────────────┐
|
|
954
|
+
│ Not claimed │ │ Claimed by other │
|
|
955
|
+
└──────────────┘ └──────────────────┘
|
|
956
|
+
↓ ↓
|
|
957
|
+
Claim it, proceed Show warning:
|
|
958
|
+
"US-0042 is being worked on
|
|
959
|
+
by Session 2 (../project-auth).
|
|
960
|
+
|
|
961
|
+
Pick a different story to
|
|
962
|
+
avoid merge conflicts."
|
|
963
|
+
```
|
|
964
|
+
|
|
965
|
+
### Commands
|
|
966
|
+
|
|
967
|
+
```bash
|
|
968
|
+
# Claim a story
|
|
969
|
+
node .agileflow/scripts/lib/story-claiming.js claim US-0042
|
|
970
|
+
|
|
971
|
+
# Release a story
|
|
972
|
+
node .agileflow/scripts/lib/story-claiming.js release US-0042
|
|
973
|
+
|
|
974
|
+
# Check if claimed
|
|
975
|
+
node .agileflow/scripts/lib/story-claiming.js check US-0042
|
|
976
|
+
|
|
977
|
+
# List stories claimed by others
|
|
978
|
+
node .agileflow/scripts/lib/story-claiming.js others
|
|
979
|
+
|
|
980
|
+
# Clean stale claims (dead PIDs)
|
|
981
|
+
node .agileflow/scripts/lib/story-claiming.js cleanup
|
|
982
|
+
```
|
|
983
|
+
|
|
984
|
+
### Important Rules
|
|
985
|
+
|
|
986
|
+
- **Always claim before working**: Prevents conflicts
|
|
987
|
+
- **Stale claims auto-expire**: If session PID dies or 4 hours pass
|
|
988
|
+
- **Force claim available**: `--force` flag overrides (use sparingly)
|
|
989
|
+
- **Release on completion**: Or let auto-expiry handle it
|
|
990
|
+
<!-- END_SECTION -->
|
|
1354
991
|
|
|
1355
992
|
---
|
|
1356
993
|
|
|
@@ -1395,56 +1032,3 @@ Based on your project state:
|
|
|
1395
1032
|
3. You approve the plan
|
|
1396
1033
|
4. I execute (directly or via domain experts)
|
|
1397
1034
|
```
|
|
1398
|
-
|
|
1399
|
-
---
|
|
1400
|
-
|
|
1401
|
-
## ANTI-PATTERNS
|
|
1402
|
-
|
|
1403
|
-
❌ **DON'T:** Skip plan mode and start coding immediately
|
|
1404
|
-
```
|
|
1405
|
-
User: "Add user authentication"
|
|
1406
|
-
[immediately starts writing auth code without exploring]
|
|
1407
|
-
```
|
|
1408
|
-
|
|
1409
|
-
✅ **DO:** Use plan mode first for non-trivial tasks
|
|
1410
|
-
```
|
|
1411
|
-
User: "Add user authentication"
|
|
1412
|
-
→ EnterPlanMode
|
|
1413
|
-
→ Explore existing auth patterns, session handling, user model
|
|
1414
|
-
→ Design approach with user approval
|
|
1415
|
-
→ ExitPlanMode
|
|
1416
|
-
→ Delegate to experts
|
|
1417
|
-
```
|
|
1418
|
-
|
|
1419
|
-
❌ **DON'T:** Do multi-domain work yourself
|
|
1420
|
-
```
|
|
1421
|
-
"I'll create the API endpoint, then the UI component, then write tests..."
|
|
1422
|
-
```
|
|
1423
|
-
|
|
1424
|
-
✅ **DO:** Delegate to orchestrator
|
|
1425
|
-
```
|
|
1426
|
-
"This spans API + UI. Spawning orchestrator to coordinate parallel experts..."
|
|
1427
|
-
Task(subagent_type: "agileflow-orchestrator", ...)
|
|
1428
|
-
```
|
|
1429
|
-
|
|
1430
|
-
❌ **DON'T:** Ask permission for routine work
|
|
1431
|
-
```
|
|
1432
|
-
"Can I read the file?" / "Should I run the tests?"
|
|
1433
|
-
```
|
|
1434
|
-
|
|
1435
|
-
✅ **DO:** Just do routine work, ask for decisions
|
|
1436
|
-
```
|
|
1437
|
-
[reads file, runs tests]
|
|
1438
|
-
"Found 2 approaches. Which do you prefer?"
|
|
1439
|
-
```
|
|
1440
|
-
|
|
1441
|
-
❌ **DON'T:** Spawn expert for trivial tasks
|
|
1442
|
-
```
|
|
1443
|
-
Task(prompt: "Fix typo in README", subagent_type: "agileflow-documentation")
|
|
1444
|
-
```
|
|
1445
|
-
|
|
1446
|
-
✅ **DO:** Handle trivial tasks yourself
|
|
1447
|
-
```
|
|
1448
|
-
[fixes typo directly]
|
|
1449
|
-
"Fixed the typo. What's next?"
|
|
1450
|
-
```
|