@relipa/ai-flow-kit 0.1.1 → 0.1.2

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 (253) hide show
  1. package/README.md +0 -0
  2. package/bin/aiflow.js +55 -2
  3. package/bin/ak.js +0 -0
  4. package/custom/mcp-presets/README.md +204 -237
  5. package/custom/mcp-presets/backlog.json +0 -0
  6. package/custom/mcp-presets/figma-desktop.json +0 -0
  7. package/custom/mcp-presets/figma.json +0 -0
  8. package/custom/mcp-presets/gitnexus.json +0 -0
  9. package/custom/mcp-presets/google-sheets.json +0 -0
  10. package/custom/mcp-presets/jira.json +0 -0
  11. package/custom/prompts/bug-fix.md +0 -0
  12. package/custom/prompts/feature.md +0 -0
  13. package/custom/prompts/investigation.md +0 -0
  14. package/custom/rules/code-style.md +0 -0
  15. package/custom/rules/java/code-style.md +0 -0
  16. package/custom/rules/java/naming.md +0 -0
  17. package/custom/rules/java/review-checklist.md +0 -0
  18. package/custom/rules/java/spring-boot-examples.md +0 -0
  19. package/custom/rules/javascript/code-style.md +0 -0
  20. package/custom/rules/javascript/naming.md +0 -0
  21. package/custom/rules/ml-conventions.md +88 -0
  22. package/custom/rules/ml-review-checklist.md +14 -0
  23. package/custom/rules/naming.md +0 -0
  24. package/custom/rules/php/code-style.md +0 -0
  25. package/custom/rules/php/naming.md +0 -0
  26. package/custom/rules/project-conventions.md +0 -0
  27. package/custom/rules/review-checklist.md +0 -0
  28. package/custom/skills/deploy-model/SKILL.md +90 -0
  29. package/custom/skills/design-experiment/SKILL.md +88 -0
  30. package/custom/skills/evaluate-model/SKILL.md +93 -0
  31. package/custom/skills/explore-data/SKILL.md +87 -0
  32. package/custom/skills/figma-to-component/SKILL.md +0 -0
  33. package/custom/skills/frame-ml-problem/SKILL.md +88 -0
  34. package/custom/skills/generate-spec/SKILL.md +0 -0
  35. package/custom/skills/impact-analysis/SKILL.md +0 -0
  36. package/custom/skills/improve-algorithm/SKILL.md +74 -0
  37. package/custom/skills/investigate-bug/SKILL.md +0 -0
  38. package/custom/skills/read-study-requirement/SKILL.md +0 -0
  39. package/custom/skills/report-customer/SKILL.md +0 -0
  40. package/custom/skills/review-plan/SKILL.md +0 -0
  41. package/custom/skills/train-model/SKILL.md +78 -0
  42. package/custom/templates/laravel.md +0 -0
  43. package/custom/templates/nestjs.md +0 -0
  44. package/custom/templates/nextjs.md +0 -0
  45. package/custom/templates/nodejs-express.md +0 -0
  46. package/custom/templates/php-plain.md +0 -0
  47. package/custom/templates/php.md +0 -0
  48. package/custom/templates/python-django.md +0 -0
  49. package/custom/templates/python-fastapi.md +0 -0
  50. package/custom/templates/python-ml.md +273 -0
  51. package/custom/templates/python.md +0 -0
  52. package/custom/templates/reactjs.md +0 -0
  53. package/custom/templates/shared/gate-workflow.md +0 -0
  54. package/custom/templates/shared/ml-gate-workflow.md +103 -0
  55. package/custom/templates/spring-boot.md +0 -0
  56. package/custom/templates/tools/claude.md +0 -0
  57. package/custom/templates/tools/copilot.md +0 -0
  58. package/custom/templates/tools/cursor.md +0 -0
  59. package/custom/templates/tools/gemini.md +0 -0
  60. package/custom/templates/tools/generic.md +0 -0
  61. package/custom/templates/vue-nuxt.md +0 -0
  62. package/docs/common/AIFLOW.md +512 -512
  63. package/docs/common/CHANGELOG.md +32 -0
  64. package/docs/common/QUICK_START.md +0 -0
  65. package/docs/common/ai-integration.md +0 -0
  66. package/docs/common/cli-reference.md +0 -0
  67. package/docs/common/configuration.md +0 -0
  68. package/docs/common/getting-started.md +0 -0
  69. package/docs/common/troubleshooting.md +0 -0
  70. package/docs/common/workflows/bug-fix.md +0 -0
  71. package/docs/common/workflows/feature.md +0 -0
  72. package/docs/common/workflows/figma.md +0 -0
  73. package/docs/common/workflows/impact-analysis.md +0 -0
  74. package/docs/common/workflows/investigation.md +0 -0
  75. package/docs/common/workflows/refactor.md +0 -0
  76. package/docs/project/ARCHITECTURE.md +0 -0
  77. package/index.js +0 -0
  78. package/package.json +1 -1
  79. package/scripts/checkpoint.js +0 -0
  80. package/scripts/config.js +0 -0
  81. package/scripts/context.js +0 -0
  82. package/scripts/create-score-excel.js +0 -0
  83. package/scripts/detect.js +239 -239
  84. package/scripts/doctor.js +192 -218
  85. package/scripts/gitnexus-worker.js +0 -0
  86. package/scripts/guide.js +0 -0
  87. package/scripts/hooks/block-git-write.js +0 -0
  88. package/scripts/hooks/session-start.js +0 -0
  89. package/scripts/hooks/session-stop.js +0 -0
  90. package/scripts/init.js +1112 -1009
  91. package/scripts/link-resolver.js +0 -0
  92. package/scripts/memory.js +0 -0
  93. package/scripts/prompt.js +538 -538
  94. package/scripts/remove.js +0 -0
  95. package/scripts/task.js +546 -546
  96. package/scripts/telemetry/cli.js +0 -0
  97. package/scripts/telemetry/config.js +0 -0
  98. package/scripts/telemetry/crypto.js +0 -0
  99. package/scripts/telemetry/flush.js +0 -0
  100. package/scripts/telemetry/record.js +0 -0
  101. package/scripts/update.js +10 -7
  102. package/scripts/use.js +33 -12
  103. package/scripts/validate.js +0 -0
  104. package/upstream/.claude-plugin/marketplace.json +0 -0
  105. package/upstream/.claude-plugin/plugin.json +0 -0
  106. package/upstream/.codex/INSTALL.md +0 -0
  107. package/upstream/.cursor-plugin/plugin.json +0 -0
  108. package/upstream/.gitattributes +0 -0
  109. package/upstream/.github/FUNDING.yml +0 -0
  110. package/upstream/.github/ISSUE_TEMPLATE/bug_report.md +0 -0
  111. package/upstream/.github/ISSUE_TEMPLATE/config.yml +0 -0
  112. package/upstream/.github/ISSUE_TEMPLATE/feature_request.md +0 -0
  113. package/upstream/.github/ISSUE_TEMPLATE/platform_support.md +0 -0
  114. package/upstream/.github/PULL_REQUEST_TEMPLATE.md +0 -0
  115. package/upstream/.opencode/INSTALL.md +0 -0
  116. package/upstream/.opencode/plugins/superpowers.js +0 -0
  117. package/upstream/.version-bump.json +0 -0
  118. package/upstream/AGENTS.md +0 -0
  119. package/upstream/CHANGELOG.md +0 -0
  120. package/upstream/CLAUDE.md +0 -0
  121. package/upstream/CODE_OF_CONDUCT.md +0 -0
  122. package/upstream/GEMINI.md +0 -0
  123. package/upstream/LICENSE +0 -0
  124. package/upstream/README.md +0 -0
  125. package/upstream/RELEASE-NOTES.md +0 -0
  126. package/upstream/agents/code-reviewer.md +0 -0
  127. package/upstream/commands/brainstorm.md +0 -0
  128. package/upstream/commands/execute-plan.md +0 -0
  129. package/upstream/commands/write-plan.md +0 -0
  130. package/upstream/docs/README.codex.md +0 -0
  131. package/upstream/docs/README.opencode.md +0 -0
  132. package/upstream/docs/plans/2025-11-22-opencode-support-design.md +0 -0
  133. package/upstream/docs/plans/2025-11-22-opencode-support-implementation.md +0 -0
  134. package/upstream/docs/plans/2025-11-28-skills-improvements-from-user-feedback.md +0 -0
  135. package/upstream/docs/plans/2026-01-17-visual-brainstorming.md +0 -0
  136. package/upstream/docs/superpowers/plans/2026-01-22-document-review-system.md +0 -0
  137. package/upstream/docs/superpowers/plans/2026-02-19-visual-brainstorming-refactor.md +0 -0
  138. package/upstream/docs/superpowers/plans/2026-03-11-zero-dep-brainstorm-server.md +0 -0
  139. package/upstream/docs/superpowers/plans/2026-03-23-codex-app-compatibility.md +0 -0
  140. package/upstream/docs/superpowers/specs/2026-01-22-document-review-system-design.md +0 -0
  141. package/upstream/docs/superpowers/specs/2026-02-19-visual-brainstorming-refactor-design.md +0 -0
  142. package/upstream/docs/superpowers/specs/2026-03-11-zero-dep-brainstorm-server-design.md +0 -0
  143. package/upstream/docs/superpowers/specs/2026-03-23-codex-app-compatibility-design.md +0 -0
  144. package/upstream/docs/testing.md +0 -0
  145. package/upstream/docs/windows/polyglot-hooks.md +0 -0
  146. package/upstream/gemini-extension.json +0 -0
  147. package/upstream/hooks/hooks-cursor.json +0 -0
  148. package/upstream/hooks/hooks.json +0 -0
  149. package/upstream/hooks/run-hook.cmd +0 -0
  150. package/upstream/hooks/session-start +0 -0
  151. package/upstream/package.json +0 -0
  152. package/upstream/scripts/bump-version.sh +0 -0
  153. package/upstream/skills/brainstorming/SKILL.md +0 -0
  154. package/upstream/skills/brainstorming/scripts/frame-template.html +0 -0
  155. package/upstream/skills/brainstorming/scripts/helper.js +0 -0
  156. package/upstream/skills/brainstorming/scripts/server.cjs +0 -0
  157. package/upstream/skills/brainstorming/scripts/start-server.sh +0 -0
  158. package/upstream/skills/brainstorming/scripts/stop-server.sh +0 -0
  159. package/upstream/skills/brainstorming/spec-document-reviewer-prompt.md +0 -0
  160. package/upstream/skills/brainstorming/visual-companion.md +0 -0
  161. package/upstream/skills/dispatching-parallel-agents/SKILL.md +0 -0
  162. package/upstream/skills/executing-plans/SKILL.md +0 -0
  163. package/upstream/skills/finishing-a-development-branch/SKILL.md +0 -0
  164. package/upstream/skills/receiving-code-review/SKILL.md +0 -0
  165. package/upstream/skills/requesting-code-review/SKILL.md +0 -0
  166. package/upstream/skills/requesting-code-review/code-reviewer.md +0 -0
  167. package/upstream/skills/subagent-driven-development/SKILL.md +0 -0
  168. package/upstream/skills/subagent-driven-development/code-quality-reviewer-prompt.md +0 -0
  169. package/upstream/skills/subagent-driven-development/implementer-prompt.md +0 -0
  170. package/upstream/skills/subagent-driven-development/spec-reviewer-prompt.md +0 -0
  171. package/upstream/skills/systematic-debugging/CREATION-LOG.md +0 -0
  172. package/upstream/skills/systematic-debugging/SKILL.md +0 -0
  173. package/upstream/skills/systematic-debugging/condition-based-waiting-example.ts +0 -0
  174. package/upstream/skills/systematic-debugging/condition-based-waiting.md +0 -0
  175. package/upstream/skills/systematic-debugging/defense-in-depth.md +0 -0
  176. package/upstream/skills/systematic-debugging/find-polluter.sh +0 -0
  177. package/upstream/skills/systematic-debugging/root-cause-tracing.md +0 -0
  178. package/upstream/skills/systematic-debugging/test-academic.md +0 -0
  179. package/upstream/skills/systematic-debugging/test-pressure-1.md +0 -0
  180. package/upstream/skills/systematic-debugging/test-pressure-2.md +0 -0
  181. package/upstream/skills/systematic-debugging/test-pressure-3.md +0 -0
  182. package/upstream/skills/tdd-lean/SKILL.md +0 -0
  183. package/upstream/skills/test-driven-development/SKILL.md +0 -0
  184. package/upstream/skills/test-driven-development/testing-anti-patterns.md +0 -0
  185. package/upstream/skills/using-git-worktrees/SKILL.md +0 -0
  186. package/upstream/skills/using-superpowers/SKILL.md +0 -0
  187. package/upstream/skills/using-superpowers/references/codex-tools.md +0 -0
  188. package/upstream/skills/using-superpowers/references/copilot-tools.md +0 -0
  189. package/upstream/skills/using-superpowers/references/gemini-tools.md +0 -0
  190. package/upstream/skills/verification-before-completion/SKILL.md +0 -0
  191. package/upstream/skills/writing-plans/SKILL.md +0 -0
  192. package/upstream/skills/writing-plans/plan-document-reviewer-prompt.md +0 -0
  193. package/upstream/skills/writing-skills/SKILL.md +0 -0
  194. package/upstream/skills/writing-skills/anthropic-best-practices.md +0 -0
  195. package/upstream/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +0 -0
  196. package/upstream/skills/writing-skills/graphviz-conventions.dot +0 -0
  197. package/upstream/skills/writing-skills/persuasion-principles.md +0 -0
  198. package/upstream/skills/writing-skills/render-graphs.js +0 -0
  199. package/upstream/skills/writing-skills/testing-skills-with-subagents.md +0 -0
  200. package/upstream/tests/brainstorm-server/package-lock.json +0 -0
  201. package/upstream/tests/brainstorm-server/package.json +0 -0
  202. package/upstream/tests/brainstorm-server/server.test.js +0 -0
  203. package/upstream/tests/brainstorm-server/windows-lifecycle.test.sh +0 -0
  204. package/upstream/tests/brainstorm-server/ws-protocol.test.js +0 -0
  205. package/upstream/tests/claude-code/README.md +0 -0
  206. package/upstream/tests/claude-code/analyze-token-usage.py +0 -0
  207. package/upstream/tests/claude-code/run-skill-tests.sh +0 -0
  208. package/upstream/tests/claude-code/test-document-review-system.sh +0 -0
  209. package/upstream/tests/claude-code/test-helpers.sh +0 -0
  210. package/upstream/tests/claude-code/test-subagent-driven-development-integration.sh +0 -0
  211. package/upstream/tests/claude-code/test-subagent-driven-development.sh +0 -0
  212. package/upstream/tests/explicit-skill-requests/prompts/action-oriented.txt +0 -0
  213. package/upstream/tests/explicit-skill-requests/prompts/after-planning-flow.txt +0 -0
  214. package/upstream/tests/explicit-skill-requests/prompts/claude-suggested-it.txt +0 -0
  215. package/upstream/tests/explicit-skill-requests/prompts/i-know-what-sdd-means.txt +0 -0
  216. package/upstream/tests/explicit-skill-requests/prompts/mid-conversation-execute-plan.txt +0 -0
  217. package/upstream/tests/explicit-skill-requests/prompts/please-use-brainstorming.txt +0 -0
  218. package/upstream/tests/explicit-skill-requests/prompts/skip-formalities.txt +0 -0
  219. package/upstream/tests/explicit-skill-requests/prompts/subagent-driven-development-please.txt +0 -0
  220. package/upstream/tests/explicit-skill-requests/prompts/use-systematic-debugging.txt +0 -0
  221. package/upstream/tests/explicit-skill-requests/run-all.sh +0 -0
  222. package/upstream/tests/explicit-skill-requests/run-claude-describes-sdd.sh +0 -0
  223. package/upstream/tests/explicit-skill-requests/run-extended-multiturn-test.sh +0 -0
  224. package/upstream/tests/explicit-skill-requests/run-haiku-test.sh +0 -0
  225. package/upstream/tests/explicit-skill-requests/run-multiturn-test.sh +0 -0
  226. package/upstream/tests/explicit-skill-requests/run-test.sh +0 -0
  227. package/upstream/tests/opencode/run-tests.sh +0 -0
  228. package/upstream/tests/opencode/setup.sh +0 -0
  229. package/upstream/tests/opencode/test-plugin-loading.sh +0 -0
  230. package/upstream/tests/opencode/test-priority.sh +0 -0
  231. package/upstream/tests/opencode/test-tools.sh +0 -0
  232. package/upstream/tests/skill-triggering/prompts/dispatching-parallel-agents.txt +0 -0
  233. package/upstream/tests/skill-triggering/prompts/executing-plans.txt +0 -0
  234. package/upstream/tests/skill-triggering/prompts/requesting-code-review.txt +0 -0
  235. package/upstream/tests/skill-triggering/prompts/systematic-debugging.txt +0 -0
  236. package/upstream/tests/skill-triggering/prompts/test-driven-development.txt +0 -0
  237. package/upstream/tests/skill-triggering/prompts/writing-plans.txt +0 -0
  238. package/upstream/tests/skill-triggering/run-all.sh +0 -0
  239. package/upstream/tests/skill-triggering/run-test.sh +0 -0
  240. package/upstream/tests/subagent-driven-dev/go-fractals/design.md +0 -0
  241. package/upstream/tests/subagent-driven-dev/go-fractals/plan.md +0 -0
  242. package/upstream/tests/subagent-driven-dev/go-fractals/scaffold.sh +0 -0
  243. package/upstream/tests/subagent-driven-dev/run-test.sh +0 -0
  244. package/upstream/tests/subagent-driven-dev/svelte-todo/design.md +0 -0
  245. package/upstream/tests/subagent-driven-dev/svelte-todo/plan.md +0 -0
  246. package/upstream/tests/subagent-driven-dev/svelte-todo/scaffold.sh +0 -0
  247. package/custom/mcp-presets/playwright.json +0 -11
  248. package/custom/rules/test-patterns.md +0 -105
  249. package/custom/skills/automation-testing/SKILL.md +0 -168
  250. package/custom/skills/automation-testing/templates/BasePage.ts +0 -30
  251. package/custom/skills/automation-testing/templates/playwright.config.ts +0 -21
  252. package/custom/skills/automation-testing/templates/repos.json +0 -8
  253. package/scripts/score_members.js +0 -320
