@thierrynakoa/fire-flow 10.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 (215) hide show
  1. package/.claude-plugin/plugin.json +64 -0
  2. package/ARCHITECTURE-DIAGRAM.md +440 -0
  3. package/COMMAND-REFERENCE.md +172 -0
  4. package/DOMINION-FLOW-OVERVIEW.md +421 -0
  5. package/LICENSE +21 -0
  6. package/QUICK-START.md +351 -0
  7. package/README.md +398 -0
  8. package/TROUBLESHOOTING.md +264 -0
  9. package/agents/fire-codebase-mapper.md +484 -0
  10. package/agents/fire-debugger.md +535 -0
  11. package/agents/fire-executor.md +949 -0
  12. package/agents/fire-fact-checker.md +276 -0
  13. package/agents/fire-learncoding-explainer.md +237 -0
  14. package/agents/fire-learncoding-walker.md +147 -0
  15. package/agents/fire-planner.md +675 -0
  16. package/agents/fire-project-researcher.md +155 -0
  17. package/agents/fire-research-synthesizer.md +166 -0
  18. package/agents/fire-researcher.md +723 -0
  19. package/agents/fire-reviewer.md +499 -0
  20. package/agents/fire-roadmapper.md +203 -0
  21. package/agents/fire-verifier.md +880 -0
  22. package/bin/cli.js +208 -0
  23. package/commands/fire-0-orient.md +476 -0
  24. package/commands/fire-1-new.md +281 -0
  25. package/commands/fire-1a-discuss.md +455 -0
  26. package/commands/fire-2-plan.md +527 -0
  27. package/commands/fire-3-execute.md +1303 -0
  28. package/commands/fire-4-verify.md +845 -0
  29. package/commands/fire-5-handoff.md +515 -0
  30. package/commands/fire-6-resume.md +501 -0
  31. package/commands/fire-7-review.md +409 -0
  32. package/commands/fire-add-new-skill.md +598 -0
  33. package/commands/fire-analytics.md +499 -0
  34. package/commands/fire-assumptions.md +78 -0
  35. package/commands/fire-autonomous.md +528 -0
  36. package/commands/fire-brainstorm.md +413 -0
  37. package/commands/fire-complete-milestone.md +270 -0
  38. package/commands/fire-dashboard.md +375 -0
  39. package/commands/fire-debug.md +663 -0
  40. package/commands/fire-discover.md +616 -0
  41. package/commands/fire-double-check.md +460 -0
  42. package/commands/fire-execute-plan.md +182 -0
  43. package/commands/fire-learncoding.md +242 -0
  44. package/commands/fire-loop-resume.md +272 -0
  45. package/commands/fire-loop-stop.md +198 -0
  46. package/commands/fire-loop.md +1168 -0
  47. package/commands/fire-map-codebase.md +313 -0
  48. package/commands/fire-new-milestone.md +356 -0
  49. package/commands/fire-reflect.md +235 -0
  50. package/commands/fire-research.md +246 -0
  51. package/commands/fire-search.md +330 -0
  52. package/commands/fire-security-audit-repo.md +293 -0
  53. package/commands/fire-security-scan.md +484 -0
  54. package/commands/fire-session-summary.md +252 -0
  55. package/commands/fire-skills-diff.md +506 -0
  56. package/commands/fire-skills-history.md +388 -0
  57. package/commands/fire-skills-rollback.md +408 -0
  58. package/commands/fire-skills-sync.md +470 -0
  59. package/commands/fire-test.md +520 -0
  60. package/commands/fire-todos.md +335 -0
  61. package/commands/fire-transition.md +186 -0
  62. package/commands/fire-update.md +312 -0
  63. package/commands/fire-verify-uat.md +146 -0
  64. package/commands/fire-vuln-scan.md +493 -0
  65. package/hooks/hooks.json +16 -0
  66. package/hooks/run-hook.cmd +69 -0
  67. package/hooks/run-hook.sh +8 -0
  68. package/hooks/run-session-end.cmd +49 -0
  69. package/hooks/run-session-end.sh +7 -0
  70. package/hooks/session-end.sh +90 -0
  71. package/hooks/session-start.sh +111 -0
  72. package/package.json +52 -0
  73. package/plugin.json +7 -0
  74. package/references/auto-skill-extraction.md +136 -0
  75. package/references/behavioral-directives.md +365 -0
  76. package/references/blocker-tracking.md +155 -0
  77. package/references/checkpoints.md +165 -0
  78. package/references/circuit-breaker.md +410 -0
  79. package/references/context-engineering.md +587 -0
  80. package/references/decision-time-guidance.md +289 -0
  81. package/references/error-classification.md +326 -0
  82. package/references/execution-mode-intelligence.md +242 -0
  83. package/references/git-integration.md +217 -0
  84. package/references/honesty-protocols.md +304 -0
  85. package/references/integration-architecture.md +470 -0
  86. package/references/issue-to-pr-pipeline.md +150 -0
  87. package/references/metrics-and-trends.md +234 -0
  88. package/references/playwright-e2e-testing.md +326 -0
  89. package/references/questioning.md +125 -0
  90. package/references/research-improvements.md +110 -0
  91. package/references/skills-usage-guide.md +429 -0
  92. package/references/tdd.md +131 -0
  93. package/references/testing-enforcement.md +192 -0
  94. package/references/ui-brand.md +383 -0
  95. package/references/validation-checklist.md +456 -0
  96. package/references/verification-patterns.md +187 -0
  97. package/references/warrior-principles.md +173 -0
  98. package/skills-library/SKILLS-INDEX.md +588 -0
  99. package/skills-library/_general/frontend/html-visual-reports.md +292 -0
  100. package/skills-library/_general/methodology/debug-swarm-researcher-escape-hatch.md +240 -0
  101. package/skills-library/_general/methodology/learncoding-agentic-pattern.md +114 -0
  102. package/skills-library/_general/methodology/shell-autonomous-loop-fixplan.md +238 -0
  103. package/skills-library/basics/api-rest-basics.md +162 -0
  104. package/skills-library/basics/env-variables.md +96 -0
  105. package/skills-library/basics/error-handling-basics.md +125 -0
  106. package/skills-library/basics/git-commit-conventions.md +106 -0
  107. package/skills-library/basics/readme-template.md +108 -0
  108. package/skills-library/common-tasks/async-await-patterns.md +157 -0
  109. package/skills-library/common-tasks/auth-jwt-basics.md +164 -0
  110. package/skills-library/common-tasks/database-schema-design.md +166 -0
  111. package/skills-library/common-tasks/file-upload-basics.md +166 -0
  112. package/skills-library/common-tasks/form-validation.md +159 -0
  113. package/skills-library/debugging/FAILURE_TAXONOMY_CLASSIFICATION.md +117 -0
  114. package/skills-library/debugging/THREE_AGENT_HYPOTHESIS_DEBUGGING.md +86 -0
  115. package/skills-library/methodology/BREATH_BASED_PARALLEL_EXECUTION.md +678 -0
  116. package/skills-library/methodology/CONFIDENCE_GATED_EXECUTION.md +243 -0
  117. package/skills-library/methodology/EVIDENCE_BASED_VALIDATION.md +308 -0
  118. package/skills-library/methodology/MULTI_PERSPECTIVE_CODE_REVIEW.md +330 -0
  119. package/skills-library/methodology/PATH_VERIFICATION_GATE.md +211 -0
  120. package/skills-library/methodology/REFLEXION_MEMORY_PATTERN.md +183 -0
  121. package/skills-library/methodology/RESEARCH_BACKED_WORKFLOW_UPGRADE.md +263 -0
  122. package/skills-library/methodology/SABBATH_REST_PATTERN.md +267 -0
  123. package/skills-library/methodology/STONE_AND_SCAFFOLD.md +220 -0
  124. package/skills-library/performance/cache-augmented-generation.md +172 -0
  125. package/skills-library/quality-safety/debugging-steps.md +147 -0
  126. package/skills-library/quality-safety/deployment-checklist.md +155 -0
  127. package/skills-library/quality-safety/security-checklist.md +204 -0
  128. package/skills-library/quality-safety/testing-basics.md +180 -0
  129. package/skills-library/security/agent-security-scanner.md +445 -0
  130. package/skills-library/specialists/api-architecture/api-designer.md +49 -0
  131. package/skills-library/specialists/api-architecture/graphql-architect.md +49 -0
  132. package/skills-library/specialists/api-architecture/mcp-developer.md +51 -0
  133. package/skills-library/specialists/api-architecture/microservices-architect.md +50 -0
  134. package/skills-library/specialists/api-architecture/websocket-engineer.md +48 -0
  135. package/skills-library/specialists/backend/django-expert.md +52 -0
  136. package/skills-library/specialists/backend/fastapi-expert.md +52 -0
  137. package/skills-library/specialists/backend/laravel-specialist.md +52 -0
  138. package/skills-library/specialists/backend/nestjs-expert.md +51 -0
  139. package/skills-library/specialists/backend/rails-expert.md +53 -0
  140. package/skills-library/specialists/backend/spring-boot-engineer.md +56 -0
  141. package/skills-library/specialists/data-ml/fine-tuning-expert.md +48 -0
  142. package/skills-library/specialists/data-ml/ml-pipeline.md +47 -0
  143. package/skills-library/specialists/data-ml/pandas-pro.md +47 -0
  144. package/skills-library/specialists/data-ml/rag-architect.md +51 -0
  145. package/skills-library/specialists/data-ml/spark-engineer.md +47 -0
  146. package/skills-library/specialists/frontend/angular-architect.md +52 -0
  147. package/skills-library/specialists/frontend/flutter-expert.md +51 -0
  148. package/skills-library/specialists/frontend/nextjs-developer.md +54 -0
  149. package/skills-library/specialists/frontend/react-native-expert.md +50 -0
  150. package/skills-library/specialists/frontend/vue-expert.md +51 -0
  151. package/skills-library/specialists/infrastructure/chaos-engineer.md +74 -0
  152. package/skills-library/specialists/infrastructure/cloud-architect.md +70 -0
  153. package/skills-library/specialists/infrastructure/database-optimizer.md +64 -0
  154. package/skills-library/specialists/infrastructure/devops-engineer.md +70 -0
  155. package/skills-library/specialists/infrastructure/kubernetes-specialist.md +52 -0
  156. package/skills-library/specialists/infrastructure/monitoring-expert.md +70 -0
  157. package/skills-library/specialists/infrastructure/sre-engineer.md +70 -0
  158. package/skills-library/specialists/infrastructure/terraform-engineer.md +51 -0
  159. package/skills-library/specialists/languages/cpp-pro.md +74 -0
  160. package/skills-library/specialists/languages/csharp-developer.md +69 -0
  161. package/skills-library/specialists/languages/dotnet-core-expert.md +54 -0
  162. package/skills-library/specialists/languages/golang-pro.md +51 -0
  163. package/skills-library/specialists/languages/java-architect.md +49 -0
  164. package/skills-library/specialists/languages/javascript-pro.md +68 -0
  165. package/skills-library/specialists/languages/kotlin-specialist.md +68 -0
  166. package/skills-library/specialists/languages/php-pro.md +49 -0
  167. package/skills-library/specialists/languages/python-pro.md +52 -0
  168. package/skills-library/specialists/languages/react-expert.md +51 -0
  169. package/skills-library/specialists/languages/rust-engineer.md +50 -0
  170. package/skills-library/specialists/languages/sql-pro.md +56 -0
  171. package/skills-library/specialists/languages/swift-expert.md +69 -0
  172. package/skills-library/specialists/languages/typescript-pro.md +51 -0
  173. package/skills-library/specialists/platform/atlassian-mcp.md +52 -0
  174. package/skills-library/specialists/platform/embedded-systems.md +53 -0
  175. package/skills-library/specialists/platform/game-developer.md +53 -0
  176. package/skills-library/specialists/platform/salesforce-developer.md +53 -0
  177. package/skills-library/specialists/platform/shopify-expert.md +49 -0
  178. package/skills-library/specialists/platform/wordpress-pro.md +49 -0
  179. package/skills-library/specialists/quality/code-documenter.md +51 -0
  180. package/skills-library/specialists/quality/code-reviewer.md +67 -0
  181. package/skills-library/specialists/quality/debugging-wizard.md +51 -0
  182. package/skills-library/specialists/quality/fullstack-guardian.md +51 -0
  183. package/skills-library/specialists/quality/legacy-modernizer.md +50 -0
  184. package/skills-library/specialists/quality/playwright-expert.md +65 -0
  185. package/skills-library/specialists/quality/spec-miner.md +56 -0
  186. package/skills-library/specialists/quality/test-master.md +65 -0
  187. package/skills-library/specialists/security/secure-code-guardian.md +55 -0
  188. package/skills-library/specialists/security/security-reviewer.md +53 -0
  189. package/skills-library/specialists/workflow/architecture-designer.md +53 -0
  190. package/skills-library/specialists/workflow/cli-developer.md +70 -0
  191. package/skills-library/specialists/workflow/feature-forge.md +65 -0
  192. package/skills-library/specialists/workflow/prompt-engineer.md +54 -0
  193. package/skills-library/specialists/workflow/the-fool.md +62 -0
  194. package/templates/ASSUMPTIONS.md +125 -0
  195. package/templates/BLOCKERS.md +73 -0
  196. package/templates/DECISION_LOG.md +116 -0
  197. package/templates/UAT.md +96 -0
  198. package/templates/blueprint.md +94 -0
  199. package/templates/brainstorm.md +185 -0
  200. package/templates/conscience.md +92 -0
  201. package/templates/fire-handoff.md +159 -0
  202. package/templates/metrics.md +67 -0
  203. package/templates/phase-prompt.md +142 -0
  204. package/templates/record.md +131 -0
  205. package/templates/review-report.md +117 -0
  206. package/templates/skills-index.md +157 -0
  207. package/templates/verification.md +149 -0
  208. package/templates/vision.md +79 -0
  209. package/validation-config.yml +793 -0
  210. package/version.json +7 -0
  211. package/workflows/execute-phase.md +732 -0
  212. package/workflows/handoff-session.md +678 -0
  213. package/workflows/new-project.md +578 -0
  214. package/workflows/plan-phase.md +592 -0
  215. package/workflows/verify-phase.md +874 -0
