@dv.nghiem/flowdeck 0.3.9 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/README.md +13 -21
  2. package/dist/agents/code-explorer.d.ts.map +1 -1
  3. package/dist/agents/mapper.d.ts.map +1 -1
  4. package/dist/agents/orchestrator.d.ts.map +1 -1
  5. package/dist/agents/planner.d.ts.map +1 -1
  6. package/dist/agents/specialist.d.ts.map +1 -1
  7. package/dist/dashboard/server.mjs +12 -2
  8. package/dist/hooks/compaction-hook.d.ts +1 -2
  9. package/dist/hooks/compaction-hook.d.ts.map +1 -1
  10. package/dist/hooks/file-tracker.d.ts +6 -0
  11. package/dist/hooks/file-tracker.d.ts.map +1 -1
  12. package/dist/hooks/notifications.d.ts +73 -8
  13. package/dist/hooks/notifications.d.ts.map +1 -1
  14. package/dist/hooks/notifications.test.d.ts +14 -0
  15. package/dist/hooks/notifications.test.d.ts.map +1 -0
  16. package/dist/hooks/session-idle-hook.d.ts +5 -3
  17. package/dist/hooks/session-idle-hook.d.ts.map +1 -1
  18. package/dist/hooks/session-start.d.ts.map +1 -1
  19. package/dist/index.d.ts.map +1 -1
  20. package/dist/index.js +822 -796
  21. package/dist/lib/completion-validator.d.ts +51 -0
  22. package/dist/lib/completion-validator.d.ts.map +1 -0
  23. package/dist/lib/recommended-question.d.ts +24 -0
  24. package/dist/lib/recommended-question.d.ts.map +1 -0
  25. package/dist/lib/research-gate.d.ts +97 -0
  26. package/dist/lib/research-gate.d.ts.map +1 -0
  27. package/dist/lib/research-gate.test.d.ts +2 -0
  28. package/dist/lib/research-gate.test.d.ts.map +1 -0
  29. package/dist/mcp/index.d.ts +12 -2
  30. package/dist/mcp/index.d.ts.map +1 -1
  31. package/dist/services/codegraph.d.ts +36 -0
  32. package/dist/services/codegraph.d.ts.map +1 -0
  33. package/dist/services/codegraph.test.d.ts +2 -0
  34. package/dist/services/codegraph.test.d.ts.map +1 -0
  35. package/dist/services/question-guard.d.ts +4 -0
  36. package/dist/services/question-guard.d.ts.map +1 -1
  37. package/dist/services/recommended-question.test.d.ts +2 -0
  38. package/dist/services/recommended-question.test.d.ts.map +1 -0
  39. package/dist/services/supervisor-binding.d.ts +3 -1
  40. package/dist/services/supervisor-binding.d.ts.map +1 -1
  41. package/dist/tools/codebase-index.d.ts +30 -0
  42. package/dist/tools/codebase-index.d.ts.map +1 -0
  43. package/dist/tools/codebase-index.test.d.ts +2 -0
  44. package/dist/tools/codebase-index.test.d.ts.map +1 -0
  45. package/dist/tools/codegraph-tool.d.ts +3 -0
  46. package/dist/tools/codegraph-tool.d.ts.map +1 -0
  47. package/dist/tools/planning-state-lib.d.ts +23 -0
  48. package/dist/tools/planning-state-lib.d.ts.map +1 -1
  49. package/docs/agents/index.md +154 -0
  50. package/docs/commands/fd-ask.md +71 -39
  51. package/docs/commands/fd-checkpoint.md +63 -8
  52. package/docs/commands/fd-deploy-check.md +166 -9
  53. package/docs/commands/fd-design.md +101 -0
  54. package/docs/commands/fd-discuss.md +87 -20
  55. package/docs/commands/fd-doctor.md +100 -13
  56. package/docs/commands/fd-done.md +215 -0
  57. package/docs/commands/fd-execute.md +104 -0
  58. package/docs/commands/fd-fix-bug.md +144 -24
  59. package/docs/commands/fd-map-codebase.md +85 -21
  60. package/docs/commands/fd-multi-repo.md +155 -40
  61. package/docs/commands/fd-new-feature.md +63 -19
  62. package/docs/commands/fd-plan.md +80 -27
  63. package/docs/commands/fd-quick.md +143 -29
  64. package/docs/commands/fd-reflect.md +81 -13
  65. package/docs/commands/fd-resume.md +65 -8
  66. package/docs/commands/fd-status.md +80 -12
  67. package/docs/commands/fd-suggest.md +114 -0
  68. package/docs/commands/fd-translate-intent.md +69 -9
  69. package/docs/commands/fd-verify.md +71 -14
  70. package/docs/commands/fd-write-docs.md +121 -8
  71. package/docs/concepts/architecture.md +163 -0
  72. package/docs/concepts/governance.md +242 -0
  73. package/docs/concepts/intelligence.md +145 -0
  74. package/docs/concepts/multi-repo.md +227 -0
  75. package/docs/concepts/workflows.md +205 -0
  76. package/docs/configuration/index.md +208 -0
  77. package/docs/configuration/opencode-settings.md +98 -0
  78. package/docs/getting-started/first-project.md +126 -0
  79. package/docs/getting-started/installation.md +73 -0
  80. package/docs/getting-started/quick-start.md +74 -0
  81. package/docs/index.md +36 -72
  82. package/docs/reference/hooks.md +176 -0
  83. package/docs/reference/rules.md +109 -0
  84. package/docs/skills/code-review.md +47 -0
  85. package/docs/skills/index.md +148 -0
  86. package/docs/skills/planning.md +39 -0
  87. package/package.json +1 -1
  88. package/src/commands/fd-discuss.md +74 -10
  89. package/src/commands/fd-done.md +196 -0
  90. package/src/commands/fd-execute.md +43 -6
  91. package/src/commands/fd-fix-bug.md +43 -6
  92. package/src/commands/fd-map-codebase.md +99 -19
  93. package/src/commands/fd-new-feature.md +14 -5
  94. package/src/commands/fd-plan.md +38 -1
  95. package/src/commands/fd-quick.md +1 -1
  96. package/src/commands/fd-resume.md +1 -1
  97. package/src/commands/fd-status.md +1 -1
  98. package/src/commands/fd-verify.md +16 -2
  99. package/src/commands/fd-write-docs.md +30 -5
  100. package/src/skills/context-load/SKILL.md +1 -1
  101. package/dist/hooks/memory-hook.d.ts +0 -28
  102. package/dist/hooks/memory-hook.d.ts.map +0 -1
  103. package/dist/services/memory-store.d.ts +0 -73
  104. package/dist/services/memory-store.d.ts.map +0 -1
  105. package/dist/services/memory-store.test.d.ts +0 -2
  106. package/dist/services/memory-store.test.d.ts.map +0 -1
  107. package/dist/tools/memory-search.d.ts +0 -3
  108. package/dist/tools/memory-search.d.ts.map +0 -1
  109. package/dist/tools/memory-status.d.ts +0 -3
  110. package/dist/tools/memory-status.d.ts.map +0 -1
  111. package/docs/USER_GUIDE.md +0 -20
  112. package/docs/agents.md +0 -544
  113. package/docs/best-practices.md +0 -47
  114. package/docs/commands/fd-new-project.md +0 -24
  115. package/docs/commands.md +0 -557
  116. package/docs/configuration.md +0 -325
  117. package/docs/design-first-workflow.md +0 -94
  118. package/docs/feature-integration-architecture.md +0 -227
  119. package/docs/installation.md +0 -123
  120. package/docs/intelligence.md +0 -370
  121. package/docs/memory.md +0 -69
  122. package/docs/multi-repo.md +0 -201
  123. package/docs/notifications.md +0 -170
  124. package/docs/optimization-baseline.md +0 -21
  125. package/docs/quick-start.md +0 -197
  126. package/docs/rules.md +0 -432
  127. package/docs/skills.md +0 -417
  128. package/docs/workflows.md +0 -134
  129. package/src/commands/fd-new-project.md +0 -114
