cmux-billing
Installation
SKILL.md
cmux Billing
Use this skill before changing billing, pricing, Stripe, Pro entitlement, checkout, webhook, or subscription code.
Architecture Map
/api/billing/checkoutcreates Stripe Checkout Sessions for Pro whenSTRIPE_SECRET_KEYis set. It setsclient_reference_idto the Stack user id, auto-creates an anonymous Stack user for signed-out buyers, and falls back to the legacy Stack purchase path when Stripe is unset orplan=team./api/billing/portalresolves the current Stack user, looks up theirstripe_customersrow, and creates a Stripe customer portal session returning to/pricing./api/billing/subscriptioncancels or resumes the current user's active Stripe Pro subscription, and/dashboard/billingrenders localized in-dashboard plan state and self-serve billing actions.web/services/billing/purchase.tsis the shared idempotent recorder used by both/api/billing/completeand/api/stripe/webhook. It attaches email to the purchaser, recordsbilling_email_claimson conflict, and never cross-grants based on an unverified email.cmuxPlanin StackclientReadOnlyMetadatais the only entitlement VM code reads.cmuxVmPlanmanual override wins.resolveProPlanStatusORs legacy Stack products with activestripe_subscriptionsDB rows./api/stripe/webhookis signature-verified, insert-first idempotent throughstripe_webhook_events, safe for foreign events in the shared Stripe account, and gates cmux handling onmetadata.app === "cmux". Return 2xx only after durable writes; return 500 to make Stripe retry.