@@ -0,0 +1,289 @@
1
+ # Decision-Time Guidance System
2
+
3
+ > Lightweight micro-instruction injection at key decision moments — inspired by Replit Agent's decision-time compute pattern.
4
+
5
+ ---
6
+
7
+ ## Overview
8
+
9
+ Instead of bloating system prompts with every possible instruction, Decision-Time Guidance (DTG) injects **targeted micro-instructions from the skills library at the exact moment they're needed**. This keeps context lean while ensuring the right guidance is available at decision points.
10
+
11
+ **Core principle:** Don't pre-load everything. Load the right thing at the right time.
12
+
13
+ ---
14
+
15
+ ## Architecture
16
+
17
+ ```
18
+ ┌──────────────────────────────────────────────────────────────┐
19
+ │ DECISION POINT DETECTED │
20
+ │ │
21
+ │ Classifier analyzes: │
22
+ │ • Current task type (API, UI, DB, test, deploy, debug) │
23
+ │ • File patterns being touched │
24
+ │ • Error patterns encountered │
25
+ │ • Technology stack in use │
26
+ │ │
27
+ │ ┌──────────────┐ │
28
+ │ │ SKILLS BANK │ │
29
+ │ │ │ │
30
+ │ │ 190+ skills │──→ Select 1-3 relevant skills │
31
+ │ │ organized │ │
32
+ │ │ by domain │ │
33
+ │ └──────────────┘ │
34
+ │ │ │
35
+ │ ┌───────▼───────┐ │
36
+ │ │ MICRO-INJECT │ │
37
+ │ │ │ │
38
+ │ │ Extract key │ │
39
+ │ │ patterns and │──→ Inject into current context │
40
+ │ │ decision │ │
41
+ │ │ guidance │ │
42
+ │ └───────────────┘ │
43
+ └──────────────────────────────────────────────────────────────┘
44
+ ```
45
+
46
+ ---
47
+
48
+ ## Decision Points
49
+
50
+ DTG activates at these moments in the Dominion Flow pipeline:
51
+
52
+ ### 1. Task Start (in /fire-execute-plan)
53
+
54
+ **Trigger:** Beginning a new task from BLUEPRINT.md
55
+ **Classifier input:** Task description, file paths, technology tags
56
+ **Action:** Search skills library for matching patterns, inject relevant guidance
57
+
58
+ ```
59
+ BEFORE executing Task {N}:
60
+ keywords = extract_keywords(task.description + task.files)
61
+ skills = search_skills_library(keywords, limit=3)
62
+
63
+ IF skills.found:
64
+ inject: "Apply these patterns for this task:"
65
+ FOR each skill:
66
+ inject: skill.key_pattern + skill.common_pitfalls
67
+ ```
68
+
69
+ ### 2. Error Encountered (in /fire-loop, /fire-debug)
70
+
71
+ **Trigger:** Test failure, build error, runtime exception
72
+ **Classifier input:** Error message, stack trace, file context
73
+ **Action:** Search skills library for error patterns, inject fix guidance
74
+
75
+ ```
76
+ ON error_detected(error):
77
+ error_keywords = extract_error_signature(error)
78
+ skills = search_skills_library(error_keywords, category="debug")
79
+
80
+ IF skills.found:
81
+ inject: "Known pattern for this error:"
82
+ inject: skill.resolution_steps
83
+ ELSE:
84
+ inject: "No known pattern. Apply systematic debugging protocol."
85
+ ```
86
+
87
+ ### 3. Architecture Decision (checkpoint:decision in plans)
88
+
89
+ **Trigger:** Reaching a decision checkpoint in plan execution
90
+ **Classifier input:** Decision description, options, constraints
91
+ **Action:** Search for relevant architecture patterns, inject trade-off analysis
92
+
93
+ ```
94
+ ON checkpoint_decision(decision):
95
+ domain = classify_domain(decision) # auth, api, database, ui
96
+ skills = search_skills_library(domain + "architecture", limit=2)
97
+
98
+ inject: "Consider these proven patterns before deciding:"
99
+ FOR each skill:
100
+ inject: skill.pattern_name + skill.trade_offs
101
+ ```
102
+
103
+ ### 4. Technology Boundary (new framework/library interaction)
104
+
105
+ **Trigger:** First interaction with a specific technology in the plan
106
+ **Classifier input:** Import statements, package.json changes, file extensions
107
+ **Action:** Search for integration-specific skills
108
+
109
+ ```
110
+ ON technology_detected(tech):
111
+ skills = search_skills_library(tech.name, category="integrations")
112
+
113
+ IF skills.found:
114
+ inject: "Integration guidance for {tech.name}:"
115
+ inject: skill.setup_pattern + skill.gotchas
116
+ ```
117
+
118
+ ### 5. Test Writing (in testing-enforcement gate)
119
+
120
+ **Trigger:** About to write or modify tests
121
+ **Classifier input:** Test framework, component type, coverage target
122
+ **Action:** Search for testing patterns specific to the domain
123
+
124
+ ```
125
+ ON test_phase(component):
126
+ skills = search_skills_library(
127
+ component.type + "testing",
128
+ category="methodology"
129
+ )
130
+
131
+ inject: "Testing patterns for {component.type}:"
132
+ inject: skill.test_structure + skill.assertion_patterns
133
+ ```
134
+
135
+ ---
136
+
137
+ ## Classifier Logic
138
+
139
+ The DTG classifier uses a lightweight keyword-matching approach:
140
+
141
+ ### Input Signals
142
+
143
+ | Signal | Source | Example |
144
+ |--------|--------|---------|
145
+ | File extensions | Task files list | `.tsx` → frontend, `.sql` → database |
146
+ | Directory patterns | File paths | `src/api/` → backend, `src/components/` → frontend |
147
+ | Error signatures | Error output | `ECONNREFUSED` → connection, `TypeError` → type safety |
148
+ | Package names | imports/deps | `prisma` → ORM, `stripe` → payments |
149
+ | Task verbs | Description | "migrate" → database, "render" → UI, "authenticate" → auth |
150
+
151
+ ### Domain Classification
152
+
153
+ ```
154
+ classify_domain(context):
155
+ signals = collect_signals(context)
156
+
157
+ domain_scores = {
158
+ backend: count(signals matching ["api", "route", "middleware", "server", "express"]),
159
+ frontend: count(signals matching ["component", "page", "style", "react", "ui"]),
160
+ database: count(signals matching ["schema", "migration", "query", "model", "prisma"]),
161
+ auth: count(signals matching ["login", "token", "jwt", "session", "password"]),
162
+ testing: count(signals matching ["test", "spec", "assert", "mock", "coverage"]),
163
+ deploy: count(signals matching ["build", "docker", "ci", "deploy", "env"]),
164
+ payments: count(signals matching ["stripe", "payment", "invoice", "subscription"]),
165
+ media: count(signals matching ["video", "image", "upload", "stream", "player"])
166
+ }
167
+
168
+ RETURN top_domains(domain_scores, limit=2)
169
+ ```
170
+
171
+ ---
172
+
173
+ ## Skills Bank Integration
174
+
175
+ ### Search Protocol
176
+
177
+ ```
178
+ search_skills_library(keywords, category=null, limit=3):
179
+ # 1. Exact match on skill filename
180
+ exact = glob("skills-library/**/*{keyword}*.md")
181
+
182
+ # 2. Content match in skill files
183
+ content = grep(keywords, "skills-library/**/*.md")
184
+
185
+ # 3. Category filter
186
+ IF category:
187
+ results = filter(exact + content, path contains category)
188
+ ELSE:
189
+ results = exact + content
190
+
191
+ # 4. Rank by relevance (keyword density in file)
192
+ ranked = sort_by_relevance(results)
193
+
194
+ RETURN ranked[:limit]
195
+ ```
196
+
197
+ ### Micro-Instruction Extraction
198
+
199
+ Don't inject entire skill files. Extract only the actionable parts:
200
+
201
+ ```
202
+ extract_micro_instruction(skill_file):
203
+ sections = parse_markdown_sections(skill_file)
204
+
205
+ # Priority extraction order:
206
+ micro = {
207
+ pattern: sections["## Pattern"] or sections["## Solution"],
208
+ pitfalls: sections["## Common Pitfalls"] or sections["## Gotchas"],
209
+ checklist: sections["## Checklist"] or sections["## Steps"]
210
+ }
211
+
212
+ # Keep it under 20 lines total
213
+ RETURN truncate(micro, max_lines=20)
214
+ ```
215
+
216
+ ---
217
+
218
+ ## Integration with Dominion Flow Commands
219
+
220
+ ### /fire-execute-plan
221
+
222
+ ```markdown
223
+ # In Step 5 (Execute Segments), before each task:
224
+
225
+ ## DTG Check
226
+ FOR each task in segment:
227
+ guidance = DTG.classify_and_search(task)
228
+ IF guidance:
229
+ context += "## Guidance for Task {N}\n" + guidance
230
+ ```
231
+
232
+ ### /fire-loop
233
+
234
+ ```markdown
235
+ # In Step 7 (Execute Task), at each iteration:
236
+
237
+ ## DTG Check
238
+ IF iteration == 1 OR error_detected OR approach_changed:
239
+ guidance = DTG.classify_and_search(current_context)
240
+ IF guidance != previous_guidance:
241
+ inject(guidance)
242
+ ```
243
+
244
+ ### /fire-debug
245
+
246
+ ```markdown
247
+ # In debug cycle, when new error encountered:
248
+
249
+ ## DTG Check
250
+ ON new_error(error):
251
+ guidance = DTG.search_error_pattern(error)
252
+ IF guidance:
253
+ inject: "Known resolution pattern found"
254
+ inject(guidance)
255
+ ```
256
+
257
+ ---
258
+
259
+ ## Performance Considerations
260
+
261
+ | Concern | Mitigation |
262
+ |---------|-----------|
263
+ | Search overhead | Skills library is local filesystem — glob/grep is fast |
264
+ | Context bloat | Extract micro-instructions (max 20 lines), not full files |
265
+ | Redundant injection | Track injected skills per session, don't re-inject |
266
+ | False matches | Require 2+ signal matches before injecting |
267
+
268
+ ---
269
+
270
+ ## Metrics
271
+
272
+ Track DTG effectiveness in RECORD.md:
273
+
274
+ ```yaml
275
+ dtg_metrics:
276
+ activations: [N] # How many times DTG triggered
277
+ skills_injected: [N] # Skills that were injected
278
+ skills_useful: [N] # Skills that influenced the outcome
279
+ missed_guidance: [N] # Cases where DTG should have fired but didn't
280
+ ```
281
+
282
+ ---
283
+
284
+ ## References
285
+
286
+ - **Inspiration:** Replit Agent's "Decision-Time Compute" pattern (inject micro-instructions at decision points instead of front-loading system prompts)
287
+ - **Skills Library:** `~/.claude/plugins/warrior-workflow/skills-library/`
288
+ - **Skills Index:** `SKILLS_LIBRARY_INDEX.md`
289
+ - **Related:** `references/skills-usage-guide.md`
@@ -0,0 +1,326 @@
1
+ # Error Classification Layer
2
+
3
+ > State machine that classifies execution health into PROGRESS / STALLED / SPINNING / DEGRADED / BLOCKED — each state drives different automated responses.
4
+
5
+ ---
6
+
7
+ ## Overview
8
+
9
+ Instead of treating all problems the same way ("try again"), the Error Classification Layer assigns a **health state** to the current execution and triggers **state-specific responses**. This prevents the common failure mode where an agent keeps retrying the same broken approach.
10
+
11
+ **Core principle:** Different problems need different responses. Classify first, then act.
12
+
13
+ ---
14
+
15
+ ## Five Health States
16
+
17
+ ```
18
+ ┌────────────┐ no progress ┌──────────┐ same error ┌──────────┐
19
+ │ PROGRESS │──────────────────►│ STALLED │──────────────►│ SPINNING │
20
+ │ │ │ │ │ │
21
+ │ Making │ │ No forward│ │ Repeating│
22
+ │ measurable │ │ movement │ │ same │
23
+ │ progress │ │ │ │ error │
24
+ └─────┬──────┘ └─────┬─────┘ └─────┬────┘
25
+ │ │ │
26
+ │ context filling │ external dep │ 5th repeat
27
+ │ │ │
28
+ ▼ ▼ ▼
29
+ ┌────────────┐ ┌──────────┐ ┌──────────────┐
30
+ │ DEGRADED │ │ BLOCKED │ │ CIRCUIT BREAK│
31
+ │ │ │ │ │ │
32
+ │ Context rot│ │ External │ │ Hard stop │
33
+ │ declining │ │ blocker │ │ from breaker │
34
+ │ output │ │ can't │ │ │
35
+ │ quality │ │ proceed │ │ │
36
+ └────────────┘ └──────────┘ └──────────────┘
37
+ ```
38
+
39
+ ---
40
+
41
+ ## State Definitions
42
+
43
+ ### PROGRESS
44
+
45
+ **Signals:**
46
+ - Files are being modified between iterations
47
+ - Test results are changing (even if still failing — different failures = progress)
48
+ - New errors replacing old ones (moving forward through the problem)
49
+ - Output remains detailed and focused
50
+
51
+ **Response:** Continue normally. No intervention needed.
52
+
53
+ ```
54
+ classify_as_progress():
55
+ files_changed_this_iteration > 0
56
+ OR error_hash != previous_error_hash
57
+ OR test_count_changed
58
+ OR new_files_created
59
+ ```
60
+
61
+ ### STALLED
62
+
63
+ **Signals:**
64
+ - No file changes for 2+ iterations
65
+ - Same test results (no change in pass/fail counts)
66
+ - Agent is reading files but not writing
67
+ - Output shows analysis but no action
68
+
69
+ **Response:**
70
+ 1. Inject urgency: "You have not made file changes in {N} iterations"
71
+ 2. Suggest concrete next action
72
+ 3. Search skills library for alternative approaches
73
+ 4. If persists 3+ iterations → escalate to SPINNING or BLOCKED
74
+
75
+ ```
76
+ classify_as_stalled():
77
+ files_changed == 0 for 2+ iterations
78
+ AND no new errors (same or no errors)
79
+ AND output_is_analytical (reading, exploring, but not writing)
80
+ ```
81
+
82
+ ### SPINNING
83
+
84
+ **Signals:**
85
+ - Same error appearing 3+ times
86
+ - Agent is making changes but they don't fix the issue
87
+ - Cycle: change file → run test → same error → change file → same error
88
+ - Git log shows repeated edits to same files
89
+
90
+ **Response:**
91
+ 1. **Approach rotation** (forced): "You have seen this error {N} times. You MUST try a fundamentally different approach."
92
+ 2. Display error history: "Here are the {N} approaches you've already tried"
93
+ 3. Inject anti-patterns: "Do NOT do: {list of failed approaches}"
94
+ 4. Search skills library for the specific error pattern
95
+ 5. If persists after rotation → CIRCUIT BREAK
96
+
97
+ ```
98
+ classify_as_spinning():
99
+ same_error_hash for 3+ iterations
100
+ AND files_changed > 0 (agent IS trying, but failing)
101
+ ```
102
+
103
+ ### DEGRADED
104
+
105
+ **Signals:**
106
+ - Output volume declining (50%+ below baseline)
107
+ - Responses becoming shorter, less structured
108
+ - Agent forgetting earlier instructions or context
109
+ - Repetitive phrasing or circular logic
110
+ - Loss of formatting quality
111
+
112
+ **Response:**
113
+ 1. Trigger Sabbath Rest warning
114
+ 2. Save complete state to loop file
115
+ 3. Recommend fresh context restart
116
+ 4. If user forces continue → operate in "minimal mode" (short, focused actions only)
117
+
118
+ ```
119
+ classify_as_degraded():
120
+ output_volume < 50% of baseline
121
+ OR response_length_declining for 3+ iterations
122
+ OR instruction_amnesia_detected (re-asking clarified questions)
123
+ ```
124
+
125
+ ### BLOCKED
126
+
127
+ **Signals:**
128
+ - Error requires external action (missing env var, service down, permission needed)
129
+ - Dependency not installed and can't be auto-installed
130
+ - API rate limit hit
131
+ - File/resource locked by another process
132
+ - Requires human decision that wasn't planned for
133
+
134
+ **Response:**
135
+ 1. **Stop immediately** — don't waste iterations
136
+ 2. Classify the blocker (external dependency, permission, decision needed)
137
+ 3. Create blocker entry in BLOCKERS.md
138
+ 4. Save state for resume
139
+ 5. Present clear options to user
140
+
141
+ ```
142
+ classify_as_blocked():
143
+ error_type IN [
144
+ "EACCES", "EPERM", # Permission
145
+ "ECONNREFUSED", # Service down
146
+ "MODULE_NOT_FOUND", # Missing dependency
147
+ "rate_limit_exceeded", # API limit
148
+ "ENOENT" on external resource # Missing external file
149
+ ]
150
+ OR error_message contains ["permission denied", "not authorized",
151
+ "service unavailable", "rate limit", "quota exceeded"]
152
+ ```
153
+
154
+ ---
155
+
156
+ ## Classification Algorithm
157
+
158
+ Run this after each iteration/task:
159
+
160
+ ```
161
+ classify_health(iteration_data):
162
+ # Priority order: BLOCKED > SPINNING > DEGRADED > STALLED > PROGRESS
163
+ # Higher-severity states take precedence
164
+
165
+ # 1. Check for external blockers first
166
+ IF is_external_blocker(iteration_data.error):
167
+ RETURN BLOCKED
168
+
169
+ # 2. Check for spinning (same error, agent IS trying)
170
+ IF same_error_count >= 3 AND files_changed_recently:
171
+ RETURN SPINNING
172
+
173
+ # 3. Check for degradation (context rot)
174
+ IF output_volume_decline >= 50%:
175
+ RETURN DEGRADED
176
+
177
+ # 4. Check for stalling (no progress, no errors)
178
+ IF no_file_changes >= 2 AND no_new_errors:
179
+ RETURN STALLED
180
+
181
+ # 5. Default: making progress
182
+ RETURN PROGRESS
183
+ ```
184
+
185
+ ---
186
+
187
+ ## State Transition Rules
188
+
189
+ | From | To | Trigger | Auto-Action |
190
+ |------|----|---------|-------------|
191
+ | PROGRESS | STALLED | 2 iterations no file changes | Inject urgency prompt |
192
+ | PROGRESS | DEGRADED | Output drops 50%+ | Sabbath Rest warning |
193
+ | PROGRESS | BLOCKED | External error detected | Stop + blocker report |
194
+ | STALLED | SPINNING | Same error appears 3x | Force approach rotation |
195
+ | STALLED | PROGRESS | Files change again | Clear warning state |
196
+ | STALLED | BLOCKED | External error detected | Stop + blocker report |
197
+ | SPINNING | CIRCUIT BREAK | 5th same error | Hard stop via circuit breaker |
198
+ | SPINNING | PROGRESS | Different error or files change | Clear spin counter |
199
+ | DEGRADED | SABBATH REST | Output drops 70%+ | Auto-save + pause |
200
+ | DEGRADED | PROGRESS | Output recovers (unlikely) | Clear degradation flag |
201
+ | BLOCKED | PROGRESS | Blocker resolved | Resume from checkpoint |
202
+
203
+ ---
204
+
205
+ ## Response Templates
206
+
207
+ ### STALLED Response Injection
208
+
209
+ ```markdown
210
+ ---
211
+ HEALTH CHECK: STALLED (iteration {N})
212
+ ---
213
+
214
+ No file changes detected for {count} iterations.
215
+
216
+ Your recent actions:
217
+ - [iter N-2]: Read src/auth.ts, read src/utils.ts
218
+ - [iter N-1]: Read src/models/user.ts, ran tests
219
+ - [iter N]: Read src/middleware/auth.ts
220
+
221
+ You are in analysis mode. To make progress, you must:
222
+ 1. Pick ONE specific change to make
223
+ 2. Make the change
224
+ 3. Test it
225
+
226
+ Suggested actions from skills library:
227
+ - {skill_suggestion_1}
228
+ - {skill_suggestion_2}
229
+ ---
230
+ ```
231
+
232
+ ### SPINNING Response Injection
233
+
234
+ ```markdown
235
+ ---
236
+ HEALTH CHECK: SPINNING (iteration {N})
237
+ ---
238
+
239
+ SAME ERROR seen {count} times:
240
+ {normalized_error_message}
241
+
242
+ Approaches already tried (DO NOT REPEAT):
243
+ 1. [iteration X]: {approach_1} → FAILED
244
+ 2. [iteration Y]: {approach_2} → FAILED
245
+ 3. [iteration Z]: {approach_3} → FAILED
246
+
247
+ You MUST try a fundamentally different approach.
248
+
249
+ Consider:
250
+ - Instead of fixing WHERE the error appears, fix WHERE the bad data originates
251
+ - Instead of patching the consumer, fix the producer
252
+ - Instead of adding null checks, ensure non-null at the source
253
+ - Check skills library for this error pattern
254
+
255
+ If you cannot think of a new approach, explain what you've learned
256
+ and request help from the user.
257
+ ---
258
+ ```
259
+
260
+ ### BLOCKED Response Display
261
+
262
+ ```
263
+ ┌─────────────────────────────────────────────────────────────────────────────┐
264
+ │ EXECUTION BLOCKED │
265
+ ├─────────────────────────────────────────────────────────────────────────────┤
266
+ │ │
267
+ │ Blocker Type: [External Dependency | Permission | Decision | Service] │
268
+ │ Error: {error_message} │
269
+ │ │
270
+ │ This error requires action outside the loop: │
271
+ │ {specific_action_needed} │
272
+ │ │
273
+ │ State saved to: .planning/loops/fire-loop-{ID}.md │
274
+ │ Resume with: /fire-loop-resume {ID} │
275
+ │ │
276
+ │ Added to BLOCKERS.md as BLOCKER-{NNN} [P{priority}] │
277
+ │ │
278
+ └─────────────────────────────────────────────────────────────────────────────┘
279
+ ```
280
+
281
+ ---
282
+
283
+ ## Tracking in Loop File
284
+
285
+ ```markdown
286
+ ## Health Classification History
287
+
288
+ | Iteration | State | Trigger | Action Taken |
289
+ |-----------|-------|---------|-------------|
290
+ | 1 | PROGRESS | Files changed: 3 | - |
291
+ | 2 | PROGRESS | New error (different from iter 1) | - |
292
+ | 3 | PROGRESS | Files changed: 2 | - |
293
+ | 4 | STALLED | No file changes | Urgency injection |
294
+ | 5 | STALLED | No file changes (2nd) | Skills search |
295
+ | 6 | SPINNING | Same error 3x | Approach rotation |
296
+ | 7 | PROGRESS | Different approach, new error | Cleared spin state |
297
+ | 8 | PROGRESS | Files changed: 4 | - |
298
+ ```
299
+
300
+ ---
301
+
302
+ ## Integration with Circuit Breaker
303
+
304
+ Error Classification and Circuit Breaker work together:
305
+
306
+ ```
307
+ Error Classification → diagnoses WHAT is happening
308
+ Circuit Breaker → enforces WHEN to stop
309
+
310
+ Example flow:
311
+ 1. Error Classification detects SPINNING state
312
+ 2. Injects approach rotation prompt
313
+ 3. Circuit Breaker tracks: same_error_count = 3 (WARNING)
314
+ 4. If rotation doesn't work: same_error_count = 5 (BREAK)
315
+ 5. Circuit Breaker triggers hard stop
316
+ ```
317
+
318
+ ---
319
+
320
+ ## References
321
+
322
+ - **Inspiration:** Manus AI error preservation, Replit Agent doom loop detection
323
+ - **Related:** `references/circuit-breaker.md` — quantitative thresholds
324
+ - **Related:** `references/honesty-protocols.md` — "admit when stuck" principle
325
+ - **Consumer:** `commands/fire-loop.md` — primary integration point
326
+ - **Consumer:** `commands/fire-debug.md` — debug session health tracking