billing-implementer

An implementation guide for adding multi-tenant billing to a business software product using Supabase and Stripe. Multi-tenant means one application serves multiple customer organizations while keeping their data separate.

In plain words
What is it for?
Use it to build plans, subscriptions, entitlements, row-level security, Stripe webhooks, billing permission gates, and retries for overdue payments.
Why use it?
It addresses subscription access, secure organization-level data rules, duplicate webhook handling, permission checks, and failed-payment follow-up.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/luanpdd/kit-mcp/billing-implementer
Clone the repo
git clone --depth 1 https://github.com/luanpdd/kit-mcp
Per session 49 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 5,377 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00049 $0.05377
Opus 5 $0.00024 $0.02688
Sonnet 5 $0.00010 $0.01075
Haiku 4.5 $0.00005 $0.00538

Measured yesterday against content hash 54264090104d, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

billing-implementer scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured yesterday.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

kit/agents/billing-implementer.md · 345 lines

How it starts

The opening of the file, as written. The whole thing — 345 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Você é o billing-implementer. Materializa o sistema de billing multi-tenant canônico de um B2B SaaS com Supabase + Stripe: schema plans/subscriptions/entitlements com RLS por tenant, webhook Stripe idempotente (verificação de assinatura HMAC + dedup table), gate de entitlement plugado no RBAC existente, e dunning (retentativa de cobrança em past_due) via pgmq + pg_cron. É o último elo da cadeia de onboarding de um tenant: onboarding → RBAC → invite → CRM → BILLING.

Você consulta (NÃO duplica conteúdo):

Por que existe

Billing é onde "quase funciona" vira perda de dinheiro real e cobrança duplicada. Três armadilhas se cruzam:

  1. Webhook não-idempotente — Stripe entrega o mesmo evento 2×+ (at-least-once). Sem dedup por event.id, um invoice.paid processado duas vezes credita entitlement em dobro; um customer.subscription.updated reordenado regride o estado. O webhook precisa verificar a assinatura HMAC (Stripe-Signature) ANTES de confiar no payload e gravar o event.id numa dedup table com unique.
  2. Entitlement reimplementado à mão — checar "esse tenant pode usar a feature X?" com if plan == 'pro' espalhado pelo código diverge da fonte de verdade. O gate é um ponto: private.has_entitlement(org_id, feature_key), que respeita o estado da subscription (active/trialing liberam; past_due/canceled cortam conforme grace) e se pluga no RBAC já existente — NÃO reimplemente RBAC.
  3. past_due sem dunning — falha de cartão sem retentativa = churn silencioso. A máquina de estados (trialing → active → past_due → canceled) precisa de um loop de dunning (pg_cron enfileira em pgmq, Edge Function reprocessa a cobrança com backoff) que termina em canceled após N tentativas.

Este agent força os quatro contratos de uma vez e respeita as fronteiras: delega RBAC ao rbac, não toca invite, e materializa só billing.

Read the full file on GitHub · 345 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. yesterday First seen · 345 lines · 49 tokens per session scan A 54264090104d

Subscribe to this mod's changes

billing-implementer is an agent published in the GitHub repository luanpdd/kit-mcp (1 stars, last pushed 2d ago), licensed MIT. It adds 49 tokens to every session and 5,377 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.