agentleFS
hi-donwihi-donwi/Donwi-Skills/skills/saas-billing/SKILL.md

saas-billing

Skill0 starsChanged 13 days agoMITView on GitHub

Implement recurring subscription billing, payment reconciliation, pricing, usage metering, and paid entitlements. Use for subscription economics, not member eligibility, ERP ledger posting, or general partner webhooks.

3 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

4 rules. About 0 are common, 4 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use stable idempotency keys for checkout creation and other provider-side mutations.

    line 42
  2. Distinctive:

    Verify signatures and replay windows using the provider's supported mechanism and unmodified body.

    line 43
  3. Distinctive:

    Commit a deduplicated inbox and durable work record before acknowledging delivery.

    line 45
  4. Distinctive:

    Read-then-increment quota checks without concurrency protection or currency precision.

    line 64

≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

SaaS Billing and Subscriptions

Overview

Separate payment-provider facts, commercial subscription policy, and application access. Retries, delayed events, and concurrent consumption must not create value twice.

When to use

  • Integrating payment providers (Stripe, LemonSqueezy, Paddle, Midtrans).
  • Managing subscription states: trialing, active, past_due, unpaid, canceled.
  • Handling payment and invoice webhooks reliably with signature validation and deduplication.
  • Implementing flat-rate tiered, per-seat, or usage-based metered pricing models.
  • Gating premium features and enforcing tenant quotas based on active subscriptions.

Hand off when

NeedSkill
Tenant data isolation and organization scopingsaas-multitenancy
Member eligibility, renewal, and owner transfermembership-management
General partner webhook transportwebhook-integrations
REST endpoints, problem+json error formattingrest-api-contract
API key auth, secret rotation, and HMAC defensesecurity-hardening
User-facing billing portals, pricing tables, UI statesweb-development

Process

  1. Define versioned prices, currency precision, billing account ownership, billable seats, trial policy, proration, tax inputs, refunds, and effective change times. Obtain jurisdictional requirements rather than inventing tax rules or grace periods.
  2. Map provider customer and subscription IDs to verified tenants and environments. Use stable idempotency keys for checkout creation and other provider-side mutations.
  3. Verify signatures and replay windows using the provider's supported mechanism and unmodified body. Bound input sizes and reject invalid deliveries before side effects.
  4. Commit a deduplicated inbox and durable work record before acknowledging delivery. Duplicate pending events must remain recoverable; persistence failure is not success.
  5. Serialize reconciliation per subscription. Providers may deliver snapshots out of order; fetch authoritative state when necessary rather than sorting by timestamps.
  6. Evaluate paid capabilities independently of role permissions and release flags. Atomically reserve limited quota or seats; deduplicate consumption and corrections.
  7. Derive effective access from explicit policy and provider state. Distinguish scheduled end-of-period cancellation from terminal cancellation; preserve billing/support access.
  8. Reconcile provider totals periodically, monitor failed work, and test trial end, payment failure, retries, immediate cancellation, refunds, and concurrent quota use.

Red flags

  • Trusting client-side checkout redirects for order fulfillment instead of verified server webhooks.
  • Processing webhooks non-idempotently, causing duplicated seat licenses or double balance credits.
  • Hardcoding plan strings (if (user.plan === "pro")) scattered across business logic.
  • Verifying webhooks against parsed JSON rather than raw incoming request body buffers.
  • Locking customer accounts immediately upon the first transient payment failure.
  • Acknowledging before durable capture, skipping pending duplicates, or trusting event order.
  • Read-then-increment quota checks without concurrency protection or currency precision.

Verification

  • Webhook endpoint rejects invalid or missing provider-required signatures.
  • Delivering the identical webhook payload twice results in single execution and idempotent 200 responses.
  • Feature entitlement checks block unauthorized tenants with informative upgrade errors.
  • Scheduled cancellation and immediate terminal cancellation follow distinct policies.
  • Usage metering records events correctly and enforces configured quota thresholds.
  • Out-of-order delivery, worker crashes, and concurrent usage cannot duplicate value.

References

  • references/webhook-idempotency.md - verified durable ingestion and reconciliation.
  • references/pricing-and-entitlements.md - commercial policy and atomic quota handling.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.