dubs-auth-skill
SKILL.md
Dubs Auth Integration Skill
Guide for implementing @wiseiodev/dubs-auth cleanly in consumer applications.
When To Use
- User asks to set up
dubs-auth, Better Auth + Stripe + Drizzle, or Next.js auth/billing routes. - User asks how to use package exports like
createDubsAuth,createBillingRouteHandlers,createDubsAuthClient, or subscription helpers. - User needs troubleshooting for webhook sync, billing portal redirects, or env wiring.
When Not To Use
- Maintaining this library's internal release/build/test workflows.
- Non-Next.js stacks that do not use App Router style route handlers.
Workflow (Follow In Order)
- Discover app context first.
- Detect package manager, Next.js App Router presence, DB adapter usage, and whether auth/billing routes already exist.
- Reuse existing app conventions before suggesting new structure.
- Plan the smallest vertical slice.
- Install package.
- Scaffold with CLI (
init,generate schema) when useful. - Wire env +
createDubsAuth+/api/auth/[...all].
- Add billing flow.
- Wire
/api/billing/portaland/api/stripe/webhook. - Resolve Stripe customer ID from current identity.
- Wire
- Add subscription persistence.
- Normalize Stripe events with
toDubsSubscriptionEvent. - Build patch via
deriveSubscriptionPatchFromEvent. - Apply idempotent upsert via
upsertSubscriptionRecord.
- Normalize Stripe events with
- Provide concrete verification.
- Include exact commands and route checks.
- Include expected success/failure signals.
- Prefer the
examples/next-app-routerflow as the default verification baseline.
Response Rules
- Best-practice-first guidance: production-safe defaults, explicit error handling, and idempotent webhook processing.
- Keep guidance grounded in real package exports and templates. Do not invent APIs.
- Prefer complete copy-paste snippets tied to concrete file locations.
- Always end with targeted validation commands and quick rollback/debug steps.
Verification Baseline (Use This First)
pnpm --dir examples/next-app-router install
pnpm --dir examples/next-app-router exec dubs-auth generate schema --cwd .
cp examples/next-app-router/.env.example examples/next-app-router/.env
pnpm --dir examples/next-app-router db:migrate
PORT=4000 pnpm --dir examples/next-app-router dev
Validate in order:
/sign-upcan create an account./sign-incan authenticate that account./dashboardshows sessioned state./billingworks for signed-in users.
Expected Stripe-optional behavior:
- If Stripe env vars are unset, billing portal/webhook routes should return a clear "not configured" response instead of crashing the app.
Troubleshooting Quick Fixes
If local PGlite files are unstable, reset and remigrate:
pnpm --dir examples/next-app-router exec node --input-type=module -e "import { rm } from 'node:fs/promises'; await rm('.data/dubs-auth', { recursive: true, force: true }); await rm('.data/dubs-auth-wal', { force: true }); await rm('.data/dubs-auth-shm', { force: true });"
pnpm --dir examples/next-app-router db:migrate
If auth requests hit the wrong port in local dev, ensure auth client/server base URL resolves to the current origin/port.
Reference Loading Map
- Bootstrap and scaffold flow:
references/bootstrap-and-scaffold.md - Runtime exports and usage patterns:
references/runtime-api-guide.md - Billing portal + webhook + idempotent subscription sync:
references/billing-webhook-patterns.md - Troubleshooting and production hardening:
references/troubleshooting-and-hardening.md
Weekly Installs
2
Repository
wiseiodev/dubs-authFirst Seen
4 days ago
Security Audits
Installed on
amp2
cline2
opencode2
cursor2
kimi-cli2
codex2