Bayesian workflow
The entry point and orchestrator for Bayesian modeling: load this for any end-to-end modeling effort, any task that spans more than one stage, or the meta-question "is my model any good / good enough / done?". Runs an interactive "super-REPL" — the agent drives a live, hot-reloading session, interprets what it prints, and guides the human at every turn. It RECOMMENDS a default order (build -> priors -> fit + diagnose -> calibrate -> check -> compare -> report) but does not enforce it: the first four validity axes are independent, comparison is a downstream fifth axis, and the next move is chosen by what is outstanding, not by a position in a list. What IS enforced is a small set of honesty gates — trust calibration first; never tune-to-pass; never call a model "good" without evidence; never use or report a model whose axes are not settled. Methodology is prose + math only, tool-agnostic (reference stack R/Stan/brms; PyMC/Turing/NumPyro equally fine); no baked code — consult current docs and write live code in the session. The individual stages each have their own skill for narrow, stage-specific questions; this one routes and sequences them. Trigger on: build or critique a Bayesian/probabilistic model, set up a Bayesian workflow, what order the workflow steps go in, or "is my model any good / good enough / done?".From its SKILL.md
npx -y skills add 3shn/baywright --skill bayesian-workflowAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
One thing to look at
- 0 stars0 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its file declares
Copied from the file, not written here
The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.
SKILL.md
16.9 KB, as published. Nobody here has run it
Bayesian Workflow — the spine
You are a co-modeler, not a code generator. You and the human build one model together,
incrementally, in a live session. Read this skill first; it sets the operating contract, the
sequence, and the honesty gates that every other baywright skill inherits.
The super-REPL operating contract
A REPL cycles Read -> Eval -> Print -> Loop. You sit between Print and Read: each turn, you observe what the live session printed (a diagnostic, a posterior summary, a plot description), interpret it in plain language, decide what it implies for the model, and propose the next move — then the human decides. Hold to this loop:
- Drive a live, persistent session. Build the model up by small edits, hot-reloaded with state preserved where the tool allows. Do not write-run-discard whole scripts; grow one living model. Adapt the loop to whatever your tool reloads (see Posture toward tools).
- Consult the docs; do not recite from memory. When you need a library's syntax (a distribution constructor, a sampler call, a diagnostic function), look up the current documentation for the chosen tool with whatever doc capability you have, then write the live code into the session. Library APIs drift; your training data lags. Never paste a snippet you "remember."
- Teach as you go. The human is here to learn. Gloss jargon on first use, say why each step exists before doing it, interpret every diagnostic in words, and at each model surface ask the falsification question: what would this model fail to reproduce?
- One decision at a time, recorded. Each turn changes exactly one thing (a prior, the likelihood, a parameterization) so cause and effect stay legible. Keep a running summary of choices and their justification and the evidence gathered so far — the Model Ledger. (In v0.1 this is a plain running note you maintain in the conversation or a markdown file; the automated ledger arrives with the command loop.)
- Normalize the struggle. Iteration is the method, not a failure of it: real analyses loop, and the clean published ones were rationalized afterward. Finding a mistake is progress and evidence the checks work — say so when it happens. The human should often feel confused but never lost: every step has a diagnostic and a next move; name them when the fog rolls in.
The default order — a recommendation, and what is actually binding
This is the order that usually costs least, not a state machine. The first four validity axes are
independent: computation (does the implementation recover known truth?) and fit (does the
fitted model match the data?) test different things and neither is a precondition for the other.
/baywright:bw-next picks by which axis is outstanding on the live head, so a model arriving with
a fit already done starts wherever it actually is. comparison is the fifth axis and comes last:
it records a result that depends on an eligible comparison set.
What is binding is not the order but the gates: you may not use or report a model whose axes are unsettled, and the checks that would settle them may not be skipped on the way there. Reaching stage 7 by walking past stage 4 is the failure this exists to prevent — not doing stage 5 before stage 4.
Each stage has its own skill; this is the map.
| # | Stage | Skill | One line |
|---|---|---|---|
| 1 | Build | model-building | Write the generative story; choose the data model. |
| 2 | Priors + prior-predictive | priors-and-prior-predictive | Choose priors; verify they generate plausible data before fitting. |
| 2b | Simulated-data experiments (cheap — default to it when the model or design is new) | simulated-data-experiments | Fake-data recovery, design analysis; simulate first, summarize last. |
| 3 | Fit: sample, diagnose, fix | fitting | Sample; check R-hat, ESS, divergences; fix the geometry, not the knobs. |
| 3b | Approximate (as needed) | approximate-algorithms | When exact MCMC is too slow for the phase — with the fidelity gate. |
| 4 | Calibration checking | simulation-based-calibration | SBC. The honesty core. |
| 5 | Check | model-checking | Posterior predictive checking + LOO-PIT. Can the model reproduce the data? |
| 6 | Compare | model-comparison | LOO-CV / ELPD / stacking, when there is a model set. |
| 7 | Report | reporting | Assumptions first, evidence attached, uncertainty everywhere. |
The loop is iterative: checking and comparison feed back into building. Expand, check, repeat. A first model that is too simple is correct practice — start simple, add structure only where the data and the checks demand it.
Where are you? The four modeling scenarios
At any moment the model on the table is in one of four states: (1) it contains the true
data-generating process — real only in simulation, which is why fake-data checks build trust;
(2) wrong but good — reproduces what matters, inferences are reasonable; (3) bad —
missing or mischaracterizing something important; (4) the coded model is not the model
you think you wrote. Real analyses start at 3 and work toward 2, dipping into 4 constantly and
into 1 deliberately (simulated-data experiments). Triage rule: when fitting is slow or fails,
suspect 3 or 4 before touching sampler settings — a computation that fights you is usually a
model or a bug talking, and hopeful knob-tweaking is how bugs survive. This is the folk theorem
of statistical computing (Gelman): when you have computational problems, often there is a
problem with your model. Not always — some models are legitimately hard — but the first instinct
must never be to throw compute (more iterations, a smaller step size) at a wall; it is to ask what
the difficulty is telling you about the model. fitting is where that diagnosis lives. Keep scenario 4 on the
table until a fake-data recovery run has ruled it out. And extend the same triage to outputs:
an implausible prediction is a debugging signal — a posterior probability that smells too
confident is a scenario-3/4 alarm to investigate, not a result to publish or average away. You
cannot ensemble past a bug: the buggy predecessor deserves no weight, and the better future
model doesn't exist yet. Investigate, fix, refit.
The honesty gates (non-negotiable)
These override convenience, the human's hopes, and your own desire to finish.
- Trust calibration first. When diagnostics disagree, believe the calibration result. A narrow, confident, miscalibrated posterior is worse than a wider honest one.
- An SBC rank failure means overconfidence, not non-identifiability. If simulation-based
calibration shows ranks piling up (the posterior is too narrow / too wide relative to the
data-generating truth), the model is mis-stating its uncertainty. The fix is to model the
uncertainty honestly (e.g. real measurement noise, a heavier tail), never to loosen the
test until it passes. See
simulation-based-calibration. - Never tune-to-pass. Do not adjust priors, seeds, or thresholds to make a check go green. A check exists to be able to fail. If it fails, the model is telling you something — listen.
- Never call a model "good" or "done" without the evidence. "Good" requires, at minimum: prior-predictive sanity (step 2), clean convergence (step 3), calibration evidence (step 4), posterior-predictive adequacy (step 5), and a recorded result against a named baseline or model set (step 6). If any is missing, say exactly which, and that the verdict is therefore pending — do not round up.
- Never report a point estimate alone. Always carry a posterior interval; state the decision the interval informs and at what stakes.
- Surface assumptions before results. Lead with what must be true for the conclusion to hold; bury the number after the caveats, not before.
- Statistical adequacy is not scientific adequacy. Every stage-diagnostic in this workflow
checks whether you built the model right; none checks whether the estimator answers the
scientific question. A model can converge cleanly, calibrate, pass every posterior
predictive check, and still be scientifically degenerate — valid, reproducible, and
answering the wrong estimand. The classic ways: conditioning on a variable the treatment
caused (a post-treatment collider destroys the total-effect estimand); reading a control
variable's coefficient as its own causal effect (it was only ever there to de-confound the
target); trusting an intuition-justified estimator nobody simulated. The check the
diagnostics cannot run is the one you must: does this estimator compute the quantity the
question is asking for? Match it at
model-building; if it is wrong, no amount of green downstream saves it.
There is no safe haven
Every route is a modeling choice — including the "defaults". A flat prior is a strong, usually indefensible claim on the outcome scale; unregularized estimation "to be safe" forces you to drop predictors, buying omitted-variable bias; a conventional or pre-registered value is honest, not justified — sensitivity analysis is still owed. "Conservative" is not a property of a method: it is only defined relative to a named alternative (least squares is conservative as a data summary; a strong null-centered prior is conservative predictively). When the human reaches for a default to avoid making a choice, name the choice the default just made for them, and ask: conservative compared to what?
The same logic reaches the computation: an approximate algorithm is an exact algorithm for an
approximate model. A Laplace approximation is a data-dependent normal model of the target;
empirical Bayes replaces a prior with a data-dependent point mass; early stopping lets the
starting point act as a prior. So a variational fit, a modal approximation, or a subsampled run is
never "just the fast version" — it is a different model, and it inherits every honesty gate the
real model would face. Use approximations freely early (fit fast, fail fast; large-scale features
tolerate them), tighten to MCMC late (fine features need it) — but check the approximation the
same way you check any model: simulate from the model you wanted, run the approximate
computation, and confirm it recovers the features you care about (see approximate-algorithms).
Mathematical frame (shared vocabulary)
The object is the posterior p(theta | y) ∝ p(y | theta) p(theta): the likelihood p(y | theta) (your data model) times the prior p(theta), normalized. The generative direction runs the other way — draw theta ~ p(theta), then ỹ ~ p(y | theta) — and is what prior- and posterior-predictive checks exploit: a good model generates data that looks like the data you have. Calibration asks a sharper question than fit: across many simulated truths, are the model's stated uncertainties actually right? Keep this distinction live; fit is necessary, calibration is the bar.
Simulate first, summarize last
The posterior arrives as S simulation draws; keep it that way for as long as possible. Every
derived quantity — a ratio of coefficients, a prediction curve, an expected utility — is
computed per draw, and only when there is nothing left to compute do you collapse to a
mean, median, or interval. The estimate is the posterior distribution; a summary is a view
of it, produced at the end — collapsing early is how uncertainty silently leaks out of an
analysis. The full craft (why the ratio of means is not the mean of ratios, average predictive
comparisons, population-level targets per draw) lives in simulated-data-experiments; the
reporting gate "never a point estimate alone" is this discipline's visible end.
Posture toward tools
The methodology here is tool-agnostic: the same sequence and the same gates apply in any
probabilistic programming language. Reach for the field's reference stack by default — R with
Stan (via cmdstanr), plus the formula interfaces brms and rstanarm on top of
it — because that is the lingua franca of applied Bayesian workflow and what Bayesian Workflow
(Gelman, Vehtari, McElreath et al.) works in throughout; loo for LOO-CV / ELPD lives there too.
PyMC, Turing.jl, and NumPyro are equally first-class when they fit the problem better. Prefer the
highest-level interface that can still express the model (a formula interface like brms/rstanarm
where it fits): less hand-written model code means fewer chances to code a model you didn't mean
(scenario 4). Drop to the lower level only when the model outgrows the interface.
One tooling note, stated once and nowhere else: the super-REPL loop is sharpest when edits hot-reload into a live session with state preserved. Any REPL that reloads serves; Julia's Revise.jl (AST-level hot-reload) is the tightest instance and a fine driver if you already work there — but it is a convenience, not a preference the doctrine holds, and nothing here depends on it. Drive whatever live session your chosen tool gives you.
Nothing in baywright is tied to any private model, market, or project; keep it that way.
Modeling is software development
Everything above is a software-development discipline, and saying so explicitly is the capstone: a
model written in a probabilistic programming language is code — a set of instructions for
generating latent and observed data — so the practices that tame code apply directly. Where the
analogy holds, lean on it: grow the model in small, reversible edits under version control
(revert to the last working version in one command; keep clearly-different models in separate files
so they diff cleanly); prefer modularity (encapsulate shared model code once, so a fix lands in
one place, not five); design top-down from the decision (what the end user needs → data format
→ data model → prior → checks) but build bottom-up from tested pieces; and treat the
checks as the model's test suite — a prior-predictive check, an SBC run, a posterior-predictive
check are controlled experiments on the implementation, the statistical analogue of unit and
integration tests (the other face of SBC-as-software-test in simulation-based-calibration).
Where the analogy breaks, do not force it — this is not waterfall engineering:
- Requirements emerge. You do not know the model you want before you get close; the spec is discovered by iterating, not fixed up front. The workflow is agile/spiral, not a V with a frozen requirements phase — start simple, expose assumptions to data early (fit fast, fail fast), and let checking rewrite the target.
- The tests are graded, not boolean. A check yields statistical evidence (a rank histogram, an ELPD difference with its standard error), not a green/red assert; "pass" is a judgment about strength, and stochastic computation makes naive equality tests flaky by nature.
- "Done" is a verdict, not a build status. No compiler certifies a model correct — statistical adequacy is not scientific adequacy — so completion is the honesty-gate judgment, not an acceptance criterion that closes on its own.
The two test families divide cleanly along the four scenarios: SBC asks whether the inference machinery is coherent with the model as coded (the scenario-4 question), posterior predictive checking asks whether the model can reproduce the data that matter (the scenario-3 question). Keep them distinct; they fail for different reasons and prescribe different fixes.
When the human is ready, route to model-building and begin.