skills/analysis/policyengine-district-analysis-skill/SKILL.md
Analyze policy impacts for congressional districts and representatives' constituents. Use when the user mentions a specific district (NY-17, CA-52), a representative's name, or asks about geographic policy impacts at district level. Provides HuggingFace district datasets.
npx skillsauth add policyengine/policyengine-claude policyengine-district-analysisInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
MicroSeries handles all weighting automatically. Never access .weights or do manual math.
# ✅ CORRECT
change = reformed.calc('household_net_income', period=2026, map_to='person') - \
baseline.calc('household_net_income', period=2026, map_to='person')
loser_share = (change < 0).mean() # Weighted automatically!
# ❌ WRONG
loser_share = change.weights[change.values < 0].sum() / change.weights.sum()
from policyengine_us import Microsimulation
from policyengine_core.reforms import Reform
# 1. Load district data
# IMPORTANT: Single-digit districts need zero-padding (CT-01, not CT-1)
district = "NY-17" # Mike Lawler's district
baseline = Microsimulation(dataset=f'hf://policyengine/policyengine-us-data/districts/{district}.h5')
# 2. Define reform (find params with: grep -r "salt" policyengine_us/parameters/gov/irs/)
reform = Reform.from_dict({
'gov.irs.deductions.itemized.salt_and_real_estate.cap.SINGLE': {'2026-01-01.2100-12-31': 10000},
'gov.irs.deductions.itemized.salt_and_real_estate.cap.JOINT': {'2026-01-01.2100-12-31': 10000},
'gov.irs.deductions.itemized.salt_and_real_estate.cap.SEPARATE': {'2026-01-01.2100-12-31': 5000},
'gov.irs.deductions.itemized.salt_and_real_estate.cap.HEAD_OF_HOUSEHOLD': {'2026-01-01.2100-12-31': 10000},
'gov.irs.deductions.itemized.salt_and_real_estate.cap.SURVIVING_SPOUSE': {'2026-01-01.2100-12-31': 10000},
}, 'policyengine_us')
reformed = Microsimulation(dataset=f'hf://policyengine/policyengine-us-data/districts/{district}.h5', reform=reform)
# 3. Calculate impact - MicroSeries handles weights automatically!
baseline_income = baseline.calc('household_net_income', period=2026, map_to='person')
reformed_income = reformed.calc('household_net_income', period=2026, map_to='person')
change = reformed_income - baseline_income
# 4. Results - no manual weight math needed
print(f"Share losing: {(change < 0).mean():.1%}")
print(f"Average change: ${change.mean():,.0f}")
print(f"Total impact: ${change.sum()/1e6:,.1f}M")
national_baseline = Microsimulation()
national_reformed = Microsimulation(reform=reform)
national_change = national_reformed.calc('household_net_income', period=2026, map_to='person') - \
national_baseline.calc('household_net_income', period=2026, map_to='person')
print(f"District: {(change < 0).mean():.1%} lose")
print(f"National: {(national_change < 0).mean():.1%} lose")
development
ALWAYS LOAD THIS SKILL for PolicyEngine PR reviews, including when the user invokes $review-program or Codex /review on a PolicyEngine PR. Performs read-only code validation, source-reference checks, regulatory review, optional PDF audit, summary reporting, and optional GitHub comment posting.
development
Use when the user invokes $fix-pr or asks Codex to apply fixes to a PolicyEngine PR based on $review-program findings, GitHub review comments, CI failures, or local review reports.
development
Use when the user invokes $encode-policy-v2 or asks Codex to implement a new PolicyEngine-US state benefit program from official rules. Covers research, source collection, requirement extraction, scoped implementation, tests, validation, and draft PR preparation.
development
Deploying PolicyEngine frontend apps to Vercel - naming, scope, team settings