Polarize
GitHub Get in touch

Work · Repository

scientific-research-scaffold

A protocol for studies and simulators across repositories, and a CLI that scaffolds and checks them.

  • Python
  • 1 post
  • 11 merged PRs

View on GitHub → Changelog ↓

Posts about it

README

A protocol for laying out research across repositories, and scaffold, a small CLI that sets up new studies, simulators and tools in that shape and checks existing ones against it.

Three kinds of repo

  a study a sim a tool
is one research question, and everything used to pursue it one simulator, under adaptive preregistration one job done for other repos: an instrument, a recorder, a service, a library
holds apps, sims still in development, datasets and calculators, each preregistered where it predicts the model, its preregistrations, its assumptions the tool, and the list of repos that depend on it and what they use
versions apps/<slug>/v1, apps/<slug>/v2 folders, and tags model-vX.Y.Z tags, all in one repo vX.Y.Z tags, one version said the same everywhere
findings go to the shared research corpus, referenced by claim ID the same none: a tool holds no research; its comparison units’ results stay in them

A sim starts as a folder inside the study that needs it, and moves to its own repo when a second study uses it, it needs its own releases, or it is shared on its own. Repos are named for their subject, with no lab- or sim- prefix: the kind goes in the manifest.

Studies and sims build on four other pieces, named in a profile so the protocol itself stays generic:

  • a research corpus, the one shared record of claims and findings;
  • a preregistration kit, adaptive-preregistration, which installs the predict-first protocol;
  • a design system for the apps, polarize-ui in ours;
  • a workbench of shared tools not yet released as libraries.

Quick start

git clone --recurse-submodules https://github.com/polarizetech/scientific-research-scaffold.git
git clone https://github.com/polarizetech/adaptive-preregistration.git   # found automatically as a sibling
cd ~/code
export SCAFFOLD_PROFILE=example   # or your own; there is no built-in default (see below)

scientific-research-scaffold/bin/scaffold new study reef-acoustics \
  --goal "Learn whether a reef's sound tracks its coral cover" \
  --approach "Record healthy and degraded sites and compare their soundscapes" --visibility private
cd reef-acoustics
../scientific-research-scaffold/bin/scaffold new app site-listener \
  -q "Can a degraded site be heard?" --hypothesis-element H1
../scientific-research-scaffold/bin/scaffold new sim sound-propagation \
  -q "How reef sound carries" --inside . --hypothesis-element H1
../scientific-research-scaffold/bin/scaffold check

new study renders the template, makes the first commit, installs the preregistration kit and prints the gh repo create line. It never publishes anything. Visibility is yours to decide: without --visibility public|private the manifest says undecided, and check fails until you record a decision.

command does
scaffold new study <name> --goal "..." --approach "..." [--visibility public\|private] a new study repo, exploratory: a goal and a rough approach, sized with the person before anything is built
scaffold new study <name> -q "..." --hypothesis "..." a new study repo that starts from the person’s hypothesis, preserved verbatim
scaffold new tool <name> --goal "..." --approach "..." [--claim] a new tool repo, exploratory by default; --claim scopes it first instead
scaffold new sim <name> -q "..." [--inside STUDY] [--hypothesis-element H1] a new sim repo, or a sim folder linked into a study’s hypothesis map
scaffold new tool <name> -j "..." [--inside STUDY\|WORKBENCH] a new tool repo, or a tool folder inside a study or workbench
scaffold new workbench <name> -q "..." a workbench: general tools, sims and apps, and studies as folders (new study --inside)
scaffold new app <slug> -q "..." --hypothesis-element H1 the app’s next version, apps/<slug>/vN/, registered in STUDY.toml and linked in HYPOTHESIS.toml
scaffold new <app\|sim\|tool\|dataset\|calculator> ... --exploratory the same unit with no claim asked for: a build note in SCOPE.toml, and an exploratory label
scaffold link-hypothesis <unit-path> --element H1 --role "..." associate an existing unit with accepted elements and write the same provenance into its local scope
scaffold sync-hypothesis [PATH ...] detect changed element/evidence snapshots across affected studies and queue units for agent review without changing claims
scaffold promote-sim sims/<slug> split a sim out of a study into its own repo, keeping its history
scaffold check [PATH] check a repo against the protocol; nonzero exit on failure, for CI
scaffold status [PATH ...] one line per repo: kind, stage, scaffold release, CI ref, check result, pending update
scaffold update [PATH] [--apply] [--adopt FILE] bring the files the scaffold owns up to this release; a dry run unless --apply
scaffold version [PATH] whether a repo follows the current scaffold, and the steps to upgrade it (sessions run this themselves)
scaffold usage [PATH ...] [--days N] [--all] tokens and API-equivalent cost per repo from Claude Code and Codex logs, and Codex’s plan limits
scaffold profiles list profiles