@@ -0,0 +1,14 @@
1
+ # ML Review Checklist
2
+
3
+ Before completing Gate 4 and creating a Pull Request, verify:
4
+
5
+ - [ ] Evaluation metric matches the problem type and business goal defined in Gate 1.
6
+ - [ ] Model beats the baseline by at least the success threshold defined in Gate 1.
7
+ - [ ] No data leakage — all three types re-checked: target leakage, train/test contamination, and temporal leakage.
8
+ - [ ] Result is reproducible: re-run with the logged seed, pinned environment, and saved config produces the same metric.
9
+ - [ ] No overfitting: train / validation / test metric gap is acceptable and documented.
10
+ - [ ] Error analysis performed: worst slices, classes, or failure cases identified and documented.
11
+ - [ ] Robustness assessed: behavior under noise, shifted inputs, or edge cases verified; fairness across sensitive slices checked where applicable.
12
+ - [ ] All experiments tracked: params, metrics, data version, and git commit SHA logged in MLflow / wandb for every run (including failures).
13
+ - [ ] Model card present: intended use, training data, evaluation metrics, known limitations, and owner documented.
14
+ - [ ] Impact on data pipeline assessed via `impact-analysis` skill and implications documented.
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,90 @@
1
+ ---
2
+ name: deploy-model
3
+ description: Package and ship a model — versioned artifact, serving API, model card, and a monitoring plan for production.
4
+ keywords: deploy, serving, mlops, model card, monitoring, versioning, registry
5
+ ---
6
+
7
+ # Deploy Model
8
+
9
+ > Pairs with `superpowers:requesting-code-review` at Gate 5 — once the model is packaged and the monitoring plan is written, open the PR with the ticket link for peer review before any production rollout.
10
+
11
+ ---
12
+
13
+ ## When to use this skill
14
+
15
+ - Gate 5 of the ML workflow, after the evaluation has been APPROVED
16
+ - Any time a trained model artifact needs to be promoted from experiment to production
17
+ - When a new model version replaces an existing one in a registry or serving endpoint
18
+
19
+ ---
20
+
21
+ ## Steps
22
+
23
+ ### 1. Version the artifact
24
+
25
+ Register the model in the artifact store or model registry (MLflow Model Registry, Weights & Biases Artifacts, or equivalent). The registered entry must include:
26
+
27
+ - Model version number
28
+ - Training data version (DVC hash, dataset URI, or snapshot timestamp)
29
+ - Code commit SHA that produced the artifact
30
+ - Config file used for training (hyperparameters, seed)
31
+
32
+ Without these four identifiers, the artifact cannot be reproduced or audited. Do not promote an unversioned artifact to production.
33
+
34
+ ### 2. Package the full inference pipeline
35
+
36
+ Save the complete end-to-end inference pipeline — preprocessing transforms plus the model — as a single serializable object (sklearn `Pipeline`, MLflow `pyfunc` model, ONNX graph, TorchScript, TF SavedModel, etc.). The packaging must guarantee **train/serve parity**: the identical preprocessing that was applied during training must run at inference time, with no manual re-implementation in the serving layer.
37
+
38
+ Pin the serving environment to the same dependency versions used during training. Document any framework-specific serialization caveats (e.g., custom PyTorch modules, sklearn custom transformers).
39
+
40
+ ### 3. Expose a serving API
41
+
42
+ Build or configure an inference endpoint with the following properties:
43
+
44
+ - **Input validation:** reject malformed or out-of-range inputs with a clear error before they reach the model
45
+ - **Batch and timeout handling:** define the maximum batch size and inference timeout; return a graceful error on timeout
46
+ - **Health check endpoint:** a lightweight `/health` or equivalent that confirms the model is loaded and responsive — required for orchestrators and load balancers
47
+ - **Versioned endpoint path:** include the model version in the route so multiple versions can coexist during a canary or A/B rollout
48
+
49
+ Example minimal stack: FastAPI + uvicorn with a Pydantic input schema for validation.
50
+
51
+ ### 4. Define the monitoring plan
52
+
53
+ Specify what will be observed in production and what actions each signal triggers. The plan must cover:
54
+
55
+ - **Input drift:** statistical test (e.g., KS test, PSI) on feature distributions vs the training baseline; alert threshold
56
+ - **Prediction distribution drift:** shift in output scores or class probabilities; alert threshold
57
+ - **Latency:** p50 / p95 / p99 response times; SLA breach alert
58
+ - **Error rate:** HTTP 5xx and model exception rate; alert threshold
59
+ - **Retraining trigger:** the specific condition (drift score, metric degradation, elapsed time, data volume) that initiates a retraining pipeline run
60
+
61
+ Document the monitoring plan in the model card and link it to the observability tooling (Prometheus, Grafana, Arize, Evidently, etc.).
62
+
63
+ ### 5. Finalize the model card
64
+
65
+ Update the model card drafted at Gate 4 with:
66
+
67
+ - Intended use and out-of-scope uses
68
+ - Training data description (source, version, date range, class balance)
69
+ - Evaluation metrics (held-out results, baseline comparison, per-slice breakdown)
70
+ - Known limitations and failure modes identified in error analysis
71
+ - Monitoring and retraining plan summary
72
+ - Owner name and contact; approval date
73
+
74
+ The model card is the primary audit document for the deployed model.
75
+
76
+ ### 6. Create the PR
77
+
78
+ Invoke `superpowers:requesting-code-review`. Open a PR that includes: serving code, model card, monitoring plan, and any pipeline changes. Link the ticket. Reference the eval report and the registered artifact version in the PR description.
79
+
80
+ ---
81
+
82
+ ## Completion Checklist
83
+
84
+ - [ ] Artifact registered with data version, code commit, and config
85
+ - [ ] Full inference pipeline packaged — preprocessing + model, train/serve parity guaranteed
86
+ - [ ] Serving environment pinned to training-time dependency versions
87
+ - [ ] Inference API includes input validation, batch/timeout handling, and health check
88
+ - [ ] Monitoring plan defined: input drift, prediction drift, latency, error rate, retraining trigger
89
+ - [ ] Model card finalized: intended use, data, metrics, limitations, monitoring summary, owner
90
+ - [ ] PR created with ticket link, eval report reference, and artifact version noted
@@ -0,0 +1,88 @@
1
+ ---
2
+ name: design-experiment
3
+ description: Design a leakage-safe validation strategy and experiment plan with ablations and tracking before training begins.
4
+ keywords: experiment, validation, cross-validation, ablation, tracking, splits
5
+ ---
6
+
7
+ # Design Experiment
8
+
9
+ ## When to use this skill
10
+
11
+ - Gate 2, after the problem framing document (`ml-problem.md`) has been APPROVED
12
+ - Any time a new round of experiments is planned after a framing change
13
+ - Before writing any model training code — the plan must exist first
14
+
15
+ ---
16
+
17
+ ## Steps
18
+
19
+ ### 1. Choose the validation strategy
20
+
21
+ Select the CV scheme that matches the data structure and justify the choice explicitly:
22
+ - **Stratified k-fold:** use when the target is imbalanced; preserves class proportions in every fold
23
+ - **Group k-fold / GroupShuffleSplit:** use when rows belong to named entities (users, patients, stores) and the task requires generalising to unseen entities — random splits would let the same entity appear in train and validation
24
+ - **TimeSeriesSplit:** use for temporal data; always respect chronological order; never shuffle before splitting
25
+
26
+ State the number of folds (or holdout fraction) and why that choice is appropriate given the dataset size and variance of the metric.
27
+
28
+ ### 2. Define the leakage-safe split protocol
29
+
30
+ Specify the exact sequence of operations to prevent any information from the validation or test set contaminating the training fold:
31
+ - **Split before fit:** the train/validation boundary is established before any preprocessing step is fitted
32
+ - **Pipeline inside CV:** all transformations (scaling, encoding, imputation, feature selection) are wrapped in a `Pipeline` (sklearn) or equivalent so they are fit on each training fold and applied to the validation fold — never fit on the combined data
33
+ - **Test set quarantine:** the held-out test set is touched only at Gate 4 evaluation; it is never used to tune hyperparameters or select features
34
+
35
+ ### 3. Enumerate candidate approaches and feature sets
36
+
37
+ List experiments in ascending order of complexity:
38
+ 1. **Baseline** (from `frame-ml-problem`): the simplest reference (majority class, median, or current rule)
39
+ 2. **Simple model** (e.g. logistic regression, linear regression, decision tree) with a minimal feature set
40
+ 3. **Intermediate model** (e.g. gradient-boosted trees) with engineered features
41
+ 4. **Complex model** (e.g. neural network, fine-tuned transformer) if warranted by the problem
42
+
43
+ For each approach, list the feature set explicitly — which raw columns, which engineered features. Separating feature sets from model families makes it possible to attribute performance differences cleanly.
44
+
45
+ ### 4. Define the ablation plan
46
+
47
+ Describe what each experiment isolates. The rule is **one change at a time**:
48
+ - Vary the model family while holding the feature set constant
49
+ - Add a feature group while holding the model constant
50
+ - Vary a key hyperparameter while holding everything else fixed
51
+ - Document the hypothesis for each ablation (what do you expect and why)
52
+
53
+ A plan with no ablations is not acceptable — it produces no actionable insight.
54
+
55
+ ### 5. Set up experiment tracking
56
+
57
+ Define what every tracked run must log before any experiment is executed:
58
+ - **Parameters:** all hyperparameters, including their defaults; the feature set identifier; the validation scheme
59
+ - **Metrics:** primary metric (from Gate 1) per fold + mean ± std; secondary metrics if relevant
60
+ - **Reproducibility metadata:** random seed, data version (hash or DVC tag), git commit SHA
61
+ - Agree on the tracking tool (MLflow, wandb, or simple CSV) and the run-naming convention from `ml-conventions.md` (`[ticket-id]_[approach]_[yyyymmdd-n]`)
62
+
63
+ ### 6. Define the stopping and decision rule
64
+
65
+ State, before any experiment runs, how you will decide which approach moves forward:
66
+ - Which metric on which split is the decision criterion
67
+ - What constitutes a meaningful improvement over the baseline (link to the success threshold from Gate 1)
68
+ - The budget: maximum number of experiments or wall-clock time before a decision is forced
69
+
70
+ An open-ended experiment loop with no stopping rule is out of scope for a gated workflow.
71
+
72
+ ### 7. Output the experiment plan
73
+
74
+ Write all of the above to `plan/[ticket-id]/experiment-plan.md`. The document must be self-contained: a developer who did not attend the framing discussion should be able to reproduce the full experiment sequence from the plan alone.
75
+
76
+ ---
77
+
78
+ ## Completion Checklist
79
+
80
+ - [ ] Validation scheme chosen (stratified k-fold / group k-fold / time-series split) and justified
81
+ - [ ] Leakage-safe split protocol defined (split before fit; transforms inside pipeline; test set quarantined)
82
+ - [ ] Candidate approaches listed in ascending complexity order
83
+ - [ ] Feature sets enumerated per approach
84
+ - [ ] Ablation plan written (one change at a time; hypothesis stated for each ablation)
85
+ - [ ] Experiment tracking configured (params, metrics, seed, data version, git commit)
86
+ - [ ] Run-naming convention agreed and follows `ml-conventions.md`
87
+ - [ ] Stopping and decision rule stated (metric, threshold, experiment budget)
88
+ - [ ] Full plan written to `plan/[ticket-id]/experiment-plan.md`
@@ -0,0 +1,93 @@
1
+ ---
2
+ name: evaluate-model
3
+ description: Rigorous model evaluation — held-out metrics vs baseline, error analysis, and overfitting/leakage/drift detection with reproducibility verification.
4
+ keywords: evaluation, error analysis, overfitting, leakage, robustness, model card
5
+ ---
6
+
7
+ # Evaluate Model
8
+
9
+ > Run `superpowers:verification-before-completion` first — evaluation runs must reproduce cleanly before any success claim is made. If results cannot be reproduced from the logged seed and config, the evaluation is not valid.
10
+
11
+ ---
12
+
13
+ ## When to use this skill
14
+
15
+ - Gate 4 of the ML workflow, after training and iteration are complete
16
+ - Any time a claim about model quality needs to be verified before sharing with stakeholders
17
+ - When preparing the eval report and model card for review
18
+
19
+ ---
20
+
21
+ ## Steps
22
+
23
+ ### 1. Evaluate on the held-out test set
24
+
25
+ Run inference on the test set — the split that was never touched during training or hyperparameter tuning. Report the primary metric agreed in Gate 1. Where feasible, include a confidence interval (bootstrap CI, or Wilson interval for classification). Report secondary metrics if relevant to the use case.
26
+
27
+ ### 2. Compare to baseline and success threshold
28
+
29
+ State pass or fail explicitly:
30
+
31
+ - Did the model beat the baseline (majority class / heuristic / current production model)?
32
+ - Did it meet the success threshold defined in Gate 1?
33
+
34
+ A result that beats baseline but falls short of the threshold is a fail — report it honestly and return to Gate 3 or Gate 1 as appropriate.
35
+
36
+ ### 3. Error analysis
37
+
38
+ Identify where and how the model fails:
39
+
40
+ - Break down the metric by slice (class, demographic, time period, data source, input length, etc.)
41
+ - For classification: examine the confusion matrix; find the most common error patterns
42
+ - Select representative failure cases and inspect them manually — understand the failure mode before claiming the model is production-ready
43
+
44
+ ### 4. Overfitting check
45
+
46
+ Compare train, validation, and test metrics side by side. Plot learning curves (metric vs training set size or epoch). Characterize the gap:
47
+
48
+ - Large train/val gap → overfitting; the model did not generalize
49
+ - Large train/test gap after acceptable val → distribution shift or leakage in val
50
+
51
+ A large gap must be resolved or explained before the evaluation is APPROVED.
52
+
53
+ ### 5. Leakage re-check
54
+
55
+ Re-run all three leakage checks from `explore-data` on the final pipeline:
56
+
57
+ 1. **Target leakage** — does any feature embed information derived from or computed after the target?
58
+ 2. **Train/test contamination** — were any transforms fitted on data that includes test rows? Are there duplicate IDs across splits?
59
+ 3. **Temporal leakage** — for time-ordered data, does any feature use information that would not have been available at prediction time?
60
+
61
+ Document the result of each check. A positive finding is a Gate 1 regression, not a Gate 4 footnote.
62
+
63
+ ### 6. Robustness assessment
64
+
65
+ Test behavior under distribution shifts and edge cases relevant to the production use case:
66
+
67
+ - Inject noise or missing values; check metric degradation
68
+ - Test on known difficult slices (rare classes, short inputs, boundary values)
69
+ - If the model affects decisions about people, check for disparate performance across sensitive groups and flag for review
70
+
71
+ ### 7. Verify reproducibility
72
+
73
+ Re-run the final eval using only the logged seed, the pinned config, and the registered data version. Confirm the reported number matches to within numerical noise. If it does not reproduce, stop — do not proceed to Gate 5 until the discrepancy is resolved.
74
+
75
+ ### 8. Write the eval report and model card
76
+
77
+ Output `plan/[ticket-id]/eval-report.md` containing: the metric table (baseline, threshold, achieved), error analysis findings, overfitting gap, leakage check results, and robustness notes.
78
+
79
+ Draft a model card covering: intended use, training data description, evaluation metrics and their context, known limitations, and owner/contact.
80
+
81
+ ---
82
+
83
+ ## Completion Checklist
84
+
85
+ - [ ] Held-out test metric reported with confidence interval where feasible
86
+ - [ ] Explicit pass/fail against baseline and success threshold stated
87
+ - [ ] Error analysis performed — worst slices, confusion patterns, representative failure cases
88
+ - [ ] Train / validation / test gap inspected; learning curves reviewed
89
+ - [ ] All three leakage types re-checked and documented (target, contamination, temporal)
90
+ - [ ] Robustness assessed under noise, edge cases, and sensitive slices
91
+ - [ ] Result reproduced from logged seed and config — numbers match
92
+ - [ ] `plan/[ticket-id]/eval-report.md` written
93
+ - [ ] Model card drafted (intended use, data, metrics, limitations, owner)
@@ -0,0 +1,87 @@
1
+ ---
2
+ name: explore-data
3
+ description: Systematic EDA and data-quality assessment with explicit data-leakage detection before modeling.
4
+ keywords: eda, data, leakage, data quality, exploration, dataset
5
+ ---
6
+
7
+ # Explore Data
8
+
9
+ > This skill borrows the investigative mindset of `superpowers:systematic-debugging` — form
10
+ > hypotheses about the data, verify each one with evidence, and document what you find.
11
+ > Do not skip a check because the data "looks clean".
12
+
13
+ ---
14
+
15
+ ## When to use this skill
16
+
17
+ - Gate 1, immediately after `frame-ml-problem` has defined the target and metric
18
+ - Any time a new dataset enters the project (new data source, updated extract, external dataset)
19
+ - Before re-training when data distribution changes are suspected
20
+
21
+ ---
22
+
23
+ ## Steps
24
+
25
+ ### 1. Profile the dataset
26
+
27
+ Establish the basic facts before any analysis:
28
+ - **Shape:** row count, column count; confirm against expected data volume from the ticket
29
+ - **dtypes:** numeric, categorical, datetime, free text, binary — flag any type mismatches (e.g. numeric column stored as string)
30
+ - **Missing values:** per-column missing rate; distinguish structural missing (feature does not apply) from random missing (collection gap)
31
+ - **Duplicates:** exact duplicate rows; near-duplicate rows (same entity, slightly different values); duplicate IDs that should be unique
32
+ - **Target distribution:** class balance for classification (report majority-class baseline accuracy); value range, skew, and outliers for regression
33
+
34
+ ### 2. Univariate and bivariate analysis
35
+
36
+ - **Univariate:** distribution shape, outliers, value ranges, cardinality of categoricals
37
+ - **Bivariate:** feature–target correlations or mutual information; flag suspiciously high correlations that may indicate leakage (see Step 3)
38
+ - **Temporal trends:** if a time column exists, plot target rate and key features over time to detect distribution shift
39
+
40
+ ### 3. Leakage detection (mandatory)
41
+
42
+ Run all three checks explicitly and document the result of each — do not skip any.
43
+
44
+ **(a) Target leakage** — features derived from or computed after the target event:
45
+ - Identify any column that could not be known at prediction time (e.g. a "days to resolution" column when predicting whether a ticket will be resolved)
46
+ - Drop or exclude any such column before training
47
+ - Flag columns with suspiciously high predictive power; investigate their origin
48
+
49
+ **(b) Train/test contamination** — information bleeding between splits:
50
+ - Check for duplicate or near-duplicate rows that may span the train and test sets
51
+ - Verify that entity IDs (user IDs, order IDs) do not appear in both splits if the task requires generalising to unseen entities
52
+ - Confirm that scalers, encoders, and imputers will be fit on the training fold only — fitting on the full dataset before splitting is a hard error
53
+
54
+ **(c) Temporal leakage** — using future data to predict the past:
55
+ - If the data has a time dimension, verify that all features for a given row reflect information available strictly before the prediction timestamp
56
+ - Check for lag features or aggregation windows that inadvertently include the target period
57
+ - Time-series splits must respect chronological order; random splits are wrong for temporal data
58
+
59
+ ### 4. Data-quality flags
60
+
61
+ Document any of the following that are present:
62
+ - **Inconsistent units:** mixed currencies, mixed date formats, mixed length units
63
+ - **Label noise:** suspiciously contradictory labels for near-identical features
64
+ - **Sampling bias:** is the historical sample representative of the production population? Check for selection effects (e.g. data collected only from active users)
65
+ - **Train / serving distribution drift:** if serving statistics are available, compare them to training distributions on key features; flag deviations above a sensible threshold
66
+
67
+ ### 5. Record findings in the Gate 1 data report
68
+
69
+ Write the EDA results into the `ml-problem.md` file created by `frame-ml-problem`:
70
+ - Data shape, quality issues, and missing-value strategy
71
+ - Leakage assessment — one paragraph per leakage type stating what was checked and what was found
72
+ - Cleaning actions required before training (drop columns, impute, clip outliers, re-encode)
73
+
74
+ ---
75
+
76
+ ## Completion Checklist
77
+
78
+ - [ ] Dataset shape, dtypes, and missing-value rates profiled
79
+ - [ ] Duplicate rows and duplicate IDs checked
80
+ - [ ] Target distribution inspected (class balance or value distribution)
81
+ - [ ] Univariate and bivariate analysis completed; suspiciously high correlations investigated
82
+ - [ ] **Target leakage** checked and documented (no future-derived features in the feature set)
83
+ - [ ] **Train/test contamination** checked and documented (no ID overlap, no full-data fitting)
84
+ - [ ] **Temporal leakage** checked and documented (chronological integrity verified if applicable)
85
+ - [ ] Data-quality issues listed (units, label noise, sampling bias, drift)
86
+ - [ ] Required cleaning steps noted
87
+ - [ ] All findings written into `plan/[ticket-id]/ml-problem.md` data report section
File without changes
@@ -0,0 +1,88 @@
1
+ ---
2
+ name: frame-ml-problem
3
+ description: Frame an ML problem before any modeling — define the prediction target, the correct evaluation metric, a baseline, and the success threshold.
4
+ keywords: ml, problem framing, metric, baseline, target, success criteria
5
+ ---
6
+
7
+ # Frame ML Problem
8
+
9
+ > This skill **inherits and extends** `superpowers:brainstorming` for collaborative Q&A.
10
+ > First, invoke `superpowers:brainstorming` to explore intent and ambiguities with the developer,
11
+ > then apply the structured framing steps below.
12
+
13
+ ---
14
+
15
+ ## When to use this skill
16
+
17
+ - Gate 1 of the ML workflow — always the first step before any modeling
18
+ - Any new ML ticket where the prediction target or success criterion is not yet explicit
19
+ - Whenever the evaluation metric has not been pinned down or justified against the business goal
20
+
21
+ ---
22
+
23
+ ## Steps
24
+
25
+ ### 1. Read the ticket context
26
+
27
+ Read `.aiflow/context/current.json`:
28
+ - `description` — what the stakeholder wants the model to do
29
+ - `comments` — additional context, constraints, or prior attempts
30
+ - `context.files` — related notebooks, data samples, or prior model artifacts
31
+
32
+ ### 2. State the prediction target precisely
33
+
34
+ Define what is being predicted, at what granularity (row level, user level, session level, etc.), and crucially **when the input features are available** relative to the prediction moment. Guard against accidentally incorporating future information — any feature computed from or derived after the target event is a candidate for leakage.
35
+
36
+ ### 3. Classify the problem type
37
+
38
+ Explicitly label the task:
39
+ - **Classification** (binary or multi-class): predict a category
40
+ - **Regression**: predict a continuous value
41
+ - **Ranking / Recommendation**: order items by relevance
42
+ - **Generation / Seq-to-seq**: produce text, code, or structured output
43
+ - **Clustering / Anomaly detection**: unsupervised grouping or outlier detection
44
+
45
+ State the type before choosing any model family or metric.
46
+
47
+ ### 4. Choose the evaluation metric and justify it
48
+
49
+ Select the primary metric and tie it explicitly to the business goal:
50
+ - Imbalanced classification: prefer F1, PR-AUC, or recall at fixed precision over plain accuracy
51
+ - Regression: choose MAE (robust to outliers) vs RMSE (penalises large errors) deliberately
52
+ - Ranking: use MAP, NDCG, or MRR depending on position sensitivity
53
+ - Note the difference between the **offline proxy metric** (what can be measured from historical data) and the **online KPI** (what the business ultimately cares about); acknowledge any gap
54
+
55
+ **State the metric before any modeling begins. It must not change after training.**
56
+
57
+ ### 5. Define a baseline and success threshold
58
+
59
+ - **Baseline:** the simplest defensible reference — majority-class prediction, median value, current rule-based system, or the model already in production
60
+ - **Success threshold:** the quantitative improvement over baseline that is meaningful to the business (e.g. "+3 pp F1 on the held-out set" or "<10 ms p99 latency with no accuracy regression")
61
+ - A threshold of "as high as possible" is not acceptable — make it concrete
62
+
63
+ ### 6. List constraints
64
+
65
+ Document non-negotiable constraints that shape model choice and architecture:
66
+ - **Latency / throughput:** real-time vs batch; maximum inference time
67
+ - **Memory / hardware:** CPU-only, GPU budget, edge deployment
68
+ - **Interpretability:** regulatory or stakeholder requirements for explanations
69
+ - **Data volume:** row count, feature count, labelling cost
70
+ - **Compliance:** PII handling, data residency, auditability requirements
71
+
72
+ ### 7. Ask one clarifying question at a time when ambiguous
73
+
74
+ If any of the above cannot be answered from the ticket, ask exactly **one question**, wait for a reply, and continue. Do not bundle multiple questions.
75
+
76
+ ---
77
+
78
+ ## Completion Checklist
79
+
80
+ - [ ] Ticket context read (description + comments + related files)
81
+ - [ ] Prediction target defined with the exact availability time of input features
82
+ - [ ] Problem type classified (classification / regression / ranking / generation / clustering)
83
+ - [ ] Evaluation metric chosen and justified against the business goal
84
+ - [ ] Offline proxy metric vs online KPI gap acknowledged
85
+ - [ ] Baseline defined (majority class, heuristic, or current production model)
86
+ - [ ] Success threshold quantified (not "as high as possible")
87
+ - [ ] Constraints listed (latency, memory, interpretability, data volume, compliance)
88
+ - [ ] Findings written to `plan/[ticket-id]/ml-problem.md`
File without changes
File without changes
@@ -0,0 +1,74 @@
1
+ ---
2
+ name: improve-algorithm
3
+ description: Systematically improve an existing model or algorithm — profile, hypothesize, ablate, and measure accuracy/latency/memory. No guessing.
4
+ keywords: optimization, algorithm, performance, latency, accuracy, ablation, profiling
5
+ ---
6
+
7
+ # Improve Algorithm
8
+
9
+ > This skill inherits the discipline of `superpowers:systematic-debugging` — measure before changing, change one thing at a time, measure again. Guessing is not a method; every change must be motivated by evidence from profiling or error analysis.
10
+
11
+ ---
12
+
13
+ ## When to use this skill
14
+
15
+ - Gate 3, for tickets specifically about improving an existing model or algorithm (accuracy, latency, or memory targets)
16
+ - Any time a model already exists and the goal is to make it better rather than build from scratch
17
+ - When performance regressions are reported in production
18
+
19
+ ---
20
+
21
+ ## Steps
22
+
23
+ ### 1. Establish the current baseline
24
+
25
+ Run the existing system through the eval harness and record the exact number — metric, split, and seed. This is the floor that every proposed change must be measured against. If no eval harness exists yet, invoke `train-model` first to establish one.
26
+
27
+ ### 2. Profile before optimizing
28
+
29
+ Do not form a hypothesis before you know where the bottleneck is.
30
+
31
+ - **Accuracy bottleneck:** run error analysis by slice and by class. Plot learning curves to distinguish bias (underfitting — train error high) from variance (overfitting — large train/val gap). Identify the failure pattern first.
32
+ - **Latency/memory bottleneck:** profile the hot path end-to-end. Tools: `cProfile` / `line_profiler` for Python; `torch.profiler` or `torch.autograd.profiler` for PyTorch; `tf.profiler` for TF. Measure throughput (samples/sec) and peak memory before and after every change.
33
+
34
+ Never skip this step. Optimizing the wrong part wastes time and can introduce regressions.
35
+
36
+ ### 3. Form ONE hypothesis
37
+
38
+ Based on the profiling/error-analysis evidence, form exactly one hypothesis tied to the identified bottleneck. Examples:
39
+
40
+ - "Error analysis shows the model fails on short-text inputs → hypothesis: adding n-gram features reduces error on that slice"
41
+ - "Profiler shows 60% of latency in the preprocessing step → hypothesis: vectorizing the transform halves latency"
42
+ - "Learning curves show high variance → hypothesis: stronger L2 regularization closes the train/val gap"
43
+
44
+ State the hypothesis explicitly before writing any code.
45
+
46
+ ### 4. Run a single ablation
47
+
48
+ Implement only the change implied by the hypothesis. Run the eval harness with the same seed, same split, same data version. Track the run in MLflow/wandb with a descriptive name and note the hypothesis in the run description. Compare to the baseline number directly.
49
+
50
+ ### 5. Decide: keep or revert
51
+
52
+ Keep the change only if it:
53
+
54
+ - Beats the baseline meaningfully (respects the success threshold from Gate 1)
55
+ - Respects all constraints: accuracy/latency/memory trade-off stated explicitly
56
+ - Does not introduce a new regression in a different slice or metric
57
+
58
+ Revert if it does not satisfy the above. Log the failure reason; failed experiments are also information.
59
+
60
+ ### 6. Repeat and document
61
+
62
+ Repeat steps 3–5 for the next bottleneck. Log every attempt — including reversions — so the improvement story is fully reproducible. The final state must be explainable: "we tried X (failed because Y), then tried Z (improved metric by W%)."
63
+
64
+ ---
65
+
66
+ ## Completion Checklist
67
+
68
+ - [ ] Baseline number recorded on the eval harness before any change
69
+ - [ ] Bottleneck identified by profiling (latency/memory) or error analysis (accuracy) — not guessed
70
+ - [ ] Each change is a single isolated ablation motivated by a stated hypothesis
71
+ - [ ] Every attempt (including failures) measured on the same harness and tracked with params/metrics
72
+ - [ ] Trade-offs between accuracy, latency, and memory stated explicitly for kept changes
73
+ - [ ] Kept changes beat the baseline by the success threshold
74
+ - [ ] Full improvement log available (hypothesis → result → decision for each attempt)
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,78 @@
1
+ ---
2
+ name: train-model
3
+ description: Reproducible model training — eval-harness-first, fixed seeds, pinned environment, logged configs, checkpointing, experiment tracking.
4
+ keywords: training, reproducibility, seed, checkpoint, mlflow, wandb, fine-tune
5
+ ---
6
+
7
+ # Train Model
8
+
9
+ > **Eval-harness-first is the ML analog of `superpowers:test-driven-development`** — build the metric/eval harness and a reproducible baseline BEFORE writing any model improvement code. If the harness does not run clean, stop and fix it first.
10
+
11
+ ---
12
+
13
+ ## When to use this skill
14
+
15
+ - Gate 3 of the ML workflow, after the experiment plan has been APPROVED
16
+ - Any time a new model or training run is initiated
17
+ - Fine-tuning or transfer-learning tasks where reproducibility is critical
18
+
19
+ ---
20
+
21
+ ## Steps
22
+
23
+ ### 1. Eval-harness-first
24
+
25
+ Implement the metric function and the validation loop as defined in the approved experiment plan. Run it against the baseline (majority class, heuristic, or current production model). Confirm you get a reproducible number before touching any model code. This number is the target to beat.
26
+
27
+ ### 2. Enforce reproducibility
28
+
29
+ Set all random seeds at the top of every training script:
30
+
31
+ - `random.seed(seed)` and `numpy.random.seed(seed)`
32
+ - Framework seed: `torch.manual_seed(seed)` + `torch.cuda.manual_seed_all(seed)` for PyTorch; `tf.random.set_seed(seed)` for TF/Keras
33
+ - Enable deterministic ops where feasible (`torch.use_deterministic_algorithms(True)`)
34
+
35
+ Pin the environment: `requirements.txt` or a lockfile (`pip freeze > requirements.txt`). No floating version ranges in the pinned file.
36
+
37
+ ### 3. Config over hardcoding
38
+
39
+ Place all hyperparameters (learning rate, batch size, number of layers, regularization strength, etc.) in a YAML, Hydra config, or argparse definition — never as literals in the training script. This ensures any run can be exactly reproduced from its config file alone.
40
+
41
+ ### 4. Experiment tracking
42
+
43
+ Log the following to MLflow or wandb for every run:
44
+
45
+ - All hyperparameters (from config)
46
+ - Metric per epoch / per fold
47
+ - Seed, data version (DVC hash or path), and git commit SHA
48
+ - Run name following the naming convention in `custom/rules/ml-conventions.md`: `[ticket-id]_[approach]_[yyyymmdd-n]`
49
+
50
+ Do not leave runs unnamed or untracked.
51
+
52
+ ### 5. Checkpointing
53
+
54
+ Save the best checkpoint by the primary validation metric (not the final epoch). Store the config file alongside the artifact so the checkpoint is self-contained. Use the model registry (MLflow Model Registry or equivalent) when available.
55
+
56
+ ### 6. Framework-specific considerations
57
+
58
+ - **scikit-learn:** wrap preprocessing + model in a single `Pipeline` so transforms are fitted on training data only — never on the full dataset.
59
+ - **PyTorch:** seed `DataLoader` workers (`worker_init_fn`), toggle `model.train()` before training and `model.eval()` before validation/inference. Use `torch.no_grad()` for inference.
60
+ - **TF/Keras:** use callbacks for `ModelCheckpoint` (save best) and `EarlyStopping`; set `tf.config.experimental.enable_op_determinism()` if needed.
61
+ - **Fine-tuning:** apply a freeze/unfreeze schedule; use LR warmup before unfreezing. Log the freeze schedule as a config parameter.
62
+
63
+ ### 7. Iterate per the ablation plan
64
+
65
+ Follow the ablation plan from the experiment design — change exactly one factor per run, track it, compare to the established baseline on the same harness. Do not run ad-hoc experiments that are not tracked or not comparable.
66
+
67
+ ---
68
+
69
+ ## Completion Checklist
70
+
71
+ - [ ] Eval harness implemented and confirmed running on baseline before any model change
72
+ - [ ] Reproducible baseline number recorded
73
+ - [ ] All random seeds set (language, numpy, framework, CUDA)
74
+ - [ ] Environment pinned (requirements.txt or lockfile committed)
75
+ - [ ] All hyperparameters in a config file — no literals in training code
76
+ - [ ] Every run tracked with params, metrics, seed, data version, and git commit
77
+ - [ ] Best checkpoint saved with its config alongside the artifact
78
+ - [ ] Experiments follow the ablation plan (one change at a time)
File without changes
File without changes
File without changes
File without changes