subscription-billing
Skill2 starsChanged 6 months agoMITView on GitHub
Use when turning payment state into product behavior — model plans and subscription status in the DB, enforce plan limits and feature entitlements server-side, and gate features with a single typed check.
1 other project uses a version of this.
Adopted by
Most recently taken up by
- YepAPI/skillstheir own version, first seen Apr 12, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- YepAPI/skills★ 8same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository14 other files it gives its agents.
- api-routes-and-validationSkill
- authenticationSkill
- authorization-rbacSkill
- background-jobsSkill
- data-access-layerSkill
- database-schemaSkill
- deployment-and-ciSkill
- environment-and-configSkill
- file-uploads-and-storageSkill
- multi-tenancySkill
- observability-and-errorsSkill
- payments-stripeSkill
- project-scaffoldingSkill
- transactional-emailSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 55
Call assertCanCreateProject inside the create action — the UI may also read the limit to show a paywall (pairs with billing-and-pricing UI).
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Subscription & Billing Logic
Overview
Once payments-stripe syncs subscription state into your database, you need to turn that state into behavior: which features are unlocked, which limits apply, what happens when a plan lapses. Model plans as data, store the org's current plan + status, and expose one entitlement(org) check the whole app uses. Enforce limits on the server, where they can't be bypassed.
When to use
- Different plans unlock different features or limits (seats, projects, API calls).
- You need paywalls, usage caps, or "upgrade to continue" gates.
- Handling trials, past-due, and cancelled states gracefully.
Model plans as data
// src/server/billing/plans.ts
export type PlanId = "free" | "pro" | "scale";
export const PLANS = {
free: { name: "Free", priceId: null, seats: 1, projects: 3, apiCallsPerMonth: 1_000 },
pro: { name: "Pro", priceId: "price_pro", seats: 10, projects: 50, apiCallsPerMonth: 100_000 },
scale: { name: "Scale", priceId: "price_scale", seats: 50, projects: Infinity, apiCallsPerMonth: 1_000_000 },
} as const satisfies Record<PlanId, { name: string; priceId: string | null; seats: number; projects: number; apiCallsPerMonth: number }>;Store on the org (synced from Stripe): planId, subscriptionStatus (active | trialing | past_due | canceled), currentPeriodEnd.
Enforce entitlements server-side
import { PLANS } from "@/server/billing/plans";
export function planFor(org: { planId: PlanId; subscriptionStatus: string }) {
// lapsed subscriptions fall back to free limits
const active = ["active", "trialing"].includes(org.subscriptionStatus);
return active ? PLANS[org.planId] : PLANS.free;
}
export async function assertCanCreateProject(org) {
const limit = planFor(org).projects;
const count = await countProjects(org.id);
if (count >= limit) {
const e = new Error("Project limit reached for your plan");
(e as any).status = 402; // Payment Required → show upgrade prompt
throw e;
}
}Call assertCanCreateProject inside the create action — the UI may also read the limit to show a paywall (pairs with billing-and-pricing UI).
Pitfalls
- Enforcing limits only in the UI — disable the button and check on the server; the endpoint is the real gate.
- Ignoring
past_due/canceled— decide the grace policy explicitly; default to downgrading to free limits. - Hard-coding plan rules across the app — centralize in
PLANS; one edit changes every gate. - Counting usage without
org_idscope — always count within the tenant. - No trial handling — treat
trialingas active untilcurrentPeriodEnd.
Hand-off
Typed entitlements enforced server-side. The pricing/paywall UI (billing-and-pricing in saas-ui-skills) reads the same PLANS; payments-stripe keeps the status fresh.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

