Inspiration
Lending laws are written to protect people, but they can backfire. A strict rate cap can shut off payday loans and push the same people onto $35 bank overdrafts and late rent. Regulators debate these trade-offs with spreadsheets and averages, and they only see the real effect years later, on real families.
We wanted a place to test a law on people before
What it does
PolicyTown simulates a town of AI residents through 26 weeks of paychecks, bills and emergencies, under up to three lending laws. Same people, same bad luck: only the law changes.
AI residents: when someone runs short, Claude decides what that person does and says why. Realistic lenders: they lend only when they expect a profit, and switch to installment loans under moderate caps. Answers for decision makers: who's better off (person by person), confidence labels on every gap, and long-term debt. Situations: plant closures, Fed hikes, recessions. Laws can be written in plain English. Experiment mode sweeps one variable with confidence bands. History compares any two runs. Every dollar goes through a double-entry ledger, checked weekly.
How we built it
Convex runs a weekly clock: open the week, collect decisions, apply them in one batch. Claude Haiku makes one call per real decision, validated, with a safe fallback. A shared TypeScript engine runs on the server and in browser Web Workers, with seeded randomness so every law faces the same luck. Rule-based residents match CFPB and Pew data: 79% of loans renewed (real world: 80%), 22% of loan sequences ending in default (20%). The frontend uses React, Tailwind, shadcn/ui, Recharts and canvas. 127 tests back it all.
Challenges we ran into
Fairness: splitting randomness into streams so every law sees the same shocks. Lender realism: our first model made zero loans under a 107% cap. Real lenders switch products, so we modeled that. Trust: single AI runs can mislead, so 20 background re-runs label each gap clear, likely or noise. Convex write limits at 250 residents.
Accomplishments that we're proud of
It surfaces the real debate on its own: strict caps shift costs to overdrafts, and moderate caps cut harm most. Person-level results like "helped 31, hurt 9 single parents". Calibrated to public data and balanced to the cent.
What we learned
The unintended consequences show up in the trade-offs, not the averages. AI agents work best tightly constrained. Calibration and auditability are what make results credible.
What's next for PolicyTown
A shareable one-page decision brief, lenders leaving unprofitable markets, real city data, and more policy areas: overdraft rules, earned-wage access and BNPL.
Built With
- anthropic-api
- claude
- convex
- html5
- lucide
- radix-ui
- react
- recharts
- shadcn-ui
- tailwindcss
- typescript
- vercel
- vite
- vitest
- web-workers
Log in or sign up for Devpost to join the conversation.