/engineering:subscription-billingfrom engineering
Designs or reviews recurring subscription lifecycle on Stripe Billing: plans/Prices, trials, proration, upgrades/downgrades, cancel/pause, Smart Retries dunning, metered usage, automatic tax, multi-currency, and subscription vs perpetual strategy.
Ships in engineering. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
| Input | Required | Use |
|---|---|---|
| Tenant, product, and lifecycle scope | yes | Bound the SaaS decision |
| Current architecture, plans, policies, and constraints | yes | Preserve enforceable behaviour |
| Production data or verified evidence | conditional | Validate thresholds and migrations |
Skill-specific inputs:
Default to read-only analysis. Change configuration, billing, identity, tenant data, infrastructure, or customer communications only with explicit authority, least-privilege credentials, tenant scope, rollback, and auditable approval. Never expose secrets or cross tenant boundaries.
If production access, policy, telemetry, or authoritative records are unavailable, produce a labelled design or dry-run plan. Do not claim deployment, reconciliation, deletion, delivery, or measured outcomes; list missing evidence and verification.
| Condition | Action | Stop condition |
|---|---|---|
| Tenant isolation, money, identity, or deletion is affected | Require approval and rollback evidence | Scope or authority is ambiguous |
| Evidence supports a reversible change | Stage, test, and record it | Acceptance checks fail |
| Only partial context is available | Return assumptions and validation | A production claim cannot be verified |
tenant-document-numbering).stripe-payments.saas-accounting-system.saas-growth-metrics.SKILL.md end-to-end; load stripe-payments for primitives the lifecycle relies on (PaymentIntents, webhook signatures, 3DS).references/ only for the specific deep dive needed.subscriptions.update call sets proration_behavior explicitly — never rely on defaults silently.customer.subscription.updated.incomplete as failure — the subscription has 23 hours to complete first payment.cancel_at_period_end).saas-accounting-system.proration_behavior choice.| Category | Artifact | Format | Example |
|---|---|---|---|
| Release evidence | Subscription billing configuration record | Markdown doc capturing plans, Prices, dunning policy, metered config, tax handling, and webhook map | docs/billing/subscription-config-2026-04-16.md |
references/dunning-management.md, references/metered-billing.md, references/revenue-recognition.md for deep detail.stripe-payments (primitives), subscription-billing (broader lifecycle/retention playbook), saas-accounting-system (revenue recognition), saas-growth-metrics (MRR cohorting).Use this skill when recurring revenue must be intentional rather than incidental. The goal is to design plans, lifecycle transitions, recovery workflows, and finance signals that support retention, predictable revenue, and trustworthy customer experience.
Skill-specific references:
saas-accounting-system.world-class-engineering.stripe-payments for Stripe payment primitives, webhook verification, and SCA flow.saas-accounting-system and saas-growth-metrics when the task crosses into revenue recognition or growth analytics.Stripe Billing's core entities, with one-line gloss from the Stripe Billing subscriptions overview:
$29 USD / month.Modelling rule: a Product is the SKU; a Price is the price-point + currency + interval. To raise the price, create a new Price and migrate subscriptions onto it — Prices are append-only by convention. Each SubscriptionItem references one Price; mixed billing schemes (flat seat fee + metered overage) live in the same Subscription as separate items.
The full enum (verbatim meaning from the Stripe Billing overview):
| Status | Meaning |
|---|---|
trialing | Subscription is in a trial period; safe to provision the product. |
active | Subscription is in good standing. |
incomplete | Customer must make a successful payment within 23 hours to activate. |
incomplete_expired | Payment failed and the customer didn't complete payment within 23 hours. |
past_due | Payment on the latest finalized invoice failed or wasn't attempted. |
unpaid | Latest invoice hasn't been paid but the subscription remains in place. |
canceled | Terminal state; cannot be updated. |
paused | Trial ended without a payment method; awaiting payment details to resume. |
Entitlement rules: trialing, active, past_due grant full access; paused and unpaid degrade access according to dunning policy; canceled ends access at period end. Wire each status to a webhook path in §7.
Required parameters on POST /v1/subscriptions:
customer — the Customer ID being subscribed.items — a list of up to 20 subscription items, each with an attached price (or price_data for ad-hoc).Key optional parameters:
trial_period_days — days before the first charge.payment_behavior — one of allow_incomplete, default_incomplete, error_if_incomplete.automatic_tax — object enabling automatic tax calculation.proration_behavior — defaults to create_prorations.cancel_at_period_end — boolean, defaults to false.collection_method — charge_automatically (default) or send_invoice.cURL:
curl https://api.stripe.com/v1/subscriptions \
-u "<<YOUR_SECRET_KEY>>:" \
-d customer={{CUSTOMER_ID}} \
-d "items[0][price]={{PRICE_ID}}"
PHP (stripe-php):
$subscription = $stripe->subscriptions->create([
'customer' => $customer->id,
'items' => [['price' => $priceId]],
'payment_behavior' => 'default_incomplete',
'expand' => ['latest_invoice.payment_intent'],
]);
Node.js (stripe-node):
const subscription = await stripeClient.subscriptions.create({
customer: customer.id,
items: [{ price: priceId }],
payment_behavior: 'default_incomplete',
expand: ['latest_invoice.payment_intent'],
});
Use payment_behavior: 'default_incomplete' when the front-end must confirm the first PaymentIntent (and handle 3DS) before the subscription transitions out of incomplete. The expanded latest_invoice.payment_intent.client_secret is what the browser SDK confirms; see stripe-payments for the SCA flow.
Classic trial. Pass trial_period_days on create. When the trial ends, the subscription moves to active and Stripe charges the customer's default payment method.
Modern trial offers (configured via trial_settings and trial offer objects):
duration.type = relative — trial length is set in billing intervals.duration.type = timestamp — trial ends on an absolute date.end_behavior — controls the price the subscription transitions to at trial end (the regular price or another configured price).0, the subscription status is trialing. Paid trials result in active, incomplete, or past_due.trial_end parameter — pick one path.Trial-end notification. The customer.subscription.trial_will_end webhook is sent 3 days before the trial ends (or immediately if the trial is shorter than 3 days). Wire it to the transactional email pipeline so the customer sees a reminder with a one-click payment-method capture link.
Trial length defaults.
Worked example from Stripe's prorations documentation: upgrading from a $10/month plan to a $20/month plan halfway through the cycle generates -5 USD for unused time on the initial price and +10 USD for remaining time on the new price.
proration_behavior enum:
create_prorations (default) — creates proration invoice items when applicable; only invoiced immediately under specific conditions.always_invoice — calculates the proration and immediately generates an invoice.none — no proration; customers are billed the full new amount when the next invoice generates.Direction rules:
Decision table:
| Transition | Recommended proration_behavior | Rationale |
|---|---|---|
| Upgrade (immediate value delivered) | always_invoice | Bill the difference now while the new entitlement unlocks. |
| Downgrade (effective at period end) | none + cancel_at_period_end-style swap | Avoid issuing an unintended credit. |
| Quantity bump on a metered seat | create_prorations | Roll prorations into the next invoice. |
| Plan rename only (same price) | none | Nothing to charge. |
Upgrade confirmation copy must disclose the immediate charge, the new recurring amount, and the next billing date. Example: "You'll be charged USD 42.33 today to upgrade to Pro. Starting 2026-05-01 you'll be billed USD 99.00 per month."
Downgrade copy must enumerate exactly what will be lost and when: "On 2026-05-01 your plan changes to Starter. You will lose API access, 3 team seats (keeping 1), and CSV export. Your data and projects are preserved."
Cancellation timing.
cancel_at_period_end = true; the subscription completes the duration the customer has already paid for.prorate to prorate the cancellation. If you set a custom cancellation date, you cannot provide a refund — a credit proration is always generated.The cancellation flow is the highest-leverage retention surface. Design an exit-intent modal that (1) acknowledges without guilt-tripping, (2) asks a structured reason-code question, (3) presents one targeted save offer matched to the reason code, (4) confirms the cancellation, and (5) sends a confirmation email with reactivation link and data-export instructions. Reason codes must be a closed list so the data is analyzable.
Pause and resume. The Stripe-managed paused status is the state when a trial ends without a payment method. Programmatic pause is performed via the pause_collection parameter on subscription update. Confirm the exact pause_collection.behavior enum (e.g. keep_as_draft, mark_uncollectible, void) against the Stripe subscription update reference before publishing handler code.
Operational rules for self-serve pause:
Smart Retries uses AI to choose the best times to retry failed payment attempts and increase the chance of successful collection.
Schedule options. Retry within a chosen window: 1 week, 2 weeks, 3 weeks, 1 month, or 2 months. Stripe's recommended default is 8 tries within 2 weeks. Disabling Smart Retries lets you set custom rules with up to three retries, each with a specific number of days after the previous attempt.
End-of-dunning disposition — pick one when configuring revenue recovery:
canceled after the maximum number of days defined in the retry schedule.unpaid after the maximum number of days; invoices continue to be generated and stay in draft.past_due after the maximum number of days.Pick cancel for self-serve B2C, unpaid for B2B where collections will follow up out-of-band, and past_due only when finance has a manual intervention process.
Webhook events to wire (verbatim event names): invoice.payment_failed (each failed attempt), customer.subscription.updated (transitions to past_due / unpaid / canceled), invoice.paid (recovery success). Handlers must be idempotent — see stripe-payments.
Dunning email cadence is captured in references/dunning-management.md. Standard pattern: notification on Day 0, soft reminder on Day 3, warning on Day 7, degradation at Day 10, final warning at Day 14, end-of-dunning action at Day 21 with a winback message.
Usage-based billing charges customers based on their consumption of the product or service. Three operational components:
Recording methods:
Stripe processes meter events asynchronously, so aggregated usage in meter event summaries and on upcoming invoices may not immediately reflect recently received events. Reconcile at end-of-cycle, not mid-cycle.
Until the exact endpoint and payload shape (event_name, payload.stripe_customer_id, payload.value, timestamp) are confirmed against the Stripe Billing meter-event API reference, this skill keeps §8 narrative-only — do not invent endpoint names, parameter keys, or aggregation enum strings in code samples. The aggregation modes are configured on the meter (not on each event); confirm the canonical enum on the meter object reference before publishing the comparison table.
Usage rules that hold regardless:
Operational depth lives in references/metered-billing.md.
Stripe Prices support several recurring billing schemes. The named families: per_unit, tiered (with tiers_mode of graduated or volume). Confirm the exact billing_scheme and tiers_mode enum strings on the Stripe Price object reference before publishing code that branches on them.
Decision matrix:
| Scheme | When to use | Example |
|---|---|---|
| Flat recurring (per_unit, quantity 1) | Single-tier SaaS plan | "Pro: $29/month" |
| Per-seat (per_unit, quantity N) | B2B seat-based plans | "$10/seat × 12 seats" |
| Graduated tiers | Per-unit price drops as usage grows, only above each tier's threshold | "First 1k API calls free, next 9k @ $0.001, then $0.0005" |
| Volume tiers | One unit price applies across all units, based on the highest tier reached | "If usage > 10k, every call billed @ $0.0005" |
| Metered + tiered | Pay-as-you-go with quantity discounts | OpenAI-style API billing |
Use a small, understandable set of plan tiers (Freemium / Starter / Pro / Enterprise). Tie pricing to delivered value, not internal implementation cost. Keep feature gates explicit and machine-enforceable.
Enable automatic tax on a subscription:
curl https://api.stripe.com/v1/subscriptions \
-u "<<YOUR_SECRET_KEY>>:" \
-d "automatic_tax[enabled]=true"
Validate customer location at the moment of the call by adding -d "tax[validate_location]=immediately".
Tax IDs on the Customer. Stripe supports over 200 specific tax ID types organised by country code (eu_vat, gb_vat, au_abn, etc.). To update a tax ID, delete the old one and create another — tax IDs are not edited in place.
Strategy note. Stripe Tax tracks sales against local registration thresholds and alerts when tax obligations may exist. This does not absolve the merchant of registering in jurisdictions where required; treat threshold alerts as input into a finance and legal workflow, not as compliance itself. East Africa VAT and withholding tax are finance and legal controls, not just API fields.
A Subscription's currency is fixed at creation, and a Price has a single currency, so a multi-currency catalogue means multiple Prices per Product — one per currency. Stripe supports charging in over 135 currencies. Presentment-vs-settlement and zero-decimal rules from stripe-payments apply identically.
Confirm the shape of currency_options on the Price object (which lets a single Price ID present in multiple currencies) against the Stripe Price object reference before relying on it as an alternative to one-Price-per-currency.
Strategic framing only; the technical guidance above stands on Stripe documentation.
Durable software companies treat the customer relationship, not the transaction, as the primary asset. The implications:
saas-growth-metrics.Recommendation table:
| Decision | Default | Trigger to revisit |
|---|---|---|
| Subscription vs perpetual licence | Subscription for SaaS | Specialised on-prem or regulated deployments. |
| Monthly vs annual | Offer both; default new customers to monthly | Sales-led B2B with negotiated annual terms. |
| Discount on annual | Offered to incentivise prepayment | Specific percentage is a pricing decision; do not assert a typical range without a sourced benchmark. A/B test via experiment-engineering. |
| Trials | 14 days, no card up-front for self-serve | Sales-assisted POCs use longer custom durations. |
stripe-payments).proration_behavior chosen explicitly on every subscriptions.update call — no defaults left implicit.automatic_tax[enabled]=true on every subscription where the business has nexus; Tax IDs collected in supported regions.customer.subscription.trial_will_end triggers the transactional email pipeline.saas-accounting-system, not duplicated here.saas-growth-metrics.currency_options has been verified for the use case.When the subscription drives an agent product, four line-item patterns appear on the invoice. Engineer them as named, distinct Stripe price IDs — not as opaque "Usage" lines — so finance, dispute teams, and customers can reconcile them.
Price model: usage_type='metered', aggregate_usage='sum'.agent_resolutions_completed_{feature}.ai-usage-metering-and-billing on agent.resolution.completed (verdict='resolved')."{Feature} — Resolutions (completed)".Price from Pattern 1, typically 20–40% of the resolution unit price.agent_tasks_attempted_only_{feature}.agent.task.attempted when the tier's pricing policy bills for attempts (see ai-agent-attempted-vs-completed-billing/references/attempt-classification.md)."{Feature} — Attempted (no resolution)".ai-agent-sla-credit-automation)."SLA breach: resolution_rate_floor — period 2026-05 — eligible_amount $X".4920 SLA Credits Issued — Agent contra-revenue account (see ai-agent-revenue-recognition/references/deferred-revenue-and-refund-reserves.md).ai-agent-abandonment-and-refund-policy)."Abandonment refund — class={technical|out-of-scope} — task={task_id}".A common anti-pattern is one negative line "Discount". The four patterns have different ledger accounts, different auditor scrutiny, and different customer-comms templates. They must remain distinguishable in the billing system, the GL, and the customer invoice.
ai-agent-pricing-engine — resolves which Price ID applies per event.ai-agent-attempted-vs-completed-billing — defines pattern 1 vs pattern 2 selection.ai-agent-sla-credit-automation — issues pattern 3.ai-agent-abandonment-and-refund-policy — issues pattern 4.ai-agent-revenue-recognition — booking of all four patterns.saas-architecture-strategy: Broader lifecycle and platform strategy.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub peterbamuhigire/chwezi-dev-engine --plugin engineering169 skills in this plugin
/accounting-engineUse when designing or implementing double-entry accounting policy and an embedded ledger engine for invoices, payments, stock, balanced postings, mapped accounts, idempotency, reversals, period locks, audit trails, and financial statements./accounting-finance-controllerUse when coordinating accounting and finance implementation reviews, doctrine routing, control evidence, remediation priorities, and release decisions across a software system./advanced-testing-strategyUse when designing or reviewing test strategy for production systems, APIs, mobile apps, SaaS platforms, ERP workflows, and AI-enabled systems. Covers unit, integration, contract, end-to-end, regression, release-gate, and risk-based testing decisions.Other plugins' skills for the same job