autonomous-coding-toolkit 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 (324) hide show
  1. package/.claude-plugin/marketplace.json +22 -0
  2. package/.claude-plugin/plugin.json +13 -0
  3. package/LICENSE +21 -0
  4. package/Makefile +21 -0
  5. package/README.md +140 -0
  6. package/SECURITY.md +28 -0
  7. package/agents/bash-expert.md +113 -0
  8. package/agents/dependency-auditor.md +138 -0
  9. package/agents/integration-tester.md +120 -0
  10. package/agents/lesson-scanner.md +149 -0
  11. package/agents/python-expert.md +179 -0
  12. package/agents/service-monitor.md +141 -0
  13. package/agents/shell-expert.md +147 -0
  14. package/benchmarks/runner.sh +147 -0
  15. package/benchmarks/tasks/01-rest-endpoint/rubric.sh +29 -0
  16. package/benchmarks/tasks/01-rest-endpoint/task.md +17 -0
  17. package/benchmarks/tasks/02-refactor-module/task.md +8 -0
  18. package/benchmarks/tasks/03-fix-integration-bug/task.md +8 -0
  19. package/benchmarks/tasks/04-add-test-coverage/task.md +8 -0
  20. package/benchmarks/tasks/05-multi-file-feature/task.md +8 -0
  21. package/bin/act.js +238 -0
  22. package/commands/autocode.md +6 -0
  23. package/commands/cancel-ralph.md +18 -0
  24. package/commands/code-factory.md +53 -0
  25. package/commands/create-prd.md +55 -0
  26. package/commands/ralph-loop.md +18 -0
  27. package/commands/run-plan.md +117 -0
  28. package/commands/submit-lesson.md +122 -0
  29. package/docs/ARCHITECTURE.md +630 -0
  30. package/docs/CONTRIBUTING.md +125 -0
  31. package/docs/lessons/0001-bare-exception-swallowing.md +34 -0
  32. package/docs/lessons/0002-async-def-without-await.md +28 -0
  33. package/docs/lessons/0003-create-task-without-callback.md +28 -0
  34. package/docs/lessons/0004-hardcoded-test-counts.md +28 -0
  35. package/docs/lessons/0005-sqlite-without-closing.md +33 -0
  36. package/docs/lessons/0006-venv-pip-path.md +27 -0
  37. package/docs/lessons/0007-runner-state-self-rejection.md +35 -0
  38. package/docs/lessons/0008-quality-gate-blind-spot.md +33 -0
  39. package/docs/lessons/0009-parser-overcount-empty-batches.md +36 -0
  40. package/docs/lessons/0010-local-outside-function-bash.md +33 -0
  41. package/docs/lessons/0011-batch-tests-for-unimplemented-code.md +36 -0
  42. package/docs/lessons/0012-api-markdown-unescaped-chars.md +33 -0
  43. package/docs/lessons/0013-export-prefix-env-parsing.md +33 -0
  44. package/docs/lessons/0014-decorator-registry-import-side-effect.md +43 -0
  45. package/docs/lessons/0015-frontend-backend-schema-drift.md +43 -0
  46. package/docs/lessons/0016-event-driven-cold-start-seeding.md +44 -0
  47. package/docs/lessons/0017-copy-paste-logic-diverges.md +43 -0
  48. package/docs/lessons/0018-layer-passes-pipeline-broken.md +45 -0
  49. package/docs/lessons/0019-systemd-envfile-ignores-export.md +41 -0
  50. package/docs/lessons/0020-persist-state-incrementally.md +44 -0
  51. package/docs/lessons/0021-dual-axis-testing.md +48 -0
  52. package/docs/lessons/0022-jsx-factory-shadowing.md +43 -0
  53. package/docs/lessons/0023-static-analysis-spiral.md +51 -0
  54. package/docs/lessons/0024-shared-pipeline-implementation.md +55 -0
  55. package/docs/lessons/0025-defense-in-depth-all-entry-points.md +65 -0
  56. package/docs/lessons/0026-linter-no-rules-false-enforcement.md +54 -0
  57. package/docs/lessons/0027-jsx-silent-prop-drop.md +64 -0
  58. package/docs/lessons/0028-no-infrastructure-in-client-code.md +49 -0
  59. package/docs/lessons/0029-never-write-secrets-to-files.md +61 -0
  60. package/docs/lessons/0030-cache-merge-not-replace.md +62 -0
  61. package/docs/lessons/0031-verify-units-at-boundaries.md +66 -0
  62. package/docs/lessons/0032-module-lifecycle-subscribe-unsubscribe.md +89 -0
  63. package/docs/lessons/0033-async-iteration-mutable-snapshot.md +72 -0
  64. package/docs/lessons/0034-caller-missing-await-silent-discard.md +65 -0
  65. package/docs/lessons/0035-duplicate-registration-silent-overwrite.md +85 -0
  66. package/docs/lessons/0036-websocket-dirty-disconnect.md +33 -0
  67. package/docs/lessons/0037-parallel-agents-worktree-corruption.md +31 -0
  68. package/docs/lessons/0038-subscribe-no-stored-ref.md +36 -0
  69. package/docs/lessons/0039-fallback-or-default-hides-bugs.md +34 -0
  70. package/docs/lessons/0040-event-firehose-filter-first.md +36 -0
  71. package/docs/lessons/0041-ambiguous-base-dir-path-nesting.md +32 -0
  72. package/docs/lessons/0042-spec-compliance-insufficient.md +36 -0
  73. package/docs/lessons/0043-exact-count-extensible-collections.md +32 -0
  74. package/docs/lessons/0044-relative-file-deps-worktree.md +39 -0
  75. package/docs/lessons/0045-iterative-design-improvement.md +33 -0
  76. package/docs/lessons/0046-plan-assertion-math-bugs.md +38 -0
  77. package/docs/lessons/0047-pytest-single-threaded-default.md +37 -0
  78. package/docs/lessons/0048-integration-wiring-batch.md +40 -0
  79. package/docs/lessons/0049-ab-verification.md +41 -0
  80. package/docs/lessons/0050-editing-sourced-files-during-execution.md +33 -0
  81. package/docs/lessons/0051-infrastructure-fixes-cant-self-heal.md +30 -0
  82. package/docs/lessons/0052-uncommitted-changes-poison-quality-gates.md +31 -0
  83. package/docs/lessons/0053-jq-compact-flag-inconsistency.md +31 -0
  84. package/docs/lessons/0054-parser-matches-inside-code-blocks.md +30 -0
  85. package/docs/lessons/0055-agents-compensate-for-garbled-prompts.md +31 -0
  86. package/docs/lessons/0056-grep-count-exit-code-on-zero.md +42 -0
  87. package/docs/lessons/0057-new-artifacts-break-git-clean-gates.md +42 -0
  88. package/docs/lessons/0058-dead-config-keys-never-consumed.md +49 -0
  89. package/docs/lessons/0059-contract-test-shared-structures.md +53 -0
  90. package/docs/lessons/0060-set-e-silent-death-in-runners.md +53 -0
  91. package/docs/lessons/0061-context-injection-dirty-state.md +50 -0
  92. package/docs/lessons/0062-sibling-bug-neighborhood-scan.md +29 -0
  93. package/docs/lessons/0063-one-flag-two-lifetimes.md +31 -0
  94. package/docs/lessons/0064-test-passes-wrong-reason.md +31 -0
  95. package/docs/lessons/0065-pipefail-grep-count-double-output.md +39 -0
  96. package/docs/lessons/0066-local-keyword-outside-function.md +37 -0
  97. package/docs/lessons/0067-stdin-hang-non-interactive-shell.md +36 -0
  98. package/docs/lessons/0068-agent-builds-wrong-thing-correctly.md +31 -0
  99. package/docs/lessons/0069-plan-quality-dominates-execution.md +30 -0
  100. package/docs/lessons/0070-spec-echo-back-prevents-drift.md +31 -0
  101. package/docs/lessons/0071-positive-instructions-outperform-negative.md +30 -0
  102. package/docs/lessons/0072-lost-in-the-middle-context-placement.md +30 -0
  103. package/docs/lessons/0073-unscoped-lessons-cause-false-positives.md +30 -0
  104. package/docs/lessons/0074-stale-context-injection-wrong-batch.md +32 -0
  105. package/docs/lessons/0075-research-artifacts-must-persist.md +32 -0
  106. package/docs/lessons/0076-wrong-decomposition-contaminates-downstream.md +30 -0
  107. package/docs/lessons/0077-cherry-pick-merges-need-manual-resolution.md +30 -0
  108. package/docs/lessons/0078-static-review-without-live-test.md +30 -0
  109. package/docs/lessons/0079-integration-wiring-batch-required.md +32 -0
  110. package/docs/lessons/FRAMEWORK.md +161 -0
  111. package/docs/lessons/SUMMARY.md +201 -0
  112. package/docs/lessons/TEMPLATE.md +85 -0
  113. package/docs/plans/2026-02-21-code-factory-v2-design.md +204 -0
  114. package/docs/plans/2026-02-21-code-factory-v2-implementation-plan.md +2189 -0
  115. package/docs/plans/2026-02-21-code-factory-v2-phase4-design.md +537 -0
  116. package/docs/plans/2026-02-21-code-factory-v2-phase4-implementation-plan.md +2012 -0
  117. package/docs/plans/2026-02-21-hardening-pass-design.md +108 -0
  118. package/docs/plans/2026-02-21-hardening-pass-plan.md +1378 -0
  119. package/docs/plans/2026-02-21-mab-research-report.md +406 -0
  120. package/docs/plans/2026-02-21-marketplace-restructure-design.md +240 -0
  121. package/docs/plans/2026-02-21-marketplace-restructure-plan.md +832 -0
  122. package/docs/plans/2026-02-21-phase4-completion-plan.md +697 -0
  123. package/docs/plans/2026-02-21-validator-suite-design.md +148 -0
  124. package/docs/plans/2026-02-21-validator-suite-plan.md +540 -0
  125. package/docs/plans/2026-02-22-mab-research-round2.md +556 -0
  126. package/docs/plans/2026-02-22-mab-run-design.md +462 -0
  127. package/docs/plans/2026-02-22-mab-run-plan.md +2046 -0
  128. package/docs/plans/2026-02-22-operations-design-methodology-research.md +681 -0
  129. package/docs/plans/2026-02-22-research-agent-failure-taxonomy.md +532 -0
  130. package/docs/plans/2026-02-22-research-code-guideline-policies.md +886 -0
  131. package/docs/plans/2026-02-22-research-codebase-audit-refactoring.md +908 -0
  132. package/docs/plans/2026-02-22-research-coding-standards-documentation.md +541 -0
  133. package/docs/plans/2026-02-22-research-competitive-landscape.md +687 -0
  134. package/docs/plans/2026-02-22-research-comprehensive-testing.md +1076 -0
  135. package/docs/plans/2026-02-22-research-context-utilization.md +459 -0
  136. package/docs/plans/2026-02-22-research-cost-quality-tradeoff.md +548 -0
  137. package/docs/plans/2026-02-22-research-lesson-transferability.md +508 -0
  138. package/docs/plans/2026-02-22-research-multi-agent-coordination.md +312 -0
  139. package/docs/plans/2026-02-22-research-phase-integration.md +602 -0
  140. package/docs/plans/2026-02-22-research-plan-quality.md +428 -0
  141. package/docs/plans/2026-02-22-research-prompt-engineering.md +558 -0
  142. package/docs/plans/2026-02-22-research-unconventional-perspectives.md +528 -0
  143. package/docs/plans/2026-02-22-research-user-adoption.md +638 -0
  144. package/docs/plans/2026-02-22-research-verification-effectiveness.md +433 -0
  145. package/docs/plans/2026-02-23-agent-suite-design.md +299 -0
  146. package/docs/plans/2026-02-23-agent-suite-plan.md +578 -0
  147. package/docs/plans/2026-02-23-phase3-cost-infrastructure-design.md +148 -0
  148. package/docs/plans/2026-02-23-phase3-cost-infrastructure-plan.md +1062 -0
  149. package/docs/plans/2026-02-23-research-bash-expert-agent.md +543 -0
  150. package/docs/plans/2026-02-23-research-dependency-auditor-agent.md +564 -0
  151. package/docs/plans/2026-02-23-research-improving-existing-agents.md +503 -0
  152. package/docs/plans/2026-02-23-research-integration-tester-agent.md +454 -0
  153. package/docs/plans/2026-02-23-research-python-expert-agent.md +429 -0
  154. package/docs/plans/2026-02-23-research-service-monitor-agent.md +425 -0
  155. package/docs/plans/2026-02-23-research-shell-expert-agent.md +533 -0
  156. package/docs/plans/2026-02-23-roadmap-to-completion.md +530 -0
  157. package/docs/plans/2026-02-24-headless-module-split-design.md +98 -0
  158. package/docs/plans/2026-02-24-headless-module-split.md +443 -0
  159. package/docs/plans/2026-02-24-lesson-scope-metadata-design.md +228 -0
  160. package/docs/plans/2026-02-24-lesson-scope-metadata-plan.md +968 -0
  161. package/docs/plans/2026-02-24-npm-packaging-design.md +841 -0
  162. package/docs/plans/2026-02-24-npm-packaging-plan.md +1965 -0
  163. package/docs/plans/audit-findings.md +186 -0
  164. package/docs/telegram-notification-format.md +98 -0
  165. package/examples/example-plan.md +51 -0
  166. package/examples/example-prd.json +72 -0
  167. package/examples/example-roadmap.md +33 -0
  168. package/examples/quickstart-plan.md +63 -0
  169. package/hooks/hooks.json +26 -0
  170. package/hooks/setup-symlinks.sh +48 -0
  171. package/hooks/stop-hook.sh +135 -0
  172. package/package.json +47 -0
  173. package/policies/bash.md +71 -0
  174. package/policies/python.md +71 -0
  175. package/policies/testing.md +61 -0
  176. package/policies/universal.md +60 -0
  177. package/scripts/analyze-report.sh +97 -0
  178. package/scripts/architecture-map.sh +145 -0
  179. package/scripts/auto-compound.sh +273 -0
  180. package/scripts/batch-audit.sh +42 -0
  181. package/scripts/batch-test.sh +101 -0
  182. package/scripts/entropy-audit.sh +221 -0
  183. package/scripts/failure-digest.sh +51 -0
  184. package/scripts/generate-ast-rules.sh +96 -0
  185. package/scripts/init.sh +112 -0
  186. package/scripts/lesson-check.sh +428 -0
  187. package/scripts/lib/common.sh +61 -0
  188. package/scripts/lib/cost-tracking.sh +153 -0
  189. package/scripts/lib/ollama.sh +60 -0
  190. package/scripts/lib/progress-writer.sh +128 -0
  191. package/scripts/lib/run-plan-context.sh +215 -0
  192. package/scripts/lib/run-plan-echo-back.sh +231 -0
  193. package/scripts/lib/run-plan-headless.sh +396 -0
  194. package/scripts/lib/run-plan-notify.sh +57 -0
  195. package/scripts/lib/run-plan-parser.sh +81 -0
  196. package/scripts/lib/run-plan-prompt.sh +215 -0
  197. package/scripts/lib/run-plan-quality-gate.sh +132 -0
  198. package/scripts/lib/run-plan-routing.sh +315 -0
  199. package/scripts/lib/run-plan-sampling.sh +170 -0
  200. package/scripts/lib/run-plan-scoring.sh +146 -0
  201. package/scripts/lib/run-plan-state.sh +142 -0
  202. package/scripts/lib/run-plan-team.sh +199 -0
  203. package/scripts/lib/telegram.sh +54 -0
  204. package/scripts/lib/thompson-sampling.sh +176 -0
  205. package/scripts/license-check.sh +74 -0
  206. package/scripts/mab-run.sh +575 -0
  207. package/scripts/module-size-check.sh +146 -0
  208. package/scripts/patterns/async-no-await.yml +5 -0
  209. package/scripts/patterns/bare-except.yml +6 -0
  210. package/scripts/patterns/empty-catch.yml +6 -0
  211. package/scripts/patterns/hardcoded-localhost.yml +9 -0
  212. package/scripts/patterns/retry-loop-no-backoff.yml +12 -0
  213. package/scripts/pipeline-status.sh +197 -0
  214. package/scripts/policy-check.sh +226 -0
  215. package/scripts/prior-art-search.sh +133 -0
  216. package/scripts/promote-mab-lessons.sh +126 -0
  217. package/scripts/prompts/agent-a-superpowers.md +29 -0
  218. package/scripts/prompts/agent-b-ralph.md +29 -0
  219. package/scripts/prompts/judge-agent.md +61 -0
  220. package/scripts/prompts/planner-agent.md +44 -0
  221. package/scripts/pull-community-lessons.sh +90 -0
  222. package/scripts/quality-gate.sh +266 -0
  223. package/scripts/research-gate.sh +90 -0
  224. package/scripts/run-plan.sh +329 -0
  225. package/scripts/scope-infer.sh +159 -0
  226. package/scripts/setup-ralph-loop.sh +155 -0
  227. package/scripts/telemetry.sh +230 -0
  228. package/scripts/tests/run-all-tests.sh +52 -0
  229. package/scripts/tests/test-act-cli.sh +46 -0
  230. package/scripts/tests/test-agents-md.sh +87 -0
  231. package/scripts/tests/test-analyze-report.sh +114 -0
  232. package/scripts/tests/test-architecture-map.sh +89 -0
  233. package/scripts/tests/test-auto-compound.sh +169 -0
  234. package/scripts/tests/test-batch-test.sh +65 -0
  235. package/scripts/tests/test-benchmark-runner.sh +25 -0
  236. package/scripts/tests/test-common.sh +168 -0
  237. package/scripts/tests/test-cost-tracking.sh +158 -0
  238. package/scripts/tests/test-echo-back.sh +180 -0
  239. package/scripts/tests/test-entropy-audit.sh +146 -0
  240. package/scripts/tests/test-failure-digest.sh +66 -0
  241. package/scripts/tests/test-generate-ast-rules.sh +145 -0
  242. package/scripts/tests/test-helpers.sh +82 -0
  243. package/scripts/tests/test-init.sh +47 -0
  244. package/scripts/tests/test-lesson-check.sh +278 -0
  245. package/scripts/tests/test-lesson-local.sh +55 -0
  246. package/scripts/tests/test-license-check.sh +109 -0
  247. package/scripts/tests/test-mab-run.sh +182 -0
  248. package/scripts/tests/test-ollama-lib.sh +49 -0
  249. package/scripts/tests/test-ollama.sh +60 -0
  250. package/scripts/tests/test-pipeline-status.sh +198 -0
  251. package/scripts/tests/test-policy-check.sh +124 -0
  252. package/scripts/tests/test-prior-art-search.sh +96 -0
  253. package/scripts/tests/test-progress-writer.sh +140 -0
  254. package/scripts/tests/test-promote-mab-lessons.sh +110 -0
  255. package/scripts/tests/test-pull-community-lessons.sh +149 -0
  256. package/scripts/tests/test-quality-gate.sh +241 -0
  257. package/scripts/tests/test-research-gate.sh +132 -0
  258. package/scripts/tests/test-run-plan-cli.sh +86 -0
  259. package/scripts/tests/test-run-plan-context.sh +305 -0
  260. package/scripts/tests/test-run-plan-e2e.sh +153 -0
  261. package/scripts/tests/test-run-plan-headless.sh +424 -0
  262. package/scripts/tests/test-run-plan-notify.sh +124 -0
  263. package/scripts/tests/test-run-plan-parser.sh +217 -0
  264. package/scripts/tests/test-run-plan-prompt.sh +254 -0
  265. package/scripts/tests/test-run-plan-quality-gate.sh +222 -0
  266. package/scripts/tests/test-run-plan-routing.sh +178 -0
  267. package/scripts/tests/test-run-plan-scoring.sh +148 -0
  268. package/scripts/tests/test-run-plan-state.sh +261 -0
  269. package/scripts/tests/test-run-plan-team.sh +157 -0
  270. package/scripts/tests/test-scope-infer.sh +150 -0
  271. package/scripts/tests/test-setup-ralph-loop.sh +63 -0
  272. package/scripts/tests/test-telegram-env.sh +38 -0
  273. package/scripts/tests/test-telegram.sh +121 -0
  274. package/scripts/tests/test-telemetry.sh +46 -0
  275. package/scripts/tests/test-thompson-sampling.sh +139 -0
  276. package/scripts/tests/test-validate-all.sh +60 -0
  277. package/scripts/tests/test-validate-commands.sh +89 -0
  278. package/scripts/tests/test-validate-hooks.sh +98 -0
  279. package/scripts/tests/test-validate-lessons.sh +150 -0
  280. package/scripts/tests/test-validate-plan-quality.sh +235 -0
  281. package/scripts/tests/test-validate-plans.sh +187 -0
  282. package/scripts/tests/test-validate-plugin.sh +106 -0
  283. package/scripts/tests/test-validate-prd.sh +184 -0
  284. package/scripts/tests/test-validate-skills.sh +134 -0
  285. package/scripts/validate-all.sh +57 -0
  286. package/scripts/validate-commands.sh +67 -0
  287. package/scripts/validate-hooks.sh +89 -0
  288. package/scripts/validate-lessons.sh +98 -0
  289. package/scripts/validate-plan-quality.sh +369 -0
  290. package/scripts/validate-plans.sh +120 -0
  291. package/scripts/validate-plugin.sh +86 -0
  292. package/scripts/validate-policies.sh +42 -0
  293. package/scripts/validate-prd.sh +118 -0
  294. package/scripts/validate-skills.sh +96 -0
  295. package/skills/autocode/SKILL.md +285 -0
  296. package/skills/autocode/ab-verification.md +51 -0
  297. package/skills/autocode/code-quality-standards.md +37 -0
  298. package/skills/autocode/competitive-mode.md +364 -0
  299. package/skills/brainstorming/SKILL.md +97 -0
  300. package/skills/capture-lesson/SKILL.md +187 -0
  301. package/skills/check-lessons/SKILL.md +116 -0
  302. package/skills/dispatching-parallel-agents/SKILL.md +110 -0
  303. package/skills/executing-plans/SKILL.md +85 -0
  304. package/skills/finishing-a-development-branch/SKILL.md +201 -0
  305. package/skills/receiving-code-review/SKILL.md +72 -0
  306. package/skills/requesting-code-review/SKILL.md +59 -0
  307. package/skills/requesting-code-review/code-reviewer.md +82 -0
  308. package/skills/research/SKILL.md +145 -0
  309. package/skills/roadmap/SKILL.md +115 -0
  310. package/skills/subagent-driven-development/SKILL.md +98 -0
  311. package/skills/subagent-driven-development/code-quality-reviewer-prompt.md +18 -0
  312. package/skills/subagent-driven-development/implementer-prompt.md +73 -0
  313. package/skills/subagent-driven-development/spec-reviewer-prompt.md +57 -0
  314. package/skills/systematic-debugging/SKILL.md +134 -0
  315. package/skills/systematic-debugging/condition-based-waiting.md +64 -0
  316. package/skills/systematic-debugging/defense-in-depth.md +32 -0
  317. package/skills/systematic-debugging/root-cause-tracing.md +55 -0
  318. package/skills/test-driven-development/SKILL.md +167 -0
  319. package/skills/using-git-worktrees/SKILL.md +219 -0
  320. package/skills/using-superpowers/SKILL.md +54 -0
  321. package/skills/verification-before-completion/SKILL.md +140 -0
  322. package/skills/verify/SKILL.md +82 -0
  323. package/skills/writing-plans/SKILL.md +128 -0
  324. package/skills/writing-skills/SKILL.md +93 -0
