跳至正文
OpenAgentSkill
浏览已开放 · 目录记录日期 2026-11-21 · 自动更新和账户服务暂时关闭。
开发与测试

policyengine-standards

PolicyEngine coding standards, environment setup, formatters, changelog, and CI requirements across every repo — what makes a PR pass and merge cleanly. Covers uv + .venv, ruff, bun, towncrier changelog fragments, the "wait for CI" PR pattern, and the repo-rename checklist. Triggers: "CI failing", "linting", "formatting", "before committing", "PR standards", "code style", "ruff", "prettier", "changelog", "towncrier", "create a PR", "wait for CI", "rename a repo", "set up the venv", "which Python version".

PolicyEngine · 已有静态检查记录

安装与使用

运行命令前先阅读来源与依赖说明。复制命令不会自动安装或执行。

npx skills add PolicyEngine/policyengine-claude --skill policyengine-standards

技能说明


name: policyengine-standards description: | PolicyEngine coding standards, environment setup, formatters, changelog, and CI requirements across every repo — what makes a PR pass and merge cleanly. Covers uv + .venv, ruff, bun, towncrier changelog fragments, the "wait for CI" PR pattern, and the repo-rename checklist. Triggers: "CI failing", "linting", "formatting", "before committing", "PR standards", "code style", "ruff", "prettier", "changelog", "towncrier", "create a PR", "wait for CI", "rename a repo", "set up the venv", "which Python version". metadata: category: process

PolicyEngine development standards

Load this before committing to, reviewing, or setting up any PolicyEngine repository. It encodes the org conventions that CI enforces — the things a frontier model would otherwise guess wrong. For prose style (blog posts, PR bodies, docs) see the policyengine-writing skill.

Environment: uv + a local .venv

All PolicyEngine Python work uses uv with a .venv at the repository root. Never use bare pip, and never run bare python/pytest.

uv venv                       # creates ./.venv (uv picks the interpreter from pyproject.toml)
uv pip install -e ".[dev]"    # editable install with dev extras
uv run pytest                 # run anything through uv so it uses ./.venv
  • Python version is per-repo — check pyproject.toml (requires-python). The org spans the 3.13/3.14 era; there is no single global version. Do not downgrade a repo to satisfy a stale assumption, and do not hardcode a version across repos.
  • uv run <cmd> guarantees the command runs in the repo's .venv with its locked deps. Bare python script.py / pytest is the most common cause of "works locally, fails in CI".
  • Verifying "latest": if asked for the latest version of a package, read PyPI (https://pypi.org/pypi/<pkg>/json → info.version) immediately before pinning. Never infer "latest" from a lockfile, a local install, or search snippets.

Documentation builds

Python docs use Jupyter Book 2.0 (MyST-NB) — build with myst build docs, never jb build (that is Jupyter Book 1.x). Use MyST markdown syntax.

Before committing — checklist

  1. Write the test first (TDD, below).
  2. Format: make format (or uv run ruff format . for Python, bun run lint -- --fix && bunx prettier --write . for JS).
  3. Run tests: make test (or uv run pytest).
  4. Add a changelog fragment (towncrier, below).
  5. Reference the issue in the PR: "Fixes #123".

Creating pull requests

The CI waiting problem

Common failure pattern:

User: "Create a PR and mark it ready when CI passes"
Claude: "I've created the PR as draft. CI will take a while, I'll check back later..."
[Chat ends - Claude never checks back]
Result: PR stays in draft, user has to manually check CI and mark ready

Solution: use the /create-pr command

When creating PRs, use the /create-pr command. It creates the PR as draft, actually waits for CI (polls every 15 seconds), marks it ready when CI passes, and reports failures with details. It works because the command carries explicit polling logic that Claude executes, so it waits instead of giving up.

If /create-pr is not available

Implement the polling pattern directly:

# 1. Create PR as draft. Create the branch ON the PolicyEngine repo, not a fork.
gh pr create --repo PolicyEngine/policyengine-us --draft --title "Title" --body "Body"
PR_NUMBER=$(gh pr view --json number --jq '.number')

# 2. Wait for CI (ACTUALLY WAIT - don't give up!)
POLL_INTERVAL=15
ELAPSED=0

while true; do  # No timeout - wait as long as needed
  CHECKS=$(gh pr checks $PR_NUMBER --json status,conclusion)
  TOTAL=$(echo "$CHECKS" | jq '. | length')
  COMPLETED=$(echo "$CHECKS" | jq '[.[] | select(.status == "COMPLETED")] | length')

  echo "[$ELAPSED s] CI: $COMPLETED/$TOTAL completed"

  if [ "$COMPLETED" -eq "$TOTAL" ] && [ "$TOTAL" -gt 0 ]; then
    FAILED=$(echo "$CHECKS" | jq '[.[] | select(.conclusion == "FAILURE")] | length')
    if [ "$FAILED" -eq 0 ]; then
      echo "All CI passed. Marking ready..."
      gh pr ready $PR_NUMBER
      break
    else
      echo "CI failed. PR remains draft."
      gh pr checks $PR_NUMBER
      break
    fi
  fi

  sleep $POLL_INTERVAL
  ELAPSED=$((ELAPSED + POLL_INTERVAL))
done

Never say "I'll check back later" — the chat session ends. Default to draft PRs; mark ready only when the user asks or CI is already verified green. Merge only after every check passes and the PR is MERGEABLE.

Test-driven development

PolicyEngine follows TDD: write the test (RED), implement (GREEN), refactor. In multi-agent encoding workflows, test authoring and rule implementation proceed independently from the same regulations so the test is not shaped to the implementation.

Country models test with YAML integration cases, not hand-built Python situations. A case declares inputs and expected outputs against named variables; the runner builds the simulation:

# policyengine_us/tests/.../ctc.yaml
- name: CTC for a married couple with two children
  period: 2026
  input:
    people:
      parent1: {age: 40, employment_income: 75_000}
      parent2: {age: 40, employment_income: 50_000}
      child1: {age: 5, is_tax_unit_dependent: true}
      child2: {age: 8, is_tax_unit_dependent: true}
    tax_units:
      tax_unit:
        members: [parent1, parent2, child1, child2]
        filing_status: JOINT
  output:
    ctc: 4_400   # $2,200 per child under post-OBBBA law in 2026

Run country-model YAML tests through the core test runner (this is what make test wraps):

uv run policyengine-core test policyengine_us/tests/policy/ -c policyengine_us

For non-model Python packages, write pytest tests under tests/ mirroring the source layout; run with uv run pytest tests/ -v. Test behavior, not implementation; give tests clear names and docstrings citin

阅读完整来源 ↗