brycewang-stanford/Auto-Empirical-Research-Skills / skills/23-Learning-Bayesian-Statistics-baygent-skills/bayesian-workflow
bayesian-workflow
VerifiedOpinionated Bayesian modeling workflow with PyMC and ArviZ. Contains critical guardrails (nutpie sampler, prior/posterior predictive checks, LOO-PIT calibration, prior sensitivity checks, 94% HDI, non-centered parameterizations, reproducible seeds) that agents won't apply unprompted — always consult before writing Bayesian model code. Trigger on: building probabilistic/Bayesian models, prior elicitation, MCMC inference, convergence diagnostics (divergences, R-hat, ESS), model comparison (LOO-CV, ELPD, stacking weights), hierarchical/multilevel models, count regressions, logistic regression with uncertainty, prior sensitivity analysis, reporting Bayesian results, or mentions of PyMC, ArviZ, InferenceData, credible intervals, posterior distributions, shrinkage, uncertainty quantification. Also trigger for model comparison, diagnosing sampling problems, choosing priors, or presenting stats to non-technical audiences.
| File | Kind | Size |
|---|---|---|
| README.md | markdown | 3.9 KB |
| SKILL.md | skill md | 13.9 KB |
| main.py | script | 95 B |
| pyproject.toml | manifest | 181 B |
| references/diagnostics.md | markdown | 5.6 KB |
| references/hierarchical.md | markdown | 7.8 KB |
| references/model-comparison.md | markdown | 3.9 KB |
| references/model-criticism.md | markdown | 11.4 KB |
| references/priors.md | markdown | 7.8 KB |
| references/reporting.md | markdown | 8.8 KB |
| references/sensitivity.md | markdown | 4.5 KB |
| scripts/calibration_check.py | script | 9.8 KB |
| scripts/diagnose_model.py | script | 6.1 KB |
README.md
View on GitHub# bayesian-workflow
An opinionated [Agent Skill](https://agentskills.io) for building, diagnosing, and reporting on Bayesian statistical models using PyMC and ArviZ.
Compatible with Claude Code, Kimi Code, Cursor, Gemini CLI, and any agent that supports the [Agent Skills spec](https://agentskills.io/specification).
Full breakdown [here](https://learnbayesstats.com/blog-posts/bayesian-workflow-agent-skill-pymc-arviz).
## What it does
Guides your coding agent through the full Bayesian workflow:
1. **Formulate** the generative story
2. **Specify priors** with documented justifications
3. **Implement in PyMC** using modern best practices (coords, dims, nutpie)
4. **Prior predictive checks** before fitting
5. **Inference** via MCMC (nutpie sampler by default)
6. **Convergence diagnostics** (R-hat, ESS, trace plots, energy plots)
7. **Model criticism** (posterior predictive checks, LOO-PIT calibration)
8. **Prior/likelihood sensitivity** (power-scaling via PSIS)
9. **Model comparison** (LOO-CV, ELPD, stacking weights)
10. **Reporting** with companion analysis notes and audience-adapted reports
The skill enforces guardrails that agents won't apply on their own: 94% HDI, mandatory calibration checks, prior/likelihood sensitivity checks, non-centered parameterizations for hierarchical models, reproducible descriptive seeds, immediate save-to-disk after sampling, and xarray-first data manipulation.
## Install
### Claude Code
Clone and copy the skill into your personal skills directory:
```bash
git clone https://github.com/Learning-Bayesian-Statistics/baygent-skills.git /tmp/baygent-skills
mkdir -p ~/.claude/skills
cp -r /tmp/baygent-skills/bayesian-workflow ~/.claude/skills/
```
For project-level installation (available only in that project), copy into `.claude/skills/` at the project root instead.
### Other compatible agents (Kimi Code, Cursor, etc.)
Clone the repo and copy the skill folder into your agent's skills directory:
```bash
git clone https://github.com/Learning-Bayesian-Statistics/baygent-skills.git /tmp/baygent-skills
cp -r /tmp/baygent-skills/bayesian-workflow/ ~/.config/agents/skills/bayesian-workflow/
```
### PyMC installation
The skill recommends conda-forge / mamba-forge for PyMC and its dependencies:
```bash
mamba install -c conda-forge pymc nutpie arviz arviz-stats preliz
```
## Example prompts
Once installed, just ask your agent naturally:
- *"I have customer churn data with binary outcome plus age, tenure, and monthly spend. Build me a Bayesian logistic regression with uncertainty estimates."*
- *"My model has 47 divergences and R-hat of 1.03. What do I do?"*
- *"I have test scores for 200 students across 15 schools. Some schools only have 5 students. Help me build a hierarchical model."*
- *"Compare these two models and tell me which one to use. I have the InferenceData objects."*
- *"I need to present Bayesian results to my boss who has no stats background."*
## What's included
```
bayesian-workflow/
├── SKILL.md # Main workflow instructions
├── main.py # Entrypoint for programmatic use
├── pyproject.toml # Package metadata
├── references/
│ ├── priors.md # Prior selection guide
│ ├── diagnostics.md # Convergence diagnostics
│ ├── model-criticism.md # PPC, calibration, LOO-PIT
│ ├── model-comparison.md # LOO-CV, ELPD, stacking weights
│ ├── hierarchical.md # Partial pooling, non-centered parameterization
│ ├── sensitivity.md # Prior/likelihood sensitivity analysis (power-scaling)
│ └── reporting.md # Report templates, audience adaptation
└── scripts/
├── diagnose_model.py # Post-sampling diagnostics report
└── calibration_check.py # Calibration plots from InferenceData
```
## License
MIT - see [LICENSE](../LICENSE).
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis. | Stars: 472k | Updated | Claude CodeCodex | Unverified | Install |
| diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness. | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependencies | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |
| executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is available | Stars: 322k | Updated | Claude CodeCodex | Verified | Install |