@@ -0,0 +1,134 @@
1
+ ---
2
+ name: systematic-debugging
3
+ description: Use when encountering any bug, test failure, or unexpected behavior, before proposing fixes
4
+ version: 1.0.0
5
+ ---
6
+
7
+ # Systematic Debugging
8
+
9
+ ## Overview
10
+
11
+ Random fixes waste time and create new bugs. Quick patches mask underlying issues.
12
+
13
+ **Core principle:** ALWAYS find root cause before attempting fixes. Symptom fixes are failure.
14
+
15
+ **Violating the letter of this process is violating the spirit of debugging.**
16
+
17
+ ## The Iron Law
18
+
19
+ ```
20
+ NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST
21
+ ```
22
+
23
+ If you haven't completed Phase 1, you cannot propose fixes.
24
+
25
+ ## When to Use
26
+
27
+ Use for ANY technical issue:
28
+ - Test failures
29
+ - Bugs in production
30
+ - Unexpected behavior
31
+ - Performance problems
32
+ - Build failures
33
+ - Integration issues
34
+
35
+ ## The Four Phases
36
+
37
+ You MUST complete each phase before proceeding to the next.
38
+
39
+ ### Phase 1: Root Cause Investigation
40
+
41
+ **BEFORE attempting ANY fix:**
42
+
43
+ 1. **Read Error Messages Carefully**
44
+ - Don't skip past errors or warnings
45
+ - Read stack traces completely
46
+ - Note line numbers, file paths, error codes
47
+
48
+ 2. **Reproduce Consistently**
49
+ - Can you trigger it reliably?
50
+ - What are the exact steps?
51
+ - If not reproducible → gather more data, don't guess
52
+
53
+ 3. **Check Recent Changes**
54
+ - What changed that could cause this?
55
+ - Git diff, recent commits
56
+ - New dependencies, config changes
57
+
58
+ 4. **Gather Evidence in Multi-Component Systems**
59
+
60
+ **WHEN system has multiple components:**
61
+
62
+ **BEFORE proposing fixes, add diagnostic instrumentation:**
63
+ ```
64
+ For EACH component boundary:
65
+ - Log what data enters component
66
+ - Log what data exits component
67
+ - Verify environment/config propagation
68
+ - Check state at each layer
69
+
70
+ Run once to gather evidence showing WHERE it breaks
71
+ THEN analyze evidence to identify failing component
72
+ THEN investigate that specific component
73
+ ```
74
+
75
+ 5. **Trace Data Flow**
76
+ - Where does bad value originate?
77
+ - What called this with bad value?
78
+ - Keep tracing up until you find the source
79
+ - Fix at source, not at symptom
80
+
81
+ ### Phase 2: Pattern Analysis
82
+
83
+ 1. **Find Working Examples** - Locate similar working code
84
+ 2. **Compare Against References** - Read reference implementation COMPLETELY
85
+ 3. **Identify Differences** - List every difference, however small
86
+ 4. **Understand Dependencies** - What other components does this need?
87
+
88
+ ### Phase 3: Hypothesis and Testing
89
+
90
+ 1. **Form Single Hypothesis** - "I think X is the root cause because Y"
91
+ 2. **Test Minimally** - SMALLEST possible change, one variable at a time
92
+ 3. **Verify Before Continuing** - Did it work? If not, form NEW hypothesis
93
+ 4. **When You Don't Know** - Say so. Don't pretend.
94
+
95
+ ### Phase 4: Implementation
96
+
97
+ 1. **Create Failing Test Case** - Simplest possible reproduction
98
+ 2. **Implement Single Fix** - ONE change at a time, no "while I'm here" improvements
99
+ 3. **Verify Fix** - Test passes? No other tests broken?
100
+ 4. **If Fix Doesn't Work** - If < 3 attempts: return to Phase 1. If >= 3: question the architecture.
101
+
102
+ ## Red Flags - STOP and Follow Process
103
+
104
+ - "Quick fix for now, investigate later"
105
+ - "Just try changing X and see if it works"
106
+ - "I don't fully understand but this might work"
107
+ - Proposing solutions before tracing data flow
108
+ - **"One more fix attempt" (when already tried 2+)**
109
+
110
+ **ALL of these mean: STOP. Return to Phase 1.**
111
+
112
+ ## Common Rationalizations
113
+
114
+ | Excuse | Reality |
115
+ |--------|---------|
116
+ | "Issue is simple, don't need process" | Simple issues have root causes too. |
117
+ | "Emergency, no time for process" | Systematic debugging is FASTER than thrashing. |
118
+ | "I see the problem, let me fix it" | Seeing symptoms ≠ understanding root cause. |
119
+ | "One more fix attempt" (after 2+ failures) | 3+ failures = architectural problem. |
120
+
121
+ ## Quick Reference
122
+
123
+ | Phase | Key Activities | Success Criteria |
124
+ |-------|---------------|------------------|
125
+ | **1. Root Cause** | Read errors, reproduce, check changes | Understand WHAT and WHY |
126
+ | **2. Pattern** | Find working examples, compare | Identify differences |
127
+ | **3. Hypothesis** | Form theory, test minimally | Confirmed or new hypothesis |
128
+ | **4. Implementation** | Create test, fix, verify | Bug resolved, tests pass |
129
+
130
+ ## Supporting Techniques
131
+
132
+ - **root-cause-tracing.md** - Trace bugs backward through call stack
133
+ - **defense-in-depth.md** - Add validation at multiple layers after finding root cause
134
+ - **condition-based-waiting.md** - Replace arbitrary timeouts with condition polling
@@ -0,0 +1,64 @@
1
+ # Condition-Based Waiting
2
+
3
+ ## Overview
4
+
5
+ Flaky tests often guess at timing with arbitrary delays. This creates race conditions.
6
+
7
+ **Core principle:** Wait for the actual condition you care about, not a guess about how long it takes.
8
+
9
+ ## Core Pattern
10
+
11
+ ```typescript
12
+ // ❌ BEFORE: Guessing at timing
13
+ await new Promise(r => setTimeout(r, 50));
14
+ const result = getResult();
15
+ expect(result).toBeDefined();
16
+
17
+ // ✅ AFTER: Waiting for condition
18
+ await waitFor(() => getResult() !== undefined);
19
+ const result = getResult();
20
+ expect(result).toBeDefined();
21
+ ```
22
+
23
+ ## Quick Patterns
24
+
25
+ | Scenario | Pattern |
26
+ |----------|---------|
27
+ | Wait for event | `waitFor(() => events.find(e => e.type === 'DONE'))` |
28
+ | Wait for state | `waitFor(() => machine.state === 'ready')` |
29
+ | Wait for count | `waitFor(() => items.length >= 5)` |
30
+ | Wait for file | `waitFor(() => fs.existsSync(path))` |
31
+
32
+ ## Implementation
33
+
34
+ ```typescript
35
+ async function waitFor<T>(
36
+ condition: () => T | undefined | null | false,
37
+ description: string,
38
+ timeoutMs = 5000
39
+ ): Promise<T> {
40
+ const startTime = Date.now();
41
+
42
+ while (true) {
43
+ const result = condition();
44
+ if (result) return result;
45
+
46
+ if (Date.now() - startTime > timeoutMs) {
47
+ throw new Error(`Timeout waiting for ${description} after ${timeoutMs}ms`);
48
+ }
49
+
50
+ await new Promise(r => setTimeout(r, 10)); // Poll every 10ms
51
+ }
52
+ }
53
+ ```
54
+
55
+ ## Common Mistakes
56
+
57
+ **❌ Polling too fast:** `setTimeout(check, 1)` - wastes CPU
58
+ **✅ Fix:** Poll every 10ms
59
+
60
+ **❌ No timeout:** Loop forever if condition never met
61
+ **✅ Fix:** Always include timeout with clear error
62
+
63
+ **❌ Stale data:** Cache state before loop
64
+ **✅ Fix:** Call getter inside loop for fresh data
@@ -0,0 +1,32 @@
1
+ # Defense-in-Depth Validation
2
+
3
+ ## Overview
4
+
5
+ When you fix a bug caused by invalid data, adding validation at one place feels sufficient. But that single check can be bypassed by different code paths, refactoring, or mocks.
6
+
7
+ **Core principle:** Validate at EVERY layer data passes through. Make the bug structurally impossible.
8
+
9
+ ## The Four Layers
10
+
11
+ ### Layer 1: Entry Point Validation
12
+ Reject obviously invalid input at API boundary
13
+
14
+ ### Layer 2: Business Logic Validation
15
+ Ensure data makes sense for this operation
16
+
17
+ ### Layer 3: Environment Guards
18
+ Prevent dangerous operations in specific contexts
19
+
20
+ ### Layer 4: Debug Instrumentation
21
+ Capture context for forensics
22
+
23
+ ## Applying the Pattern
24
+
25
+ When you find a bug:
26
+
27
+ 1. **Trace the data flow** - Where does bad value originate? Where used?
28
+ 2. **Map all checkpoints** - List every point data passes through
29
+ 3. **Add validation at each layer** - Entry, business, environment, debug
30
+ 4. **Test each layer** - Try to bypass layer 1, verify layer 2 catches it
31
+
32
+ **Don't stop at one validation point.** Add checks at every layer.
@@ -0,0 +1,55 @@
1
+ # Root Cause Tracing
2
+
3
+ ## Overview
4
+
5
+ Bugs often manifest deep in the call stack. Your instinct is to fix where the error appears, but that's treating a symptom.
6
+
7
+ **Core principle:** Trace backward through the call chain until you find the original trigger, then fix at the source.
8
+
9
+ ## When to Use
10
+
11
+ **Use when:**
12
+ - Error happens deep in execution (not at entry point)
13
+ - Stack trace shows long call chain
14
+ - Unclear where invalid data originated
15
+
16
+ ## The Tracing Process
17
+
18
+ ### 1. Observe the Symptom
19
+ ```
20
+ Error: git init failed in /Users/jesse/project/packages/core
21
+ ```
22
+
23
+ ### 2. Find Immediate Cause
24
+ ```typescript
25
+ await execFileAsync('git', ['init'], { cwd: projectDir });
26
+ ```
27
+
28
+ ### 3. Ask: What Called This?
29
+ ```typescript
30
+ WorktreeManager.createSessionWorktree(projectDir, sessionId)
31
+ → called by Session.initializeWorkspace()
32
+ → called by Session.create()
33
+ → called by test at Project.create()
34
+ ```
35
+
36
+ ### 4. Keep Tracing Up
37
+ - `projectDir = ''` (empty string!)
38
+ - Empty string as `cwd` resolves to `process.cwd()`
39
+
40
+ ### 5. Find Original Trigger
41
+ ```typescript
42
+ const context = setupCoreTest(); // Returns { tempDir: '' }
43
+ Project.create('name', context.tempDir); // Accessed before beforeEach!
44
+ ```
45
+
46
+ ## Key Principle
47
+
48
+ **NEVER fix just where the error appears.** Trace back to find the original trigger.
49
+
50
+ ## Stack Trace Tips
51
+
52
+ - **In tests:** Use `console.error()` not logger
53
+ - **Before operation:** Log before the dangerous operation, not after it fails
54
+ - **Include context:** Directory, cwd, environment variables
55
+ - **Capture stack:** `new Error().stack` shows complete call chain
@@ -0,0 +1,167 @@
1
+ ---
2
+ name: test-driven-development
3
+ description: Use when implementing any feature or bugfix, before writing implementation code
4
+ version: 1.0.0
5
+ ---
6
+
7
+ # Test-Driven Development (TDD)
8
+
9
+ ## Overview
10
+
11
+ Write the test first. Watch it fail. Write minimal code to pass.
12
+
13
+ **Core principle:** If you didn't watch the test fail, you don't know if it tests the right thing.
14
+
15
+ **Violating the letter of the rules is violating the spirit of the rules.**
16
+
17
+ ## When to Use
18
+
19
+ **Always:**
20
+ - New features
21
+ - Bug fixes
22
+ - Refactoring
23
+ - Behavior changes
24
+
25
+ **Exceptions (ask your human partner):**
26
+ - Throwaway prototypes
27
+ - Generated code
28
+ - Configuration files
29
+
30
+ Thinking "skip TDD just this once"? Stop. That's rationalization.
31
+
32
+ ## The Iron Law
33
+
34
+ ```
35
+ NO PRODUCTION CODE WITHOUT A FAILING TEST FIRST
36
+ ```
37
+
38
+ Write code before the test? Delete it. Start over.
39
+
40
+ **No exceptions:**
41
+ - Don't keep it as "reference"
42
+ - Don't "adapt" it while writing tests
43
+ - Don't look at it
44
+ - Delete means delete
45
+
46
+ Implement fresh from tests. Period.
47
+
48
+ ## Red-Green-Refactor
49
+
50
+ ### RED - Write Failing Test
51
+
52
+ Write one minimal test showing what should happen.
53
+
54
+ **Requirements:**
55
+ - One behavior
56
+ - Clear name
57
+ - Real code (no mocks unless unavoidable)
58
+
59
+ ### Verify RED - Watch It Fail
60
+
61
+ **MANDATORY. Never skip.**
62
+
63
+ ```bash
64
+ npm test path/to/test.test.ts
65
+ ```
66
+
67
+ Confirm:
68
+ - Test fails (not errors)
69
+ - Failure message is expected
70
+ - Fails because feature missing (not typos)
71
+
72
+ **Test passes?** You're testing existing behavior. Fix test.
73
+
74
+ **Test errors?** Fix error, re-run until it fails correctly.
75
+
76
+ ### GREEN - Minimal Code
77
+
78
+ Write simplest code to pass the test.
79
+
80
+ Don't add features, refactor other code, or "improve" beyond the test.
81
+
82
+ ### Verify GREEN - Watch It Pass
83
+
84
+ **MANDATORY.**
85
+
86
+ ```bash
87
+ npm test path/to/test.test.ts
88
+ ```
89
+
90
+ Confirm:
91
+ - Test passes
92
+ - Other tests still pass
93
+ - Output pristine (no errors, warnings)
94
+
95
+ **Test fails?** Fix code, not test.
96
+
97
+ **Other tests fail?** Fix now.
98
+
99
+ ### REFACTOR - Clean Up
100
+
101
+ After green only:
102
+ - Remove duplication
103
+ - Improve names
104
+ - Extract helpers
105
+
106
+ Keep tests green. Don't add behavior.
107
+
108
+ ### Repeat
109
+
110
+ Next failing test for next feature.
111
+
112
+ ## Common Rationalizations
113
+
114
+ | Excuse | Reality |
115
+ |--------|---------|
116
+ | "Too simple to test" | Simple code breaks. Test takes 30 seconds. |
117
+ | "I'll test after" | Tests passing immediately prove nothing. |
118
+ | "Tests after achieve same goals" | Tests-after = "what does this do?" Tests-first = "what should this do?" |
119
+ | "Already manually tested" | Ad-hoc ≠ systematic. No record, can't re-run. |
120
+ | "Deleting X hours is wasteful" | Sunk cost fallacy. Keeping unverified code is technical debt. |
121
+ | "Keep as reference, write tests first" | You'll adapt it. That's testing after. Delete means delete. |
122
+ | "Need to explore first" | Fine. Throw away exploration, start with TDD. |
123
+ | "Test hard = design unclear" | Listen to test. Hard to test = hard to use. |
124
+ | "TDD will slow me down" | TDD faster than debugging. Pragmatic = test-first. |
125
+
126
+ ## Red Flags - STOP and Start Over
127
+
128
+ - Code before test
129
+ - Test after implementation
130
+ - Test passes immediately
131
+ - Can't explain why test failed
132
+ - Tests added "later"
133
+ - Rationalizing "just this once"
134
+ - "I already manually tested it"
135
+ - "Tests after achieve the same purpose"
136
+
137
+ **All of these mean: Delete code. Start over with TDD.**
138
+
139
+ ## Verification Checklist
140
+
141
+ Before marking work complete:
142
+
143
+ - [ ] Every new function/method has a test
144
+ - [ ] Watched each test fail before implementing
145
+ - [ ] Each test failed for expected reason (feature missing, not typo)
146
+ - [ ] Wrote minimal code to pass each test
147
+ - [ ] All tests pass
148
+ - [ ] Output pristine (no errors, warnings)
149
+ - [ ] Tests use real code (mocks only if unavoidable)
150
+ - [ ] Edge cases and errors covered
151
+
152
+ Can't check all boxes? You skipped TDD. Start over.
153
+
154
+ ## Debugging Integration
155
+
156
+ Bug found? Write failing test reproducing it. Follow TDD cycle. Test proves fix and prevents regression.
157
+
158
+ Never fix bugs without a test.
159
+
160
+ ## Final Rule
161
+
162
+ ```
163
+ Production code → test exists and failed first
164
+ Otherwise → not TDD
165
+ ```
166
+
167
+ No exceptions without your human partner's permission.
@@ -0,0 +1,219 @@
1
+ ---
2
+ name: using-git-worktrees
3
+ description: Use when starting feature work that needs isolation from current workspace or before executing implementation plans - creates isolated git worktrees with smart directory selection and safety verification
4
+ version: 1.0.0
5
+ ---
6
+
7
+ # Using Git Worktrees
8
+
9
+ ## Overview
10
+
11
+ Git worktrees create isolated workspaces sharing the same repository, allowing work on multiple branches simultaneously without switching.
12
+
13
+ **Core principle:** Systematic directory selection + safety verification = reliable isolation.
14
+
15
+ **Announce at start:** "I'm using the using-git-worktrees skill to set up an isolated workspace."
16
+
17
+ ## Directory Selection Process
18
+
19
+ Follow this priority order:
20
+
21
+ ### 1. Check Existing Directories
22
+
23
+ ```bash
24
+ # Check in priority order
25
+ ls -d .worktrees 2>/dev/null # Preferred (hidden)
26
+ ls -d worktrees 2>/dev/null # Alternative
27
+ ```
28
+
29
+ **If found:** Use that directory. If both exist, `.worktrees` wins.
30
+
31
+ ### 2. Check `CLAUDE.md`
32
+
33
+ ```bash
34
+ grep -i "worktree.*director" CLAUDE.md 2>/dev/null
35
+ ```
36
+
37
+ **If preference specified:** Use it without asking.
38
+
39
+ ### 3. Ask User
40
+
41
+ If no directory exists and no `CLAUDE.md` preference:
42
+
43
+ ```
44
+ No worktree directory found. Where should I create worktrees?
45
+
46
+ 1. .worktrees/ (project-local, hidden)
47
+ 2. ~/.config/superpowers/worktrees/<project-name>/ (global location)
48
+
49
+ Which would you prefer?
50
+ ```
51
+
52
+ ## Safety Verification
53
+
54
+ ### For Project-Local Directories (.worktrees or worktrees)
55
+
56
+ **MUST verify directory is ignored before creating worktree:**
57
+
58
+ ```bash
59
+ # Check if directory is ignored (respects local, global, and system gitignore)
60
+ git check-ignore -q .worktrees 2>/dev/null || git check-ignore -q worktrees 2>/dev/null
61
+ ```
62
+
63
+ **If NOT ignored:**
64
+
65
+ Per Jesse's rule "Fix broken things immediately":
66
+ 1. Add appropriate line to .gitignore
67
+ 2. Commit the change
68
+ 3. Proceed with worktree creation
69
+
70
+ **Why critical:** Prevents accidentally committing worktree contents to repository.
71
+
72
+ ### For Global Directory (~/.config/superpowers/worktrees)
73
+
74
+ No .gitignore verification needed - outside project entirely.
75
+
76
+ ## Creation Steps
77
+
78
+ ### 1. Detect Project Name
79
+
80
+ ```bash
81
+ project=$(basename "$(git rev-parse --show-toplevel)")
82
+ ```
83
+
84
+ ### 2. Create Worktree
85
+
86
+ ```bash
87
+ # Determine full path
88
+ case $LOCATION in
89
+ .worktrees|worktrees)
90
+ path="$LOCATION/$BRANCH_NAME"
91
+ ;;
92
+ ~/.config/superpowers/worktrees/*)
93
+ path="~/.config/superpowers/worktrees/$project/$BRANCH_NAME"
94
+ ;;
95
+ esac
96
+
97
+ # Create worktree with new branch
98
+ git worktree add "$path" -b "$BRANCH_NAME"
99
+ cd "$path"
100
+ ```
101
+
102
+ ### 3. Run Project Setup
103
+
104
+ Auto-detect and run appropriate setup:
105
+
106
+ ```bash
107
+ # Node.js
108
+ if [ -f package.json ]; then npm install; fi
109
+
110
+ # Rust
111
+ if [ -f Cargo.toml ]; then cargo build; fi
112
+
113
+ # Python
114
+ if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
115
+ if [ -f pyproject.toml ]; then poetry install; fi
116
+
117
+ # Go
118
+ if [ -f go.mod ]; then go mod download; fi
119
+ ```
120
+
121
+ ### 4. Verify Clean Baseline
122
+
123
+ Run tests to ensure worktree starts clean:
124
+
125
+ ```bash
126
+ # Examples - use project-appropriate command
127
+ npm test
128
+ cargo test
129
+ pytest
130
+ go test ./...
131
+ ```
132
+
133
+ **If tests fail:** Report failures, ask whether to proceed or investigate.
134
+
135
+ **If tests pass:** Report ready.
136
+
137
+ ### 5. Report Location
138
+
139
+ ```
140
+ Worktree ready at <full-path>
141
+ Tests passing (<N> tests, 0 failures)
142
+ Ready to implement <feature-name>
143
+ ```
144
+
145
+ ## Quick Reference
146
+
147
+ | Situation | Action |
148
+ |-----------|--------|
149
+ | `.worktrees/` exists | Use it (verify ignored) |
150
+ | `worktrees/` exists | Use it (verify ignored) |
151
+ | Both exist | Use `.worktrees/` |
152
+ | Neither exists | Check `CLAUDE.md` → Ask user |
153
+ | Directory not ignored | Add to .gitignore + commit |
154
+ | Tests fail during baseline | Report failures + ask |
155
+ | No package.json/Cargo.toml | Skip dependency install |
156
+
157
+ ## Common Mistakes
158
+
159
+ ### Skipping ignore verification
160
+
161
+ - **Problem:** Worktree contents get tracked, pollute git status
162
+ - **Fix:** Always use `git check-ignore` before creating project-local worktree
163
+
164
+ ### Assuming directory location
165
+
166
+ - **Problem:** Creates inconsistency, violates project conventions
167
+ - **Fix:** Follow priority: existing > `CLAUDE.md` > ask
168
+
169
+ ### Proceeding with failing tests
170
+
171
+ - **Problem:** Can't distinguish new bugs from pre-existing issues
172
+ - **Fix:** Report failures, get explicit permission to proceed
173
+
174
+ ### Hardcoding setup commands
175
+
176
+ - **Problem:** Breaks on projects using different tools
177
+ - **Fix:** Auto-detect from project files (package.json, etc.)
178
+
179
+ ## Example Workflow
180
+
181
+ ```
182
+ You: I'm using the using-git-worktrees skill to set up an isolated workspace.
183
+
184
+ [Check .worktrees/ - exists]
185
+ [Verify ignored - git check-ignore confirms .worktrees/ is ignored]
186
+ [Create worktree: git worktree add .worktrees/auth -b feature/auth]
187
+ [Run npm install]
188
+ [Run npm test - 47 passing]
189
+
190
+ Worktree ready at /Users/jesse/myproject/.worktrees/auth
191
+ Tests passing (47 tests, 0 failures)
192
+ Ready to implement auth feature
193
+ ```
194
+
195
+ ## Red Flags
196
+
197
+ **Never:**
198
+ - Create worktree without verifying it's ignored (project-local)
199
+ - Skip baseline test verification
200
+ - Proceed with failing tests without asking
201
+ - Assume directory location when ambiguous
202
+ - Skip `CLAUDE.md` check
203
+
204
+ **Always:**
205
+ - Follow directory priority: existing > `CLAUDE.md` > ask
206
+ - Verify directory is ignored for project-local
207
+ - Auto-detect and run project setup
208
+ - Verify clean test baseline
209
+
210
+ ## Integration
211
+
212
+ **Called by:**
213
+ - **brainstorming** (Phase 4) - REQUIRED when design is approved and implementation follows
214
+ - **subagent-driven-development** - REQUIRED before executing any tasks
215
+ - **executing-plans** - REQUIRED before executing any tasks
216
+ - Any skill needing isolated workspace
217
+
218
+ **Pairs with:**
219
+ - **finishing-a-development-branch** - REQUIRED for cleanup after work complete