developing-data-science-notebooks
Skill1 starsChanged 13 days agoMITView on GitHub
Develop production-grade Jupyter notebooks for data science research that follow state-of-the-art code practices (cell structure, modularization, reproducibility) and are designed to transition cleanly into production artifacts (API, worker, DAG). Use when creating, restructuring, or reviewing data science notebooks.
In this repository15 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- llms.txtllms.txt
- critic-reviewSkill
- expectation-driven-scienceSkill
- experiment-graphSkill
- experiment-pipelineSkill
- exp-reviewSkill
- hypothesysSkill
- let-it-ripSkill
- literature-researchSkill
- mad-science-setupSkill
- notify-gchat-human-waitSkill
- to-articleSkill
- to-docSkill
- what-i-doSkill
The file
We split this skill into the rules it gives an agent
11 rules. About 0 are common, 10 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈10
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 18
Use this ordering when building the notebook top-down:
- Distinctive: line 29
No cell state dependency — restart & run all must work from clean kernel.
- Distinctive: line 36
No duplicated logic between cells/notebooks (DRY).
- Distinctive: line 37
Keep code PEP8 and Clean Code: meaningful names, sensible comments, small functions.
- Very specific: line 43
Never edit raw data (immutable): read from data/raw, write final products to data/processed.
- Distinctive: line 76
CI: every commit must validate the notebook — clean execution top-down + test suite + lint — before merge.
- Distinctive: line 77
CD: every tested version automatically generates an artifact and deploys (staging → production) via scheduler/event (e.g.
- Distinctive: line 82
When reviewing an existing notebook, check in order:
- Distinctive: line 85
No import+compute cells; cells ≤100 lines with clear purpose.
- Distinctive: line 86
No duplicated code across cells.
- Distinctive: line 89
If it will be productionized: parameterized, CI-covered, extracted modules tested, experiments logged.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Developing Data Science Notebooks
Applies engineering best practices to Jupyter notebooks so the research code is readable, reproducible, and ready to be productionized. Synthesized from: PLOS "Ten Simple Rules" (2019), Google Cloud Jupyter Notebook Manifesto, Cookiecutter Data Science (DrivenData), nbdev, papermill, and the arXiv study on notebook collaboration practices.
Core Mindset
- The notebook is exploration and narrative; the product is born from the modules extracted from it. Treat the notebook like software, not a draft.
- Code that stabilizes gets refactored into functions and modules of your own installable package. The notebook becomes the orchestrator/consumer of that package.
- A "consolidated" notebook is one you can Runtime → Restart & Run All with zero errors, top to bottom.
Checklist: Code Structure
Use this ordering when building the notebook top-down:
- Title + preamble (Markdown, H1): what the analysis answers, its purpose, audience. Write for your future self (over-explain).
- Imports isolated from logic — never mix
importstatements with computation in the same cell (breaks doc generation and hides side effects; only top-level statements count — imports inside functions/tryare fine). - Parameters cell at the top marked with the
parameterstag (dates, thresholds, paths, file names) — everything that changes between runs. Never bury config in the middle. - One cell = one meaningful step: one transformation, one function, one plot. Max ~100 lines per cell. Use Markdown above each cell explaining the why, not just the what.
- Functions over duplicated code: any snippet reused between cells or notebooks becomes a function. When in doubt, wrap it.
- Table of contents + section headers (Markdown H2/H3) for navigation; split very long notebooks into sequenced small notebooks with serialized intermediates (a top-level index notebook linking them).
Checklist: Code Quality
- No cell state dependency — restart & run all must work from clean kernel.
%load_ext autoreload+%autoreload 2and import your own modules when working in parallel with package code:%load_ext autoreload %autoreload 2 from mypkg.features import make_dataset- No duplicated logic between cells/notebooks (DRY). Signs you should refactor to a module: copying an old notebook to start a new one, copy-pasting functions between notebooks, creating classes inside cells.
- Keep code PEP8 and Clean Code: meaningful names, sensible comments, small functions.
- Options supported:
ipytestfor unit tests inside the notebook; a real IDE for refactoring/debugging.
Checklist: Reproducibility
- Declare the environment: pinned
requirements.txt/environment.yml. Print critical dependency versions at the end (e.g.watermarkextension). - Never edit raw data (immutable): read from
data/raw, write final products todata/processed. - Version control:
git+nbdimefor human-readable notebook diffs, or save notebooks as plain text (.py/.md) via Jupytext — trivial diffs and code review. - Validate reproducibility: full restart→run-all before considering it done.
Path to Production (API, Worker, DAG)
Signs the notebook is ready to be productionized (CCDS)
| Signal | Action |
| Duplicating notebooks to start new ones | Extract shared logic to a module |
| Copy-pasting functions between notebooks | Move to module + add tests |
| Creating classes inside cells | Refactor into package module |
Step 0 — Parameterize (papermill)
- Tag one cell as
parameters(variables for dates, paths, thresholds). - The notebook becomes non-interactively executable:
papermill input.ipynb output.ipynb -p start_date 2026-01-01 - This is the gateway to running it as a scheduled job/stage.
Delivery shapes
| Target | How |
| DAG / pipeline step | Break long notebook into per-stage notebooks that serialize intermediates to disk; orchestrate with Makefile, Airflow, Luigi, Prefect, Dagster, or Flyte. |
| API | Refactor stable stages (extraction, cleaning, features) into package modules; implement the service (e.g. FastAPI) on the tested modules; the notebook remains the demo/contract. |
| Worker | Event (Pub/Sub, queue) triggers execution of the parameterized notebook (Google manifest CD pattern), or of the extracted module. |
CI/CD for notebooks (Google manifest)
- CI: every commit must validate the notebook — clean execution top-down + test suite + lint — before merge. Notebook is reviewed like a PR.
- CD: every tested version automatically generates an artifact and deploys (staging → production) via scheduler/event (e.g. Cloud Functions + Scheduler).
- Experiment logging: automatically record code, hyperparameters, data sources, results, and runtime for every execution so experiments are auditable.
Review Pass
When reviewing an existing notebook, check in order:
- Runs clean top-to-bottom; no hidden state.
- Params at top in a
parameterscell; no config buried mid-notebook. - No import+compute cells; cells ≤100 lines with clear purpose.
- No duplicated code across cells; functions used; stable logic heads toward a module.
- Dependencies pinned; versions printed; raw data untouched.
- Committed via nbdime/Jupytext — diffs are human-readable.
- If it will be productionized: parameterized, CI-covered, extracted modules tested, experiments logged.
Red Flags
- Notebook that only works because only some cells were executed in a particular order.
- Hardcoded secrets, credentials, or absolute machine-specific paths inside cells.
- Long-lived notebook duplicating logic that already exists in the package.
- Claims of "done" without a clean restart→run-all verification.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

