Skip to content
Skills Library
Finance & accounting · Building & coding

implement-metered-billing

/implement-metered-billing

Implement usage-based / metered billing correctly — idempotent usage recording, aggregation & rating to billable quantities, on-time usage reporting before invoice close, and counted-vs-billed reconciliation. Use when billing on API calls, seats used, GB, events, or any consumption metric.

Repository
ravenclaude ↗
Licence
MIT
Last repository change
27.10.2026

Assessment and security

90/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content25 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 27.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Implement usage-based / metered billing correctly — idempotent usage recording, aggregation & rating to billable quantities, on-time usage reporting before invoice close, and counted-vs-billed reconciliation. Use when billing on API calls, seats used, GB, events, or any consumption metric.

Original author description

Implement usage-based / metered billing correctly — idempotent usage recording, aggregation & rating to billable quantities, on-time usage reporting before invoice close, and counted-vs-billed reconciliation. Use when billing on API calls, seats used, GB, events, or any consumption metric.

How it works

  1. When to use
  2. Steps
  3. Anti-patterns
  4. Output
Original SKILL.md headings · 32 lines, 372 words
SKILL.md preview
---
name: implement-metered-billing
description: "Implement usage-based / metered billing correctly — idempotent usage recording, aggregation & rating to billable quantities, on-time usage reporting before invoice close, and counted-vs-billed reconciliation. Use when billing on API calls, seats used, GB, events, or any consumption metric."
---

# Skill: Implement Metered Billing

Usage-based billing is a **metering problem before it is a billing problem**. Revenue is silently lost when usage is under-counted and clawed back when over-counted. This skill builds the counting → rating → reporting → reconciliation path so billed usage equals real usage.

## When to use

- Billing on consumption (API calls, compute, storage, messages, events) or metered seats.
- Adding overage to a base plan (hybrid model).
- Diagnosing a discrepancy between what you counted and what the provider invoiced.

## Steps

1. **Define the meter precisely.** What single unit is billable, at what granularity, with what rounding, over what window (aligned to the billing period)? Ambiguity here becomes a billing dispute.
2. **Record usage idempotently.** Every usage event carries a stable, caller-supplied event key; dedupe on it so retries/at-least-once producers can't double-count. Store raw events before aggregation so you can re-derive.
3. **Aggregate and rate.** Roll raw events to billable quantity per subscription per period; apply the rating rules (tiers, included allowance, overage price). Keep aggregation deterministic and replayable from raw events.
4. **Report before invoice close.** Push usage to the provider (or generate the invoice line) before the billing period closes, respecting the provider's cutoff. Late usage either misses the invoice or triggers a correction — decide which on purpose.
5. **Reconcile counted-vs-billed.** A scheduled job compares your aggregated quantity to what the provider billed and alerts on drift. This is the safety net that catches dropped or duplicated usage. See [`../../knowledge/webhooks-idempotency-and-revrec.md`](../../knowledge/webhooks-idempotency-and-revrec.md).
6. **Handle backfills and corrections explicitly.** When late/corrected usage arrives after close, apply it as an adjustment on the next invoice, not a silent mutation of a closed period.

## Anti-patterns

- Recording usage without an idempotency key, so a producer retry double-bills.
- Aggregating destructively (no raw events) so you can't re-derive or reconcile.
- Reporting usage after the provider's cutoff and losing it silently.
- No counted-vs-billed reconciliation — drift is invisible until a customer disputes.
- Mutating a closed billing period instead of issuing an adjustment.

## Output

A metering implementation: meter definition → idempotent recording → deterministic aggregation/rating → on-time reporting → reconciliation job + drift alert → backfill/correction policy. Prove it with duplicate- and out-of-order-delivery fixtures.

Versions

The database has no other skills named implement-metered-billing.

Database snapshot: 13.11.2026 · package version fbf6827bf1ab (SHA-256 digest of the entire package)

Downloads in the last 30 days: 3 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100usage-based-billing
    Dodo Payments usage-based billing that charges per measured unit, covering meters, usage event ingestion by event_name, aggregation, free thresholds, price_per_unit, and metered subscriptions. Use when billing per API call, AI token, storage, or bandwidth, sending usage events,…
  • 100account-billing
    Check a three.ws account's plan quotas, metered usage, invoices, receipts and the platform fee rate through the billing-mcp tools. Use when asked how much of a plan is left, what was charged in a month, or for a receipt or CSV export.
  • 100billing-automation
    Automates invoice generation, billing workflows, payment tracking, and revenue recognition for SaaS and service businesses. Use when building billing pipelines, generating invoice PDFs, usage-based invoicing, subscription management, payment reminders, or financial reporting.…
  • 100subscription-billing-reconciliation
    Reconcile what a subscription contract says should have been billed for a period against what invoices actually billed. Covers proration, billing terms, invoice exports with revisions, credit notes, merged and churned accounts, parent/child billing, currency conversion and…
  • 100stripe-integration-expert
    Implement Stripe integrations for SaaS billing: subscriptions, checkout, proration, usage- based billing, idempotent webhooks, customer portal, dunning, and SCA. Use when building billing, handling webhooks, or testing with Stripe CLI.
  • 100polar-typescript-sdk
    Integrate Polar billing in server-side TypeScript applications using the versioned createPolar and createPolarCore clients. Use when implementing Polar customers and external IDs, checkout or customer portal sessions, customer-state entitlement checks, webhook validation and…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.