StatsPAI: Instructions file for Claude Code

CLAUDE.md

StatsPAI CLAUDE.md is an instructions file for Claude Code from brycewang-stanford/StatsPAI. It costs 20,503 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.

This is brycewang-stanford/StatsPAI's own configuration. It tells Claude Code how to work on StatsPAI itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything StatsPAI configures →

Reuse

Borrowing it

Nothing to install: this file belongs to brycewang-stanford/StatsPAI. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/brycewang-stanford/StatsPAI/main/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/github.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/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for StatsPAI CLAUDE.md

Your own site · 80×15
<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="Reviewed on agentmods" width="80" height="20"></a>
Per session 20,503 This file is loaded in full into every session.
When invoked 20,503 The same file — it is already loaded in full.
Security scan C 1 finding. A grade says what 26 rules found in the file — not that it is safe.
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.20503 $0.20503
Opus 5.5 $0.08201 $0.08201
Sonnet 5.5 $0.04101 $0.04101
Haiku 4.5 $0.02050 $0.02050

Measured 2d ago against content hash 2feb11e710b2, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 2d ago.

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/*`。**再把 sdist 的文件清单对照 `git ls-files`**:`MANIFEST.in` 的 `recursive-include tests *` 会把工作树里被 gitignore 的本地产物一起打包——1.32.0 发版时先后抓到复现检查的临时目录、Track C 的 38 MB 共享输入、以及可由包内
CLAUDE.md · 444 lines

How it starts

The opening of the file, as written. The whole thing — 444 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——已有参考实现的方法,先对齐再扩展。
版本 以 pyproject.toml / sp.__version__ 为准(不在此处写死,2026-09 审查发现此行停在 1.24.0)
Python 3.10 – 3.13(2026-10-04 起不再支持 3.9;Windows 暂不在测试矩阵里,见 docs/dev/2026-10-04-windows-test-gaps.md)
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/          # 主包:90 子模块 / 1,566 个注册符号,其中约 400 个是结果类与异常类(实时数 `python scripts/registry_stats.py`;此行 2026-10-12 核对)
│   ├── __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 mcmc 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
  • 因果发现 / ML:causal_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 doe
  • 分解 / 诊断 / 回归: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 · 444 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. 2d ago Changed · +1 lines · +48 tokens per session 2feb11e710b2
  2. 3d ago Changed · +77 tokens per session 857cda263f54
  3. 4d ago Changed · +43 tokens per session d5f63b9d52fb
  4. 5d ago Changed · +1 lines · +393 tokens per session b33b7feb94af
  5. 6d ago Changed · +7 lines · +884 tokens per session eaaa2f0b76f7
  6. 7d ago Changed · -41 lines · -28,783 tokens per session 24fea647752d
  7. 8d ago Changed · +83 tokens per session 9e9da613e363
  8. 9d ago Changed 71e47c2293d0
  9. 10d ago Changed · +12 lines · +2,185 tokens per session 923412ac08b1
  10. 11d ago First seen · 464 lines · 45,573 tokens per session scan C aa7658365662

Subscribe to this mod's changes

StatsPAI CLAUDE.md is an instructions file published in the GitHub repository brycewang-stanford/StatsPAI (345 stars, last pushed yesterday), licensed MIT. It adds 20,503 tokens to every session, about $0.0820 per session on Opus 5.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.

Related

Other instructions, from other repositories

vscode buildNext.instructions.md

Working notes and architecture documentation for the new esbuild-based build system in build/next. Use when making changes to the new build pipeline (transpile/bundle commands, NLS plugin, source-map handling, resource copying, or self-hosting watch tasks).

microsoft/vscode · 9,715 tokens

next.js AGENTS.md

AGENTS.md instructions for vercel/next.js, covering next.js development guide, codebase structure, monorepo overview, core package: packages/next and other important packages.

vercel/next.js · 7,581 tokens

vscode oss-third-party-notices.instructions.md

Instructions for microsoft/vscode, covering vs code oss third-party-notices pipeline, architecture, pipeline flow in ci, cache eligibility and rollout and applying the notice (cutover).

microsoft/vscode · 5,262 tokens

langchain AGENTS.md

AGENTS.md instructions for langchain-ai/langchain, covering global development guidelines for the langchain monorepo, corridor security analysis, project architecture and context, monorepo structure and development tools & commands.

langchain-ai/langchain · 4,680 tokens

deepseek-harness AGENTS.md

AGENTS.md instructions for deepseek-ai/deepseek-harness, covering agents.md, pre-stable apis and released session data, repository layout, commands and host sandbox failures.

deepseek-ai/deepseek-harness · 4,261 tokens

vscode copilot-instructions.md

Copilot instructions for microsoft/vscode, covering vs code copilot instructions, project overview, root folders, core architecture (src/ folder) and built-in extensions (extensions/ folder).

microsoft/vscode · 2,731 tokens