feed-the-machine 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +268 -0
  3. package/bin/generate-manifest.mjs +210 -0
  4. package/bin/install.mjs +114 -0
  5. package/ftm/SKILL.md +88 -0
  6. package/ftm-audit/SKILL.md +146 -0
  7. package/ftm-audit/references/protocols/PROJECT-PATTERNS.md +91 -0
  8. package/ftm-audit/references/protocols/RUNTIME-WIRING.md +66 -0
  9. package/ftm-audit/references/protocols/WIRING-CONTRACTS.md +135 -0
  10. package/ftm-audit/references/strategies/AUTO-FIX-STRATEGIES.md +69 -0
  11. package/ftm-audit/references/templates/REPORT-FORMAT.md +96 -0
  12. package/ftm-audit/scripts/run-knip.sh +23 -0
  13. package/ftm-audit.yml +2 -0
  14. package/ftm-brainstorm/SKILL.md +379 -0
  15. package/ftm-brainstorm/evals/evals.json +100 -0
  16. package/ftm-brainstorm/evals/promptfoo.yaml +109 -0
  17. package/ftm-brainstorm/references/agent-prompts.md +224 -0
  18. package/ftm-brainstorm/references/plan-template.md +121 -0
  19. package/ftm-brainstorm.yml +2 -0
  20. package/ftm-browse/SKILL.md +415 -0
  21. package/ftm-browse/daemon/browser-manager.ts +206 -0
  22. package/ftm-browse/daemon/bun.lock +30 -0
  23. package/ftm-browse/daemon/cli.ts +347 -0
  24. package/ftm-browse/daemon/commands.ts +410 -0
  25. package/ftm-browse/daemon/main.ts +357 -0
  26. package/ftm-browse/daemon/package.json +17 -0
  27. package/ftm-browse/daemon/server.ts +189 -0
  28. package/ftm-browse/daemon/snapshot.ts +519 -0
  29. package/ftm-browse/daemon/tsconfig.json +22 -0
  30. package/ftm-browse.yml +4 -0
  31. package/ftm-codex-gate/SKILL.md +302 -0
  32. package/ftm-codex-gate.yml +2 -0
  33. package/ftm-config/SKILL.md +310 -0
  34. package/ftm-config.default.yml +80 -0
  35. package/ftm-config.yml +2 -0
  36. package/ftm-council/SKILL.md +132 -0
  37. package/ftm-council/references/prompts/CLAUDE-INVESTIGATION.md +60 -0
  38. package/ftm-council/references/prompts/CODEX-INVESTIGATION.md +58 -0
  39. package/ftm-council/references/prompts/GEMINI-INVESTIGATION.md +58 -0
  40. package/ftm-council/references/prompts/REBUTTAL-TEMPLATE.md +57 -0
  41. package/ftm-council/references/protocols/PREREQUISITES.md +47 -0
  42. package/ftm-council/references/protocols/STEP-0-FRAMING.md +46 -0
  43. package/ftm-council.yml +2 -0
  44. package/ftm-dashboard.yml +4 -0
  45. package/ftm-debug/SKILL.md +146 -0
  46. package/ftm-debug/references/phases/PHASE-0-INTAKE.md +58 -0
  47. package/ftm-debug/references/phases/PHASE-1-TRIAGE.md +46 -0
  48. package/ftm-debug/references/phases/PHASE-2-WAR-ROOM-AGENTS.md +279 -0
  49. package/ftm-debug/references/phases/PHASE-3-TO-6-EXECUTION.md +436 -0
  50. package/ftm-debug/references/protocols/BLACKBOARD.md +86 -0
  51. package/ftm-debug/references/protocols/EDGE-CASES.md +103 -0
  52. package/ftm-debug.yml +2 -0
  53. package/ftm-diagram/SKILL.md +233 -0
  54. package/ftm-diagram.yml +2 -0
  55. package/ftm-executor/SKILL.md +657 -0
  56. package/ftm-executor/references/STYLE-TEMPLATE.md +73 -0
  57. package/ftm-executor/references/phases/PHASE-0-VERIFICATION.md +62 -0
  58. package/ftm-executor/references/phases/PHASE-2-AGENT-ASSEMBLY.md +34 -0
  59. package/ftm-executor/references/phases/PHASE-3-WORKTREES.md +38 -0
  60. package/ftm-executor/references/phases/PHASE-4-5-AUDIT.md +72 -0
  61. package/ftm-executor/references/phases/PHASE-4-DISPATCH.md +66 -0
  62. package/ftm-executor/references/phases/PHASE-5-5-CODEX-GATE.md +73 -0
  63. package/ftm-executor/references/protocols/DOCUMENTATION-BOOTSTRAP.md +36 -0
  64. package/ftm-executor/references/protocols/MODEL-PROFILE.md +44 -0
  65. package/ftm-executor/references/protocols/PROGRESS-TRACKING.md +66 -0
  66. package/ftm-executor/runtime/ftm-runtime.mjs +252 -0
  67. package/ftm-executor/runtime/package.json +8 -0
  68. package/ftm-executor.yml +2 -0
  69. package/ftm-git/SKILL.md +195 -0
  70. package/ftm-git/evals/evals.json +26 -0
  71. package/ftm-git/evals/promptfoo.yaml +75 -0
  72. package/ftm-git/hooks/post-commit-experience.sh +92 -0
  73. package/ftm-git/references/patterns/SECRET-PATTERNS.md +104 -0
  74. package/ftm-git/references/protocols/REMEDIATION.md +139 -0
  75. package/ftm-git/scripts/pre-commit-secrets.sh +110 -0
  76. package/ftm-git.yml +2 -0
  77. package/ftm-intent/SKILL.md +198 -0
  78. package/ftm-intent.yml +2 -0
  79. package/ftm-map.yml +2 -0
  80. package/ftm-mind/SKILL.md +986 -0
  81. package/ftm-mind/evals/promptfoo.yaml +142 -0
  82. package/ftm-mind/references/blackboard-schema.md +328 -0
  83. package/ftm-mind/references/complexity-guide.md +110 -0
  84. package/ftm-mind/references/event-registry.md +299 -0
  85. package/ftm-mind/references/mcp-inventory.md +296 -0
  86. package/ftm-mind/references/protocols/COMPLEXITY-SIZING.md +72 -0
  87. package/ftm-mind/references/protocols/MCP-HEURISTICS.md +32 -0
  88. package/ftm-mind/references/protocols/PLAN-APPROVAL.md +80 -0
  89. package/ftm-mind/references/reflexion-protocol.md +249 -0
  90. package/ftm-mind/references/routing/SCENARIOS.md +22 -0
  91. package/ftm-mind/references/routing-scenarios.md +35 -0
  92. package/ftm-mind.yml +2 -0
  93. package/ftm-pause/SKILL.md +133 -0
  94. package/ftm-pause/references/protocols/SKILL-RESTORE-PROTOCOLS.md +186 -0
  95. package/ftm-pause/references/protocols/VALIDATION.md +80 -0
  96. package/ftm-pause.yml +2 -0
  97. package/ftm-researcher.yml +2 -0
  98. package/ftm-resume/SKILL.md +166 -0
  99. package/ftm-resume/references/protocols/VALIDATION.md +172 -0
  100. package/ftm-resume.yml +2 -0
  101. package/ftm-retro/SKILL.md +189 -0
  102. package/ftm-retro/references/protocols/SCORING-RUBRICS.md +89 -0
  103. package/ftm-retro/references/templates/REPORT-FORMAT.md +109 -0
  104. package/ftm-retro.yml +2 -0
  105. package/ftm-routine.yml +4 -0
  106. package/ftm-state/blackboard/context.json +23 -0
  107. package/ftm-state/blackboard/experiences/index.json +9 -0
  108. package/ftm-state/blackboard/patterns.json +6 -0
  109. package/ftm-state/schemas/context.schema.json +130 -0
  110. package/ftm-state/schemas/experience-index.schema.json +77 -0
  111. package/ftm-state/schemas/experience.schema.json +78 -0
  112. package/ftm-state/schemas/patterns.schema.json +44 -0
  113. package/ftm-upgrade/SKILL.md +153 -0
  114. package/ftm-upgrade/scripts/check-version.sh +76 -0
  115. package/ftm-upgrade/scripts/upgrade.sh +143 -0
  116. package/ftm-upgrade.yml +2 -0
  117. package/ftm.yml +2 -0
  118. package/install.sh +102 -0
  119. package/package.json +74 -0
  120. package/uninstall.sh +25 -0
@@ -0,0 +1,657 @@
1
+ ---
2
+ name: ftm-executor
3
+ description: Autonomous plan execution engine. Takes any plan document and executes it end-to-end with a dynamically assembled agent team — analyzing tasks, creating purpose-built agents, dispatching them in parallel worktrees, and running each through a commit-review-fix loop until complete. Use this skill whenever the user wants to execute a plan, run a plan doc, launch an agent team on tasks, or says things like "execute this plan", "run this", "launch agents on this doc", "take this plan and go", or points to a plan file and wants it implemented autonomously. Even if they just paste a plan path and say "go" — this is the skill.
4
+ ---
5
+
6
+ ## Events
7
+
8
+ ### Emits
9
+ - `task_received` — when a new task is acknowledged and added to the execution queue
10
+ - `plan_generated` — when a plan document is created or validated and ready for review
11
+ - `plan_approved` — when the user confirms a plan and execution is authorized to begin
12
+ - `code_changed` — when files are modified in a worktree (pre-commit state)
13
+ - `code_committed` — when a git commit is successfully made in any worktree
14
+ - `test_passed` — when the test suite passes (post-task verification or full-suite run)
15
+ - `test_failed` — when the test suite fails during post-task verification or regression check
16
+ - `task_completed` — when a task passes all verification gates (tests, audit, Codex gate)
17
+ - `error_encountered` — when an unexpected error occurs that halts or disrupts a task or wave
18
+
19
+ ### Listens To
20
+ - `plan_approved` — begin Phase 3 worktree setup and dispatch agents for the first wave
21
+
22
+ ## Blackboard Read
23
+
24
+ Before starting, load context from the blackboard:
25
+
26
+ 1. Read `/Users/kioja.kudumu/.claude/ftm-state/blackboard/context.json` — check current_task, recent_decisions, active_constraints
27
+ 2. Read `/Users/kioja.kudumu/.claude/ftm-state/blackboard/experiences/index.json` — filter entries by task_type matching plan tasks and tags overlapping with the plan domain
28
+ 3. Load top 3-5 matching experience files for relevant lessons on agent performance and timing
29
+ 4. Read `/Users/kioja.kudumu/.claude/ftm-state/blackboard/patterns.json` — check execution_patterns for agent performance and timing accuracy patterns
30
+
31
+ If index.json is empty or no matches found, proceed normally without experience-informed shortcuts.
32
+
33
+ # Plan Executor
34
+
35
+ Autonomous agent-team orchestrator for plan documents. You read the plan, assemble the right team, give each agent its own worktree, and let them rip through tasks in a commit-review-fix loop until everything is done.
36
+
37
+ ## Why This Exists
38
+
39
+ Executing a multi-task plan manually means: read plan, pick a task, do it, commit, review, fix, repeat — while also tracking dependencies and parallelism yourself. That's slow and error-prone. This skill automates the entire thing by treating the plan as a job spec and dynamically building the team to fulfill it.
40
+
41
+ ## The Process
42
+
43
+ ### Phase 0: Plan Requirement Gate
44
+
45
+ **Before anything else, verify that a plan document exists and has been approved by the user.**
46
+
47
+ This gate exists because the executor's entire value comes from structured, parallel execution of a well-defined plan. Without a plan, you're just grinding through code changes sequentially — which is what ftm-mind's direct action path does, and it's worse at it than a focused engineer because it lacks the user's judgment about ordering and priorities.
48
+
49
+ **Check for a plan:**
50
+
51
+ 1. Was a plan path provided? (e.g., the user said "execute ~/.claude/plans/foo.md" or ftm-mind routed with a plan reference)
52
+ 2. If yes, read the plan and proceed to Phase 0.5.
53
+ 3. If no plan path was provided, **do not start coding**. Instead:
54
+
55
+ a. Read the user's request and the codebase context passed from ftm-mind.
56
+ b. Generate a structured plan document with numbered tasks, file lists, dependencies, acceptance criteria, and verification steps.
57
+ c. Present the plan to the user for approval:
58
+
59
+ ```
60
+ I need a plan before I can execute. Here's what I'd propose:
61
+
62
+ 1. [ ] [task description] → [files] | verify: [method]
63
+ 2. [ ] [task description] → [files] | verify: [method]
64
+ 3. [ ] [task description] → [files] | verify: [method]
65
+ ...
66
+
67
+ Approve? Or tell me what to change.
68
+ ```
69
+
70
+ d. Wait for user approval. Parse their response the same way ftm-mind's Interactive Plan Approval handles it (approve, skip N, modify step N, deny).
71
+ e. Only after approval, save the plan to `~/.claude/plans/` and proceed to Phase 0.5.
72
+
73
+ **Why this gate matters**: The Jira rerouting incident showed what happens without it — the executor (or mind acting as executor) jumped straight into reading files and making 15+ edits across a 1700-line file without ever presenting a plan. The user never got to say "wait, also draft a Slack message to Mo" or "check with the ARIA team about epic assignment first" or "actually, don't change the sprint logic yet." By the time the user saw the changes, 2 minutes of grinding had already happened in the wrong direction. A 30-second plan would have caught all of this.
74
+
75
+ ---
76
+
77
+ ### Phase 0.5: Plan Verification Gate
78
+
79
+ **Before executing anything, validate the plan.** A bad plan wastes every agent's time. This gate catches structural problems, missing dependencies, and unrealistic scope before any code is written.
80
+
81
+ Spawn a **Plan Checker** agent to verify the plan:
82
+
83
+ ```
84
+ You are a plan quality checker. Analyze this implementation plan and report issues.
85
+ Do NOT implement anything — just verify the plan is sound.
86
+
87
+ Plan path: [path]
88
+
89
+ Check these dimensions:
90
+
91
+ 1. STRUCTURAL INTEGRITY
92
+ - Every task has: description, files list, dependencies, acceptance criteria
93
+ - Task numbering is consistent (no gaps, no duplicates)
94
+ - Dependencies reference valid task numbers
95
+ - No circular dependencies (Task A depends on B, B depends on A)
96
+
97
+ 2. DEPENDENCY GRAPH VALIDITY
98
+ - Build the full dependency graph
99
+ - Verify all referenced tasks exist
100
+ - Check for implicit dependencies (two tasks modifying the same file
101
+ but not declared as dependent)
102
+ - Flag tasks with too many dependencies (>3 usually means bad decomposition)
103
+
104
+ 3. FILE CONFLICT DETECTION
105
+ - Map every task to its file list
106
+ - Flag any files touched by multiple tasks in the same wave
107
+ - These MUST be sequential, not parallel — if the plan puts them
108
+ in the same wave, that's a bug
109
+
110
+ 4. SCOPE REASONABLENESS
111
+ - Flag tasks that touch >10 files (probably too big for one agent)
112
+ - Flag tasks with vague acceptance criteria ("make it work", "looks good")
113
+ - Flag tasks with no verification steps
114
+
115
+ 5. PROJECT COMPATIBILITY
116
+ - Check that file paths reference real directories in the project
117
+ - Verify the tech stack matches what the plan assumes
118
+ - Check that dependencies/libraries the plan references are installed
119
+ or listed in package.json/requirements.txt
120
+
121
+ Return a structured report:
122
+
123
+ PASS — plan is sound, proceed to execution
124
+ WARN — issues found but execution can proceed (list warnings)
125
+ FAIL — critical issues that must be fixed before execution (list blockers)
126
+
127
+ For FAIL findings, suggest specific fixes.
128
+ ```
129
+
130
+ **Interpret the result:**
131
+ - **PASS**: Proceed to Phase 1
132
+ - **WARN**: Show warnings to user, proceed unless they object
133
+ - **FAIL**: Present blockers and suggested fixes. Ask user: fix the plan and re-run, or override and execute anyway?
134
+
135
+ If the plan checker finds file conflicts between tasks in the same wave, automatically restructure the wave ordering to make conflicting tasks sequential. Report the change.
136
+
137
+ ---
138
+
139
+ ### Phase 0.7: Load Model Profile
140
+
141
+ Read `~/.claude/ftm-config.yml` to determine which models to use for agent dispatch. If the file doesn't exist, use balanced defaults:
142
+ - Planning agents: opus
143
+ - Execution agents: sonnet
144
+ - Review/audit agents: sonnet
145
+
146
+ When spawning agents in subsequent phases, pass the `model` parameter based on the agent's role:
147
+ - Phase 2 (team assembly / plan checking): use `planning` model
148
+ - Phase 4 (task execution): use `execution` model
149
+ - Phase 4.5 (audit): use `review` model
150
+
151
+ If the profile specifies `inherit`, omit the `model` parameter (uses session default).
152
+
153
+ ---
154
+
155
+ ### Phase 1: Analyze the Plan
156
+
157
+ Read the plan document and extract:
158
+
159
+ 1. **All tasks** — number, description, files touched, dependencies
160
+ 2. **Dependency graph** — which tasks block which (the plan usually states this)
161
+ 3. **Domain clusters** — group tasks by what kind of work they are (frontend, backend, infra, testing, styling, etc.)
162
+ 4. **Parallelism opportunities** — independent tasks or independent clusters that can run simultaneously
163
+
164
+ Output a brief execution summary before proceeding:
165
+ ```
166
+ Plan: [title]
167
+ Tasks: [N] total
168
+ Agents needed: [list with reasoning]
169
+ Parallel waves:
170
+ Wave 1 (independent): Tasks 1, 2, 3, 4
171
+ Wave 2 (depends on wave 1): Tasks 5, 6, 7
172
+ Wave 3: Tasks 8-14
173
+ ...
174
+ Final: Task [N] (integration/cleanup)
175
+ ```
176
+
177
+ ### Phase 1.5: Documentation Layer Bootstrap
178
+
179
+ Before dispatching any agents, check if the project has the required documentation layer. If any of these files are missing, create them.
180
+
181
+ **Check for and create if missing:**
182
+ 1. **INTENT.md** (project root) — If missing, bootstrap from the plan's Vision and Architecture Decisions sections. Use the ftm-intent skill's root template format.
183
+ 2. **ARCHITECTURE.mmd** (project root) — If missing, bootstrap by scanning the codebase for modules and their import relationships. Use the ftm-diagram skill's root template format.
184
+ 3. **STYLE.md** (project root) — If missing, copy from `~/.claude/skills/ftm-executor/references/STYLE-TEMPLATE.md` into the project root.
185
+ 4. **DEBUG.md** (project root) — If missing, create with a header:
186
+ ```markdown
187
+ # Debug Log
188
+
189
+ Failed approaches and their outcomes. Codex and Claude append here — never retry what's already logged.
190
+ ```
191
+
192
+ This bootstrap runs once at the start of execution. If the files already exist, skip this phase entirely.
193
+
194
+ ---
195
+
196
+ ### Phase 2: Assemble the Agent Team
197
+
198
+ For each domain cluster, you need an agent. Here's how to pick or create them:
199
+
200
+ #### Check existing agents first
201
+
202
+ Look at the available agent types (the ones in the Agent tool). Map each task cluster to the best fit:
203
+
204
+ | Domain | Likely Agent |
205
+ |--------|-------------|
206
+ | React/UI/CSS/components | frontend-developer |
207
+ | API/server/database | backend-architect |
208
+ | CI/CD/deploy/infra | devops-automator |
209
+ | Tests/coverage | test-writer-fixer |
210
+ | Mobile/native | mobile-app-builder |
211
+ | AI/ML features | ai-engineer |
212
+ | General coding | general-purpose |
213
+
214
+ #### When no existing agent fits
215
+
216
+ If a task cluster requires specialized knowledge that none of the standard agents cover well — for example, "theme system with CSS custom properties and dark mode" or "WebSocket terminal integration" — create a purpose-built agent prompt.
217
+
218
+ Write a focused agent definition that includes:
219
+ - **Domain expertise**: What this agent knows deeply
220
+ - **Task context**: The specific tasks from the plan it will handle
221
+ - **Standards**: Coding conventions from the project (infer from existing code)
222
+ - **Constraints**: Don't touch files outside your scope
223
+
224
+ Store these as reference prompts in the skill workspace so they can be reused. The prompt becomes the `prompt` parameter when spawning the agent.
225
+
226
+ The goal is that over time, your agent library grows with battle-tested specialists. A "theme-engineer" agent created for one project's CSS system can be reused next time themes come up.
227
+
228
+ ### Phase 3: Set Up Worktrees
229
+
230
+ Each agent gets its own isolated worktree so they don't step on each other's changes.
231
+
232
+ For each agent in the current wave:
233
+
234
+ 1. Create a worktree branch: `plan-exec/<agent-name>` (e.g., `plan-exec/frontend-tasks-1-4`)
235
+ 2. Use git worktree to create isolation:
236
+ ```bash
237
+ git worktree add .worktrees/plan-exec-<agent-name> -b plan-exec/<agent-name>
238
+ ```
239
+ 3. Run any project setup (npm install, etc.) in the worktree
240
+ 4. Verify the worktree starts clean (tests pass or at least build succeeds)
241
+
242
+ Make sure `.worktrees/` is in `.gitignore` first. If it's not, add it.
243
+
244
+ ### Phase 3.5: Initialize Progress Tracking
245
+
246
+ If `progress_tracking` is enabled in `~/.claude/ftm-config.yml` (default: true), create a `PROGRESS.md` file in the project root that gets updated after every significant event. This gives visibility into long-running executions without interrupting them.
247
+
248
+ **Create the initial file:**
249
+
250
+ ```markdown
251
+ # FTM Executor — Progress
252
+
253
+ **Plan:** [plan title]
254
+ **Started:** [timestamp]
255
+ **Status:** IN PROGRESS
256
+
257
+ ## Execution Summary
258
+ | Wave | Tasks | Status | Started | Completed |
259
+ |------|-------|--------|---------|-----------|
260
+ | 1 | [task list] | PENDING | — | — |
261
+ | 2 | [task list] | PENDING | — | — |
262
+ | ... | | | | |
263
+
264
+ ## Task Status
265
+ | # | Title | Agent | Status | Audit | Notes |
266
+ |---|-------|-------|--------|-------|-------|
267
+ | 1 | [title] | [agent] | PENDING | — | |
268
+ | 2 | [title] | [agent] | PENDING | — | |
269
+ | ... | | | | | |
270
+
271
+ ## Activity Log
272
+ [reverse chronological — newest first]
273
+ ```
274
+
275
+ **Update PROGRESS.md at these events:**
276
+ - Wave starts → update wave status to `IN PROGRESS`, add timestamp
277
+ - Task agent returns → update task status to `COMPLETE` or `FAILED`, add audit result
278
+ - Wave completes → update wave status to `COMPLETE`, add timestamp
279
+ - Merge completes → add to activity log
280
+ - Errors/blockers → add to activity log with details
281
+
282
+ **Activity log entries** use this format:
283
+ ```
284
+ ### [HH:MM] [event type]
285
+ [brief description]
286
+ ```
287
+
288
+ Example:
289
+ ```
290
+ ### 14:32 Wave 1 complete
291
+ Tasks 1-4 merged to main. All audits passed. 2 auto-fixes applied.
292
+
293
+ ### 14:15 Task 3 audit — auto-fix
294
+ Added missing import for UserPreferences in SettingsView.tsx
295
+
296
+ ### 13:45 Wave 1 started
297
+ Dispatching 4 agents in parallel: frontend (tasks 1,2), backend (task 3), testing (task 4)
298
+ ```
299
+
300
+ This file is for human consumption — the user can check it anytime without interrupting execution. Keep entries concise and informative.
301
+
302
+ ---
303
+
304
+ ### Phase 4: Dispatch Agents
305
+
306
+ Launch agents for all tasks in the current wave **in parallel**. Each agent gets a prompt structured like this:
307
+
308
+ ```
309
+ You are working in an isolated git worktree at: [worktree path]
310
+ Your working directory is: [worktree path]
311
+
312
+ ## Your Assignment
313
+
314
+ Execute the following tasks from the plan:
315
+
316
+ [paste the relevant task sections verbatim from the plan doc]
317
+
318
+ ## Plan Context
319
+
320
+ Full plan: [plan path]
321
+ Your tasks: [task numbers]
322
+ Dependencies satisfied: [list what was already completed in prior waves]
323
+
324
+ ## Execution Loop
325
+
326
+ For EACH task, follow this cycle:
327
+
328
+ 1. **Implement** — Follow the plan's steps exactly. Read files before modifying them. Use the project's existing patterns.
329
+
330
+ 2. **Commit** — Before committing, run **ftm-git** to scan staged files for hardcoded secrets. If ftm-git emits `secrets_found`, stop and remediate before proceeding. Only after ftm-git emits `secrets_clear` or `secrets_remediated`, stage and commit your changes with a clear message describing what was done. Never reference AI/Claude in commit messages.
331
+
332
+ 2.5. **Document** — Every commit must include documentation updates:
333
+ - Update the module's INTENT.md: add entries for new functions, update entries for changed functions (Does/Why/Relationships/Decisions format)
334
+ - Update the module's DIAGRAM.mmd: add nodes for new functions, update edges for changed dependencies
335
+ - If you created a new module directory, also create its INTENT.md and DIAGRAM.mmd, and add rows to root INTENT.md module map and root ARCHITECTURE.mmd
336
+ - Reference STYLE.md for code standards — your code must comply with all Hard Limits and Structure Rules
337
+
338
+ 3. **Review** — After committing, review your own changes:
339
+ - Run `git diff HEAD~1` to see what changed
340
+ - Check for: bugs, missing error handling, type errors, style inconsistencies
341
+ - Run any verification commands the plan specifies
342
+ - Run the project's linter/typecheck if available
343
+
344
+ 4. **Fix** — If the review surfaces issues:
345
+ - Fix them immediately
346
+ - Commit the fixes
347
+ - Review again
348
+ - Repeat until clean
349
+
350
+ 5. **Continue** — Move to the next task. Do not stop to ask questions. If something is ambiguous, make the best technical decision and document it in your commit message.
351
+
352
+ ## Rules
353
+
354
+ - NEVER stop to ask for input. Make decisions and keep going.
355
+ - ALWAYS commit after each task (not one big commit at the end).
356
+ - ALWAYS review after each commit. The review-fix loop is not optional.
357
+ - Follow the plan's steps exactly — don't improvise unless the plan is clearly wrong.
358
+ - Stay in your worktree. Don't touch files outside your assigned scope.
359
+ - If a verification step fails and you can't fix it in 3 attempts, note it in a commit message and move on.
360
+ - Run tests/build after each task if the project supports it.
361
+ - Read STYLE.md at the project root before writing code. Follow all Hard Limits and Structure Rules.
362
+ - Every commit must include: code changes + tests + INTENT.md update + DIAGRAM.mmd update. A commit without documentation updates is incomplete.
363
+ ```
364
+
365
+ ### Phase 4.5: Post-Task Audit (automatic)
366
+
367
+ After each task agent returns and before marking the task complete, run the ftm-audit verification automatically.
368
+
369
+ **Per-Task Verification Gate (runs before audit):**
370
+
371
+ Before running ftm-audit, verify these four checks pass for every task:
372
+
373
+ 1. **Claude's tests pass** — any tests written or affected by the task must be green
374
+ 2. **INTENT.md updated** — check that new/changed functions have entries in their module's INTENT.md
375
+ 3. **Diagram updated** — check that new/changed functions have nodes in their module's DIAGRAM.mmd
376
+ 4. **Full suite still green** — run the project's test suite (if one exists) and verify no regressions
377
+
378
+ 5. **Visual smoke test (optional)** — If the project has a running dev server (detected via `lsof -i :3000` or `lsof -i :5173` or configured in plan metadata as `dev_server_url`), run:
379
+ - `$PB goto <dev_server_url>`
380
+ - `$PB screenshot`
381
+ - Verify the screenshot shows a rendered page (not a blank screen or error page)
382
+ - If the task modified UI components, `$PB snapshot -i` to verify new elements appear in the ARIA tree
383
+
384
+ Where `$PB` is `$HOME/.claude/skills/ftm-browse/bin/ftm-browse`.
385
+
386
+ **Graceful degradation**: If ftm-browse binary is not installed at `$HOME/.claude/skills/ftm-browse/bin/ftm-browse`, skip visual checks with a note: "Visual smoke test skipped — ftm-browse not installed." Do not fail the task.
387
+
388
+ A task is NOT marked complete until all four checks pass (check 5 is optional). If a check fails:
389
+ - For test failures: the agent must fix them before the task can complete
390
+ - For missing INTENT.md entries: add them (use ftm-intent format)
391
+ - For missing diagram nodes: add them (use ftm-diagram format)
392
+ - For regression failures: investigate and fix before continuing
393
+
394
+ **When to run:**
395
+ - After EVERY task agent returns with completed work
396
+ - SKIP for documentation-only tasks (tasks that only create/modify .md files with no code)
397
+ - SKIP if the plan explicitly marks a task with `audit: skip`
398
+
399
+ **How to run:**
400
+
401
+ 1. **Invoke ftm-audit** against the agent's changes:
402
+ - Scope the audit to the files the task modified (check the agent's commits)
403
+ - If the task has a `Wiring:` contract in the plan, pass it to ftm-audit for contract checking
404
+ - Run all three layers: knip static analysis → adversarial audit → auto-fix
405
+
406
+ 2. **Interpret results:**
407
+ - **PASS (no findings):** Mark task complete, proceed to next task
408
+ - **PASS after auto-fix:** FTM-audit found issues and fixed them automatically. Commit the fixes in the agent's worktree with message "Auto-fix: wire [description]". Mark task complete.
409
+ - **FAIL (manual intervention needed):** Task stays in-progress. Report the findings to the user:
410
+ ```
411
+ ⚠ Task [N] audit failed — manual intervention needed:
412
+ - [finding 1 with file:line]
413
+ - [finding 2 with file:line]
414
+ Suggested fixes: [ftm-audit's suggestions]
415
+ ```
416
+ Wait for user input before continuing to next task.
417
+
418
+ 3. **Include audit results in task completion report:**
419
+ ```
420
+ Task [N]: [title] — COMPLETE
421
+ Audit: PASS (0 findings) | PASS after auto-fix (2 fixed) | FAIL (1 manual)
422
+ [if auto-fixed: list what was fixed]
423
+ [if failed: list outstanding issues]
424
+ ```
425
+
426
+ **Skipping the audit:**
427
+
428
+ To skip the audit for a specific task, the plan can include:
429
+ ```yaml
430
+ audit: skip
431
+ reason: "Documentation-only task" | "Config change" | "Test-only change"
432
+ ```
433
+
434
+ The audit is also automatically skipped when:
435
+ - The task only modified `.md`, `.txt`, `.json` (config), or `.yml` files
436
+ - The task is explicitly marked as a "setup" or "scaffold" task
437
+ - The project has no `package.json` AND no identifiable entry point (nothing to trace wiring against)
438
+
439
+ ### Phase 5: Collect and Integrate
440
+
441
+ As each agent completes:
442
+
443
+ 1. **Read the agent's summary** — what was done, any issues encountered
444
+ 2. **Review the worktree's commits** — `git log` in each worktree to see what changed
445
+ 3. **Merge into the main branch** — one worktree at a time, resolving conflicts if any:
446
+ ```bash
447
+ git checkout main # or whatever the working branch is
448
+ git merge plan-exec/<agent-name> --no-ff -m "Merge <agent-name> tasks [N-M]"
449
+ ```
450
+ 4. **Run full verification** — tests, build, lint after each merge
451
+ 5. **Fix merge issues** — if merging breaks something, fix it before proceeding
452
+
453
+ If there are multiple waves, after merging wave N:
454
+ - Verify everything still works
455
+ - Update each wave N+1 worktree with the merged changes (or create fresh worktrees from the updated branch)
456
+ - Dispatch wave N+1
457
+
458
+ ### Phase 5.5: Codex Gate (Wave Boundary Validation)
459
+
460
+ After merging all agents' work for a wave (Phase 5) and before proceeding to the next wave, invoke the ftm-codex-gate skill for adversarial validation.
461
+
462
+ **When to invoke:**
463
+ - After EVERY wave completes and is merged — this is the heavy validation gate
464
+ - For single-task executor runs (plans with only 1 task), invoke on task completion instead of wave completion
465
+
466
+ **How to invoke:**
467
+
468
+ 1. **Gather inputs for ftm-codex-gate:**
469
+ - `file_list`: All files changed across the wave (collect from all agents' commits via `git diff --name-only` against the pre-wave state)
470
+ - `acceptance_criteria`: Combined acceptance criteria from all tasks in the wave
471
+ - `wave_context`: Summary of what the wave accomplished (task titles + brief descriptions)
472
+ - `project_root`: The project working directory
473
+ - `mode`: `"wave"` for multi-task waves, `"single-task"` for single-task runs
474
+
475
+ 2. **Invoke the Codex gate** by using the ftm-codex-gate skill with these inputs. The gate will:
476
+ - Construct a Codex CLI command with the adversarial review prompt
477
+ - Run `codex exec --yolo --ephemeral -m "gpt-5.4"` against the changed files
478
+ - Return structured results
479
+
480
+ 3. **Interpret the results:**
481
+
482
+ **PASS (no issues found):**
483
+ - Log in PROGRESS.md: "Codex gate PASSED — 0 issues"
484
+ - Proceed to next wave (or Phase 6 if this was the last wave)
485
+
486
+ **PASS_WITH_FIXES (issues found and auto-fixed by Codex):**
487
+ - Codex committed fixes directly — review the fix commits
488
+ - Read each fix commit and diff it against INTENT.md entries for the affected functions
489
+ - **No INTENT.md conflict?** Accept the fixes. Log in PROGRESS.md and DEBUG.md. Proceed.
490
+ - **INTENT.md conflict detected?** See "INTENT.md Conflict Resolution" below.
491
+
492
+ **FAIL (issues Codex could not fix):**
493
+ - Read the remaining issues from the gate results
494
+ - Attempt to fix them yourself (you have full context from the wave)
495
+ - If you can fix them, commit and re-run the Codex gate
496
+ - If you cannot fix them after 2 attempts, report to the user:
497
+ ```
498
+ ⚠ Codex gate FAILED for Wave [N] — manual intervention needed:
499
+ - [remaining issue 1]
500
+ - [remaining issue 2]
501
+ Codex attempted [N] fixes but these remain unresolved.
502
+ ```
503
+ Wait for user input before continuing.
504
+
505
+ **INTENT.md Conflict Resolution:**
506
+
507
+ When Codex fixes code in a way that contradicts what INTENT.md says a function should do:
508
+
509
+ 1. **Detect the conflict**: Compare Codex's fix diff against the INTENT.md entry for the affected function. A conflict exists when:
510
+ - Codex changed a function's behavior but INTENT.md's "Does" field describes different behavior
511
+ - Codex reverted a deliberate choice documented in INTENT.md's "Decisions" field
512
+ - Codex changed the function signature documented in the INTENT.md header
513
+
514
+ 2. **Auto-invoke ftm-council** with a structured conflict payload:
515
+ ```
516
+ CONFLICT TYPE: Codex fix contradicts INTENT.md
517
+
518
+ ORIGINAL INTENT (from INTENT.md):
519
+ [paste the full INTENT.md entry for the affected function]
520
+
521
+ CODEX'S CHANGE:
522
+ [paste the diff of what Codex changed]
523
+
524
+ CODEX'S REASONING:
525
+ [paste Codex's explanation from the gate results]
526
+
527
+ THE CODE IN QUESTION:
528
+ [file path and relevant code section]
529
+
530
+ DEBUG.md HISTORY:
531
+ [paste relevant entries from DEBUG.md so the council doesn't suggest already-failed approaches]
532
+
533
+ QUESTION FOR THE COUNCIL:
534
+ Should we (A) update INTENT.md to match Codex's fix, or (B) revert Codex's fix and keep the original intent?
535
+ ```
536
+
537
+ 3. **Execute the council's verdict:**
538
+ - If verdict is "update intent": Update the INTENT.md entry to reflect the new behavior. Commit with message "Update intent: [function] — council verdict [round N]"
539
+ - If verdict is "revert fix": Revert Codex's fix commit. Commit with message "Revert codex fix: [function] — council verdict preserves original intent"
540
+ - Log the full decision + reasoning in DEBUG.md
541
+
542
+ 4. **Continue to next wave** after all conflicts are resolved.
543
+
544
+ ---
545
+
546
+ ### Phase 6: Final Verification and Completion
547
+
548
+ After all waves are merged:
549
+
550
+ 1. Run the full test suite
551
+ 2. Run the build
552
+ 3. Run linting/typechecking
553
+ 4. Fix any remaining issues (zero broken windows — fix everything, not just "your" stuff)
554
+ 4.5. **Final Codex gate** — Run one last Codex gate across ALL files changed in the entire plan execution. This catches cross-wave integration issues that per-wave gates might miss. Use `mode: "wave"` with the complete file list.
555
+ 5. **Branch finishing** — After all verification passes (including the final Codex gate), present exactly 4 options to the user:
556
+
557
+ ```
558
+ All tasks complete. All tests pass. Codex gate passed. Choose how to finish:
559
+
560
+ 1. **Merge locally** — Merge the work branch into main/develop right now
561
+ - Verifies all tests pass one final time before merging
562
+ - Uses --no-ff to preserve branch history
563
+ - Deletes the work branch after successful merge
564
+
565
+ 2. **Push + Create PR** — Push the branch and create a pull request
566
+ - Pushes the branch to origin
567
+ - Creates a PR with auto-generated summary from:
568
+ - Root INTENT.md vision section
569
+ - Task list with acceptance criteria status
570
+ - Codex gate results summary
571
+ - Files changed count
572
+ - Returns the PR URL
573
+
574
+ 3. **Keep branch as-is** — Leave everything on the current branch
575
+ - Prints the branch name so the user can return to it
576
+ - Preserves all worktrees (does NOT run cleanup)
577
+ - Good for: "I want to review this myself first"
578
+
579
+ 4. **Discard** — Delete the branch and all changes
580
+ - Requires typed confirmation: user must type "discard" to proceed
581
+ - Runs full cleanup (worktrees + branches)
582
+ - Cannot be undone
583
+ ```
584
+
585
+ Wait for the user to choose. Execute their choice. Do not proceed without explicit selection.
586
+
587
+ ### Phase 6.5: Retrospective
588
+
589
+ After all verification passes and before presenting branch finishing options, automatically invoke the ftm-retro skill with execution context.
590
+
591
+ **Invoke ftm-retro** with this context:
592
+ - Plan title and path
593
+ - Task count, wave count
594
+ - Total agents spawned (count of Agent tool invocations)
595
+ - Per-task audit results: for each task, whether it passed audit on first attempt, needed auto-fix, or required manual intervention
596
+ - Codex gate results: for each wave, whether it passed on first attempt or needed fixes
597
+ - Any errors, blockers, or manual interventions that occurred during execution
598
+
599
+ The retro runs automatically — do not ask the user whether to run it. The report is saved to `~/.claude/ftm-retros/` and a one-line summary of the overall score (X/50) is shown to the user before presenting the branch finishing options.
600
+
601
+ **Graceful degradation**: If the ftm-retro skill is not available (not installed), skip with a note and proceed to branch finishing.
602
+
603
+ ### Cleanup
604
+
605
+ Cleanup runs automatically after options 1 (merge), 2 (PR), and 4 (discard). It does NOT run for option 3 (keep branch).
606
+
607
+ ```bash
608
+ git worktree list # verify what exists
609
+ git worktree remove .worktrees/plan-exec-<name> # for each worktree
610
+ git branch -d plan-exec/<name> # delete branches (use -D for discard option)
611
+ ```
612
+
613
+ For option 3, print a reminder:
614
+ ```
615
+ Branch preserved: plan-exec/<name>
616
+ Worktrees at: .worktrees/plan-exec-*
617
+ Run cleanup manually when ready: git worktree remove .worktrees/plan-exec-<name>
618
+ ```
619
+
620
+ ## Handling Edge Cases
621
+
622
+ **Plan has no dependency map**: Analyze task descriptions and file lists yourself. Tasks touching the same files must be sequential. Tasks touching different files/domains can be parallel.
623
+
624
+ **Agent fails or gets stuck**: If an agent returns with unfinished tasks or errors it couldn't resolve, don't panic. Read its output, understand what went wrong, and either:
625
+ - Fix it yourself in the worktree
626
+ - Respawn the agent with more context about what failed
627
+
628
+ **Merge conflicts**: These happen when parallel agents touched overlapping files (shouldn't happen with good task partitioning, but sometimes it does). Resolve them manually — you have context from both agents' work.
629
+
630
+ **Very large plans (20+ tasks)**: Don't try to explain every task upfront. Show the wave structure and agent assignments, then execute. Report progress between waves.
631
+
632
+ **No tests in the project**: The review step becomes more important. Pay extra attention to the diff review and manual verification steps in the plan.
633
+
634
+ **Single-task plans**: For plans with only 1 task, skip the wave-boundary Codex gate and instead run the gate immediately after the task completes (using `mode: "single-task"`). The flow is: task agent completes → per-task verification gate → ftm-audit → Codex gate → Phase 6 completion.
635
+
636
+ ## What Makes This Different from executing-plans
637
+
638
+ The `executing-plans` skill is a human-in-the-loop batch executor — it does 3 tasks, stops, waits for feedback, continues. That's valuable when the human wants to steer.
639
+
640
+ This skill is fully autonomous. It analyzes the plan, builds a team, and executes everything without stopping. The human trusts the plan and wants it done. The review loop is agent-self-review, not human review.
641
+
642
+ Use `executing-plans` when: human wants checkpoints and control.
643
+ Use `ftm-executor` when: human says "just go" and trusts the plan.
644
+
645
+ **Critical distinction**: "just go" means "execute this plan autonomously" — it does NOT mean "skip the plan and start coding." If no plan exists, Phase 0 generates one and gets approval first. The autonomy is in execution, not in deciding what to execute.
646
+
647
+ ## Blackboard Write
648
+
649
+ After completing, update the blackboard:
650
+
651
+ 1. Update `/Users/kioja.kudumu/.claude/ftm-state/blackboard/context.json`:
652
+ - Set current_task status to "complete"
653
+ - Append decision summary to recent_decisions (cap at 10)
654
+ - Update session_metadata.skills_invoked and last_updated
655
+ 2. Write an experience file to `/Users/kioja.kudumu/.claude/ftm-state/blackboard/experiences/YYYY-MM-DD_task-slug.json` capturing task_type, agent team used, wave count, audit outcomes, and lessons learned
656
+ 3. Update `/Users/kioja.kudumu/.claude/ftm-state/blackboard/experiences/index.json` with the new entry
657
+ 4. Emit `task_completed` event