$npx -y skills add Borda/AI-Rig --skill kaggleGenerate a Kaggle competition notebook as a Jupytext # %% Python script following the user's established ML research style: PTL for DNN training, best-fit tool selection, EDA→Baseline→Train→Inference pipeline with per-stage lens cells, small single-purpose cells each carrying a
| 1 | <objective> |
| 2 | |
| 3 | Generate Kaggle competition notebook script, Jupytext `# %%` format. |
| 4 | |
| 5 | Two goals, equal weight — neither traded for other: |
| 6 | - **Win** — leaderboard-competitive: leakage-safe CV, metric-aligned loss/model choice, tuning/ensembling when it moves the score, not style theater |
| 7 | - **Teach** — read top to bottom like a university/seminar lecture on solving this competition: reader new to it follows the full reasoning chain, every decision motivated, nothing left as unexplained code |
| 8 | |
| 9 | Follows user's ML research style distilled from past notebooks: |
| 10 | - **PTL always for DNN training** (PyTorch Lightning + torchmetrics) — even simple baselines |
| 11 | - **Tool agnostic** — best-fit library for problem; PTL when training loop needed |
| 12 | - **Stages with lenses** — each major stage: quick sanity check cell (show one batch, print shapes, verify submission format) |
| 13 | - **Small, single-purpose cells** — one action per cell (load, one transform, one plot, one check); never bundle setup + run + verify to save cell count |
| 14 | - **Every cell earns its place** — one-line why (comment or markdown sentence) before/in each cell: the specific reason this step happens now — never a restatement of what the code does |
| 15 | - **Section markdown is extensive and structured** — full explanation of what/why/how-it-advances-the-goal per section, formatted as tables/lists/blockquotes over dense prose paragraphs; markdown before a plot sets up the question, markdown after states the finding and its implication — plot and prose flow as one beat, never an orphaned chart |
| 16 | - **`# !` bash over subprocess** — package installs, `nvidia-smi`, `ls -lh`, `# ! head submission.csv` |
| 17 | - **EDA is visual** — distribution plots, sample grids, dimension scatters before any model |
| 18 | - **Inference included** — model save pattern + separate load-and-infer cells |
| 19 | - **CSVLogger + seaborn** — metrics plotted from `metrics.csv` after every training run |
| 20 | |
| 21 | NOT for writing Python packages, modules, production code — notebook scripts only. |
| 22 | NOT research literature survey — use `/research:topic` for SOTA literature search. |
| 23 | |
| 24 | </objective> |
| 25 | |
| 26 | <inputs> |
| 27 | |
| 28 | - **$ARGUMENTS**: one of: |
| 29 | - `<competition-name>` — short slug for output filename; generates blank template |
| 30 | - `<competition-name> <url>` — fetches competition overview from URL before generating |
| 31 | - `<competition-name> "<description>"` — inline description of problem and data |
| 32 | - `--type <type>` — hint: `classification`, `regression`, `segmentation`, `detection`, `tabular` (auto-detected when omitted) |
| 33 | - `--eda-only` — generate only EDA sections (no model/training/submission); always online (no offline setup) |
| 34 | - `--inference-only` — generate inference notebook from checkpoint (no EDA, no training); always offline (frozen packages pattern); loads checkpoint from `PATH_CHECKPOINT` constant; output suffix `-inference.py` |
| 35 | - `--offline-setup` — include offline package setup (frozen_packages pattern) in setup cell; auto-applied when `--inference-only`; ignored when `--eda-only` (EDA always online) |
| 36 | - `--resume <path>` — read existing `.py` script, extend/improve it |
| 37 | |
| 38 | Output: `.experiments/kaggle/<competition-name>.py` |
| 39 | |
| 40 | </inputs> |
| 41 | |
| 42 | <constants> |
| 43 | |
| 44 | ```yaml |
| 45 | OUTPUT_DIR: .experiments/kaggle/ |
| 46 | CELL_MARK: "# %%" |
| 47 | MD_CELL_MARK: "# %% [markdown]" |
| 48 | # NOTE: documentation-only — not referenced as shell vars across separate Bash() calls (state doesn't persist); keep values in sync with literal use sites (Steps 1, 3, 4). |
| 49 | ``` |
| 50 | |
| 51 | </constants> |
| 52 | |
| 53 | <compaction> |
| 54 | |
| 55 | Key boundary: end of Step 3 — notebook script generated by `foundry:sw-engineer`, written to OUTFILE. |
| 56 | Preserve: OUTFILE path (derived from TMPDIR keys), COMPETITION_NAME (TMPDIR key), mode flags (EDA_ONLY, INFERENCE_ONLY, OFFLINE_SETUP). |
| 57 | Clear at Step 1 start (stale prior run) and after Step 4 package-distillation gate resolves. |
| 58 | |
| 59 | </compaction> |
| 60 | |
| 61 | <workflow> |
| 62 | |
| 63 | **Task hygiene**: call `TaskList` first; close orphaned tasks. Create tasks per phase. |
| 64 | |
| 65 | ## Step 1: Parse arguments and gather context |
| 66 | |
| 67 | ```bash |
| 68 | # loads: compaction-contract.md |
| 69 | export CSID="${CLAUDE_CODE_SESSION_ID:-$PPID}" |
| 70 | ARGS="$ARGUMENTS" |
| 71 | COMPETITION_NAME=$(echo "$ARGS" | awk '{print $1}') |
| 72 | RESUME_FLAG="" |
| 73 | EDA_ONLY=false |
| 74 | INFERENCE_ONLY=fal |