gatefit init
gatefit init is included in npm gatefit@0.8.0. The path from install to the first result is Onboarding.
gatefit init is free. It does not read a license key, does not call Polar, and makes no network request.
What it writes
Section titled “What it writes”npx gatefit init # uses the one ORM found in package.jsonnpx gatefit init --template prisma # or drizzle, supabase, genericnpx gatefit init --dry-run # print the write plan, write nothingnpx gatefit init --template generic --print-workflow # print a CI workflow, write nothingnpx gatefit init --template generic --write-workflow # also write .github/workflows/gatefit.yml| Template | Detected when package.json has |
Extra files |
|---|---|---|
drizzle |
drizzle-orm |
gatefit/schema.ts, gatefit/migration.sql |
prisma |
@prisma/client or prisma |
gatefit/access.prisma, gatefit/migration.sql |
supabase |
@supabase/supabase-js (or supabase/config.toml exists) |
supabase/migrations/<timestamp>_gatefit_access.sql (RLS on, no policies) |
generic |
never detected; pass --template generic |
gatefit/migration.sql |
If no ORM or more than one is found, init asks on a terminal. In CI, with --no-prompt, or when stdin is not a terminal, it exits 2 and tells you to pass --template. It never picks one silently.
Every template also writes:
gatefit/adapter.ts: the adaptergatefit runloads.gatefit/access-rules.ts: the adapter contract types and a copy of the reference entitlement rules. Generated code imports nothing from Gatefit, so the files are yours to change.gatefit/db.ts,gatefit/README.md,gatefit/env.example.gatefit.config.jsonat the project root:{ "adapter", "suite", "stripeApiVersion" }.gatefit rundoes not read it; pass--adapterand--suiteas shown below.
All four templates use raw pg (node-postgres) against the same two tables. Your drizzle client, Prisma Client, or Supabase client is not loaded in CI. The template only changes the schema file and the migration path. Supabase uses its Postgres connection string, not API keys.
adapter.ts exports STRIPE_API_VERSION (2025-10-29.clover), the Stripe API version the goldens model. Pin your Stripe client to it.
Run the goldens
Section titled “Run the goldens”npm install --save-dev gatefit pgexport DATABASE_URL=postgres://localhost:5432/gatefit_cipsql "$DATABASE_URL" -f gatefit/migration.sqlnpx gatefit run --suite paid_grants_access --adapter gatefit/adapter.tsnpx gatefit run --suite tests/entitlements/goldens --adapter gatefit/adapter.tsThe generated adapter asserts the row in gatefit_access. HTTP 200 from Stripe is not access. A replayed Stripe event id is a no-op (gatefit_seen_events). decide() starts as the reference rules in access-rules.ts, so the goldens pass on a fresh install. Replace it with the function your webhook handler uses.
CI workflow
Section titled “CI workflow”--print-workflow and --write-workflow render a GitHub Actions job. It starts a throwaway Postgres service (trust auth, no password), runs npm ci, applies the migration with psql, and calls uses: gatefit/gatefit@v0.8.0 with your adapter path. The job needs no stored secrets. Database setup is yours to adapt.
Safety
Section titled “Safety”- No overwrite without
--force. If any planned file exists,initwrites nothing and lists the conflicts. The write is all-or-nothing. With--force, originals are moved aside and put back if a later write fails. - Files stay inside the project. A
--diroutside the working directory, or a symlink (such as agatefit/link) that resolves outside it, is refused with exit 2. - Live keys are refused first. A live-mode Stripe secret key in the arguments, the environment, or a
.env*file in the project makesinitexit 4 before anything else is checked. It names where the key is and never prints the key. - No secrets in generated files.
env.exampleholds placeholders only.DATABASE_URLis read at run time. - Local databases only. The adapter truncates its own
gatefit_*tables between goldens, so it refuses a non-localDATABASE_URLhost unlessGATEFIT_ALLOW_REMOTE_DB=1. Local hosts arelocalhost,127.0.0.1,::1, and the CI service namespostgresanddb.
Exit codes
Section titled “Exit codes”These codes apply to gatefit init only. gatefit run keeps 0 (pass) and 1 (fail).
| Code | Meaning |
|---|---|
| 0 | Files written, --dry-run plan printed, or --print-workflow output |
| 1 | Unexpected error (a failed write is rolled back) |
| 2 | Usage error: unknown template, unknown flag, no or ambiguous ORM without --template, or a path outside the project |
| 3 | A planned file already exists; rerun with --force |
| 4 | Live Stripe secret key found; nothing written |
The $49 one-time Gatefit Indie License unlocks only chaos mode and the Polar and Paddle packs. The core, Phase 2, and S1–S12 (17 goldens) stay free. init is free and does not read a license key. The buy page is the Gatefit Indie License (Polar), $49 one-time.