subscription-billing
Skill1 starsChanged 18 days agoMITView on GitHub
Model subscription state, renewal charges, proration, and dunning without treating a renewal as a new one-time checkout. Use when adding or changing recurring billing, plan changes, cancellation, or failed renewal recovery.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- peterbamuhigire/chwezi-dev-enginetheir own version, first seen Nov 15, 2026
- YepAPI/skillstheir own version, first seen Apr 12, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- peterbamuhigire/chwezi-dev-engine★ 31same name
- 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 repository28 other files it gives its agents.
- b2b-pricingSkill
- catalog-import-and-migrationSkill
- checkout-ux-and-conversionSkill
- conversion-event-trackingSkill
- ecommerce-seo-structured-dataSkill
- fraud-and-risk-basicsSkill
- google-merchant-product-feedsSkill
- headless-nextjs-storefrontSkill
- inventory-and-multi-warehouseSkill
- iranian-payment-gatewaysSkill
- marketplace-search-and-rankingSkill
- mcp-store-toolingSkill
- multi-vendor-payoutsSkill
- order-and-webhook-reliabilitySkill
- payment-gateway-integrationSkill
- product-catalog-modelingSkill
- product-description-guardrailsSkill
- returns-and-refundsSkill
- rtl-and-persian-localizationSkill
- shopify-app-developmentSkill
- storefront-accessibilitySkill
- storefront-performanceSkill
- stripe-paymentsSkill
- tax-and-shippingSkill
- vector-product-searchSkill
- woocommerce-plugin-developmentSkill
- woocommerce-rest-apiSkill
- wordpress-plugin-securitySkill
The file
We split this skill into the rules it gives an agent
5 rules. About 0 are common, 3 are distinctive, and 2 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 12
Use this skill for recurring charges.
- Distinctive: line 20
When a period ends, create one renewal invoice and one charge.
- Distinctive: line 28
Use these statuses unless the platform already has its own set.
- Very specific: line 38
Do not overload active to mean "card on file but the last charge failed".
- Very specific: line 57
After the last retry fails, set canceled or leave past_due with access off, according to the plan.
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 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
Use this skill for recurring charges. The first payment still follows the payment skill. A renewal is another charge with its own idempotency key, not a replay of the checkout.
WooCommerce core does not include subscriptions. WooCommerce Subscriptions is a separate extension. Shopify subscriptions use selling plans. Use the product the store already runs. Do not invent a cron job that inserts orders with wp_insert_post.
Procedure
- Store the contract separately from any one invoice: customer, plan, quantity, currency, interval, current period start and end, and status.
- Charge the initial invoice with the payment skill. Move the contract to
activeortrialingonly after that payment is confirmed, unless the plan really has a trial with no charge. - When a period ends, create one renewal invoice and one charge. The idempotency key is the subscription id plus the period start.
- On success, advance the period. On failure, follow the dunning schedule. Do not delete the entitlement on the first failure.
- Cancel either at period end or immediately, and record which one the shopper chose. Prorate only when the plan change says to.
State transitions are in the state notes. Worked examples and checks are in evals/tasks.json.
Status
Use these statuses unless the platform already has its own set. Map the platform's names onto them in one function.
| Status | Meaning |
trialing | Access is on. No charge yet, and a trial end is stored. |
active | The latest renewal succeeded and the period end is in the future. |
past_due | A renewal failed and retries remain. Access policy is explicit. |
paused | The merchant or shopper paused billing. No renewal is attempted. |
canceled | No further renewals. Access ends now or at the stored period end. |
Do not overload active to mean "card on file but the last charge failed".
Renewals
- One renewal invoice per period. A retried charge uses the same idempotency key.
- The amount is the plan price at renewal time, plus tax from the tax skill, unless a scheduled price change says otherwise.
- Store the provider payment id on that invoice. A second webhook does not create a second invoice.
- Advance
current_period_endonly after the charge is confirmed.
Changes and cancellation
- Upgrade or downgrade mid-period either waits until period end or prorates. Record the policy on the plan. Do not do both.
- Proration is a signed amount on an invoice: unused time credited, new time debited. It is not a silent edit of a paid invoice.
- Cancel at period end sets
cancel_at_period_end. The status staysactiveuntil the period ends, then becomescanceled. - Immediate cancel stops renewal and sets the entitlement end to now. Refund the unused time only if the policy says so, through the payment skill's refund path.
Dunning
- Retry a failed renewal on a short written schedule, for example day 1, day 3, and day 7. Those days are a default to configure, not a measured optimum.
- After the last retry fails, set
canceledor leavepast_duewith access off, according to the plan. Tell the shopper which one happened. - A shopper who updates the payment method retries the open invoice. It does not open a second period.
Gotchas
- Treating the webhook for the first payment as every renewal will extend the period on a retry.
- Billing today and also billing at period end double-charges the first cycle.
- Local midnight is not a period boundary. Store period ends in UTC.
- A paused subscription that still runs the renewal job will charge a shopper who asked to stop.
Verification
- Two workers processing the same period create one invoice and one charge.
- A failed renewal does not advance
current_period_end. - Cancel at period end leaves access on until that timestamp and does not create another invoice.
- A plan change records proration as its own invoice lines.
Evaluation
Worked examples and the checks they must satisfy are in evals/tasks.json.
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.

