CliffSafe
Inspiration
The One Big Beautiful Bill Act was signed on July 4, 2025. Within days, the numbers started circulating: 863 billion dollars in Medicaid cuts over ten years. 10.3 million people projected to lose coverage by 2034. SNAP slashed by 120 billion dollars. ACA premium subsidies expired. Work requirements tightened.
But buried beneath the headline figures was a quieter, older problem that just got dramatically worse: the benefits cliff.
We kept coming back to a simple, devastating scenario: a gig worker making 28,000 dollars a year gets offered a raise to 32,000 dollars. They take it. And they end up poorer. Not because they made a bad decision, but because the structure of the system punishes earning more at precisely the wrong income levels.
The cliff is not new. But the One Big Beautiful Bill made it steeper, less predictable, and applicable to millions more people. We built CliffSafe as a direct, urgent response.
What We Built
CliffSafe is a benefits cliff calculator, visualizer, and decision engine for low-income workers in the 20k to 60k dollar range. It answers three questions:
- Where is your cliff? Exact income thresholds where SNAP, Medicaid, and housing assistance disappear.
- How likely are you to hit it? Monte Carlo simulation of 10,000 income paths based on your employment volatility.
- What should you do about it? An optimizer that finds pre-tax contribution strategies to protect benefits, plus a Gemini AI advisor that explains everything in plain English using your exact numbers.
The Math
Benefits Cliff Detection
The total compensation function \(C(g)\) is defined as:
$$C(g) = N(g) + B(g)$$
where \(g\) is gross annual income, \(N(g)\) is post-tax take-home pay, and \(B(g)\) is the total annual value of government benefits.
A cliff occurs when earning slightly more reduces total compensation. The severity of the cliff is:
$$\Delta C = C(g^* - \epsilon) - C(g^*)$$
For the Medicaid cliff (138% FPL hard cutoff):
$$B_{\text{medicaid}}(g) = V_{\text{medicaid}} \text{ if } g \leq 1.38 \times \text{FPL}, \quad 0 \text{ if } g > 1.38 \times \text{FPL}$$
where \(V_{\text{medicaid}}\) ranges from 5,400 USD (NC) to 8,000 USD (NY) depending on state.
Tax Model
Post-tax income uses 2025 federal brackets plus state income tax and FICA:
$$N(g) = g - T_{\text{federal}}(g) - \tau_{\text{state}} \cdot g - \tau_{\text{FICA}} \cdot g$$
The effective marginal rate has a tax component and a cliff penalty:
$$\text{EMR}(g) = \frac{dT_{\text{federal}}}{dg} + \tau_{\text{state}} + \tau_{\text{FICA}} + \sum_{i} \frac{B_i^{\text{lost}}(g)}{g}$$
The cliff penalty only applies if \(g\) is above the threshold but below break-even:
$$g_{\text{break-even}} = g^* + \frac{B^{\text{lost}}}{1 - \tau_{\text{effective}}}$$
Monte Carlo Simulation
Income is modeled as a lognormal process:
$$G_{\text{sim}} \sim \text{LogNormal}(\mu, \sigma^2)$$
where \(\mu = \ln(\bar{g}) - \frac{\sigma^2}{2}\) ensures \(\mathbb{E}[G_{\text{sim}}] = \bar{g}\), and sigma is calibrated per employment type:
| Employment Type | Annual Sigma |
|---|---|
| Full-time salaried | 0.03 |
| Part-time | 0.12 |
| Self-employed / gig | 0.25 |
| Seasonal | 0.20 |
Over \(n = 10{,}000\) simulations, cliff probability is:
$$P_{\text{cliff}} = \frac{1}{n} \sum_{k=1}^{n} \mathbf{1}[\text{cliff event}_k]$$
Optimizer
The optimizer finds the pre-tax contribution \(\delta\) that maximizes total compensation:
$$C^*(\delta) = N(g - \delta) + B(g - \delta) + (\delta - \Delta N)$$
where \(\Delta N = N(g) - N(g - \delta)\) is the after-tax cost of contributing. Capped at 15% of gross for affordability.
How We Built It
Backend (FastAPI + NumPy): The cliff engine runs real 2025 FPL math, not hardcoded thresholds. Every calculation is parameterized by state, household size, and employment type. The Monte Carlo runs 10,000 lognormal simulations in under 200ms using vectorized NumPy operations.
Frontend (React + Recharts + Framer Motion): The cliff curve visualization animates in phases: the line draws first, then danger zones fade in, then drop badges fall, then a "you are here" marker slides up. The sequence is designed to build comprehension progressively so the user feels the cliff before reading a single number.
AI Advisor (Gemini 2.5 Flash): The advisor streams a personalized plain-English summary via Server-Sent Events. It receives the user's exact cliff numbers, nearest threshold, Monte Carlo probability, and optimizer recommendation, and is explicitly prompted to never give generic advice.
Infrastructure: The FastAPI backend and React frontend spin up together with a single bash script. The frontend deploys to Vercel. Main is always demo-ready, never broken.
Challenges
The EMR Trap. Naively computing the effective marginal rate produced nonsensical spikes. Someone 999 dollars below a cliff would show an 80%+ marginal rate because of upcoming benefit loss. We implemented break-even logic: the cliff penalty only applies after the threshold is crossed and before the user has fully recovered their lost compensation through higher earnings.
Cliff Detection Precision. The 500-dollar-step scan for cliff detection introduces a rounding artifact where the detected cliff income is the next scan step after the actual threshold. We fixed this by computing exact values at cliff_income - 1 to get the true just-below-threshold benefit bundle, ensuring descriptions always reference the same computed values as the displayed header numbers.
The Optimizer Double-Count Problem. In the cliff protection scenario, the optimizer initially double-counted benefits by adding the at-risk benefit to a current_total that already included all benefits. The fix required separating the local net_income variable from the response's total_compensation field, and computing optimized total as:
$$C_{\text{opt}} = N(g) + B_{\text{total}} + \tau \cdot \delta$$
rather than treating current_total + benefits_retained as additive.
Making it Human. The hardest challenge was not the math. It was writing an AI prompt that produces advice specific enough to be actionable, referencing the user's exact cliff threshold, their exact benefit value, their exact Monte Carlo probability, without ever sounding like it is reading from a spreadsheet. That required multiple iterations of prompt engineering and real user testing.
What We Learned
The benefits cliff is not a bug in the system. It is a structural feature that emerged from programs designed in isolation, each with its own eligibility rules, each cutting off at a different income level. No single program is to blame. The harm emerges from their combination.
What CliffSafe taught us is that information itself has economic value for low-income workers. Knowing you are 1,200 dollars below the Medicaid cliff, and that a 2,000 dollar IRA contribution would keep you safely below it while saving you 400 dollars in taxes, is worth thousands of dollars a year. That knowledge currently lives in the heads of social workers and tax professionals. It should not.
Built at HackDuke 2026 in response to the One Big Beautiful Bill Act, signed July 4, 2025.
Built With
- axios
- bash
- fastapi
- framer-motion
- google-gemini-api-(gemini-2.5-flash)
- javascript
- numpy
- pydantic
- python
- react
- recharts
- server-sent-events-(sse)
- tailwind-css
Log in or sign up for Devpost to join the conversation.