Agents

Every repo gets specialist role briefs in .claude/agents/: a scout, a computational engineer, a designer, a frontend developer, a researcher, an analyst and a science writer. A sim, which has no UI, gets no designer or frontend developer. Claude Code discovers them as subagents; ChatGPT, Codex and other repository-aware assistants read the same briefs through AGENTS.md and can apply them in the current session when subagents are unavailable. Each agent starts on a cheap model and is escalated on a signal, and agents pass short handoffs, not transcripts (agents/COORDINATION.md). scaffold usage shows what each repo actually costs. The agents live in their own repo, scientific-research-agents, included here as a submodule pinned to a tag: clone with --recurse-submodules, or run git submodule update --init.

skills/new-study/ is a portable skill for creating and adopting studies with this scaffold. Install the whole repository as a skills-only plugin in ChatGPT or Codex, or copy the skill to the host’s skill folder:

  • Claude Code: ~/.claude/skills/new-study/ or .claude/skills/new-study/.
  • Codex: ~/.codex/skills/new-study/ or .codex/skills/new-study/.

Plain ChatGPT does not operate on an unconnected local checkout. Use the plugin in a workspace with local repository access, or use Codex for the filesystem and shell steps.

Keeping repos current

scaffold status ~/code/* surveys every repo at once. scaffold update brings one repo’s scaffold-owned files (the CI workflow, the Makefile, shared/workbench.py, the agents) up to this release, and never touches anything else. It replaces a file only when nobody has edited it since the scaffold wrote it, which it knows from .scaffold.lock, or by matching the file against what each earlier release would have written. An edited CI workflow gets only its scaffold ref: moved. Any other edited file is kept, with the difference shown; --adopt FILE replaces it anyway. It prints a dry run first, writes nothing without --apply, refuses to overwrite uncommitted work, and never commits.

Every release says how to upgrade to it in UPGRADING.md, and every repo notices: a session hook runs scaffold version when a session starts and, if the repo is behind, prints the steps and offers to do them.

Requirements: Python 3.9+ and git. No other dependencies.

Using it for your own work

The protocol is written to be forked. Copy profiles/example.toml, name your own corpus, preregistration kit, design system and workbench (any can be left empty), and pass --profile <name> (or set SCAFFOLD_PROFILE). There is no default profile, so nothing of ours ends up in your repos by accident. profiles/polarizetech.toml is ours, as a worked example.

Licence

Code is MIT; the protocol and documentation are CC BY 4.0. See LICENSE. To cite it, see CITATION.cff.

Changelog

2026-11-30 #23

Release scaffold v0.17.0: exploratory work is MVP work

  • Moves the agents submodule to scientific-research-agents v0.14.0, which adds “Exploratory work is MVP work”.
  • Study and tool rules: a first pass is whittled down to about an hour, built from open-source and peer-reviewed pieces that already work, with every try versioned.
  • Predict first now applies once the work is out of exploratory: there’s no preregistration while exploratory.
  • Releases app version names and URLs (polarizetech/scientific-research-scaffold#22).
  • Bumps the CI ref, the manifests and CITATION, and adds an UPGRADING section.

Tests: 108 OK (2 skipped).

🤖 Generated with Claude Code

2026-11-30 #22

App versions: one name and one URL per version

Finishes the app-urls work that had been sitting uncommitted since 2026-10-21, ported onto current main:

  • PROTOCOL.md § 6: a version is named <slug> <vN>, with no separate product name, and served at /<slug>/<vN>/ when hosted under a shared address. A retired version’s route is removed, and apps use relative URLs only. This is marked as advice, not a check.
  • Study agent rules: the same rule.
  • App template: redirects to the trailing-slash form so the same files work at the sub-path.
  • CHANGELOG: an Unreleased entry.

Tests: 108 OK (2 skipped).

🤖 Generated with Claude Code

2026-11-30 #21

Release scaffold v0.16.0: research folder on first research, nothing saved twice

  • Moves the agents submodule to scientific-research-agents v0.13.0: the corpus project folder is opened the first time research comes up, without asking, and what the corpus already holds is linked, never copied.
  • Updates the tool and study rules to match.
  • Releases the “report in three lists” rule (polarizetech/scientific-research-scaffold#6), which was under Unreleased.
  • Bumps the CI ref, the manifests and CITATION to v0.16.0, and adds an UPGRADING section.

Tests: 108 OK (2 skipped).

🤖 Generated with Claude Code

2026-11-30 #6

Tell assistants in every repo to report in three lists

Every repo’s AGENTS.md (all kinds, all profiles) now tells assistants to report back in three short bullet lists:

  • Results: what is true now, not what was done (works, broke, didn’t work, new problem, unclear)
  • Next (assistant): the work it will do next
  • Needed from you: decisions or input from the person, or “Nothing”

Existing repos pick it up with scaffold update --apply. Test added; 82 tests pass. The 8 ruff findings in bin/ and tests/ predate this change.

🤖 Generated with Claude Code

2026-11-27 #20

Release scaffold v0.15.0: research is saved, never a blocker

Moves the agents submodule to scientific-research-agents v0.12.0, which adds “Research is saved, never a blocker” to the AGENTS.md section and every brief. It joins the tool, study and workbench rules from polarizetech/scientific-research-scaffold#19. Bumps the generated CI ref, plugin manifests and CITATION to v0.15.0, and adds the CHANGELOG and UPGRADING sections. Tests: 107 OK (2 skipped).

🤖 Generated with Claude Code

2026-11-27 #19

Agent rules: research is saved, never a blocker

Adds the rule from scientific-research-agents v0.12.0 to agent-rules/tool.md, study.md and workbench.md, and to the tool section of PROTOCOL.md. Research is saved to the corpus project (or the study’s atlas) without asking, linked from the work, and never holds the work up. Scope files citing papers count as scope, not research. “No research here” is kept. Tests: 107 OK (2 skipped). The agents submodule bump to v0.12.0 follows once that release is tagged.

🤖 Generated with Claude Code

2026-11-22 #18

Release v0.14.0: the designer's MVP mode for exploratory work

  • While the work is exploratory (mode = "exploratory" in HYPOTHESIS.toml, stage = "exploratory" in SCOPE.toml, or Tier: explore in a scope file), the design rule in AGENTS.md and each new app’s README now send pages through the designer’s MVP mode: one quick pass that designs and builds the page on the design system, aiming for something workable within about an hour, with numbers and methods still from established papers.
  • Past exploratory (a hypothesis or claim, or Tier: grounded/publication), the full designer pass: a Claude Design from the Design artifact type (or a zero-build mockup) handed to frontend-developer.
  • agents submodule moves to scientific-research-agents v0.11.0 (polarizetech/scientific-research-agents#6); SCAFFOLD_REF, plugin manifests and CITATION.cff move to v0.14.0; CHANGELOG.md and UPGRADING.md have v0.14.0 sections.

Tests: python3 -m unittest discover tests: 107 run, OK (2 skipped).

🤖 Generated with Claude Code

2026-11-21 #17

Release v0.13.0: visual work uses the profile's design system (#14, rebased)

What changed

The work of #14 (branch design-system), rebased onto main at v0.12.1, plus a release commit for v0.13.0. The three commits from #14 are unchanged in substance; the conflicts were resolved keeping v0.12.x behaviour, including scaffold check skipping the .scaffold/ CI checkout.

  • A profile’s [design] table names a design system pinned by tag (name, package, repo, ref, rules, optional house_rules, artifact). scaffold refuses a ref that is a branch or rules that name another tag.
  • When a profile names one, every repo’s AGENTS.md gets agent-rules/design.md and the house rules, and a new repo gets a README Design section and a manifest [design] table.
  • New apps are wired to the pinned design system (serve.py reads the files at the pinned tag, serves the fonts, and shows a banner when the checkout is missing). scaffold check warns about each page that doesn’t load it, pins a branch, or hand-writes hex colours outside allow_hex.
  • Pages are designed first, by the designer agent, and carry no documentation.
  • The polarizetech profile moves polarize-ui from v0.4.2 to v0.6.7, the tag downstream repos already pin.

Full notes: CHANGELOG.md § v0.13.0, and UPGRADING.md.

Why

Repos made with the scaffold already carry the design section in their AGENTS.md, from this branch while it was unmerged. Released scaffolds don’t know it, so scaffold update to v0.12.1 would delete that section. polarize-holo’s dry run showed this on 2026-11-21. Releasing this fixes the upgrade path.

For the reviewer

  • 107 tests pass (pytest -q tests).
  • polarize-holo’s scaffold update dry run against this branch reports AGENTS.md as current. It would only change the CI ref (v0.12.1 → v0.13.0) and the session-hook order in .claude/settings.json.
  • This supersedes #14. Close #14 once this merges. Not tagged: tag v0.13.0 after merge, following the scaffold’s own release steps.

🤖 Generated with Claude Code

2026-11-21 #14

Use the profile's design system for visual work, and wire new apps to it

Scaffolded projects now use the profile’s design system for anything visual, and new apps actually load it.

Design-system setting (79de1b9)

  • Optional [design] table in profiles: name, package, repo, a pinned release tag (ref), and the URL of its own rules. Empty means nothing changes.
  • When set: an agent rule in AGENTS.md, a README Design section, a [design] table in the manifest (theme, allow_hex), and scaffold check warnings.
  • polarizetech profile pins polarize-ui.

New apps wired to it (59f4b42) New apps weren’t using the design system. Fixes:

  • serve.py reads design files at the pinned tag, not whatever branch the local checkout has out.
  • The stylesheet’s fonts are served; before, every app fell back to system fonts.
  • A missing design system shows a yellow banner with the fix instead of a quietly unstyled page.
  • Each new app’s README has a Design section; app.css is layout only.
  • <body> class comes from the profile’s body_class.
  • scaffold check warns about each HTML page that doesn’t load it or lacks the class (was repo-wide).
  • Pin moved to polarize-ui v0.6.7.

Design checks are warnings, not failures. UPGRADING.md has the by-hand steps for existing repos.

Tests: python3 -m unittest discover -v tests passes on Python 3.9 and 3.12 (105 tests, 2 skipped).

🤖 Generated with Claude Code

2026-11-17 #16

Release scaffold v0.12.1

Patch release for #15: scaffold check skips the scaffold’s own .scaffold/ CI checkout, so tool repos stop failing on the templates’ preregistrations/ folders.

  • SCAFFOLD_REF, plugin.json, .codex-plugin/plugin.json, CITATION.cff → 0.12.1 (released 2026-11-17)
  • CHANGELOG.md: the Unreleased entry becomes v0.12.1
  • UPGRADING.md: v0.12.1 section (scaffold update moves the CI ref; no session steps)

The agents submodule is unchanged. Tests: 95 run, OK (2 skipped). After merge, tag v0.12.1 on the merge commit.

🤖 Generated with Claude Code

2026-11-17 #15

check: skip the scaffold's own .scaffold/ checkout

Summary

  • The workflow the scaffold generates checks the scaffold out into .scaffold/ inside the repo. The check’s tree walk didn’t skip that folder, so in a tool repo it read the templates’ preregistrations/ folders as misplaced units and failed (3 failures on polarizetech/entropy-fetch’s first CI run).
  • .scaffold is added to the walk’s skip set and to the backup SCOPE.toml search that runs when git isn’t available.
  • New test test_tool_check_skips_the_scaffold_checkout: it fails on main with the same error and passes with this change.
  • CHANGELOG entry under Unreleased.

Test plan

  • python -m unittest discover tests on Python 3.12: 95 tests pass.
  • The new test fails without the fix.

After this is released, entropy-fetch can drop its workaround of moving .scaffold to $RUNNER_TEMP before make check.

🤖 Generated with Claude Code