StatsPAI CLAUDE.md

StatsPAI CLAUDE.md is an instructions file for Claude Code from brycewang-stanford/StatsPAI. It costs 7,986 tokens per session, scanned C, original, MIT.

A set of instructions for AI coding agents working on StatsPAI, a Python toolkit for causal analysis and empirical research.

In plain words
What is it for?
Use it when changing or reviewing the StatsPAI repository so the work follows its documented design and code rules.
Why use it?
It gives agents the project’s purpose, structure, supported methods, coding conventions, and version details.

Instructions file for Claude Code

Written for Claude Code: PreToolUse hook event. Also seen: reads .claude/ paths; mentions CLAUDE.md; mentions Claude Code.

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add instructions/brycewang-stanford/statspai/claude-md
Clone the repo
git clone --depth 1 https://github.com/brycewang-stanford/StatsPAI

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for StatsPAI CLAUDE.md

README.md
[![agentmods](https://agentmods.dev/badge/instructions/brycewang-stanford/statspai/claude-md.svg)](https://agentmods.dev/instructions/brycewang-stanford/statspai/claude-md)
Your own site
<a href="https://agentmods.dev/instructions/brycewang-stanford/statspai/claude-md"><img src="https://agentmods.dev/badge/instructions/brycewang-stanford/statspai/claude-md.svg" alt="Measured on agentmods" height="20"></a>
Per session 7,986 This file is loaded in full into every session.
When invoked 7,986 The same file — it is already loaded in full.
Security scan C 1 finding. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.07986 $0.07986
Opus 5 $0.03993 $0.03993
Sonnet 5 $0.01597 $0.01597
Haiku 4.5 $0.00799 $0.00799

Measured today against content hash 4dbec81e2b34, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade C, and why

StatsPAI CLAUDE.md scanned grade C with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured today.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

4. `rm -rf dist/ && python -m build && twine check dist/*`。
CLAUDE.md · 336 lines

How it starts

The opening of the file, as written. The whole thing — 336 lines — stays where its author put it; the contents beside it link to each section on GitHub.

CLAUDE.md — StatsPAI

Claude Code / AI agent 在本仓库工作的指引。动手前请通读。


1. 项目定位

StatsPAI 的目标是面向 Agent 设计,适合人类以及 agent 进行调用,并致力于超越 Stata、R、以及老的 Python 生态,成为全世界最好的因果推断与实证分析工具

做法有三条:

  1. 一次 import statspai as sp 覆盖 DiD / IV / RD / 合成控制 / DML / Meta-Learner / 贝叶斯因果 / 因果发现 / 结构计量 / 面板 / 空间 / 时序。
  2. Agent 原生——所有函数返回结构化结果、带自描述 schema,人和 Agent 用同一入口。v1.6 起进入 P1 阶段sp.causal_question(estimand-first DSL)、sp.llm_dag_propose / validate / constrained(LLM-DAG 闭环)、sp.paper()(自动论文)、sp.causal_text(文本因果 MVP)。
  3. 数值对齐 Stata / R——已有参考实现的方法,先对齐再扩展。
版本 1.21.0(见 pyproject.toml
Python 3.9 – 3.13
License MIT
作者 Biaoyue (Bryce) Wang · [email protected] · CoPaper.AI / Stanford REAP
PyPI https://pypi.org/project/StatsPAI/
导入别名 import statspai as sp —— 所有示例、docstring、测试一律 sp.xxx

2. 仓库结构

StatsPAI/
├── src/statspai/          # 主包:87 子模块 / 1,167 函数(实时数 `python scripts/registry_stats.py`)
│   ├── __init__.py          # 对外 API 入口
│   ├── registry.py          # 函数注册表(sp.help / sp.list_functions 依赖)
│   ├── help.py              # sp.help / sp.describe_function / sp.function_schema
│   ├── cli.py
│   └── <领域模块>/          # did iv rd synth dml metalearners …
├── rust/statspai_hdfe/    # HDFE Rust 后端(PyO3)
├── tests/                 # pytest 套件 + reference_parity/ + external_parity/
├── docs/ · mkdocs.yml     # MkDocs 文档
├── paper.md · paper.bib   # JOSS
├── benchmarks/            # 性能基准
└── pyproject.toml

领域分组(对外 API 按下列七类组织):

  • 因果 / 处理效应causal did rd iv synth dml metalearners tmle bcf bayes causal_impact policy_learning ope dtr multi_treatment qte principal_strat proximal mediation mendelian assimilation bridge
  • 面板 / 结构panel fixest structural frontier multilevel gformula gmm msm longitudinal
  • 空间 / 时序spatial timeseries bartik
  • 因果发现 / MLcausal_discovery dag neural_causal deepiv conformal_causal matrix_completion bunching causal_llm causal_rl causal_text fairness
  • 设计 / 抽样 / 推断matching power mht survey bounds dose_response interference selection censoring imputation transport target_trial epi survival surrogate
  • 分解 / 诊断 / 回归decomposition regression nonparametric diagnostics robustness postestimation inference smart
  • 基础设施core utils compat fast datasets output plots workflow agent experimental question

Read the full file on GitHub · 336 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. today Changed · +23 lines · +1,515 tokens per session 4dbec81e2b34
  2. 6d ago First seen · 313 lines · 6,471 tokens per session scan C fe454d9983bb

Subscribe to this mod's changes

StatsPAI CLAUDE.md is an instructions file published in the GitHub repository brycewang-stanford/StatsPAI (309 stars, last pushed yesterday), licensed MIT. It adds 7,986 tokens to every session, about $0.0399 per session on Opus 5. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.