@@ -1,21 +1,108 @@
1
- ---
2
- description: Check FlowDeck installation and environment health
3
- ---
1
+ # /fd-doctor
4
2
 
5
- # Doctor
3
+ **Purpose:** Check FlowDeck installation and environment health across the system.
6
4
 
7
- Check FlowDeck installation and environment health.
5
+ ## Usage
8
6
 
9
- ## Checks
7
+ /fd-doctor
8
+
9
+ ## What Happens
10
+
11
+ The command runs a series of diagnostic checks and reports status for each:
12
+
13
+ 1. **OpenCode CLI** — runs `opencode --version`. Reports the version if found, warns if not found.
14
+
15
+ 2. **FlowDeck plugin registration** — reads `~/.config/opencode/opencode.json` (or `$OPENCODE_CONFIG_DIR/opencode.json`). Checks that `@dv.nghiem/flowdeck` is present in the `plugins` array.
16
+
17
+ 3. **Workspace state** — checks whether `.planning/STATE.md` exists in the current directory. Warns (non-fatal) if missing.
18
+
19
+ 4. **Codebase map** — checks whether `.codebase/ARCHITECTURE.md` exists. Notes if missing and suggests `/fd-map-codebase`.
20
+
21
+ 5. **Planning phases** — if STATE.md exists, parses the current phase and verifies that `.planning/phases/phase-N/` directory exists.
22
+
23
+ ## Notation Legend
24
+
25
+ The report uses check box notation:
10
26
 
