metered-billing
Skill0 starsChanged 25 days agoMITView on GitHub
Turn consumption into invoices without silently dropping usage or shocking the customer with a runaway bill. Use when wiring usage-based pricing, creating a Stripe Meter, reporting meter events, or reviewing metered/usage code (including any code calling the dead createUsageRecord API).
In this repository33 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- llms.txtllms.txt
- agent-runtimeSkill
- frontend-designSkill
- architectSkill
- deep-thinkSkill
- design-systemsSkill
- ecosystem-referenceSkill
- fractal-delegationSkill
- harness-reviewSkill
- heartbeatSkill
- integrate-resourcesSkill
- llm-council-critiqueSkill
- loop-createSkill
- mcp-setupSkill
- memory-compressionSkill
- memorySkill
- model-routingSkill
- oss-project-scaffoldSkill
- playwright-cliSkill
- repo-scoutSkill
- self-improveSkill
- skill-creatorSkill
- skill-routingSkill
- sprintSkill
- test-visualSkill
- troubleshootSkill
- ux-auditSkill
- agent-spend-credentialSkill
- stripe-version-migrationSkill
- stripe-webhook-correctnessSkill
- subscription-prorationSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
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
- Distinctive: line 21
Run in order. Each step cites the brain ref it enforces.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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
metered-billing
Law (JTBD-0): the meter summary is the ledger; an accepted event is not proof it counted. The whole metered surface fails silently — events drop at period boundaries, meters are near-immutable, and a "correct" meter can still produce a business-disaster invoice. —
brain/EXPERTISE-MAP.mdJTBD-3.
Trigger
Invoke when ANY of these are true:
- You are wiring usage-based / metered pricing, or creating a Stripe Meter.
- Code reports usage (
v1/billing/meter_events) — or worse, callssubscriptionItems.createUsageRecord()(dead since Basil). - The symptom is "internal usage > Stripe-recorded usage near period boundaries", "usage never appears on invoices", or a usage spec mentions agent/AI consumption billing.
- You are reviewing whether a metered system can run up an unbounded invoice.
Steps
Run in order. Each step cites the brain ref it enforces.
- Meters are mandatory;
createUsageRecordis a deleted API. Since2025-03-31.basilthe legacy usage-records API is gone — every metered price needs a backing Meter +v1/billing/meter_events. Grep forcreateUsageRecord, forusage_type: 'metered'without a Meter, and for any pre-2025 metered tutorial copy; treat all three as poison. — P-08 (brain/KNOWN-PITFALLS.mdP-08;brain/EXPERTISE-MAP.md3.1). - Send near real-time; the timestamp rules silently drop usage. Events must be within the past 35 calendar days (≤5 min future); Stripe rejects events outside the current billing period and does not backfill; the ~1-hour late grace is not a guarantee. A nightly batch whose flush crosses a period boundary silently under-bills — and staging never crosses a boundary, so every test passed. Treat UTC-midnight-on-the-anchor-day as a hard flush deadline. — P-09 / S-09 (
brain/KNOWN-PITFALLS.mdP-09,brain/BATTLE-TESTED-SCENARIOS.mdS-09). - Reconcile daily against
meter-event-summary; alarm on divergence. Keep your own usage ledger and diff it against Stripe'smeter-event-summaryevery day — this is the canary for the silent drop in step 2 (staging can't catch it). — O-06 / S-09 (brain/OPINIONS.mdO-06;brain/EXPERTISE-MAP.md3.6). - Name the meter like a public API; decide the unit of value before creating it. Configured meters can only change their display name — wrong aggregation (
sum/count/last_during_period) or wrong unit forces a brand-new meter + a subscription migration (the exact pain you were avoiding).event_name≤100 chars. Review aggregation + unit against the unit of value before the meter exists. — O-07 / P-10 (brain/OPINIONS.mdO-07,brain/KNOWN-PITFALLS.mdP-10). penny'smeter createrefuses to re-create an existing meter for this reason. - Bill-shock is a product failure — cap, warn before money moves, degrade gracefully. A silent $40k invoice is "technically correct and a business disaster" + a likely chargeback. Set billing thresholds + usage alerts; on hitting a cap, degrade (cheaper model / queue runs / require human approval) instead of billing through. Warn before money moves, not after. — O-08 / S-10 (
brain/OPINIONS.mdO-08,brain/BATTLE-TESTED-SCENARIOS.mdS-10). - Don't promise a clean Stripe-native P&L for advanced UBB.
billable_itemsaren't fully wired into reports — journal entries show thebillable_itemID as the product ID and the product name comes back empty. Keep your own usage ledger as the reporting source of truth for advanced usage. — P-11 (brain/KNOWN-PITFALLS.mdP-11;brain/EXPERTISE-MAP.md3.5).
Output
A corrected metered integration (for authoring) or a findings list (for review), each item shaped:
{ check: <step>, status: pass|fail, brainRef: O-0n|P-0n|S-0n, file:line, fix }.
- Authoring: emit Meters +
meter_events(nevercreateUsageRecord), a near-real-time flush, a daily reconciliation againstmeter-event-summary, and a billing-threshold cap with graceful degrade. - Review: any
createUsageRecordcall is a HIGH finding (P-08, dead API → exit non-zero); a batch flush with no daily reconcile is a revenue-leak finding (P-09/S-09); an uncapped metered agent is a bill-shock finding (O-08/S-10). Cite the brain ref.
Self-test rig
Stripe test mode: create a Meter, push a meter_event with a timestamp just past a period boundary, and assert the drop is caught by the daily reconcile against meter-event-summary (S-09). penny meter create self-tests the immutability refusal (re-create same name → refused, O-07/P-10).
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.

