devforgeai 1.0.8 → 1.0.9

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.
@@ -0,0 +1,1054 @@
1
+ # DevForgeAI API Reference
2
+
3
+ Version: 0.1.0 | Last Updated: 2026-03-03
4
+
5
+ ---
6
+
7
+ ## Table of Contents
8
+
9
+ 1. [CLI Reference](#1-cli-reference)
10
+ 2. [Skill Interface](#2-skill-interface)
11
+ 3. [Subagent Interface](#3-subagent-interface)
12
+ 4. [Hook System](#4-hook-system)
13
+ 5. [Phase State JSON Schema](#5-phase-state-json-schema)
14
+
15
+ ---
16
+
17
+ ## 1. CLI Reference
18
+
19
+ The `devforgeai-validate` CLI provides workflow validation and phase state management commands.
20
+
21
+ **Installation:**
22
+
23
+ ```bash
24
+ pip install -e .claude/scripts/
25
+ ```
26
+
27
+ **Global Options:**
28
+
29
+ | Option | Description |
30
+ |--------|-------------|
31
+ | `--version` | Show version (0.1.0) |
32
+ | `--help` | Show help for any command |
33
+
34
+ ---
35
+
36
+ ### 1.1 phase-init
37
+
38
+ Initialize a phase state file for a story.
39
+
40
+ ```
41
+ devforgeai-validate phase-init <story_id> [options]
42
+ ```
43
+
44
+ **Arguments:**
45
+
46
+ | Argument | Required | Description |
47
+ |----------|----------|-------------|
48
+ | `story_id` | Yes | Story identifier (e.g., `STORY-527`) |
49
+
50
+ **Options:**
51
+
52
+ | Option | Default | Description |
53
+ |--------|---------|-------------|
54
+ | `--project-root` | `.` | Project root directory |
55
+ | `--format` | `text` | Output format: `text` or `json` |
56
+ | `--workflow` | `dev` | Workflow type: `dev`, `qa`, or custom (via WORKFLOW_SCHEMAS) |
57
+
58
+ **Exit Codes:**
59
+
60
+ | Code | Meaning |
61
+ |------|---------|
62
+ | 0 | State file created |
63
+ | 1 | State file already exists |
64
+ | 2 | Invalid story ID or invalid workflow type |
65
+
66
+ **Examples:**
67
+
68
+ ```bash
69
+ # Initialize dev workflow
70
+ devforgeai-validate phase-init STORY-527 --project-root=.
71
+
72
+ # Initialize QA workflow
73
+ devforgeai-validate phase-init STORY-527 --workflow=qa --project-root=.
74
+
75
+ # JSON output
76
+ devforgeai-validate phase-init STORY-527 --format=json --project-root=.
77
+ ```
78
+
79
+ **JSON Output (success):**
80
+
81
+ ```json
82
+ {
83
+ "success": true,
84
+ "story_id": "STORY-527",
85
+ "path": "devforgeai/workflows/STORY-527-phase-state.json",
86
+ "current_phase": "01"
87
+ }
88
+ ```
89
+
90
+ ---
91
+
92
+ ### 1.2 phase-status
93
+
94
+ Display current phase status for a story.
95
+
96
+ ```
97
+ devforgeai-validate phase-status <story_id> [options]
98
+ ```
99
+
100
+ **Arguments:**
101
+
102
+ | Argument | Required | Description |
103
+ |----------|----------|-------------|
104
+ | `story_id` | Yes | Story identifier |
105
+
106
+ **Options:**
107
+
108
+ | Option | Default | Description |
109
+ |--------|---------|-------------|
110
+ | `--project-root` | `.` | Project root directory |
111
+ | `--format` | `text` | Output format: `text` or `json` |
112
+
113
+ **Exit Codes:**
114
+
115
+ | Code | Meaning |
116
+ |------|---------|
117
+ | 0 | Status displayed successfully |
118
+ | 1 | State file not found |
119
+
120
+ **Text Output Example:**
121
+
122
+ ```
123
+ Story: STORY-527
124
+ Started: 2026-03-03T10:00:00Z
125
+ Current Phase: 03
126
+ Blocking: none
127
+
128
+ Phase Status:
129
+ [x] Phase 01: completed
130
+ Subagents: git-validator, tech-stack-detector, context-preservation-validator
131
+ [x] Phase 02: completed
132
+ Subagents: test-automator
133
+ [ ] Phase 03: in_progress
134
+ [ ] Phase 04: pending
135
+ ...
136
+ ```
137
+
138
+ ---
139
+
140
+ ### 1.3 phase-check
141
+
142
+ Validate whether a phase transition is allowed.
143
+
144
+ ```
145
+ devforgeai-validate phase-check <story_id> --from=<phase> --to=<phase> [options]
146
+ ```
147
+
148
+ **Arguments:**
149
+
150
+ | Argument | Required | Description |
151
+ |----------|----------|-------------|
152
+ | `story_id` | Yes | Story identifier |
153
+
154
+ **Options:**
155
+
156
+ | Option | Required | Default | Description |
157
+ |--------|----------|---------|-------------|
158
+ | `--from` | Yes | - | Source phase (e.g., `01`) |
159
+ | `--to` | Yes | - | Target phase (e.g., `02`) |
160
+ | `--project-root` | No | `.` | Project root directory |
161
+ | `--format` | No | `text` | Output format |
162
+
163
+ **Exit Codes:**
164
+
165
+ | Code | Meaning |
166
+ |------|---------|
167
+ | 0 | Transition allowed |
168
+ | 1 | Transition blocked (phase not completed or non-sequential) |
169
+ | 2 | Missing required subagents |
170
+
171
+ **Transition Rules:**
172
+ 1. Source phase must have `status: "completed"`
173
+ 2. Transitions must be sequential (no phase skipping)
174
+ 3. All required subagents for the source phase must be invoked
175
+
176
+ **OR-group subagent logic:** Some phases accept alternative subagents. For example, Phase 03 requires `backend-architect` OR `frontend-developer`. If either has been invoked, the requirement is satisfied.
177
+
178
+ ---
179
+
180
+ ### 1.4 phase-complete
181
+
182
+ Mark a phase as complete.
183
+
184
+ ```
185
+ devforgeai-validate phase-complete <story_id> --phase=<phase> [options]
186
+ ```
187
+
188
+ **Arguments:**
189
+
190
+ | Argument | Required | Description |
191
+ |----------|----------|-------------|
192
+ | `story_id` | Yes | Story identifier |
193
+
194
+ **Options:**
195
+
196
+ | Option | Required | Default | Description |
197
+ |--------|----------|---------|-------------|
198
+ | `--phase` | Yes | - | Phase to complete (e.g., `02`) |
199
+ | `--checkpoint-passed` | No | `true` | Mark checkpoint as passed |
200
+ | `--checkpoint-failed` | No | `false` | Mark checkpoint as failed |
201
+ | `--project-root` | No | `.` | Project root directory |
202
+ | `--format` | No | `text` | Output format |
203
+ | `--workflow` | No | `dev` | Workflow type: `dev`, `qa` |
204
+
205
+ **Exit Codes:**
206
+
207
+ | Code | Meaning |
208
+ |------|---------|
209
+ | 0 | Phase completed successfully |
210
+ | 1 | Phase incomplete or error (e.g., step validation failure) |
211
+
212
+ ---
213
+
214
+ ### 1.5 phase-record
215
+
216
+ Record a subagent invocation for a phase. Idempotent -- duplicate invocations are ignored.
217
+
218
+ ```
219
+ devforgeai-validate phase-record <story_id> --phase=<phase> --subagent=<name> [options]
220
+ ```
221
+
222
+ **Arguments:**
223
+
224
+ | Argument | Required | Description |
225
+ |----------|----------|-------------|
226
+ | `story_id` | Yes | Story identifier |
227
+
228
+ **Options:**
229
+
230
+ | Option | Required | Default | Description |
231
+ |--------|----------|---------|-------------|
232
+ | `--phase` | Yes | - | Phase ID (`01` through `10`, including `4.5`, `5.5`) |
233
+ | `--subagent` | Yes | - | Subagent name (e.g., `test-automator`) |
234
+ | `--project-root` | No | `.` | Project root directory |
235
+ | `--format` | No | `text` | Output format |
236
+
237
+ **Exit Codes:**
238
+
239
+ | Code | Meaning |
240
+ |------|---------|
241
+ | 0 | Subagent recorded |
242
+ | 1 | State file not found |
243
+ | 2 | Error |
244
+
245
+ ---
246
+
247
+ ### 1.6 phase-record-step
248
+
249
+ Record a step completion for a phase. Validates the step ID against the phase-steps-registry.
250
+
251
+ ```
252
+ devforgeai-validate phase-record-step <story_id> --phase=<phase> --step=<step_id> [options]
253
+ ```
254
+
255
+ **Arguments:**
256
+
257
+ | Argument | Required | Description |
258
+ |----------|----------|-------------|
259
+ | `story_id` | Yes | Story identifier |
260
+
261
+ **Options:**
262
+
263
+ | Option | Required | Default | Description |
264
+ |--------|----------|---------|-------------|
265
+ | `--phase` | Yes | - | Phase ID (e.g., `02`) |
266
+ | `--step` | Yes | - | Step ID (e.g., `02.2`) |
267
+ | `--project-root` | No | `.` | Project root directory |
268
+ | `--format` | No | `text` | Output format |
269
+
270
+ **Exit Codes:**
271
+
272
+ | Code | Meaning |
273
+ |------|---------|
274
+ | 0 | Step recorded |
275
+ | 1 | Error (unknown step ID, registry not found, state file missing) |
276
+
277
+ **Validation:** The step ID is checked against `.claude/hooks/phase-steps-registry.json`. Unknown step IDs are rejected with exit code 1.
278
+
279
+ ---
280
+
281
+ ### 1.7 phase-observe
282
+
283
+ Record a workflow observation for a phase. Captures friction, gaps, successes, and patterns during TDD execution.
284
+
285
+ ```
286
+ devforgeai-validate phase-observe <story_id> --phase=<phase> --category=<cat> --note="<text>" [options]
287
+ ```
288
+
289
+ **Arguments:**
290
+
291
+ | Argument | Required | Description |
292
+ |----------|----------|-------------|
293
+ | `story_id` | Yes | Story identifier |
294
+
295
+ **Options:**
296
+
297
+ | Option | Required | Default | Description |
298
+ |--------|----------|---------|-------------|
299
+ | `--phase` | Yes | - | Phase ID |
300
+ | `--category` | Yes | - | One of: `friction`, `gap`, `success`, `pattern` |
301
+ | `--note` | Yes | - | Observation description (non-empty) |
302
+ | `--severity` | No | `medium` | One of: `low`, `medium`, `high` |
303
+ | `--project-root` | No | `.` | Project root directory |
304
+ | `--format` | No | `text` | Output format |
305
+
306
+ **Exit Codes:**
307
+
308
+ | Code | Meaning |
309
+ |------|---------|
310
+ | 0 | Observation recorded |
311
+ | 1 | State file not found |
312
+ | 2 | Invalid input (bad category, severity, or empty note) |
313
+
314
+ ---
315
+
316
+ ### 1.8 validate-dod
317
+
318
+ Validate Definition of Done completion for a story file. Detects autonomous deferrals and validates user approval markers.
319
+
320
+ ```
321
+ devforgeai-validate validate-dod <story_file> [options]
322
+ ```
323
+
324
+ **Arguments:**
325
+
326
+ | Argument | Required | Description |
327
+ |----------|----------|-------------|
328
+ | `story_file` | Yes | Path to `.story.md` file |
329
+
330
+ **Options:**
331
+
332
+ | Option | Default | Description |
333
+ |--------|---------|-------------|
334
+ | `--format` | `text` | Output format: `text` or `json` |
335
+ | `--project-root` | `.` | Project root directory |
336
+
337
+ **Exit Codes:**
338
+
339
+ | Code | Meaning |
340
+ |------|---------|
341
+ | 0 | Validation passed |
342
+ | 1 | Validation failed (violations found) |
343
+
344
+ **Violation Severities:**
345
+
346
+ | Severity | Description |
347
+ |----------|-------------|
348
+ | CRITICAL | Autonomous deferral without user approval; DoD marked `[x]` but missing from Implementation Notes |
349
+ | HIGH | Referenced stories do not exist; missing Implementation Notes section |
350
+ | MEDIUM | Deferred items with incomplete justifications |
351
+
352
+ ---
353
+
354
+ ### 1.9 Other Commands
355
+
356
+ | Command | Description | Exit Codes |
357
+ |---------|-------------|------------|
358
+ | `check-git --directory=.` | Validate Git repository availability | 0=valid, 1=not a repo |
359
+ | `validate-context --directory=.` | Check all 6 context files exist and are non-empty | 0=valid, 1=missing files |
360
+ | `check-hooks --operation=dev --status=success` | Check if hooks should trigger | 0=should trigger, 1=no trigger |
361
+ | `invoke-hooks --operation=dev --story=STORY-XXX` | Invoke feedback skill for operation | 0=success |
362
+ | `validate-installation --project-root=.` | Run 6 installation checks (CLI, context, hooks, PYTHONPATH, Git, settings) | 0=pass, 1=fail |
363
+ | `ast-grep scan <path>` | Semantic code analysis with ast-grep or grep fallback | 0=clean, 1=violations |
364
+ | `feedback-reindex --project-root=.` | Rebuild feedback index from all sources | 0=success |
365
+
366
+ ---
367
+
368
+ ## 2. Skill Interface
369
+
370
+ Skills are inline prompt expansions invoked by the orchestrator (opus). They are not background processes -- the orchestrator executes all skill phases sequentially.
371
+
372
+ ### Invocation Pattern
373
+
374
+ ```
375
+ Skill(command="<skill-name>")
376
+ ```
377
+
378
+ After invocation, the skill's `SKILL.md` content expands inline and the orchestrator executes each phase.
379
+
380
+ ### Available Skills
381
+
382
+ | Skill | Command | Location | Purpose |
383
+ |-------|---------|----------|---------|
384
+ | Implementing Stories | `implementing-stories` | `.claude/skills/implementing-stories/SKILL.md` | TDD development (10 phases, Red-Green-Refactor) |
385
+ | QA Validation | `devforgeai-qa` | `.claude/skills/devforgeai-qa/SKILL.md` | Quality validation (deep/light modes) |
386
+ | Documentation | `devforgeai-documentation` | `.claude/skills/devforgeai-documentation/SKILL.md` | Documentation generation |
387
+ | Story Creation | `devforgeai-story-creation` | `.claude/skills/devforgeai-story-creation/SKILL.md` | Story file creation with validation |
388
+ | Root Cause Diagnosis | `root-cause-diagnosis` | `.claude/skills/root-cause-diagnosis/SKILL.md` | 4-phase failure diagnosis (Capture-Investigate-Hypothesize-Prescribe) |
389
+ | Designing Systems | `designing-systems` | `.claude/skills/designing-systems/SKILL.md` | Architecture design |
390
+ | DevForgeAI Release | `devforgeai-release` | `.claude/skills/devforgeai-release/SKILL.md` | Release management |
391
+
392
+ ### Skill Execution Rules
393
+
394
+ 1. ALL phases execute in sequence -- no skipping, no reordering
395
+ 2. Each phase has mandatory validation checkpoints
396
+ 3. Pre-flight checks verify previous phase completion
397
+ 4. Only the user can authorize phase skipping via explicit instruction
398
+
399
+ ### Example: Implementing Stories Phases
400
+
401
+ | Phase | Name | Entry Gate | Exit Gate |
402
+ |-------|------|------------|-----------|
403
+ | 01 | Pre-Flight Validation | `phase-init` | `phase-complete --phase=01` |
404
+ | 02 | Test-First (Red) | `phase-check --from=01 --to=02` | `phase-complete --phase=02` |
405
+ | 03 | Implementation (Green) | `phase-check --from=02 --to=03` | `phase-complete --phase=03` |
406
+ | 04 | Refactoring | `phase-check --from=03 --to=04` | `phase-complete --phase=04` |
407
+ | 4.5 | AC Compliance (Post-Refactor) | `phase-check --from=04 --to=4.5` | `phase-complete --phase=4.5` |
408
+ | 05 | Integration & Validation | `phase-check --from=4.5 --to=05` | `phase-complete --phase=05` |
409
+ | 5.5 | AC Compliance (Post-Integration) | `phase-check --from=05 --to=5.5` | `phase-complete --phase=5.5` |
410
+ | 06 | Deferral Challenge | `phase-check --from=5.5 --to=06` | `phase-complete --phase=06` |
411
+ | 07 | DoD Update | `phase-check --from=06 --to=07` | `phase-complete --phase=07` |
412
+ | 08 | Git Workflow | `phase-check --from=07 --to=08` | `phase-complete --phase=08` |
413
+ | 09 | Feedback Hook | `phase-check --from=08 --to=09` | `phase-complete --phase=09` |
414
+ | 10 | Result Interpretation | `phase-check --from=09 --to=10` | `phase-complete --phase=10` |
415
+
416
+ ---
417
+
418
+ ## 3. Subagent Interface
419
+
420
+ Subagents are specialized agents delegated to by the orchestrator. Each subagent handles a single responsibility within a workflow phase.
421
+
422
+ ### Invocation Pattern
423
+
424
+ ```
425
+ Agent(subagent_type="<agent-name>", prompt="<task-description>")
426
+ ```
427
+
428
+ Alternatively, using the Task construct:
429
+
430
+ ```
431
+ Task(
432
+ subagent_type="<agent-name>",
433
+ description="<brief description>",
434
+ prompt="<detailed instructions>"
435
+ )
436
+ ```
437
+
438
+ ### Available Subagents
439
+
440
+ | Subagent | Phase(s) | Purpose |
441
+ |----------|----------|---------|
442
+ | `git-validator` | 01 | Validate Git repository state |
443
+ | `tech-stack-detector` | 01 | Detect and validate technology stack |
444
+ | `context-preservation-validator` | 01 | Validate context file integrity |
445
+ | `test-automator` | 02 | Generate failing tests (Red phase) |
446
+ | `backend-architect` | 03 | Implement backend code (Green phase) |
447
+ | `frontend-developer` | 03 | Implement frontend code (Green phase) |
448
+ | `context-validator` | 03 | Validate context compliance |
449
+ | `diagnostic-analyst` | 03 (conditional) | Root cause diagnosis on failures |
450
+ | `refactoring-specialist` | 04 | Refactor implementation |
451
+ | `code-reviewer` | 04 | Code quality review |
452
+ | `ac-compliance-verifier` | 4.5, 5.5 | Verify acceptance criteria compliance |
453
+ | `integration-tester` | 05 | Write and run integration tests |
454
+ | `deferral-validator` | 06 (conditional) | Validate deferral justifications |
455
+ | `framework-analyst` | 09 | Analyze workflow observations |
456
+ | `dev-result-interpreter` | 10 | Interpret and format dev results |
457
+
458
+ ### OR-Group Subagents
459
+
460
+ Some phases accept alternative subagents. Phase 03 requires **either** `backend-architect` OR `frontend-developer` (not both). The phase-check command supports OR-group validation.
461
+
462
+ ### Subagent Definition Files
463
+
464
+ All subagent definitions are located in `.claude/agents/`:
465
+
466
+ ```
467
+ .claude/agents/
468
+ backend-architect.md
469
+ code-reviewer.md
470
+ diagnostic-analyst.md
471
+ frontend-developer.md
472
+ integration-tester.md
473
+ refactoring-specialist.md
474
+ test-automator.md
475
+ ...
476
+ ```
477
+
478
+ ---
479
+
480
+ ## 4. Hook System
481
+
482
+ DevForgeAI uses Claude Code hooks for automatic phase enforcement. Hooks are configured in `.claude/settings.json` and execute shell scripts on specific events.
483
+
484
+ ### 4.1 SubagentStop Hook
485
+
486
+ **File:** `.claude/hooks/track-subagent-invocation.sh`
487
+
488
+ **Trigger:** `SubagentStop` event (fires after every subagent completes)
489
+
490
+ **Behavior:**
491
+ 1. Reads JSON from stdin containing `agent_type` field
492
+ 2. Filters out built-in agents (`Explore`, `Plan`, `Bash`, `general-purpose`)
493
+ 3. Validates `agent_type` format against `^[a-zA-Z0-9_-]+$` regex
494
+ 4. Finds the active story from the most recently modified `STORY-*-phase-state.json`
495
+ 5. Extracts `current_phase` from the state file
496
+ 6. Calls `devforgeai-validate phase-record` to record the invocation
497
+
498
+ **Exit Code:** Always 0 (non-blocking). Failures are logged to stderr only.
499
+
500
+ **Input Schema:**
501
+
502
+ ```json
503
+ {
504
+ "agent_type": "test-automator"
505
+ }
506
+ ```
507
+
508
+ ### 4.2 TaskCompleted Hook
509
+
510
+ **File:** `.claude/hooks/validate-step-completion.sh`
511
+
512
+ **Trigger:** `TaskCompleted` event (fires when a task is marked complete)
513
+
514
+ **Behavior:**
515
+ 1. Reads JSON from stdin containing `subject` field
516
+ 2. Checks if subject matches step pattern (`^Step [0-9]`)
517
+ 3. Extracts step ID (e.g., `"Step 02.2: test-automator invoked"` becomes `"02.2"`)
518
+ 4. Looks up the step in `phase-steps-registry.json`
519
+ 5. Skips conditional steps (`"conditional": true`)
520
+ 6. For non-conditional steps with a `subagent` field, checks if that subagent was invoked in the phase state
521
+ 7. Supports OR-logic for array subagent fields (any match passes)
522
+
523
+ **Exit Codes:**
524
+
525
+ | Code | Meaning |
526
+ |------|---------|
527
+ | 0 | Pass (step valid, no subagent required, conditional step, or lookup failed gracefully) |
528
+ | 2 | Block (required subagent was not invoked) |
529
+
530
+ **Input Schema:**
531
+
532
+ ```json
533
+ {
534
+ "subject": "Step 02.2: test-automator invoked"
535
+ }
536
+ ```
537
+
538
+ **Environment Variables:**
539
+
540
+ | Variable | Description |
541
+ |----------|-------------|
542
+ | `CLAUDE_PROJECT_DIR` | Project root override |
543
+ | `REGISTRY_PATH` | Override path to phase-steps-registry.json |
544
+ | `PHASE_STATE_PATH` | Override path to phase-state.json |
545
+
546
+ ### 4.3 Phase Steps Registry
547
+
548
+ **File:** `.claude/hooks/phase-steps-registry.json`
549
+
550
+ The registry defines all 72 steps across 12 phases (01-10, plus 4.5 and 5.5). Each step entry has:
551
+
552
+ ```json
553
+ {
554
+ "id": "02.2",
555
+ "check": "test-automator invoked",
556
+ "subagent": "test-automator",
557
+ "conditional": false
558
+ }
559
+ ```
560
+
561
+ **Step Entry Fields:**
562
+
563
+ | Field | Type | Description |
564
+ |-------|------|-------------|
565
+ | `id` | string | Unique step identifier (e.g., `"02.2"`, `"4.5.1"`) |
566
+ | `check` | string | Human-readable description of what the step validates |
567
+ | `subagent` | string, array, or null | Required subagent(s). `null` = no subagent check. Array = OR-logic. |
568
+ | `conditional` | boolean | If `true`, the step is skipped by the TaskCompleted hook |
569
+
570
+ **Phase Summary:**
571
+
572
+ | Phase | Name | Steps |
573
+ |-------|------|-------|
574
+ | 01 | Pre-Flight Validation | 8 steps (01.1 - 01.8) |
575
+ | 02 | Test-First (Red) | 7 steps (02.1 - 02.7) |
576
+ | 03 | Implementation (Green) | 7 steps (03.1 - 03.7) |
577
+ | 04 | Refactoring | 7 steps (04.1 - 04.7) |
578
+ | 4.5 | AC Compliance (Post-Refactor) | 4 steps (4.5.1 - 4.5.4) |
579
+ | 05 | Integration & Validation | 5 steps (05.1 - 05.5) |
580
+ | 5.5 | AC Compliance (Post-Integration) | 4 steps (5.5.1 - 5.5.4) |
581
+ | 06 | Deferral Challenge | 7 steps (06.1 - 06.7) |
582
+ | 07 | DoD Update | 5 steps (07.1 - 07.5) |
583
+ | 08 | Git Workflow | 6 steps (08.1 - 08.6) |
584
+ | 09 | Feedback Hook | 8 steps (09.1 - 09.8) |
585
+ | 10 | Result Interpretation | 4 steps (10.1 - 10.4) |
586
+
587
+ ---
588
+
589
+ ## 5. Phase State JSON Schema
590
+
591
+ Phase state files are stored in `devforgeai/workflows/` with the naming convention `STORY-XXX-phase-state.json` (dev) or `STORY-XXX-qa-phase-state.json` (QA).
592
+
593
+ ### Dev Workflow Schema
594
+
595
+ ```json
596
+ {
597
+ "story_id": "STORY-527",
598
+ "workflow_started": "2026-03-03T10:00:00+00:00",
599
+ "current_phase": "03",
600
+ "blocking_status": "none",
601
+ "phases": {
602
+ "01": {
603
+ "status": "completed",
604
+ "started_at": "2026-03-03T10:00:00+00:00",
605
+ "completed_at": "2026-03-03T10:05:00+00:00",
606
+ "checkpoint_passed": true,
607
+ "subagents_required": ["git-validator", "tech-stack-detector", "context-preservation-validator"],
608
+ "subagents_invoked": ["git-validator", "tech-stack-detector", "context-preservation-validator"],
609
+ "steps_completed": ["01.1", "01.2", "01.3", "01.4", "01.6", "01.7", "01.8"]
610
+ },
611
+ "02": {
612
+ "status": "completed",
613
+ "started_at": null,
614
+ "completed_at": "2026-03-03T10:15:00+00:00",
615
+ "checkpoint_passed": true,
616
+ "subagents_required": ["test-automator"],
617
+ "subagents_invoked": ["test-automator"],
618
+ "steps_completed": ["02.1", "02.2", "02.3", "02.4", "02.5", "02.6", "02.7"]
619
+ },
620
+ "03": {
621
+ "status": "in_progress",
622
+ "started_at": null,
623
+ "completed_at": null,
624
+ "checkpoint_passed": null,
625
+ "subagents_required": [["backend-architect", "frontend-developer"], "context-validator"],
626
+ "subagents_invoked": [],
627
+ "steps_completed": []
628
+ }
629
+ },
630
+ "observations": []
631
+ }
632
+ ```
633
+
634
+ ### Field Descriptions
635
+
636
+ | Field | Type | Description |
637
+ |-------|------|-------------|
638
+ | `story_id` | string | Story identifier (format: `STORY-NNN`) |
639
+ | `workflow_started` | string (ISO 8601) | Timestamp when workflow was initialized |
640
+ | `current_phase` | string | Current active phase ID |
641
+ | `blocking_status` | string | `"none"` or description of blocking issue |
642
+ | `phases` | object | Map of phase ID to phase data |
643
+ | `observations` | array | Workflow observations captured via `phase-observe` |
644
+
645
+ ### Phase Entry Fields
646
+
647
+ | Field | Type | Description |
648
+ |-------|------|-------------|
649
+ | `status` | string | `"pending"`, `"in_progress"`, or `"completed"` |
650
+ | `started_at` | string or null | ISO 8601 timestamp |
651
+ | `completed_at` | string or null | ISO 8601 timestamp |
652
+ | `checkpoint_passed` | boolean or null | Whether the phase checkpoint passed |
653
+ | `subagents_required` | array | Required subagents. Nested arrays denote OR-groups. |
654
+ | `subagents_invoked` | array of strings | Subagents that have been recorded for this phase |
655
+ | `steps_completed` | array of strings | Step IDs completed (validated against registry) |
656
+
657
+ ### Valid Phase IDs
658
+
659
+ **Dev workflow:** `01`, `02`, `03`, `04`, `4.5`, `05`, `5.5`, `06`, `07`, `08`, `09`, `10`
660
+
661
+ **QA workflow:** `00`, `01`, `1.5`, `02`, `03`, `04`
662
+
663
+ ### OR-Group Encoding
664
+
665
+ When a phase accepts alternative subagents, the `subagents_required` field uses a nested array:
666
+
667
+ ```json
668
+ {
669
+ "subagents_required": [["backend-architect", "frontend-developer"], "context-validator"]
670
+ }
671
+ ```
672
+
673
+ This means: (`backend-architect` OR `frontend-developer`) AND `context-validator`.
674
+
675
+ ### Observation Entry Fields
676
+
677
+ | Field | Type | Description |
678
+ |-------|------|-------------|
679
+ | `id` | string (UUID) | Unique observation identifier |
680
+ | `phase` | string | Phase ID when observation was captured |
681
+ | `category` | string | `"friction"`, `"gap"`, `"success"`, or `"pattern"` |
682
+ | `note` | string | Description of the observation |
683
+ | `severity` | string | `"low"`, `"medium"`, or `"high"` |
684
+ | `timestamp` | string (ISO 8601) | When observation was recorded |
685
+
686
+ ### File Locations
687
+
688
+ | Workflow | Path Pattern |
689
+ |----------|-------------|
690
+ | Dev | `devforgeai/workflows/STORY-XXX-phase-state.json` |
691
+ | QA | `devforgeai/workflows/STORY-XXX-qa-phase-state.json` |
692
+ | Custom | `devforgeai/workflows/STORY-XXX-{workflow}-phase-state.json` |
693
+
694
+ ### Concurrency
695
+
696
+ Phase state files use platform-aware file locking:
697
+ - **POSIX** (Linux, macOS, WSL): `fcntl` advisory locks
698
+ - **Windows**: `msvcrt` locking
699
+
700
+ All writes are atomic (write to temp file, then rename).
701
+
702
+ ---
703
+
704
+ ## Source Files
705
+
706
+ | Component | File |
707
+ |-----------|------|
708
+ | CLI entry point | `.claude/scripts/devforgeai_cli/cli.py` |
709
+ | Phase commands | `.claude/scripts/devforgeai_cli/commands/phase_commands.py` |
710
+ | PhaseState module | `.claude/scripts/devforgeai_cli/phase_state.py` |
711
+ | DoD validator | `.claude/scripts/devforgeai_cli/validators/dod_validator.py` |
712
+ | SubagentStop hook | `.claude/hooks/track-subagent-invocation.sh` |
713
+ | TaskCompleted hook | `.claude/hooks/validate-step-completion.sh` |
714
+ | Steps registry | `.claude/hooks/phase-steps-registry.json` |
715
+
716
+ ---
717
+
718
+ <!-- SECTION: assessing-entrepreneur START -->
719
+ ## Assessing Entrepreneur
720
+
721
+ The `assessing-entrepreneur` skill collects self-reported work-style preferences across 6 dimensions and produces a structured adaptive profile at `devforgeai/specs/business/user-profile.yaml`.
722
+
723
+ **Source:** `src/claude/skills/assessing-entrepreneur/SKILL.md` (196 lines)
724
+ **Story:** STORY-465 (Guided Self-Assessment Skill)
725
+ **Execution model:** Inline expansion (9 phases, executed sequentially by the orchestrator)
726
+
727
+ ### Skill Invocation
728
+
729
+ ```
730
+ Skill(command="assessing-entrepreneur")
731
+ ```
732
+
733
+ ### Command Interface
734
+
735
+ ```
736
+ /assess-me [--recalibrate]
737
+ ```
738
+
739
+ | Argument | Description |
740
+ |----------|-------------|
741
+ | _(none)_ | Full assessment. Creates a new `user-profile.yaml`. |
742
+ | `--recalibrate` | Re-runs the full questionnaire. Overwrites `user-profile.yaml` only; coaching history is preserved (BR-002). |
743
+
744
+ ### Workflow Phases
745
+
746
+ | Phase | Name | Description |
747
+ |-------|------|-------------|
748
+ | 1 | Disclaimer and Consent | Displays safety disclaimer; blocks data collection until user consents via AskUserQuestion |
749
+ | 2 | Work Style Preferences | Q1.1 (Daily Structure), Q1.2 (Environment), Q1.3 (Collaboration) |
750
+ | 3 | Task Completion Patterns | Q2.1 (Project Patterns), Q2.2 (Interruption Recovery) |
751
+ | 4 | Motivation Drivers | Q3.1 (Primary Drivers, multi-select), Q3.2 (Drop-off Points, multi-select) |
752
+ | 5 | Energy Management | Q4.1 (Peak Hours), Q4.2 (Recovery, multi-select) |
753
+ | 6 | Previous Attempts | Q5.1 (Experience), Q5.2 (Lessons, multi-select, conditional) |
754
+ | 7 | Self-Reported Challenges | Q6.1 (Primary, multi-select), Q6.2 (Support, multi-select) |
755
+ | 8 | Profile Generation | Invokes `entrepreneur-assessor` subagent to normalize responses |
756
+ | 9 | Results Summary | Displays profile, recommended adaptations, and next steps |
757
+
758
+ ### Questionnaire Interface
759
+
760
+ All questions use the AskUserQuestion tool:
761
+
762
+ ```
763
+ AskUserQuestion(
764
+ question: string,
765
+ header: string,
766
+ options: string[],
767
+ multiSelect?: boolean
768
+ )
769
+ ```
770
+
771
+ **Question inventory:** 13 questions across 6 dimensions.
772
+
773
+ | ID | Dimension | Header | Multi-Select |
774
+ |----|-----------|--------|-------------|
775
+ | Q1.1 | Work Style | Work Style - Daily Structure | No |
776
+ | Q1.2 | Work Style | Work Style - Environment | No |
777
+ | Q1.3 | Work Style | Work Style - Collaboration | No |
778
+ | Q2.1 | Task Completion | Task Completion - Project Patterns | No |
779
+ | Q2.2 | Task Completion | Task Completion - Interruption Recovery | No |
780
+ | Q3.1 | Motivation | Motivation - Primary Drivers | Yes |
781
+ | Q3.2 | Motivation | Motivation - Drop-off Points | Yes |
782
+ | Q4.1 | Energy Management | Energy Management - Peak Hours | No |
783
+ | Q4.2 | Energy Management | Energy Management - Recovery | Yes |
784
+ | Q5.1 | Previous Attempts | Previous Attempts - Experience | No |
785
+ | Q5.2 | Previous Attempts | Previous Attempts - Lessons | Yes |
786
+ | Q6.1 | Self-Reported Challenges | Self-Reported Challenges - Primary | Yes |
787
+ | Q6.2 | Self-Reported Challenges | Self-Reported Challenges - Support | Yes |
788
+
789
+ Q5.2 is conditional: only asked when the user reports previous experience in Q5.1.
790
+
791
+ ### Subagent Contract
792
+
793
+ **Invocation (Phase 8):**
794
+
795
+ ```
796
+ Task(
797
+ subagent_type="entrepreneur-assessor",
798
+ description="Normalize assessment responses into structured user profile",
799
+ prompt="Process the following self-reported assessment responses and generate
800
+ a structured user-profile. Responses: [collected responses from Phases 2-7].
801
+ Dimensions: Work Style, Task Completion, Motivation, Energy Management,
802
+ Previous Attempts, Self-Reported Challenges."
803
+ )
804
+ ```
805
+
806
+ **Source:** `src/claude/agents/entrepreneur-assessor.md` (128 lines)
807
+
808
+ **Tools:**
809
+
810
+ | Tool | Usage |
811
+ |------|-------|
812
+ | Read | Load reference files for adaptation frameworks |
813
+ | Glob | Discover existing profile files when updating |
814
+ | Grep | Search patterns in reference documentation |
815
+ | AskUserQuestion | Clarify ambiguous or missing responses only |
816
+
817
+ **Processing pipeline:**
818
+
819
+ 1. **Validate** -- Check all 6 dimensions have responses
820
+ 2. **Normalize** -- Map categorical to tags, multi-select to weighted lists, free-text to themes
821
+ 3. **Generate** -- Produce structured YAML profile
822
+ 4. **Cross-reference** -- Identify reinforcing or contradicting patterns across dimensions
823
+ 5. **Output** -- Write profile and return summary
824
+
825
+ ### Output Schema: Adaptive Profile
826
+
827
+ Written to `devforgeai/specs/business/user-profile.yaml`:
828
+
829
+ ```yaml
830
+ schema_version: "1.0"
831
+ created: "2026-02-21"
832
+ last_calibrated: "2026-02-21"
833
+
834
+ adaptive_profile:
835
+ task_chunk_size: micro # micro | standard | extended
836
+ session_length: short # short | medium | long
837
+ check_in_frequency: frequent # frequent | moderate | minimal
838
+ progress_visualization: per_task # per_task | daily | weekly
839
+ celebration_intensity: high # high | medium | low
840
+ reminder_style: specific # specific | balanced | gentle
841
+ overwhelm_prevention: strict # strict | moderate | open
842
+ ```
843
+
844
+ **Enum values:**
845
+
846
+ | Dimension | Values | Range |
847
+ |-----------|--------|-------|
848
+ | task_chunk_size | micro, standard, extended | 5-60 min per task |
849
+ | session_length | short, medium, long | 15-60 min per session |
850
+ | check_in_frequency | frequent, moderate, minimal | every 1-5 tasks |
851
+ | progress_visualization | per_task, daily, weekly | granularity of visual feedback |
852
+ | celebration_intensity | high, medium, low | every-completion to milestone-only |
853
+ | reminder_style | specific, balanced, gentle | specific-next-action to gentle-nudge |
854
+ | overwhelm_prevention | strict, moderate, open | next-3-tasks-only to full-roadmap |
855
+
856
+ ### Business Rules
857
+
858
+ | ID | Rule | Enforcement |
859
+ |----|------|-------------|
860
+ | BR-001 | `assessing-entrepreneur` (via `entrepreneur-assessor`) is the sole writer of `user-profile.yaml`. All other components are read-only consumers. | Subagent tool restrictions; coaching skill has no Write tool. |
861
+ | BR-002 | Recalibration (`--recalibrate`) overwrites `user-profile.yaml` only. Coaching session history is never modified. | Recalibration flow writes profile file; session log is not in scope. |
862
+ | BR-003 | The skill never diagnoses mental health conditions. All questions capture self-reported preferences only. | Phase 1 disclaimer; no diagnostic language in skill or subagent files. |
863
+
864
+ ### Reference Files
865
+
866
+ Loaded on demand during Phases 8-9:
867
+
868
+ | File | Purpose |
869
+ |------|---------|
870
+ | `references/work-style-questionnaire.md` | Detailed question sets for all 6 dimensions (Phases 2-7) |
871
+ | `references/adhd-adaptation-framework.md` | Neurodivergent-friendly coaching adaptations |
872
+ | `references/confidence-assessment-workflow.md` | Confidence calibration patterns |
873
+ | `references/plan-calibration-engine.md` | Plan complexity adjustment from profile data |
874
+
875
+ ### Integration Points
876
+
877
+ | Direction | Component | Description |
878
+ |-----------|-----------|-------------|
879
+ | Invoked by | `/assess-me` command | Primary user-facing entry point |
880
+ | Invoked by | `/assess-me --recalibrate` | Recalibration entry point |
881
+ | Invoked by | `/ideate` command | Optional assessment before ideation |
882
+ | Produces | `user-profile.yaml` | Consumed by downstream planning (BR-001: sole writer) |
883
+ | Consumed by | Plan calibration engine | Adjusts plan parameters based on adaptive profile |
884
+ | Consumed by | Coaching adaptation workflows | Adjusts coaching style (read-only per BR-001) |
885
+ <!-- SECTION: assessing-entrepreneur END -->
886
+
887
+ <!-- SECTION: coaching-entrepreneur START -->
888
+ ## Coaching Entrepreneur
889
+
890
+ The `coaching-entrepreneur` skill delivers adaptive business coaching by dynamically shifting between Coach mode (empathetic, encouraging) and Consultant mode (structured, deliverable-focused) based on user state and profile. The skill reads the adaptive profile from `user-profile.yaml` to calibrate persona blend intensity. It also reads a persistent session log to track emotional state across sessions and adapt tone at session start.
891
+
892
+ **Source:** `src/claude/skills/coaching-entrepreneur/SKILL.md` (target ≤1000 lines)
893
+ **Stories:** STORY-467 (Dynamic Persona Blend Engine), STORY-468 (Emotional State Tracking)
894
+ **Execution model:** Inline expansion (invoked via command interface)
895
+ **Dependency:** STORY-466 (Adaptive Profile Generation) — requires `user-profile.yaml` from `/assess-me`
896
+
897
+ ### Skill Invocation
898
+
899
+ ```
900
+ Skill(command="coaching-entrepreneur")
901
+ ```
902
+
903
+ ### Persona Definitions
904
+
905
+ #### Coach Mode
906
+ - **Activation:** User reports struggling, overwhelmed, or low confidence; or adaptive profile indicates high `celebration_intensity`
907
+ - **Language:** Empathetic, encouraging, validates effort, addresses self-doubt, celebrates incremental wins
908
+ - **Structure:** Narrative-driven, validates feelings first, then offers perspective
909
+
910
+ #### Consultant Mode
911
+ - **Activation:** User reports focused on deliverables; or adaptive profile indicates structured `reminder_style`; or topic requires technical framework
912
+ - **Language:** Structured, deliverable-focused, uses professional frameworks, numbered action lists
913
+ - **Structure:** Framework-first (e.g., SWOT, Lean Canvas), then concrete next steps
914
+
915
+ ### Subagent Contract
916
+
917
+ **Invocation:**
918
+
919
+ ```
920
+ Task(
921
+ subagent_type="business-coach",
922
+ description="Gather coaching context and deliver adaptive coaching",
923
+ prompt="User topic: [topic]. User state: [emotional_state].
924
+ Adaptive profile: [profile_dimensions].
925
+ Persona mode: [coach|consultant|blend].
926
+ Previous session emotional state: [prior_emotional_state|none]."
927
+ )
928
+ ```
929
+
930
+ **Source:** `src/claude/agents/business-coach.md` (target ≤500 lines)
931
+
932
+ **Tools:**
933
+
934
+ | Tool | Usage |
935
+ |------|-------|
936
+ | Read | Load user profile, session log, and reference frameworks |
937
+ | Write | Persist session log entry after emotional state is captured |
938
+ | Glob | Discover coaching reference materials |
939
+ | Grep | Search for relevant frameworks in references |
940
+ | AskUserQuestion | Gather coaching context and emotional state |
941
+
942
+ **Restrictions:** Profile writes are reserved for `assessing-entrepreneur` skill (BR-001). Session log writes are the only Write operation permitted for `business-coach`.
943
+
944
+ ### Profile Reading Integration
945
+
946
+ The skill reads `devforgeai/specs/business/user-profile.yaml` (if present) to determine:
947
+
948
+ | Profile Dimension | Influence on Coaching |
949
+ |-------------------|----------------------|
950
+ | `task_chunk_size` | Breaks goals into micro (Coach) or extended (Consultant) increments |
951
+ | `celebration_intensity` | High → Coach mode preferred; Low → Consultant mode preferred |
952
+ | `reminder_style` | Specific → Consultant; Gentle → Coach |
953
+ | `overwhelm_prevention` | Strict → Coach mode; Open → Consultant mode |
954
+ | `check_in_frequency` | Frequent → Coach mode; Minimal → Consultant mode |
955
+
956
+ **Fallback behavior:** If profile missing, defaults to Coach mode.
957
+
958
+ ### Emotional State Tracking
959
+
960
+ **Story:** STORY-468 | **Epic:** EPIC-072
961
+
962
+ The skill persists a session log at `devforgeai/specs/business/coaching/session-log.yaml` across Claude Code sessions. Each session entry records the user's self-reported emotional state and the date. At session start, the skill reads the most recent prior entry to calibrate its opening tone before prompting the user for the current state.
963
+
964
+ #### Session Log Schema
965
+
966
+ ```yaml
967
+ # devforgeai/specs/business/coaching/session-log.yaml
968
+ sessions:
969
+ - date: "2026-03-01"
970
+ emotional_state: energized
971
+ - date: "2026-03-04"
972
+ emotional_state: tired
973
+ override: focused # optional — user-supplied correction
974
+ ```
975
+
976
+ **Emotional state enum values:** `energized` | `focused` | `neutral` | `tired` | `frustrated` | `anxious` | `overwhelmed`
977
+
978
+ The `override` field is present only when the user explicitly corrects the logged state mid-session. It takes effect immediately and replaces the active state for that session's tone calibration.
979
+
980
+ #### Session Start Tone Adaptation
981
+
982
+ On each invocation, the skill:
983
+
984
+ 1. Reads `session-log.yaml` and extracts the most recent entry's `emotional_state` (or `override` if present).
985
+ 2. Uses that state to select an opening tone before asking the user about the current session.
986
+ 3. Asks the user to confirm or update their current emotional state via `AskUserQuestion`.
987
+ 4. Writes a new session entry with today's date and the confirmed state.
988
+
989
+ **Example — prior state `tired`, current session opens in Coach mode:**
990
+ ```
991
+ Last session you were tired. Let's check in — how are you feeling heading into today?
992
+ [ energized | focused | neutral | tired | frustrated | anxious | overwhelmed ]
993
+ ```
994
+
995
+ **Example — prior state `energized`, current session opens in Consultant mode:**
996
+ ```
997
+ Last session you were energized. Ready to dig into deliverables? What are we tackling today?
998
+ [ energized | focused | neutral | tired | frustrated | anxious | overwhelmed ]
999
+ ```
1000
+
1001
+ If `session-log.yaml` does not exist (first session), no prior-state prompt is shown and the skill asks directly for current state.
1002
+
1003
+ #### User Override Support
1004
+
1005
+ A user may correct their emotional state at any point during a session. The skill:
1006
+
1007
+ 1. Immediately adopts the new state for tone calibration.
1008
+ 2. Writes the override to the current session entry's `override` field.
1009
+ 3. Narrates the mode shift explicitly to the user.
1010
+
1011
+ Overrides are logged for continuity across sessions; the next session start reads `override` in preference to `emotional_state` when both are present.
1012
+
1013
+ #### Tone Mapping
1014
+
1015
+ | Emotional State | Default Opening Mode | Rationale |
1016
+ |-----------------|---------------------|-----------|
1017
+ | `energized` | Consultant | High-energy state suits structured, deliverable-focused work |
1018
+ | `focused` | Consultant | User is in execution mindset |
1019
+ | `neutral` | Blend | No strong signal; blend until user topic clarifies |
1020
+ | `tired` | Coach | Lower energy requires encouragement and reduced cognitive load |
1021
+ | `frustrated` | Coach | Validation before problem-solving |
1022
+ | `anxious` | Coach | Address self-doubt and overwhelm first |
1023
+ | `overwhelmed` | Coach | Strict micro-chunking; no frameworks until grounded |
1024
+
1025
+ ### Business Rules
1026
+
1027
+ | ID | Rule | Enforcement |
1028
+ |----|------|-------------|
1029
+ | BR-001 | Coaching skill reads `user-profile.yaml` only. Never writes user profile. | No Write tool for `user-profile.yaml`; profile writes reserved for `assessing-entrepreneur`. |
1030
+ | BR-002 | Persona mode transitions are explicit and visible to user. | Skill narrates persona shift. |
1031
+ | BR-003 | If user profile unavailable, default to Coach mode. Never infer emotional state from topic keywords. | Read() on profile path returns not-found → immediate fallback, no inference. |
1032
+ | BR-004 (STORY-468) | Emotional state is self-reported only. Never AI-inferred. | State captured exclusively via `AskUserQuestion`; no keyword scanning or sentiment analysis. |
1033
+ | BR-005 (STORY-468) | User overrides are respected immediately without negotiation. | On override signal, mode shifts in the same turn and override is written to session log. |
1034
+
1035
+ ### Reference Files
1036
+
1037
+ Loaded on demand during coaching sessions:
1038
+
1039
+ | File | Purpose |
1040
+ |------|---------|
1041
+ | `references/coach-persona-prompts.md` | Coach mode language templates |
1042
+ | `references/consultant-frameworks.md` | Structured coaching frameworks |
1043
+ | `references/persona-blend-rules.md` | Decision trees for mode selection |
1044
+
1045
+ ### Integration Points
1046
+
1047
+ | Direction | Component | Description |
1048
+ |-----------|-----------|-------------|
1049
+ | Depends on | `user-profile.yaml` (via STORY-466) | Reads adaptive profile; missing profile triggers fallback |
1050
+ | Depends on | `session-log.yaml` (STORY-468) | Reads prior emotional state for tone adaptation at session start |
1051
+ | Produces | `session-log.yaml` (STORY-468) | Writes session entry with confirmed emotional state and any user override |
1052
+ | Invoked by | Coaching commands | Primary user-facing entry point |
1053
+ | Produces | Coaching narratives (ephemeral) | Coaching content delivered in-session only; not persisted |
1054
+ <!-- SECTION: coaching-entrepreneur END -->