GSD Loop Engineering for ML Tasks
Problem
ML pipelines are naturally multi-stage loops:
- Plan → 2. Execute (data prep / train / generate submission) → 3. Verify (format / CV-LB gap / sanity) → 4. Fix or Ship.
Most agentic ML workflows fail because:
- Context rot: long sessions degrade model output (e.g., 0/1 submission bug in S6E2 was partly due to loss of focus)
- No verification: tasks accepted as done without adversarial checking (S6E4 submission would have been caught by a verifier)
- No shared memory: each step reinvents context from scratch
- Drift on style: best practices from start of session get forgotten by end
GSD Core (open-gsd/gsd-core) is the canonical loop-engineering framework solving exactly this. This skill adapts its patterns to ML.
Context / Trigger Conditions
Use this skill when:
- Working on a Kaggle competition end-to-end
- Designing a multi-stage ML pipeline (data → features → train → ensemble → submit)
- Session has > 50 turns and quality is degrading
- You want auditable proof each step worked (not just "looks right")
- You're tempted to use
--dangerously-skip-permissions (don't)
Don't use:
- Single-file one-off scripts
- Pure EDA with no downstream work
- Research tasks where you're just reading papers
Solution: 5-Phase ML Loop
┌────────────────────────────────────────────────────────────┐
│ Phase 1: DISCUSS (gsd-discuss-phase) │
│ - Resolve ambiguities in the task brief │
│ - Output: .planning/phases/<N>-DISCUSS.md │
├────────────────────────────────────────────────────────────┤
│ Phase 2: PLAN (gsd-plan-phase) │
│ - Research + plan, but in fresh-context subagent │
│ - Plans declare wave dependencies (DAG) │
│ - Output: .planning/phases/<N>/RESEARCH.md + PLAN-<M>.md │
├────────────────────────────────────────────────────────────┤
│ Phase 3: EXECUTE (gsd-execute-phase) │
│ - Run plans in waves (parallel where independent) │
│ - Each plan is a fresh-context subagent │
│ - Output: artifacts (models, submissions, logs) │
├────────────────────────────────────────────────────────────┤
│ Phase 4: VERIFY (gsd-verify) │
│ - Adversarial check: assume goal NOT achieved │
│ - Findings classified BLOCKER / WARNING / VERIFIED │
│ - Output: .planning/phases/<N>/VERIFICATION.md │
├────────────────────────────────────────────────────────────┤
│ Phase 5: SHIP or FIX │
│ - VERIFIED → ship submission, archive artefacts │
│ - BLOCKER → generate fix plan, re-enter Phase 2 │
│ - WARNING → decide case-by-case │
└────────────────────────────────────────────────────────────┘
Adapted to Kaggle Competitions
| GSD Phase |
ML Equivalent |
| DISCUSS |
Identify metric (AUC / RMSLE / mAP), submission format, deadline, data quirks |
| PLAN |
Plan features, baseline model, ensemble strategy, verification checks |
| EXECUTE |
Run feature engineering, AutoGluon baseline, blend, generate submission |
| VERIFY |
Submission format check, CV-LB gap sanity, distribution check, adversarial validation |
| SHIP |
Submit to Kaggle LB; archive all artefacts |
Concrete: GSD-Driven S6E2 Re-Run (validated pattern)
This is the pattern that produced Private LB 0.95510 in 15 minutes:
Phase 1: DISCUSS
- Metric: AUC (roc_auc) — binary classification
- Data: 630K train, 270K test, 14 features, label "Heart Disease"
- Submission: 1 proba column (PitNextLap or class 1) — CRITICAL
- Time budget: 15 min training
Output: .planning/01-discuss.md
Phase 2: PLAN
- Plan A: AutoGluon best_quality with time_limit=900s
- Plan B: Verify submission format matches sample_submission.csv
- Plan C: Probability file only, never thresholded
Output: .planning/02-plans/{A,B,C}.md
Phase 3: EXECUTE
- Wave 1: Plan A (training, 15 min) and Plan B (parallel — read sample)
- Wave 2: Plan C (re-generate submission using predict_proba)
Output: ag_models/, submission_autogluon_proba.csv
Phase 4: VERIFY (the moment of truth)
- Check 1: submission columns = sample columns? PASS
- Check 2: submission values in [0, 1]? PASS
- Check 3: OOF AUC > 0.95? PASS (0.95554)
- Check 4: CV-LB gap < 0.01? PASS (gap = 0.002 after probability fix)
Output: .planning/04-verify.md (all VERIFIED)
Phase 5: SHIP
- kaggle competitions submit ...
- Archive: ag_models/, leaderboard.csv, summary.json
Key GSD Patterns Applied to ML
Pattern 1: Fresh-Context Subagents
- Main session: thin orchestrator + state reads
- Subagents (one per heavy task): 200k clean context each
- Shared substrate: disk files (
.planning/, ag_models/, submission_*.csv)
Pattern 2: Goal-Backward Verification
- Default stance: assume goal NOT achieved until codebase evidence proves it
- For ML: assume submission is wrong until checks pass
- Checks must be concrete (file exists, value in range, format matches)
Pattern 3: Wave-Based DAG Execution
- Plans declare
depends_on: ["plan-A"]
- Independent plans run in parallel (no human bottleneck)
- For ML: feature engineering can run while baseline is training
Pattern 4: Escalation Gate
- If verifier finds BLOCKER, stop and surface to user
- Don't silently guess — better to ask than submit a broken file
Pattern 5: Spec-Driven Artefacts
- Every phase produces structured artefacts on disk
- For ML: every step produces a CSV / model file / log
- State survives session boundaries
Anti-Patterns to Avoid
| Don't |
Do |
| Submit without format check |
Always run Plan B (verify format) before submit |
| Trust CV score as final metric |
Always run Plan C (probability file) for AUC |
| Skip verification on "obvious" tasks |
The 0/1 submission bug shows even simple tasks fail verification |
| Run all plans sequentially |
Independent plans (data download + sample check) can run in parallel |
| Keep heavy research in main session |
Spawn fresh-context subagent for data exploration |
| Train 10 models to "find the best" |
Train 3-5 diverse models, ensemble is usually enough |
Implementation Status
This skill describes the GSD-driven ML pattern. To actually use GSD:
# Install (run once)
git clone https://github.com/open-gsd/gsd-core ~/projects/gsd-core
cd ~/projects/gsd-core
npm install
node bin/install.js
# Use in any project
cd ~/projects/kaggle-ps-s6e4
claude
# Inside Claude Code:
# /gsd-new-project → bootstrap .planning/
# /gsd-discuss-phase → Phase 1
# /gsd-plan-phase → Phase 2
# /gsd-execute-phase → Phase 3
# /gsd-verify → Phase 4 (THIS IS WHERE YOU CATCH THE 0/1 BUG)
# /gsd-ship → Phase 5
Real-World Validation
| Project |
Without GSD |
With GSD-style Verification |
| S6E2 first attempt |
0/1 submission, LB 0.884 |
Caught by verification, fixed to LB 0.95357 |
| S6E4 R13 |
Stacking + threshold bundled, LB worse |
Controlled variable: stacking OK, threshold bad |
| Store Sales v2 |
sales=0 fill, LB 2.83 (worse than v1) |
mean_ratio=0.11 diagnostic, ffill fix, LB 1.90 |
The S6E2 case is the canonical example: same model, two submissions, 0.07 LB difference — verification caught it.
Related Skills
kaggle-submission-format-by-metric — format check is verification step #1
autogluon-first — the "execute" phase standard recipe
cv-lb-gap-acknowledgment — verification step #4 (gap check)
ml-sweet-spot — when to STOP iterating (loop termination condition)
three-layer-wisdom-extraction — how to extract lessons from verification findings
References
1---2name: gsd-loop-engineering3description: Apply GSD Core's loop-engineering methodology to ML/data-science tasks. Use when: (1) You have a multi-step ML pipeline (data → features → train → verify → submit), (2) Context is growing long and quality is drifting, (3) You want auditable verification at each step, (4) You want fresh-context subagents to handle heavy work without polluting the main session. Validated against: gsd-build/get-shit-done (64K stars, deprecated), open-gsd/gsd-core (canonical, 4.4K stars, active 2026-06).4---56# GSD Loop Engineering for ML Tasks78## Problem910ML pipelines are naturally **multi-stage loops**:111. Plan → 2. Execute (data prep / train / generate submission) → 3. Verify (format / CV-LB gap / sanity) → 4. Fix or Ship.1213Most agentic ML workflows fail because:14- **Context rot**: long sessions degrade model output (e.g., 0/1 submission bug in S6E2 was partly due to loss of focus)15- **No verification**: tasks accepted as done without adversarial checking (S6E4 submission would have been caught by a verifier)16- **No shared memory**: each step reinvents context from scratch17- **Drift on style**: best practices from start of session get forgotten by end1819GSD Core (open-gsd/gsd-core) is the canonical loop-engineering framework solving exactly this. This skill adapts its patterns to ML.2021## Context / Trigger Conditions2223Use this skill when:24- Working on a Kaggle competition end-to-end25- Designing a multi-stage ML pipeline (data → features → train → ensemble → submit)26- Session has > 50 turns and quality is degrading27- You want auditable proof each step worked (not just "looks right")28- You're tempted to use `--dangerously-skip-permissions` (don't)2930**Don't use**:31- Single-file one-off scripts32- Pure EDA with no downstream work33- Research tasks where you're just reading papers3435## Solution: 5-Phase ML Loop3637```38┌────────────────────────────────────────────────────────────┐39│ Phase 1: DISCUSS (gsd-discuss-phase) │40│ - Resolve ambiguities in the task brief │41│ - Output: .planning/phases/<N>-DISCUSS.md │42├────────────────────────────────────────────────────────────┤43│ Phase 2: PLAN (gsd-plan-phase) │44│ - Research + plan, but in fresh-context subagent │45│ - Plans declare wave dependencies (DAG) │46│ - Output: .planning/phases/<N>/RESEARCH.md + PLAN-<M>.md │47├────────────────────────────────────────────────────────────┤48│ Phase 3: EXECUTE (gsd-execute-phase) │49│ - Run plans in waves (parallel where independent) │50│ - Each plan is a fresh-context subagent │51│ - Output: artifacts (models, submissions, logs) │52├────────────────────────────────────────────────────────────┤53│ Phase 4: VERIFY (gsd-verify) │54│ - Adversarial check: assume goal NOT achieved │55│ - Findings classified BLOCKER / WARNING / VERIFIED │56│ - Output: .planning/phases/<N>/VERIFICATION.md │57├────────────────────────────────────────────────────────────┤58│ Phase 5: SHIP or FIX │59│ - VERIFIED → ship submission, archive artefacts │60│ - BLOCKER → generate fix plan, re-enter Phase 2 │61│ - WARNING → decide case-by-case │62└────────────────────────────────────────────────────────────┘63```6465## Adapted to Kaggle Competitions6667| GSD Phase | ML Equivalent |68|---|---|69| DISCUSS | Identify metric (AUC / RMSLE / mAP), submission format, deadline, data quirks |70| PLAN | Plan features, baseline model, ensemble strategy, verification checks |71| EXECUTE | Run feature engineering, AutoGluon baseline, blend, generate submission |72| VERIFY | Submission format check, CV-LB gap sanity, distribution check, adversarial validation |73| SHIP | Submit to Kaggle LB; archive all artefacts |7475## Concrete: GSD-Driven S6E2 Re-Run (validated pattern)7677This is the pattern that produced Private LB 0.95510 in 15 minutes:7879```80Phase 1: DISCUSS81 - Metric: AUC (roc_auc) — binary classification82 - Data: 630K train, 270K test, 14 features, label "Heart Disease"83 - Submission: 1 proba column (PitNextLap or class 1) — CRITICAL84 - Time budget: 15 min training85 Output: .planning/01-discuss.md8687Phase 2: PLAN88 - Plan A: AutoGluon best_quality with time_limit=900s89 - Plan B: Verify submission format matches sample_submission.csv90 - Plan C: Probability file only, never thresholded91 Output: .planning/02-plans/{A,B,C}.md9293Phase 3: EXECUTE94 - Wave 1: Plan A (training, 15 min) and Plan B (parallel — read sample)95 - Wave 2: Plan C (re-generate submission using predict_proba)96 Output: ag_models/, submission_autogluon_proba.csv9798Phase 4: VERIFY (the moment of truth)99 - Check 1: submission columns = sample columns? PASS100 - Check 2: submission values in [0, 1]? PASS101 - Check 3: OOF AUC > 0.95? PASS (0.95554)102 - Check 4: CV-LB gap < 0.01? PASS (gap = 0.002 after probability fix)103 Output: .planning/04-verify.md (all VERIFIED)104105Phase 5: SHIP106 - kaggle competitions submit ...107 - Archive: ag_models/, leaderboard.csv, summary.json108```109110## Key GSD Patterns Applied to ML111112### Pattern 1: Fresh-Context Subagents113- Main session: thin orchestrator + state reads114- Subagents (one per heavy task): 200k clean context each115- Shared substrate: disk files (`.planning/`, `ag_models/`, `submission_*.csv`)116117### Pattern 2: Goal-Backward Verification118- Default stance: **assume goal NOT achieved until codebase evidence proves it**119- For ML: assume submission is wrong until checks pass120- Checks must be concrete (file exists, value in range, format matches)121122### Pattern 3: Wave-Based DAG Execution123- Plans declare `depends_on: ["plan-A"]`124- Independent plans run in parallel (no human bottleneck)125- For ML: feature engineering can run while baseline is training126127### Pattern 4: Escalation Gate128- If verifier finds BLOCKER, stop and surface to user129- Don't silently guess — better to ask than submit a broken file130131### Pattern 5: Spec-Driven Artefacts132- Every phase produces structured artefacts on disk133- For ML: every step produces a CSV / model file / log134- State survives session boundaries135136## Anti-Patterns to Avoid137138| Don't | Do |139|---|---|140| Submit without format check | Always run Plan B (verify format) before submit |141| Trust CV score as final metric | Always run Plan C (probability file) for AUC |142| Skip verification on "obvious" tasks | The 0/1 submission bug shows even simple tasks fail verification |143| Run all plans sequentially | Independent plans (data download + sample check) can run in parallel |144| Keep heavy research in main session | Spawn fresh-context subagent for data exploration |145| Train 10 models to "find the best" | Train 3-5 diverse models, ensemble is usually enough |146147## Implementation Status148149This skill describes the GSD-driven ML pattern. To **actually use** GSD:150151```bash152# Install (run once)153git clone https://github.com/open-gsd/gsd-core ~/projects/gsd-core154cd ~/projects/gsd-core155npm install156node bin/install.js157158# Use in any project159cd ~/projects/kaggle-ps-s6e4160claude161# Inside Claude Code:162# /gsd-new-project → bootstrap .planning/163# /gsd-discuss-phase → Phase 1164# /gsd-plan-phase → Phase 2165# /gsd-execute-phase → Phase 3166# /gsd-verify → Phase 4 (THIS IS WHERE YOU CATCH THE 0/1 BUG)167# /gsd-ship → Phase 5168```169170## Real-World Validation171172| Project | Without GSD | With GSD-style Verification |173|---|---|---|174| S6E2 first attempt | 0/1 submission, LB 0.884 | Caught by verification, fixed to LB 0.95357 |175| S6E4 R13 | Stacking + threshold bundled, LB worse | Controlled variable: stacking OK, threshold bad |176| Store Sales v2 | sales=0 fill, LB 2.83 (worse than v1) | mean_ratio=0.11 diagnostic, ffill fix, LB 1.90 |177178The S6E2 case is the canonical example: same model, two submissions, 0.07 LB difference — verification caught it.179180## Related Skills181182- `kaggle-submission-format-by-metric` — format check is verification step #1183- `autogluon-first` — the "execute" phase standard recipe184- `cv-lb-gap-acknowledgment` — verification step #4 (gap check)185- `ml-sweet-spot` — when to STOP iterating (loop termination condition)186- `three-layer-wisdom-extraction` — how to extract lessons from verification findings187188## References189190- GSD Core: https://github.com/open-gsd/gsd-core (canonical)191- Original: https://github.com/gsd-build/get-shit-done (64K stars, deprecated)192- Related repos: gsd-browser, context-packet, agent-inbox (gsd-build org)193- S6E2 verification pattern: see `docs/ml-agent-memory/lessons/s6e2_submission_format.md`