Stripe SaaS Subscription Lifecycle: Trials, Grace, Retention

    by Nate Freed

    1

    Everything after Stripe Checkout for a small SaaS: card-less trials, grace periods, export window, data retention, promo codes, webhooks, admin console and jobs, with a policy simulator that catches timeline mistakes.

    $9

    Secure checkout via Stripe

    Money-back guarantee

    Converts to your local currency at checkout

    Security scanned

    Works with the AI Agents you already use

    Stripe SaaS Subscription Lifecycle: Trials, Grace, Retention

    Example session with this skill installed

    Our Express + Prisma app already has Stripe Checkout for a monthly plan. Add a 7-day free trial with no card and remind people 7 days before it ends, plus yearly and lifetime plans. If a card fails give them 7 days. When someone leaves, let them export for 30 days, keep their data 30 days and email them a month before we delete it. Stripe's retries run about 3 weeks.

    • Read your context and instructions
    • Compiled the stripe saas subscription

    Ran the policy check before writing code

    $ python3 scripts/lifecycle_sim.py --policy policy.json --check-only
    ERROR P_TRIAL_REMINDER_TOO_EARLY trial_reminder_days_before (7) >= trial_days (7): the 'trial ending' email would go out the day the trial starts
    WARN P_DELETE_WARNING_AT_LOCK deletion warning offset equals retention: the warning arrives together with the lockout email
    WARN P_EXPORT_ENDS_AT_DELETION export window closes on the deletion day; users get no retained period
    WARN P_DUNNING_LONGER_THAN_GRACE Stripe keeps retrying for 21 days but grace ends after 7: a late successful retry charges a user you already locked
    Result: 1 error(s), 3 warning(s) -> FAIL

    In plain words, with a proposed fix for each:

    1. A reminder 7 days before the end of a 7-day trial goes out the day the trial starts. Suggest 2 days before.
    2. Keeping data 30 days with a warning a month ahead means the warning arrives with the lockout email, and export closes the day the data is deleted. Suggest keeping data 60 days: 30 days to export, then the 30-day deletion warning.
    3. Stripe retries for about 3 weeks but grace is 7 days, so a late retry would charge someone already locked out. Suggest a 7-day retry window in Stripe's Billing settings (LIFECYCLE_CANCEL_STRIPE_ON_GRACE_END=true also cancels at grace end).

    You agreed. Re-run with the new policy:
    Policy: trial 7d (reminder 2d before), grace 7d (full access), export 30d, retention 60d from lock (warning 30d before)
    Policy checks: OK
    card_fails: day 30 payment failed, grace ends day 37 / day 33 retry failed, grace unchanged / day 37 locked, export until day 67, cancel the Stripe subscription / day 67 deletion warning / day 97 deleted
    Result: 0 error(s), 0 warning(s) -> OK

    Done locally: billing/ folder from the templates, Prisma models merged, migration created and applied to your local database only, webhook mounted before express.json(), product routes behind requireAccess('full'), policy check added to CI. Test plan layers 1-3 pass.

    Waiting on your OK: setupPrices.ts --apply in test mode (dry run: create monthly, yearly and lifetime prices), Customer Portal and webhook endpoint in test mode, the Stripe retry window, real email sending, and LIFECYCLE_ENABLE_DELETION (stays report-only).

    policy.json

    Connects securely to your tools. The creator never sees your data.

    About this skill

    Most Stripe skills stop at Checkout. This one implements everything after it for a small SaaS on Node/Express and Postgres: a free trial without a card plus a reminder email, monthly, yearly and lifetime plans, four promo-code types (free lifetime, percent off, fixed amount off, free months) with usage limits and an atomic free-lifetime redemption, and signature-verified, idempotent webhooks that drive one explicit state machine. Failed payments get a grace period that never slides with Stripe's retries. When access ends, users keep an export window, data is retained for a period you choose, a warning goes out before deletion, and resubscribing within retention gives them back their data. Includes Customer Portal wiring, an access-check middleware, an audited admin console API (separate key, re-entry for sensitive actions) and idempotent scheduled jobs. Before any code, a Python simulator walks your policy day by day and flags mistakes such as a deletion warning that lands after the data is gone or a grace period longer than retention. Ships Prisma and SQL schemas, TypeScript templates written for Prisma, an email checklist and a test plan using Stripe test mode and test clocks. The agent works in Stripe test mode only and asks before every outward-facing step; going live is a checklist you run yourself.

    Stripe only, Node/Express with Postgres. The TypeScript templates are written for Prisma; on a plain-SQL project the agent ports their queries to your SQL client using schema.sql. No metered or per-seat billing, Connect, or tax setup. The admin console is an API; you build the UI in your own frontend. The shared admin key suits one or two operators, not a team. Email is queued in an outbox; sending is up to your email provider or an SMTP sender you already have. Data purge needs your own per-table purgeUserData implementation and stays report-only until enabled. Templates were type-checked and run against in-memory fakes and a local Postgres, not against a live Stripe account; re-run the test plan in your own Stripe test mode, especially after SDK upgrades.

    How to use

    1. 1

      Connect your agent to the Agensi MCP

      Copy the prompt and paste it into Claude, ChatGPT, Cursor or any agent that supports MCP. It sets up the connection for you. Manual setup

    2. 2

      Sign in to Agensi

      Your agent shows a sign-in link. Sign in and click Allow.

    3. 3

      Ask for what you need

      Your agent loads this skill and uses it on your task. It always asks before buying a skill.

    Reviews

    No reviews yet

    Be one of the first to try it. Every listed skill goes through the trust checks below.

    Security scanned

    Checked by our 8-point scan before listing

    Fresh listing

    Recently published to Agensi

    Money-back guarantee

    Doesn't do what its page promises? You get your money back.

    Trust & safety

    Security scan

    Security scan passed 7 days ago

    Accounts
    Stripe account in test mode
    Software
    Node 18+ with Express and TypeScriptPostgreSQL 13+, Prisma recommendednpm packages: stripe, zodPython 3.8+ for the simulatorprismaNode.jstsx
    Optional
    Stripe CLI for local webhook testing
    An email sender
    orSMTP account
    tsx to run setupPrices.tssupertest for handler tests

    Permissions

    Terminal / Shell
    Read Files
    Write Files
    Environment Variables
    Network Access

    Allowed Hosts

    api.stripe.com (test mode, only after the user approves each step)

    File Scopes

    Project
    source:
    a
    new
    billing/
    folder
    server
    entry
    prisma/schema.prisma
    and
    local
    migrations
    policy.json
    scenario
    files
    in
    the
    project
    .env
    presence
    of
    variables
    only;
    values
    are
    never
    read
    back
    or
    printed

    The simulator and all offline tests need no network. Network is used only for Stripe test-mode API calls (listing and creating prices, test clocks) after the user approves each step; setupPrices.ts refuses live keys, and the app's Stripe client refuses them unless the owner sets STRIPE_ALLOW_LIVE in production. Migrations on shared or live databases, enabling email sending, enabling data deletion and deploying are left to the user. No global installs; missing project dependencies are added only after asking.

    Listed7 days ago

    What's inside

    Creator

    N

    Nate Freed

    24 skills on Agensi

    Frequently Asked Questions

    No. The agent works with test-mode keys only. The app's Stripe client refuses a live key unless you set STRIPE_ALLOW_LIVE=true in production, setupPrices.ts refuses live keys entirely, and going live is a checklist you run yourself.

    schema.sql gives you every table and constraint, idempotent, for Postgres 13+. The TypeScript templates are written for Prisma, so the agent ports their queries to your SQL client and keeps the same transaction boundaries.

    No. Eleven lifecycle emails are rendered as plain text and queued in an email_outbox table with dedupe keys. You choose the sender, and real sending waits for your approval.

    Deletion stays report-only until you implement purgeUserData for your tables and set LIFECYCLE_ENABLE_DELETION=true after reading a dry-run report. It also never deletes anyone without a deletion warning sent at least a day earlier.

    A card-less trial has no payment method, so the app's own clock and access check run it. If the user subscribes with more than 48 hours of trial left, Checkout carries the remaining trial over.

    Python 3.8+ and nothing else: standard library only, no network, deterministic output. Run it in CI on your policy.json.

    Yes. Instead of the in-process hourly scheduler, call runLifecycleJobs from a scheduled function or a protected endpoint. Access stays correct between runs because it is computed from timestamps.

    The admin console is an API (users, grants, revokes, promo codes, policy, prices, analytics, activity log) with a separate key and an audit trail. You build the screens in your own frontend.

    The templates were type-checked under strict TypeScript and run against in-memory fakes and a local Postgres, not a live Stripe account. The included test plan walks you through Stripe test mode and test clocks before you go live.

    New in E-commerce

    Find more skills like this on the Claude Skills Marketplace, the Codex Skills Marketplace and the Gemini Skills Marketplace, or browse Claude Skills for E-commerce.