Skip to content

Add AGENTS.md: PyMC 6.0 and ArviZ 1.0 conventions for AI coding agents#8313

Open
twiecki wants to merge 1 commit into
pymc-devs:mainfrom
twiecki:add-agents-md
Open

Add AGENTS.md: PyMC 6.0 and ArviZ 1.0 conventions for AI coding agents#8313
twiecki wants to merge 1 commit into
pymc-devs:mainfrom
twiecki:add-agents-md

Conversation

@twiecki

@twiecki twiecki commented May 25, 2026

Copy link
Copy Markdown
Member

What this adds

A root-level AGENTS.md file — a machine-readable guide for AI coding agents (Claude Code, Codex, Cursor, Copilot, etc.) working in this repository.

The file encodes PyMC 6.0 and ArviZ 1.0 best practices that agents won't apply unprompted, including the breaking API changes that trip up most AI-generated PyMC code today.

Why AGENTS.md

AGENTS.md is an open standard adopted by 60k+ open-source projects for providing AI agents with project-specific operational guidance. It is read automatically by Claude Code, OpenAI Codex, GitHub Copilot, Cursor, Devin, and others.

Adding it here means any contributor using an AI coding agent gets PyMC 6-correct suggestions out of the box — without having to install a separate skill or configure anything.

Key pitfalls it prevents

Bug Fix encoded
idata.extend(other) — breaks in ArviZ 1.0 idata.update(other) or extend_inferencedata=True
az.plot_trace(idata) — renamed in ArviZ 1.0 az.plot_trace_dist() / az.plot_rank_dist()
nutpie silently drops log_likelihood → always call pm.compute_log_likelihood(idata) after sampling
sample_vars/freeze_vars API not used → new sample_posterior_predictive volatility API
samples=N in sample_prior_predictive draws=N (samples removed in v6)
R-hat threshold of 1.05 / 1.1 → threshold is 1.01
random_seed=42 everywhere → descriptive seeds: sum(map(ord, "analysis-name"))
np.median on posterior predictive probs np.mean (median violates probability coherence)

What's covered

  • PyMC 6 / ArviZ 1.0 API changes — DataTree, removed methods, new defaults
  • Sampler guidance — nutpie, numba backend, when NOT to use nutpie
  • Model template — coords/dims, Data containers, save-first workflow
  • Diagnosticsarviz_stats.diagnose(), R-hat < 1.01, ESS thresholds
  • Hierarchical models — non-centered vs centered parameterization
  • GPs — HSGP preference
  • Causal inferencepm.do / pm.observe
  • pymc-extras — marginalize, Laplace, R2D2
  • Testing conventions — small draws, az.assert_close
  • Documentation conventions — marimo notebooks, named dims in all examples

Prior art

Synthesizes best practices from:

🤖 Generated with Claude Code

@read-the-docs-community

Copy link
Copy Markdown

Documentation build overview

📚 pymc | 🛠️ Build #32837440 | 📁 Comparing 4ada848 against latest (f09f6b6)

  🔍 Preview build  

4 files changed
± glossary.html
± _modules/pytensor/tensor/basic.html
± _modules/pytensor/tensor/extra_ops.html
± _modules/pytensor/tensor/subtensor.html

Comment thread AGENTS.md

### Credible intervals

ArviZ 1.0 changed the default from **0.94 HDI** to **0.89 equal-tailed interval (ETI)**. When writing docs or examples, use `hdi_prob=0.94` explicitly if HDI is intended, or accept the new 0.89 ETI default.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not called hdi_prob=0.94, it is ci_kind="hdi" and ci_prob=0.94, this works both at the rcparams global level or per function call.

Comment thread AGENTS.md
# ESS_bulk > 100 * n_chains and ESS_tail > 100 * n_chains

# 3. Posterior predictive check
az.plot_ppc(idata, kind="cumulative")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
az.plot_ppc(idata, kind="cumulative")
az.plot_ppc_dist(idata, kind="ecdf")

Comment thread AGENTS.md
# R-hat < 1.01 for all parameters (not 1.05, not 1.1 — those thresholds are outdated)
# ESS_bulk > 100 * n_chains and ESS_tail > 100 * n_chains

# 3. Posterior predictive check

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to specify the following:

  • plot_ppc_pava (binary response)
  • plot_ppc_rootogram (count response)
  • plot_ppc_censored (survival)

we could be even more granular...

@Armavica

Copy link
Copy Markdown
Member

This seems fairly human-readable, and also useful for humans. Wouldn't CONTRIBUTING.md (for example, but possibly also a "quickstart" or "tips and tricks" or "migration guide" etc page in the documentation) be a better place for it?

Comment thread AGENTS.md
alpha = pm.Normal("alpha", mu_alpha, sigma_alpha, dims="group")
```

### Gaussian Processes — prefer HSGP

@bwengals bwengals Jul 9, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to say the user should always set m and c/L using this function, Since it doesn't make sense to have a default. That would save people a lot of time and bad fits.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants