replica-backend
Reads replica/architecture.md. Writes migrations and server code, and keeps
replica/backend.md (checklist below) up to date.
The rules
- Official, public APIs only, with the user's own keys. Never call the
original app's private endpoints, never reuse its OAuth client, never proxy
through it.
- The user creates accounts and keys. Claude never signs up for services,
never types a password, card or live key. The user creates the Stripe,
Supabase, Resend or Google Cloud project and puts keys in
.env.local.
Claude writes .env.example with every variable name and no values.
- Test mode first. Stripe test keys and test cards until replica-deploy.
Auth
- Email sign up with verification, password reset, magic link if the original
has it. OAuth (Google, Apple) with the user's own developer apps.
- Sessions: http-only secure cookies. Sign out everywhere.
- Roles and teams if the recon map has them: owner, admin, member, with one
function that answers "can this user do this to this record".
- Account deletion that actually deletes. Apple requires it for apps with
sign up.
Database
- Migrations from
architecture.md, checked in, run by a script.
- Access rules on every table: row level security policies on Supabase, or
the authorisation function called in every query. Test it: a second user
must get nothing back.
- Seed script with realistic fake data (no real people).
- Backups on (the host's daily backups count, check they are enabled).
Payments
- Stripe Checkout for sign up to a plan, the Customer Portal for changes and
cancelling. Do not build card forms.
- Webhooks: verify the signature, store the event id, make every handler
idempotent (Stripe retries). Handle
checkout.session.completed,
customer.subscription.updated, customer.subscription.deleted,
invoice.payment_failed.
- Subscription status lives in your database, updated by webhooks, read by
your app. Never trust the client.
- Cancelling is one click. Hard-to-cancel billing is a top complaint about
most apps, and in many places it is illegal.
Email and jobs
- Transactional email through Resend or Postmark from your own domain.
Templates written fresh.
- Jobs for anything time-based (reminders, digests, sync, cleanup) with
retries and a dead-letter log. Times in UTC, shown in the user's zone.
Integrations
For each integration in the feature matrix: the official API, the OAuth
scopes needed (fewest possible), the provider's review process, rate limits.
Google scopes like Calendar need Google's OAuth verification before public
launch, which takes weeks. Start it early and write that in backend.md.
Security checklist
Output
Working auth, database, payments in test mode, email and the integrations,
.env.example, replica/backend.md with the checklist ticked, feature
matrix rows updated. Next: /replica-test.
1---2name: replica-backend3description: >-4 Builds the backend of an app clone: auth, database migrations and access5 rules, payments with Stripe, email, background jobs and third-party6 integrations through official APIs only, plus a security checklist. Use when7 the user says "add login", "set up auth", "wire up the database", "add8 payments", "connect Stripe", "add Google Calendar", "send emails",9 "backend for my clone", or when /replica-build is running on fake data.10disable-model-invocation: true # skill-optimizer11metadata:12 source: https://skillmd.com/skills/slipcast-dev/replica-backend13---1415# replica-backend1617Reads `replica/architecture.md`. Writes migrations and server code, and keeps18`replica/backend.md` (checklist below) up to date.1920## The rules2122- **Official, public APIs only, with the user's own keys.** Never call the23 original app's private endpoints, never reuse its OAuth client, never proxy24 through it.25- **The user creates accounts and keys.** Claude never signs up for services,26 never types a password, card or live key. The user creates the Stripe,27 Supabase, Resend or Google Cloud project and puts keys in `.env.local`.28 Claude writes `.env.example` with every variable name and no values.29- **Test mode first.** Stripe test keys and test cards until replica-deploy.3031## Auth3233- Email sign up with verification, password reset, magic link if the original34 has it. OAuth (Google, Apple) with the user's own developer apps.35- Sessions: http-only secure cookies. Sign out everywhere.36- Roles and teams if the recon map has them: owner, admin, member, with one37 function that answers "can this user do this to this record".38- Account deletion that actually deletes. Apple requires it for apps with39 sign up.4041## Database4243- Migrations from `architecture.md`, checked in, run by a script.44- Access rules on every table: row level security policies on Supabase, or45 the authorisation function called in every query. Test it: a second user46 must get nothing back.47- Seed script with realistic fake data (no real people).48- Backups on (the host's daily backups count, check they are enabled).4950## Payments5152- Stripe Checkout for sign up to a plan, the Customer Portal for changes and53 cancelling. Do not build card forms.54- Webhooks: verify the signature, store the event id, make every handler55 idempotent (Stripe retries). Handle `checkout.session.completed`,56 `customer.subscription.updated`, `customer.subscription.deleted`,57 `invoice.payment_failed`.58- Subscription status lives in your database, updated by webhooks, read by59 your app. Never trust the client.60- Cancelling is one click. Hard-to-cancel billing is a top complaint about61 most apps, and in many places it is illegal.6263## Email and jobs6465- Transactional email through Resend or Postmark from your own domain.66 Templates written fresh.67- Jobs for anything time-based (reminders, digests, sync, cleanup) with68 retries and a dead-letter log. Times in UTC, shown in the user's zone.6970## Integrations7172For each integration in the feature matrix: the official API, the OAuth73scopes needed (fewest possible), the provider's review process, rate limits.74Google scopes like Calendar need Google's OAuth verification before public75launch, which takes weeks. Start it early and write that in `backend.md`.7677## Security checklist7879- [ ] secrets only in env vars, `.env*` in `.gitignore`, nothing in client bundles80- [ ] input validated on the server (zod or similar) on every route81- [ ] authorisation checked on every read and write, tested with a second user82- [ ] rate limits on auth, sign up, and anything that sends email or SMS83- [ ] webhooks verify signatures84- [ ] uploads: size and type limits, served from a separate domain or bucket85- [ ] no user data in URLs or logs86- [ ] dependencies audited (`npm audit`)87- [ ] privacy policy lists every processor (Stripe, Resend, host, analytics)8889## Output9091Working auth, database, payments in test mode, email and the integrations,92`.env.example`, `replica/backend.md` with the checklist ticked, feature93matrix rows updated. Next: `/replica-test`.