11
- - OpenCode CLI version
12
- - FlowDeck plugin registration
13
- - Workspace state (STATE.md)
14
- - Codebase map (ARCHITECTURE.md)
15
- - Planning phases directory
27
+ | Notation | Meaning |
28
+ |----------|---------|
29
+ | `[x]` | Pass — check succeeded |
30
+ | `[ ]` | Failure — blocks healthy status |
31
+ | `[!]` | Warning — non-blocking issue |
16
32
 
17
- ## Example
33
+ The report closes with `✅ Environment looks healthy!` if no failures, otherwise `❌ Some issues found.`
18
34
 
35
+ ## Output / State
36
+
37
+ The command produces a formatted report using check box notation:
38
+
39
+ ```
40
+ # FlowDeck Doctor Report
41
+
42
+ - [x] OpenCode detected: <version>
43
+ - [x] FlowDeck registered in ~/.config/opencode/opencode.json
44
+ - [x] .planning/STATE.md exists in current workspace
45
+ - [!] No .codebase/ARCHITECTURE.md found (run /fd-map-codebase)
46
+ - [x] Phase directory .planning/phases/phase-1/ exists
47
+
48
+ ✅ Environment looks healthy!
49
+ ```
50
+
51
+ Notation:
52
+ - `[x]` — pass
53
+ - `[ ]` — failure (blocks healthy status)
54
+ - `[!]` — warning (non-blocking)
55
+
56
+ The report closes with `✅ Environment looks healthy!` if no failures, otherwise `❌ Some issues found.`
57
+
58
+ ## Output Example
59
+
60
+ When running `/fd-quick "implement user login"`, the autonomous execution begins with this classification announcement:
61
+
62
+ ```
63
+ Task classified as: feature
64
+ Stage sequence: discuss → plan → execute → verify
65
+ Requires design: no
66
+ Requires TDD: yes
67
+ Evidence used: 12 items from preflight exploration
68
+
69
+ Running /fd-quick autonomously. I will proceed through each stage and pause only
70
+ if I need approval, encounter a blocker, or complete the full sequence.
71
+ ```
72
+
73
+ ## Examples
74
+
75
+ **Run diagnostics:**
19
76
  ```
20
77
  /fd-doctor
21
- ```
78
+ ```
79
+
80
+ **Sample healthy output:**
81
+ ```
82
+ # FlowDeck Doctor Report
83
+
84
+ - [x] OpenCode detected: 1.2.3
85
+ - [x] FlowDeck registered in ~/.config/opencode/opencode.json
86
+ - [x] .planning/STATE.md exists in current workspace
87
+ - [x] .codebase/ARCHITECTURE.md found
88
+ - [x] Phase directory .planning/phases/phase-1/ exists
89
+
90
+ ✅ Environment looks healthy!
91
+ ```
92
+
93
+ **Sample output with issues:**
94
+ ```
95
+ # FlowDeck Doctor Report
96
+
97
+ - [x] OpenCode detected: 1.2.3
98
+ - [ ] FlowDeck NOT registered in ~/.config/opencode/opencode.json
99
+ - [x] .planning/STATE.md exists in current workspace
100
+ - [!] No .codebase/ARCHITECTURE.md found (run /fd-map-codebase)
101
+
102
+ ❌ Some issues found.
103
+ ```
104
+
105
+ ## Related Commands
106
+
107
+ - `/fd-map-codebase` — generate .codebase/ documentation if ARCHITECTURE.md is missing
108
+ - `/fd-status` — view current project state for more detail
@@ -0,0 +1,215 @@
1
+ # /fd-done
2
+
3
+ **Purpose:** Mark a feature or phase complete, validate readiness, finalize state, and refresh the codebase mapping.
4
+
5
+ ## Usage
6
+
7
+ /fd-done [--skip-verify] [--phase=N]
8
+
9
+ ## Arguments
10
+
11
+ - `--skip-verify` (optional) — allow closing without a prior `/fd-verify` run
12
+ - `--phase=N` (optional) — target a specific phase
13
+
14
+ ## What Happens
15
+
16
+ ### Step 0: Pre-flight
17
+
18
+ 1. Check `.planning/STATE.md` exists. If not: error "No active feature. Run `/fd-map-codebase` then `/fd-new-feature` to start a feature."
19
+ 2. Read current STATE.md using `planning_state action=read`.
20
+ 3. Record: `phase`, `status`, `plan_confirmed`, `blockers`, `steps_complete`, `requires_design_first`, `design_stage`, `design_approved`.
21
+
22
+ ### Step 1: Completion Readiness Validation
23
+
24
+ Before marking done, verify the workflow is in a finishable state.
25
+
26
+ | Check | Pass condition |
27
+ |-------|---------------|
28
+ | Plan confirmed | `plan_confirmed: true` |
29
+ | Not already done | `status != "complete"` |
30
+ | Work has started | `status != "planned"` OR `steps_complete` is non-empty |
31
+ | No active blockers | `blockers` list is empty or contains only `"none"` |
32
+ | Design gate (if required) | `requires_design_first: false` OR `design_stage: handoff_complete` AND `design_approved: true` OR `design_override: true` |
33
+
34
+ If any check fails, stop and report all failures. Do NOT update any state when validation fails.
35
+
36
+ **Verify check:**
37
+ - If `status != "verified"` and `--skip-verify` was NOT passed: warn that `/fd-verify` has not been run
38
+ - If `--skip-verify` is passed: log that verification was skipped
39
+
40
+ ### Step 2: Collect Completion Evidence
41
+
42
+ Gather files changed in this feature:
43
+ ```bash
44
+ git diff --name-only HEAD
45
+ git diff --name-only HEAD~1..HEAD 2>/dev/null || echo "(no commits yet)"
46
+ ```
47
+
48
+ Record `changedFiles[]` for the summary artifact.
49
+
50
+ ### Step 3: Codebase Mapping — Refresh or Reuse
51
+
52
+ Check codegraph state: `codegraph action=status`
53
+
54
+ - **If mapping is fresh** (indexed, `freshnessStatus: fresh`, no changed files since last index):
55
+ - Log: "[fd-done] Codebase mapping is current — skipping remap"
56
+ - Record: `mappingRefreshed: false`, `mappingFreshnessStatus: fresh`
57
+
58
+ - **If mapping is stale, absent, or changed files exist since last index:**
59
+ - Log: "[fd-done] Refreshing codebase mapping..."
60
+ - Run: `codegraph action=refresh agent=fd-done`
61
+ - Record result: `mappingRefreshed: true`, `mappingFreshnessStatus: fresh|stale`
62
+ - If refresh fails: log error, set `mappingFreshnessStatus: stale`, continue — do not abort
63
+
64
+ ### Step 4: Mark Feature Complete
65
+
66
+ Update STATE.md:
67
+ ```
68
+ planning_state action=update updates={
69
+ status: "complete",
70
+ last_action: "Phase <N> marked done via /fd-done",
71
+ next_action: "Run /fd-status to review project state, or /fd-new-feature to start the next phase"
72
+ }
73
+ ```
74
+
75
+ Additional fields to upsert:
76
+ ```
77
+ completed_at: "<ISO timestamp>"
78
+ completed_by: "fd-done"
79
+ verify_skipped: <true|false>
80
+ mapping_refreshed_at_done: "<ISO timestamp if refreshed, else skipped>"
81
+ mapping_freshness_at_done: "<fresh|stale|skipped>"
82
+ ```
83
+
84
+ ### Step 5: Write Completion Artifact
85
+
86
+ Write `.planning/phases/phase-<N>/DONE.md`:
87
+ ```markdown
88
+ # Phase <N> — Done
89
+
90
+ **Completed:** <ISO timestamp>
91
+ **Completed by:** fd-done
92
+ **Prior status:** <status before this run>
93
+ **Steps complete:** <list>
94
+
95
+ ## Verification
96
+
97
+ ✅ /fd-verify ran — all checks passed before closing
98
+ — OR —
99
+ ⚠️ /fd-verify not run — skipped by user (--skip-verify)
100
+ — OR —
101
+ ⚠️ /fd-verify not run — consider running before deploying
102
+
103
+ ## Codebase Mapping
104
+
105
+ ✅ Codebase mapping refreshed (status: fresh)
106
+ — OR —
107
+ ℹ️ Codebase mapping reused — already fresh (status: fresh)
108
+ — OR —
109
+ ⚠️ Codebase mapping refresh failed (status: stale)
110
+
111
+ ## Changed Files
112
+
113
+ - <file 1>
114
+ - <file 2>
115
+ ...
116
+
117
+ ## Next Steps
118
+
119
+ - Run `/fd-status` to see the full project state
120
+ - Run `/fd-new-feature` or increment the phase to start the next feature
121
+ - Run `/fd-deploy-check` if preparing for production deployment
122
+ ```
123
+
124
+ ### Step 6: Update ROADMAP.md (if present)
125
+
126
+ If `.planning/ROADMAP.md` exists:
127
+ - Find the entry for Phase N
128
+ - Update its status to `completed`
129
+ - Preserve all other phases unchanged
130
+
131
+ ### Step 7: Report Completion
132
+
133
+ Print final summary with completion timestamp, prior status, steps complete, changed files count, verification status, and mapping freshness.
134
+
135
+ ## Error Handling
136
+
137
+ - STATE.md not found → error with remediation ("No active feature. Run `/fd-map-codebase` then `/fd-new-feature` to start a feature.")
138
+ - Completion validation fails → list all failures, do not update state
139
+ - Mapping refresh fails → log error, continue with `mappingFreshnessStatus: stale`
140
+ - DONE.md write fails → log error, do not fail overall — state is already updated
141
+ - ROADMAP.md update fails → log error, do not fail overall
142
+
143
+ No partial state writes. Either the validation passes and full state is written, or nothing is written.
144
+
145
+ ## Output / State
146
+
147
+ - `.planning/STATE.md` — status set to `complete`
148
+ - `.planning/phases/phase-<N>/DONE.md` — completion artifact written
149
+ - `.planning/ROADMAP.md` — phase marked as completed (if exists)
150
+ - Codebase mapping refreshed (if needed)
151
+
152
+ ### DONE.md Artifact Format
153
+
154
+ The completion artifact at `.planning/phases/phase-<N>/DONE.md` uses this structure:
155
+
156
+ ```markdown
157
+ # Phase <N> — Done
158
+
159
+ **Completed:** <ISO timestamp>
160
+ **Completed by:** fd-done
161
+ **Prior status:** <status before this run>
162
+ **Steps complete:** <list>
163
+
164
+ ## Verification
165
+
166
+ ✅ /fd-verify ran — all checks passed before closing
167
+ — OR —
168
+ ⚠️ /fd-verify not run — skipped by user (--skip-verify)
169
+ — OR —
170
+ ⚠️ /fd-verify not run — consider running before deploying
171
+
172
+ ## Codebase Mapping
173
+
174
+ ✅ Codebase mapping refreshed (status: fresh)
175
+ — OR —
176
+ ℹ️ Codebase mapping reused — already fresh (status: fresh)
177
+ — OR —
178
+ ⚠️ Codebase mapping refresh failed (status: stale)
179
+
180
+ ## Changed Files
181
+
182
+ - <file 1>
183
+ - <file 2>
184
+ ...
185
+
186
+ ## Next Steps
187
+
188
+ - Run `/fd-status` to see the full project state
189
+ - Run `/fd-new-feature` or increment the phase to start the next feature
190
+ - Run `/fd-deploy-check` if preparing for production deployment
191
+ ```
192
+
193
+ ## Examples
194
+
195
+ **Mark current phase complete:**
196
+ ```
197
+ /fd-done
198
+ ```
199
+
200
+ **Mark specific phase complete:**
201
+ ```
202
+ /fd-done --phase=2
203
+ ```
204
+
205
+ **Close without prior verification:**
206
+ ```
207
+ /fd-done --skip-verify
208
+ ```
209
+
210
+ ## Related Commands
211
+
212
+ - `/fd-status` — review the completed project state
213
+ - `/fd-new-feature` — start the next feature
214
+ - `/fd-deploy-check` — pre-deployment checks after completing a phase
215
+ - `/fd-verify` — full verification before marking done (recommended)
@@ -0,0 +1,104 @@
1
+ # /fd-execute
2
+
3
+ **Purpose:** Implement the current phase's plan using TDD discipline and a parallel agent pipeline — delegates to specialist agents via orchestrator, cycles through RED-GREEN-REFACTOR per step, and updates STATE.md throughout.
4
+
5
+ ## Usage
6
+
7
+ /fd-execute [--phase=N] [--override]
8
+
9
+ ## What Happens
10
+
11
+ 1. **Research gate (before touching any code).**
12
+ - CodeGraph intelligence check (`codegraph action=check`)
13
+ - If indexed and fresh: use `codegraph_context` and `codegraph_impact`
14
+ - Standard pre-flight: verify STATE.md freshness, check CODEBASE_INDEX.md for changes since plan was written
15
+ - Reuse persisted research if fresh; run fresh pass and persist if stale
16
+ - Verify design handoff is complete if `requires_design_first: true`
17
+
18
+ 2. **Guard check.**
19
+ - Verify `.planning/` and `.codebase/` exist
20
+ - Verify `plan_confirmed: true` in STATE.md
21
+ - Verify PLAN.md exists in current phase directory
22
+ - If `requires_design_first: true`: require `design_stage: handoff_complete` and `design_approved: true` (or `--override` with logged reason)
23
+ - Initialize TDD state (`stage: behavior`, `cycle: 1`)
24
+
25
+ 3. **Load PLAN.md.** Parse tasks and identify which steps are already complete.
26
+
27
+ 4. **TDD cycle per step** (repeat for each incomplete step):
28
+
29
+ a. **Define behaviors** — spawn `@orchestrator` to generate behavior checklist from the step
30
+
31
+ b. **RED** — spawn `@tester` to write failing tests (tests MUST fail before implementation)
32
+
33
+ c. **Confirm RED** — run failing tests; block until tests fail
34
+
35
+ d. **GREEN** — spawn appropriate implementation agent (`@backend-coder`, `@frontend-coder`, or `@devops`) to write minimum code to pass the failing tests
36
+
37
+ e. **Confirm GREEN** — run tests; block until they pass; return to (d) if they fail
38
+
39
+ f. **REFACTOR** — clean up code (only if GREEN); block if not GREEN
40
+
41
+ g. **Verify** — run full test suite; revert refactoring if any test fails
42
+
43
+ h. **Review step** — spawn `@reviewer` to check quality, security, TDD discipline, >= 80% test coverage
44
+
45
+ i. **Update STATE.md** — mark step complete, increment TDD cycle
46
+
47
+ j. **Refresh codegraph index** — run `codegraph action=refresh agent=fd-execute` after each source change
48
+
49
+ 5. **Wave-based execution.** Wave 1 steps execute first; Wave 2 after Wave 1; Wave 3 after Wave 2. No intra-wave dependencies.
50
+
51
+ 6. **Complete phase.**
52
+ - Update phase status to `complete` in STATE.md
53
+ - Update ROADMAP.md progress
54
+ - Present completion summary
55
+
56
+ ## Output / State
57
+
58
+ STATE.md per-step update:
59
+ ```yaml
60
+ steps_complete: [1, 2]
61
+ steps_pending: [3, 4, 5]
62
+ last_action: "Step 2 TDD complete: [behavior] (RED→GREEN→REFACTOR)"
63
+ tdd:
64
+ stage: behavior
65
+ cycle: 2
66
+ behaviors_completed: 2
67
+ ```
68
+
69
+ STATE.md on full phase completion:
70
+ ```yaml
71
+ status: complete
72
+ last_action: "Phase N TDD complete — all steps finished"
73
+ tdd:
74
+ stage: complete
75
+ cycles_used: N
76
+ behaviors_completed: M
77
+ ```
78
+
79
+ ## Examples
80
+
81
+ ```
82
+ /fd-execute
83
+ ```
84
+
85
+ Run the TDD pipeline for all steps in the current phase's PLAN.md.
86
+
87
+ ```
88
+ /fd-execute --phase=2
89
+ ```
90
+
91
+ Execute phase 2's plan instead of the current phase.
92
+
93
+ ```
94
+ /fd-execute --override
95
+ ```
96
+
97
+ Override design-first requirement (with logged reason). Use sparingly.
98
+
99
+ ## Related Commands
100
+
101
+ - `/fd-plan` — create the plan before executing
102
+ - `/fd-verify` — run full verification after execution
103
+ - `/fd-resume` — reload state and continue if execution was interrupted
104
+ - `/fd-checkpoint` — save checkpoint before a long execution session
@@ -1,24 +1,144 @@
1
- ---
2
- description: Debug and fix a bug — scope analysis, mini-plan, implementation-agent fix, regression test, reviewer confirmation
3
- argument-hint: "[bug description or issue number]"
4
- ---
5
-
6
- Systematically debug and fix a bug using FlowDeck's structured approach.
7
-
8
- **What this does:**
9
- 1. Reads `.codebase/` for architecture context
10
- 2. Delegates to `@debug-specialist` to locate the root cause
11
- 3. Creates a mini-plan (fix + regression test)
12
- 4. Delegates fix to `@backend-coder`, `@frontend-coder`, or `@devops` based on scope
13
- 5. Delegates regression test writing to `@tester`
14
- 6. Verifies the fix via `@reviewer`
15
- 7. Writes a brief post-mortem to `.planning/bugs/`
16
-
17
- **Root cause first:** Does not implement a fix until root cause is confirmed — no symptom masking.
18
-
19
- ## What Next?
20
-
21
- 1. **Run code review** → `/fd-verify`
22
- 2. **Check for more bugs** → `/fd-fix-bug [next-issue]`
23
- 3. **Update documentation**`/fd-write-docs`
24
- 4. **Deploy check** → `/fd-deploy-check`
1
+ # /fd-fix-bug
2
+
3
+ **Purpose:** Diagnose, fix, and verify a bug using TDD-based workflow with regression test.
4
+
5
+ ## Usage
6
+
7
+ ```
8
+ /fd-fix-bug [bug description] [--scope=path]
9
+ ```
10
+
11
+ **Note:** `bug description` is required. `--scope=path` is optional.
12
+
13
+ ## Arguments
14
+
15
+ - `bug description` description of the bug or reproduction steps
16
+ - `--scope=path` (optional) — limit search scope to a specific path
17
+
18
+ ## What Happens
19
+
20
+ The workflow enforces the TDD cycle with guards at each transition:
21
+
22
+ ```
23
+ BEHAVIOR REDGREEN → REFACTOR → complete
24
+ ↑______________| |
25
+ (loop if needed) |
26
+ Only if GREEN
27
+ ```
28
+
29
+ ### Pre-flight: Research Gate
30
+
31
+ Before investigating the bug, inspect relevant context:
32
+
33
+ 1. Check codegraph availability (`codegraph action=check`). If indexed, use `codegraph_context`, `codegraph_callers`, `codegraph_callees`, and `codegraph_impact` for symbol-level understanding.
34
+ 2. Read `.planning/STATE.md` — current phase, freshness.
35
+ 3. Read `.codebase/FAILURES.json` — check for prior similar failures.
36
+ 4. Read `.codebase/ARCHITECTURE.md` and `.codebase/CODEGRAPH.md` if available.
37
+ 5. Check `research_fix-bug` evidence in STATE.md from prior research passes.
38
+ 6. Check recent changes via `git log --oneline -10` on relevant files.
39
+
40
+ If research is fresh (within 5 minutes), reuse it and log: "Research skipped — fresh evidence reused from prior pass."
41
+
42
+ ### Steps 1-2: Explore and Research
43
+
44
+ - **@researcher** investigates bug scope, traces root cause via ARCHITECTURE.md and source files.
45
+ - **@researcher** identifies all affected components and prior similar failures from FAILURES.json.
46
+ - Reproduce the bug with minimal case; document inputs and expected vs actual behavior.
47
+
48
+ ### Step 3: Define Behaviors
49
+
50
+ Write acceptance cases describing what should happen after the bug is fixed.
51
+
52
+ ### Step 4: Isolate Root Cause
53
+
54
+ - Trace the execution path.
55
+ - Read stack trace completely.
56
+ - Check recent changes: `git log --oneline -20 -- <file>`.
57
+ - Identify root cause (not symptom).
58
+
59
+ ### Step 5: RED — Write Failing Test
60
+
61
+ - **@tester** writes a regression test that reproduces the bug (it MUST fail right now).
62
+ - Show test output proving it fails.
63
+
64
+ **GUARD: Do NOT proceed if test does not fail RED.**
65
+
66
+ ### Step 6: GREEN — Implement Fix
67
+
68
+ - Implementation agent (`@backend-coder`, `@frontend-coder`, or `@devops`) implements the minimum code change that makes the regression test pass.
69
+ - Do not refactor yet.
70
+
71
+ **GUARD: Do NOT proceed if test does not pass GREEN.**
72
+
73
+ ### Step 7: REFACTOR
74
+
75
+ Clean up the implementation. Run tests again to confirm they still pass.
76
+
77
+ ### Steps 8-9: Full Suite and Review
78
+
79
+ - Run the full test suite. All tests must pass.
80
+ - **@reviewer** confirms fix is correct, no regressions, TDD discipline followed.
81
+
82
+ ### Step 10: Record
83
+
84
+ Append entry to `.codebase/FAILURES.json`:
85
+ ```json
86
+ {
87
+ "id": "F-<N>",
88
+ "type": "bug",
89
+ "description": "<bug description>",
90
+ "affected_paths": ["<files changed>"],
91
+ "root_cause": "<root cause>",
92
+ "fix_applied": "<fix summary>",
93
+ "regression_test": "<test file path>",
94
+ "resolved_at": "<timestamp>"
95
+ }
96
+ ```
97
+
98
+ Refresh the codegraph index after recording:
99
+ ```
100
+ codegraph action=refresh agent=fd-fix-bug
101
+ ```
102
+
103
+ ## Guards Summary
104
+
105
+ | Transition | Guard | If Violated |
106
+ |-----------|-------|-------------|
107
+ | behavior → red | Test written and fails | Block until test fails |
108
+ | red → green | Test exists and fails | Block until test passes |
109
+ | green → refactor | Tests are green | Block until green |
110
+ | refactor → complete | All tests pass | Block until all pass |
111
+
112
+ ## Error Handling
113
+
114
+ - **GUARD VIOLATION**: If implementation agent attempts to skip RED or GREEN phase, block and return to correct phase.
115
+ - **Override mechanism**: User can override with `/fd-fix-bug --override` but every override is logged in `override_log`.
116
+ - If root cause unclear: spawn `@debug-specialist` for deeper analysis.
117
+ - If fix breaks tests: revert, reassess root cause, never suppress error.
118
+
119
+ ## Output / State
120
+
121
+ - Root cause identified
122
+ - Fix applied to affected files
123
+ - Regression test created at `<test file path>`
124
+ - Reviewer sign-off received
125
+ - Entry appended to `.codebase/FAILURES.json`
126
+ - Codegraph index refreshed
127
+
128
+ ## Examples
129
+
130
+ **Fix a bug with description:**
131
+ ```
132
+ /fd-fix-bug "Login fails when password contains special characters"
133
+ ```
134
+
135
+ **Fix a bug scoped to a specific path:**
136
+ ```
137
+ /fd-fix-bug "Session timeout error" --scope=src/auth
138
+ ```
139
+
140
+ ## Related Commands
141
+
142
+ - `/fd-verify` — run full verification suite after fix
143
+ - `/fd-discuss` — investigate before filing a bug report
144
+ - `/fd-deploy-check` — run pre-deployment checks after fix is complete