Skip to content

Preset

AI Product

Streaming chat, typed output and tool calling, on auth, Postgres and billing.

What this preset installs

  • 7

    Agents

  • 29

    Skills

  • 30

    Rules

  • 7

    Hooks

  • 75

    Solution docs

  • 5

    MCP servers

Counted from the manifests for this exact selection. Every agent reads the same AGENTS.md. Guard hooks run in Claude Code, Codex, Cursor, GitHub Copilot, Antigravity, Gemini CLI and Windsurf.

Why this one

Who it is for

For a product whose core loop is a model call. The Vercel AI SDK runs on Anthropic (or OpenAI). You get a streaming chat route and a chat page inside the signed-in app, plus Zod-checked structured output. A tool-calling scaffold ships with one read-only example tool.

Underneath is a working SaaS: sign-in with passwords, magic links and OAuth, a dashboard and settings, Polar billing with monthly, yearly and lifetime prices on a public /pricing page, and an admin panel with real users, bans, impersonation and an audit log. Better Auth, Drizzle on Neon Postgres, Resend, PostHog and Sentry.

Usage metering, background jobs, rate limits and tracing are left out on purpose. Solution docs cover when to add metering, jobs and tracing. Rules on src/lib/ai/** keep model calls on the server, streamed and schema-checked. /add-tool and /eval-prompt keep new work consistent.

AGENTS.md, skills, subagents and guard hooks work in Claude Code, Codex, Cursor, Copilot, Antigravity and every other agent that reads AGENTS.md.

Highlights

  • Vercel AI SDK on Anthropic: a streaming chat page in the signed-in app, and a Zod schema on every structured call
  • Tool-calling scaffold with one read-only example tool and a tool registry
  • Rules on src/lib/ai/**: server-only model calls, streaming, no untrusted text in system prompts
  • Polar checkout for monthly, yearly and lifetime prices, from a public /pricing page
  • Better Auth sign-in, plus an admin panel with bans, impersonation and an audit log
  • Solution docs on tool retries, streaming edge cases, metering, background jobs and tracing

The exact selection

Stack
Next.js on Vercel
Package manager
bun
Design system
Midnight
Mode
solo
AI tools
Claude Code, Codex, Cursor, GitHub Copilot, Antigravity, Gemini CLI, OpenCode, JetBrains AI, Windsurf, Kiro
Admin panel
included
AI bundle
anthropic: streaming chat, structured output, tool calling

The output

Read every file before you download it

The real generated repo for AI Product: 788 files, content hash 5a4aba834450. The same selection always produces the same bytes.

  • .agents/78 files
    • agents/7 files
      • db-inspector.md
      • designer.md
      • documentarian.md
      • pr-reviewer.md
      • product-analyst.md
      • security-auditor.md
      • system-manager.md
    • hooks/10 files
      • README.md
      • auto-lint.ts
      • block-destructive.ts
      • enforce-doc-meta.ts
      • enforce-typecheck.ts
      • env-leak-detector-write.ts
      • env-leak-detector.ts
      • guard-neon-sql.ts
      • guards.json
      • run.mjs
    • rules/30 files
      • admin-access.md
      • admin-mutations.md
      • ai-prompt-safety.md
      • ai-server-boundary.md
      • ai-structured-output.md
      • ai-tools.md
      • app-shell.md
      • auth-server-boundary.md
      • billing-core.md
      • code-style.md
      • deployment.md
      • drizzle-migrations.md
      • drizzle-schema.md
      • email-sending-discipline.md
      • event-naming.md
      • git.md
      • identify-timing.md
      • landing-and-legal.md
      • neon-connections.md
      • neon-migrations.md
      • polar-billing-adapter.md
      • polar-webhook-integrity.md
      • roles-are-server-side.md
      • security.md
      • sentry-capture.md
      • sentry-no-pii.md
      • server-truth-and-pii.md
      • testing.md
      • tokens-only.md
      • ui-kit.md
    • skills/29 files
      • add-admin-action/1 file
        • SKILL.md
      • add-admin-page/1 file
        • SKILL.md
      • add-app-page/1 file
        • SKILL.md
      • add-email-template/1 file
        • SKILL.md
      • add-event/1 file
        • SKILL.md
      • add-oauth-provider/1 file
        • SKILL.md
      • add-product/1 file
        • SKILL.md
      • add-table/1 file
        • SKILL.md
      • add-tool/1 file
        • SKILL.md
      • ask-product/1 file
        • SKILL.md
      • db-branch/1 file
        • SKILL.md
      • deploy-to-vercel/1 file
        • SKILL.md
      • edit-pricing/1 file
        • SKILL.md
      • eval-prompt/1 file
        • SKILL.md
      • help/1 file
        • SKILL.md
      • landing-copy/1 file
        • SKILL.md
      • migrate/1 file
        • SKILL.md
      • migrate-on-neon/1 file
        • SKILL.md
      • new-component/1 file
        • SKILL.md
      • preview-and-test-email/1 file
        • SKILL.md
      • protect-route/1 file
        • SKILL.md
      • qa-feature/1 file
        • SKILL.md
      • scrub-pii/1 file
        • SKILL.md
      • security-audit/1 file
        • SKILL.md
      • setup/1 file
        • SKILL.md
      • test-webhook/1 file
        • SKILL.md
      • triage-errors/1 file
        • SKILL.md
      • verify/1 file
        • SKILL.md
      • write-spec/1 file
        • SKILL.md
    • hooks.json
    • mcp_config.json
  • .aiassistant/1 file
    • rules/1 file
      • agents-md.md
  • .claude/65 files
    • agents/7 files
      • db-inspector.md
      • designer.md
      • documentarian.md
      • pr-reviewer.md
      • product-analyst.md
      • security-auditor.md
      • system-manager.md
    • rules/28 files
      • admin-access.md
      • admin-mutations.md
      • agents-md.md
      • ai-prompt-safety.md
      • ai-server-boundary.md
      • ai-structured-output.md
      • ai-tools.md
      • app-shell.md
      • auth-server-boundary.md
      • billing-core.md
      • deployment.md
      • drizzle-migrations.md
      • drizzle-schema.md
      • email-sending-discipline.md
      • event-naming.md
      • identify-timing.md
      • landing-and-legal.md
      • neon-connections.md
      • neon-migrations.md
      • polar-billing-adapter.md
      • polar-webhook-integrity.md
      • roles-are-server-side.md
      • sentry-capture.md
      • sentry-no-pii.md
      • server-truth-and-pii.md
      • testing.md
      • tokens-only.md
      • ui-kit.md
    • skills/29 files
      • add-admin-action/1 file
        • SKILL.md
      • add-admin-page/1 file
        • SKILL.md
      • add-app-page/1 file
        • SKILL.md
      • add-email-template/1 file
        • SKILL.md
      • add-event/1 file
        • SKILL.md
      • add-oauth-provider/1 file
        • SKILL.md
      • add-product/1 file
        • SKILL.md
      • add-table/1 file
        • SKILL.md
      • add-tool/1 file
        • SKILL.md
      • ask-product/1 file
        • SKILL.md
      • db-branch/1 file
        • SKILL.md
      • deploy-to-vercel/1 file
        • SKILL.md
      • edit-pricing/1 file
        • SKILL.md
      • eval-prompt/1 file
        • SKILL.md
      • help/1 file
        • SKILL.md
      • landing-copy/1 file
        • SKILL.md
      • migrate/1 file
        • SKILL.md
      • migrate-on-neon/1 file
        • SKILL.md
      • new-component/1 file
        • SKILL.md
      • preview-and-test-email/1 file
        • SKILL.md
      • protect-route/1 file
        • SKILL.md
      • qa-feature/1 file
        • SKILL.md
      • scrub-pii/1 file
        • SKILL.md
      • security-audit/1 file
        • SKILL.md
      • setup/1 file
        • SKILL.md
      • test-webhook/1 file
        • SKILL.md
      • triage-errors/1 file
        • SKILL.md
      • verify/1 file
        • SKILL.md
      • write-spec/1 file
        • SKILL.md
    • settings.json
  • .codex/9 files
    • agents/7 files
      • db-inspector.toml
      • designer.toml
      • documentarian.toml
      • pr-reviewer.toml
      • product-analyst.toml
      • security-auditor.toml
      • system-manager.toml
    • config.toml
    • hooks.json
  • .cursor/31 files
    • agents/7 files
      • db-inspector.md
      • designer.md
      • documentarian.md
      • pr-reviewer.md
      • product-analyst.md
      • security-auditor.md
      • system-manager.md
    • rules/22 files
      • admin-mutations.mdc
      • ai-server-boundary.mdc
      • ai-structured-output.mdc
      • ai-tools.mdc
      • auth-server-boundary.mdc
      • billing-core.mdc
      • deployment.mdc
      • drizzle-migrations.mdc
      • email-sending-discipline.mdc
      • event-naming.mdc
      • identify-timing.mdc
      • landing-and-legal.mdc
      • neon-connections.mdc
      • neon-migrations.mdc
      • polar-billing-adapter.mdc
      • roles-are-server-side.mdc
      • sentry-capture.mdc
      • sentry-no-pii.mdc
      • server-truth-and-pii.mdc
      • testing.mdc
      • tokens-only.mdc
      • ui-kit.mdc
    • hooks.json
    • mcp.json
  • .devin/1 file
    • hooks.v1.json
  • .gemini/8 files
    • agents/7 files
      • db-inspector.md
      • designer.md
      • documentarian.md
      • pr-reviewer.md
      • product-analyst.md
      • security-auditor.md
      • system-manager.md
    • settings.json
  • .github/9 files
    • agents/7 files
      • db-inspector.agent.md
      • designer.agent.md
      • documentarian.agent.md
      • pr-reviewer.agent.md
      • product-analyst.agent.md
      • security-auditor.agent.md
      • system-manager.agent.md
    • copilot/1 file
      • settings.json
    • hooks/1 file
      • agentic-guards.json
  • .junie/1 file
    • mcp/1 file
      • mcp.json
  • .kiro/52 files
    • settings/1 file
      • mcp.json
    • skills/29 files
      • add-admin-action/1 file
        • SKILL.md
      • add-admin-page/1 file
        • SKILL.md
      • add-app-page/1 file
        • SKILL.md
      • add-email-template/1 file
        • SKILL.md
      • add-event/1 file
        • SKILL.md
      • add-oauth-provider/1 file
        • SKILL.md
      • add-product/1 file
        • SKILL.md
      • add-table/1 file
        • SKILL.md
      • add-tool/1 file
        • SKILL.md
      • ask-product/1 file
        • SKILL.md
      • db-branch/1 file
        • SKILL.md
      • deploy-to-vercel/1 file
        • SKILL.md
      • edit-pricing/1 file
        • SKILL.md
      • eval-prompt/1 file
        • SKILL.md
      • help/1 file
        • SKILL.md
      • landing-copy/1 file
        • SKILL.md
      • migrate/1 file
        • SKILL.md
      • migrate-on-neon/1 file
        • SKILL.md
      • new-component/1 file
        • SKILL.md
      • preview-and-test-email/1 file
        • SKILL.md
      • protect-route/1 file
        • SKILL.md
      • qa-feature/1 file
        • SKILL.md
      • scrub-pii/1 file
        • SKILL.md
      • security-audit/1 file
        • SKILL.md
      • setup/1 file
        • SKILL.md
      • test-webhook/1 file
        • SKILL.md
      • triage-errors/1 file
        • SKILL.md
      • verify/1 file
        • SKILL.md
      • write-spec/1 file
        • SKILL.md
    • steering/22 files
      • admin-mutations.md
      • ai-server-boundary.md
      • ai-structured-output.md
      • ai-tools.md
      • auth-server-boundary.md
      • billing-core.md
      • deployment.md
      • drizzle-migrations.md
      • email-sending-discipline.md
      • event-naming.md
      • identify-timing.md
      • landing-and-legal.md
      • neon-connections.md
      • neon-migrations.md
      • polar-billing-adapter.md
      • roles-are-server-side.md
      • sentry-capture.md
      • sentry-no-pii.md
      • server-truth-and-pii.md
      • testing.md
      • tokens-only.md
      • ui-kit.md
  • .opencode/7 files
    • agents/7 files
      • db-inspector.md
      • designer.md
      • documentarian.md
      • pr-reviewer.md
      • product-analyst.md
      • security-auditor.md
      • system-manager.md
  • .vscode/2 files
    • extensions.json
    • settings.json
  • docs/78 files
    • plans/2 files
      • README.md
      • TEMPLATE.md
    • solutions/76 files
      • admin-panel/8 files
        • adding-an-audit-log.md
        • bans-and-session-revocation.md
        • empty-states-that-are-not-sad.md
        • first-admin-without-a-backdoor.md
        • impersonating-users-safely.md
        • paginating-a-users-table.md
        • role-checks-that-survive-a-refactor.md
        • route-group-vs-path-segment.md
      • ai-bundle/6 files
        • prompt-injection-through-user-content.md
        • streaming-edge-cases.md
        • tool-retries-and-partial-failures.md
        • when-to-add-usage-metering.md
        • when-to-move-ai-work-to-a-background-job.md
        • when-tracing-pays-for-itself.md
      • better-auth/10 files
        • account-linking-and-email-verification.md
        • better-auth-on-the-edge.md
        • csrf-and-cookie-flags.md
        • guarding-the-auth-api-itself.md
        • magic-link-tokens-and-scanners.md
        • migrating-an-existing-user-table.md
        • oauth-callback-url-mismatches.md
        • password-reset-tokens.md
        • role-modelling-for-the-admin-panel.md
        • session-invalidation-and-logged-out-on-deploy.md
      • drizzle/5 files
        • adding-a-column-with-a-backfill.md
        • generate-vs-push.md
        • relations-vs-joins.md
        • transactions-in-serverless.md
        • typing-partial-selects.md
      • midnight/4 files
        • a-chart-palette-that-survives-dark-mode.md
        • class-and-system-dark-mode-that-both-work.md
        • pasting-shadcn-components-into-your-own-token-names.md
        • tailwind-v4-dark-mode-does-nothing.md
      • neon/6 files
        • branch-per-preview-deployment.md
        • cold-start-latency.md
        • connection-exhaustion-in-serverless.md
        • local-postgres-without-a-neon-account.md
        • migrations-on-vercel.md
        • pooled-vs-unpooled-connections.md
      • nextjs-vercel/15 files
        • auth-checks-in-an-app-shell.md
        • compound-engineering-loop.md
        • env-vars-on-vercel-without-leaking-them.md
        • guard-hooks-and-how-to-extend-them.md
        • llms-txt-for-a-saas-site.md
        • one-time-purchases-vs-subscriptions.md
        • pricing-page-without-a-database.md
        • privacy-policy-that-lists-your-real-vendors.md
        • rate-limiting-checkout-in-postgres.md
        • refunds-disputes-and-entitlements.md
        • regenerate-from-config-and-diff.md
        • rules-skills-agents-when-to-use-each.md
        • sample-testimonials-without-the-ftc-risk.md
        • sidebar-state-without-a-flash.md
        • writing-path-scoped-rules-agents-follow.md
      • polar/6 files
        • merchant-of-record-vs-stripe.md
        • migrate-a-stripe-catalogue-to-polar.md
        • one-time-and-subscription-products-on-polar.md
        • refunds-and-disputes-on-polar.md
        • sandbox-to-production-checklist.md
        • webhook-idempotency.md
      • posthog/5 files
        • ad-blocker-reverse-proxy.md
        • event-naming-that-survives.md
        • feature-flags-without-flicker.md
        • identify-race-conditions.md
        • server-vs-client-events.md
      • resend/5 files
        • batching-and-rate-limits.md
        • bounces-complaints-and-webhooks.md
        • domain-verification-spf-dkim-dmarc.md
        • magic-link-deliverability.md
        • previewing-templates-locally.md
      • sentry/5 files
        • grouping-noisy-errors-with-fingerprints.md
        • scrubbing-pii-before-it-leaves-the-process.md
        • source-maps-on-vercel.md
        • telling-a-real-incident-from-a-bot.md
        • trace-sample-rates-that-do-not-bankrupt-you.md
      • README.md
  • drizzle/1 file
    • AGENTS.md
  • scripts/22 files
    • admin/3 files
      • AGENTS.md
      • grant.ts
      • load-env.ts
    • auth/2 files
      • make-admin.ts
      • seed.ts
    • billing/5 files
      • AGENTS.md
      • prune-events.ts
      • reconcile.ts
      • sync-plans.ts
      • test-webhook.ts
    • email/2 files
      • render-samples.ts
      • send-test.ts
    • lib/1 file
      • env-file.ts
    • ai-eval.ts
    • ai-models.ts
    • db-branch.ts
    • neon-local-proxy.ts
    • sentry-issues.ts
    • setup-env.json
    • setup-env.ts
    • verify-hooks.ts
    • verify.ts
  • src/372 files
    • app/68 files
      • (admin)/14 files
        • admin/12 files
          • audit/2 files
            • loading.tsx
            • page.tsx
          • settings/2 files
            • loading.tsx
            • page.tsx
          • users/4 files
            • [id]/2 files
              • loading.tsx
              • page.tsx
            • loading.tsx
            • page.tsx
          • error.tsx
          • loading.tsx
          • not-found.tsx
          • page.tsx
        • AGENTS.md
        • layout.tsx
      • (app)/17 files
        • billing/5 files
          • checkout/1 file
            • route.ts
          • AGENTS.md
          • error.tsx
          • loading.tsx
          • page.tsx
        • chat/1 file
          • page.tsx
        • dashboard/1 file
          • page.tsx
        • settings/5 files
          • profile/1 file
            • page.tsx
          • security/1 file
            • page.tsx
          • layout.tsx
          • loading.tsx
          • page.tsx
        • AGENTS.md
        • error.tsx
        • layout.tsx
        • loading.tsx
        • not-found.tsx
      • (better-auth)/7 files
        • banned/1 file
          • page.tsx
        • forgot-password/1 file
          • page.tsx
        • reset-password/1 file
          • page.tsx
        • sign-in/1 file
          • page.tsx
        • sign-up/1 file
          • page.tsx
        • AGENTS.md
        • layout.tsx
      • (legal)/2 files
        • privacy/1 file
          • page.tsx
        • terms/1 file
          • page.tsx
      • api/13 files
        • admin/1 file
          • AGENTS.md
        • agent/2 files
          • AGENTS.md
          • route.ts
        • auth/2 files
          • [...all]/1 file
            • route.ts
          • AGENTS.md
        • chat/2 files
          • AGENTS.md
          • route.ts
        • health/1 file
          • route.ts
        • webhooks/4 files
          • polar/2 files
            • AGENTS.md
            • route.ts
          • resend/2 files
            • AGENTS.md
            • route.ts
        • AGENTS.md
      • ingest/1 file
        • [...path]/1 file
          • route.ts
      • llms.txt/1 file
        • route.ts
      • pricing/2 files
        • AGENTS.md
        • page.tsx
      • AGENTS.md
      • error.tsx
      • fonts.ts
      • global-error.tsx
      • globals.css
      • layout.tsx
      • loading.tsx
      • not-found.tsx
      • page.tsx
      • robots.ts
      • sitemap.ts
    • components/146 files
      • admin/26 files
        • AGENTS.md
        • admin-header.tsx
        • admin-shell.tsx
        • admin-shortcut-card.tsx
        • admin-sidebar.tsx
        • audit-details.tsx
        • audit-feed.tsx
        • audit-filters.tsx
        • audit-table.tsx
        • ban-dialog.tsx
        • billing-summary.tsx
        • confirm-action-dialog.tsx
        • grant-admin-form.tsx
        • impersonation-banner.tsx
        • revoke-session-button.tsx
        • sessions-table.tsx
        • stat-card.tsx
        • stop-impersonating-button.tsx
        • use-admin-action.ts
        • use-provider-sign-out.ts
        • user-actions.tsx
        • user-badges.tsx
        • user-identity.tsx
        • users-filters.tsx
        • users-pagination.tsx
        • users-table.tsx
      • ai/2 files
        • AGENTS.md
        • chat.tsx
      • app/11 files
        • AGENTS.md
        • account-card.tsx
        • app-header.tsx
        • app-shell.tsx
        • app-sidebar.tsx
        • dashboard-card.tsx
        • empty-state.tsx
        • page-header.tsx
        • settings-nav.tsx
        • user-avatar.tsx
        • user-menu.tsx
      • auth/23 files
        • settings/6 files
          • connected-accounts-card.tsx
          • email-card.tsx
          • password-card.tsx
          • profile-card.tsx
          • reauthenticate-alert.tsx
          • sessions-card.tsx
        • AGENTS.md
        • account-settings.tsx
        • auth-card.tsx
        • auth-setup-notice.tsx
        • check-inbox.tsx
        • focus-first-error.ts
        • forgot-password-form.tsx
        • header-actions.tsx
        • magic-link-form.tsx
        • oauth-buttons.tsx
        • password-input.tsx
        • provider-icons.tsx
        • reset-password-form.tsx
        • session-provider.tsx
        • sign-in-form.tsx
        • sign-out-button.tsx
        • sign-up-form.tsx
      • billing/13 files
        • AGENTS.md
        • billing-notices.tsx
        • checkout-pending.tsx
        • current-plan-card.tsx
        • plan-card.tsx
        • plan-status.tsx
        • plan-summary-card.tsx
        • portal-button.tsx
        • pricing-faq.tsx
        • pricing-notice.tsx
        • pricing-preview.tsx
        • pricing-table.tsx
        • purchase-history.tsx
      • dashboard/5 files
        • card-action.tsx
        • chart-area-interactive.tsx
        • data-table.tsx
        • data.json
        • section-cards.tsx
      • marketing/18 files
        • AGENTS.md
        • brand.tsx
        • cta-band.tsx
        • faq.tsx
        • feature-grid.tsx
        • hero.tsx
        • json-ld.tsx
        • legal-document.tsx
        • logo-cloud.tsx
        • product-preview.tsx
        • sample-badge.tsx
        • section-heading.tsx
        • showcase-visuals.tsx
        • showcase.tsx
        • smart-link.tsx
        • social-icons.tsx
        • steps.tsx
        • testimonials.tsx
      • observability/1 file
        • sentry-identity.tsx
      • site/7 files
        • AGENTS.md
        • auth-frame.tsx
        • chrome.tsx
        • footer.tsx
        • header.tsx
        • mobile-nav.tsx
        • nav-link.tsx
      • theme/2 files
        • theme-provider.tsx
        • theme-toggle.tsx
      • ui/37 files
        • AGENTS.md
        • accordion.tsx
        • alert-dialog.tsx
        • alert.tsx
        • avatar.tsx
        • badge.tsx
        • breadcrumb.tsx
        • button.tsx
        • card.tsx
        • chart.tsx
        • checkbox.tsx
        • collapsible.tsx
        • dialog.tsx
        • drawer.tsx
        • dropdown-menu.tsx
        • field.tsx
        • input.tsx
        • kbd.tsx
        • label.tsx
        • pagination.tsx
        • popover.tsx
        • progress.tsx
        • radio-group.tsx
        • select.tsx
        • separator.tsx
        • sheet.tsx
        • sidebar.tsx
        • skeleton.tsx
        • spinner.tsx
        • switch.tsx
        • table.tsx
        • tabs.tsx
        • textarea.tsx
        • toaster.tsx
        • toggle-group.tsx
        • toggle.tsx
        • tooltip.tsx
      • AGENTS.md
    • db/18 files
      • AGENTS.md
      • README.md
      • audit.ts
      • billing-schema.ts
      • client.ts
      • connection-url.ts
      • direct-url.ts
      • driver.ts
      • drizzle.ts
      • email-schema.ts
      • health.ts
      • index.ts
      • load-env.ts
      • migrate.ts
      • neon-local.ts
      • schema.ts
      • tables.ts
      • verify.ts
    • hooks/1 file
      • use-mobile.ts
    • lib/135 files
      • admin/16 files
        • AGENTS.md
        • actions.ts
        • audit-store.ts
        • audit.ts
        • contract.ts
        • cursor.ts
        • format.test.ts
        • format.ts
        • policy.test.ts
        • policy.ts
        • provider.ts
        • query.test.ts
        • query.ts
        • types.ts
        • user-store.ts
        • users.ts
      • ai/17 files
        • evals/2 files
          • index.ts
          • support-triage.ts
        • tools/2 files
          • index.ts
          • search-knowledge-base.ts
        • AGENTS.md
        • access.ts
        • agent.ts
        • eval.ts
        • http.ts
        • knowledge-base.ts
        • messages.ts
        • models.ts
        • prompt.ts
        • provider.ts
        • schemas.ts
        • structured.ts
        • untrusted.ts
      • analytics/6 files
        • AGENTS.md
        • events.ts
        • identify.ts
        • posthog-client.ts
        • posthog-server.ts
        • provider.tsx
      • auth/24 files
        • AGENTS.md
        • action-limit.test.ts
        • action-limit.ts
        • actions.ts
        • adapter.ts
        • auth.ts
        • client.ts
        • endpoint-guard.test.ts
        • endpoint-guard.ts
        • errors.ts
        • guards.test.ts
        • list-sessions.test.ts
        • list-sessions.ts
        • policy.ts
        • providers.test.ts
        • providers.ts
        • roles.ts
        • schema.ts
        • schemas.ts
        • secret.ts
        • session.ts
        • setup.ts
        • user-agent.test.ts
        • user-agent.ts
      • billing/34 files
        • AGENTS.md
        • actions.ts
        • catalog.test.ts
        • catalog.ts
        • checkout.ts
        • entitlement.test.ts
        • entitlement.ts
        • entitlements.ts
        • errors.ts
        • format.ts
        • index.ts
        • origin.ts
        • overview.ts
        • polar-objects.test.ts
        • polar-objects.ts
        • polar-webhooks.test.ts
        • polar-webhooks.ts
        • polar.ts
        • price-refs.ts
        • provider.ts
        • purchase-sql.ts
        • rate-limit-rules.test.ts
        • rate-limit-rules.ts
        • rate-limit-sql.ts
        • rate-limit.test.ts
        • rate-limit.ts
        • receipt.ts
        • report.ts
        • sign-up-url.ts
        • store.ts
        • types.ts
        • user.ts
        • webhook.test.ts
        • webhook.ts
      • email/16 files
        • templates/6 files
          • magic-link.tsx
          • receipt.tsx
          • reset-password.tsx
          • theme.ts
          • verify-email.tsx
          • welcome.tsx
        • AGENTS.md
        • address.ts
        • index.ts
        • observability.ts
        • outbox.ts
        • resend.ts
        • retry.ts
        • store.ts
        • suppression.ts
        • tags.ts
      • observability/2 files
        • scrub.ts
        • sentry.ts
      • AGENTS.md
      • app-shell.test.ts
      • app-shell.ts
      • client-ip.test.ts
      • client-ip.ts
      • cn.test.ts
      • cn.ts
      • cx.ts
      • design.ts
      • env.ts
      • llms.test.ts
      • llms.ts
      • nav.test.ts
      • nav.ts
      • pricing.ts
      • routes.ts
      • site.test.ts
      • site.ts
      • validate.ts
      • verify.ts
    • AGENTS.md
    • instrumentation-client.ts
    • instrumentation.ts
    • proxy.ts
  • tests/30 files
    • e2e/14 files
      • admin.spec.ts
      • app-shell.spec.ts
      • auth.setup.ts
      • auth.spec.ts
      • auth.ts
      • billing-webhook.spec.ts
      • checkout.spec.ts
      • fixtures.ts
      • impersonation-lock.spec.ts
      • landing.spec.ts
      • legal.spec.ts
      • outbox.ts
      • pricing.spec.ts
      • users.ts
    • unit/14 files
      • ai-access.test.ts
      • ai-chat-route.test.ts
      • ai-eval.test.ts
      • ai-messages.test.ts
      • ai-mock-model.ts
      • ai-models.test.ts
      • ai-structured.test.ts
      • ai-tools.test.ts
      • ai-untrusted.test.ts
      • email-outbox.test.ts
      • email.test.ts
      • env.test.ts
      • scrub.test.ts
      • setup-env.test.ts
    • AGENTS.md
    • smoke.spec.ts
  • .env.example
  • .gitignore
  • .mcp.json
  • AGENTS.md
  • DESIGN.md
  • README.md
  • SETUP.md
  • agentic.config.json
  • biome.jsonc
  • components.json
  • drizzle.config.ts
  • next.config.ts
  • opencode.json
  • package.json
  • playwright.config.ts
  • postcss.config.mjs
  • sentry.edge.config.ts
  • sentry.server.config.ts
  • tsconfig.json
  • vercel.json
  • vitest.config.ts

The three files that do the work

AGENTS.mdmarkdown339 lines
# my-app

Generated by [Agentic Boilerplate](https://github.com/agentic-studio/agentic-boilerplate) from [Agentic Studio](https://theagentic.studio). Same `agentic.config.json`, same repo: regenerate and diff any time.

- **Stack:** Next.js on Vercel (`nextjs-vercel`)
- **Services:** Drizzle ORM (`drizzle`), Neon (`neon`), Better Auth (`better-auth`), Polar (`polar`), Resend (`resend`), Sentry (`sentry`), PostHog (`posthog`), AI bundle (`ai-bundle`), Admin panel (`admin-panel`)
- **Design:** Midnight (`midnight`). Every UI change follows [DESIGN.md](DESIGN.md).
- **Package manager:** bun
- **Mode:** solo

## Start here

On a fresh clone, run the `setup` skill: `/setup` in most agents, `$setup` in Codex.
It reads [SETUP.md](SETUP.md), which lists every environment variable, where to get
it, and the order to set the services up.

```sh
bun install
bun run setup:env -- --check   # what .env.local still needs
bun run verify
bun run dev
```

## How this repo is set up for agents

This file is the instruction file every agent reads. It holds the rules for the whole repo.

- A folder with its own `AGENTS.md` adds the rules for the files under it. Before you edit a file, read every `AGENTS.md` from the repo root down to its folder. Most agents load them for you.
- `.agents/rules/`: all 30 rules in full, one file each.
- `.agents/skills/`: 29 skills, listed below.
- `.agents/agents/`: 7 subagents, listed below. Agents with their own folder get a copy: `.claude/agents/`, `.codex/agents/`, `.cursor/agents/`, `.github/agents/`, `.gemini/agents/`, `.opencode/agents/`.
- `.agents/hooks/`: 7 guard hooks. They block destructive commands and keep secrets out of the chat. Wired for Claude Code, Codex, Cursor, GitHub Copilot, Antigravity, Gemini CLI and Windsurf. `bun run verify:hooks` proves they still block.
- MCP servers: `better-auth`, `neon`, `polar`, `posthog`, `sentry`. [SETUP.md](SETUP.md) says how to connect them in each agent.
- `docs/solutions/`: 75 solved problems. Read the relevant one before you re-solve anything.
- `docs/plans/`: one plan per unit of work.
- The `system-manager` subagent owns this agent setup: `AGENTS.md`, `.agents/` and each agent's own folder.

## Workflow

The Compound Engineering plugin adds the loop: `/ce-brainstorm`, `/ce-plan`, `/ce-work`, `/ce-code-review`, `/ce-compound`.
In Codex they start with `$`. [SETUP.md](SETUP.md) has the install line for each agent.

## Repo-wide rules

### Code style and file conventions

Source: `nextjs-vercel`

These are checkable statements. Before you finish a task, re-read the files you
touched and confirm each one.

#### Language and formatting

- TypeScript everywhere. `.js` files exist only in generated output and config
  that cannot be TS (`postcss.config.mjs`). Never add a new `.js` source file.
- Formatting is Biome's job, not yours. Two-space indent, double quotes,
  semicolons, trailing commas where Biome puts them. If you are unsure how
  something should be formatted, run `bun run lint` and accept the result.
- `strict` and `noUncheckedIndexedAccess` are on. An indexed read is
  `T | undefined`; narrow it, do not cast it away.
- `any` is never allowed in an exported signature. Inside a function body,
  prefer `unknown` plus a narrowing check. `as` casts need a comment saying why
  the compiler cannot see what you can.
- No `@ts-ignore`. `@ts-expect-error` is allowed only with a one-line reason on
  the same comment.

#### Toolchain majors

Examples online often target older majors. These are the ones installed here:

- **TypeScript 7** (the native `tsc`). It has no JavaScript API, so `next build`
  type-checks through the `tsc` CLI. Never add `baseUrl` to `tsconfig.json`:
  TS 7 rejects it, and `paths` entries are already relative to the file.
  `types` is `["node"]`, so a package that only adds globals must be listed
  there to be seen.
- **Zod 4**. Read failures from `error.issues` (`.errors` is gone). Custom
  messages use `{ error: "..." }`, not `message`, `required_error` or
  `errorMap`. Formats are top level: `z.email()`, `z.url()`, `z.uuid()`.
  `z.record()` takes a key and a value schema. For form errors use
  `z.flattenError(error)` or `z.treeifyError(error)`.
- **Vitest 5**. `vi.mock()` must sit at the top level of the file. Mock call
  history is cleared before every test.

#### Modules and exports

- Named exports only, except where a framework demands a default: Next.js
  `page.tsx`, `layout.tsx`, `route.ts` handlers, `error.tsx`, `global-error.tsx`,
  `not-found.tsx`, `loading.tsx`, `robots.ts`, `sitemap.ts`, and
  `next.config.ts`.
- Request interception lives in `src/proxy.ts` and exports a **named** `proxy`
  function, not a default. `middleware.ts` is the deprecated spelling of the same
  file and this repo does not generate one. A search result telling you to
  create it predates Next 16, and a `middleware.ts` next to `proxy.ts` fails the
  build ("Both middleware file and proxy file are detected").
- Import from the alias root: `@/lib/...`, `@/components/...`. Relative imports
  are for siblings inside the same feature folder only. Never `../../../`.
- One concern per file. If a file exports more than one unrelated public thing,
  split it.

#### Naming

- Files: `kebab-case.ts`. React components: `PascalCase` inside a
  `kebab-case.tsx` file.
- Functions and variables: `camelCase`. Types and interfaces: `PascalCase`, no
  `I` prefix. Constants that are true module-level constants: `SCREAMING_SNAKE`.
- Booleans read as predicates: `isLoading`, `hasSession`, `canPublish`.
- Async functions that fetch return the noun (`getUser`), functions that mutate
  use a verb that says so (`createUser`, `revokeSession`).

#### Server and client boundary

- Server Components are the default. Add `"use client"` only when the file
  needs state, effects, refs, or browser-only APIs, and put it as high in the
  tree as the interactivity actually requires, not on a whole page.
- Never import anything from `src/lib/**` that reads a non-`NEXT_PUBLIC_` env
  var into a `"use client"` file. That is how secrets reach the browser.
- Data fetching lives in Server Components or Route Handlers. A client
  component receives data as props or through a documented client SDK.

#### Errors

- Throw `Error` subclasses with a message a human can act on. No bare strings.
- Route Handlers return a typed JSON body and a correct status code. Never leak
  a stack trace, a SQL string, or a provider error object to the client.
- Do not swallow errors. An empty `catch {}` is a bug unless it has a comment
  explaining the exact condition being ignored.

#### Comments

- Comments explain *why*. If a comment restates the code, delete it.
- Match the comment density of the file you are editing.
- No commented-out code. Git remembers it.

### Git and change hygiene

Source: `nextjs-vercel`

#### Branches

- Never commit directly to `main`. Branch first:
  `feat/<short-slug>`, `fix/<short-slug>`, `chore/<short-slug>`,
  `docs/<short-slug>`.
- One branch per plan. If the work splits, the plan splits first.

#### Commits

- Conventional Commits: `type(scope): summary`. Types: `feat`, `fix`, `chore`,
  `docs`, `refactor`, `test`, `perf`, `build`.
- The summary says what changed and why it matters, in the imperative, under 72
  characters. `fix(billing): reject webhooks with a stale timestamp`, not
  `fix stuff`.
- A commit is one coherent change. Formatting churn goes in its own commit so
  review stays readable.
- Never commit generated artefacts, `node_modules`, build output, `.env` files
  of any kind other than `.env.example`, or editor settings.
- Never commit while untracked files are present: either `git add` them or add
  them to `.gitignore`, then commit. In team mode the `enforce-git-tracked`
  hook refuses the commit until you do. Solo mode does not install that hook, so
  the check is on you. Do not work around either.

#### What you must never run

These are blocked by the `block-destructive` hook and must not be attempted
another way:

- `git push --force` on a shared branch. Use `--force-with-lease` on your own
  branch, and only after confirming nobody else is on it.
- `git reset --hard`: it destroys uncommitted work that is not yours to
  destroy. `git stash` instead.
- `git clean -fd`, which deletes untracked files you were never shown.
- Rewriting history that has been pushed and reviewed.

#### Pull requests

- The PR description states the problem, the approach, and how it was verified.
  Link the plan in `docs/plans/` and the preview URL.
- Keep PRs reviewable. Over roughly 400 changed lines, split or explain why not.
- Every review comment is either addressed in code or answered in a reply. None
  are silently closed.
- Squash-merge; the PR title becomes the commit message, so it follows the
  commit rules above.

#### Before you say a task is done

1. `bun run typecheck`, `bun run lint`, `bun run test` are green.
2. `git status` is clean apart from the intended change.
3. `git diff --staged` has been read end to end by you: no stray debug logs, no
   commented-out code, no secrets.
4. Anything you learned that would help next time is written to
   `docs/solutions/` as a solution doc.

### Security rules

Source: `nextjs-vercel`

The guard hooks in `.agents/hooks/` enforce a subset of this mechanically. The
rest is on you. Assume every one of these will be audited by the
`security-auditor` agent before a release.

#### Secrets

- Real secret values live in `.env.local` and in the hosting provider's
  environment settings. Nowhere else. Not in `.env.example`, not in a test, not
  in a comment, not in a commit message, not in a log line, not in a doc.
- `.env.example` lists every key with a placeholder that is obviously fake and a
  comment saying where to get the real one.
- Never `echo`, `cat`, `console.log`, or interpolate a secret into a shell
  command, a URL, an error message, or an analytics event.
- Only `NEXT_PUBLIC_`-prefixed variables may be read from client code. A
  non-prefixed variable read in a `"use client"` file is a leak even if the code
  path looks unreachable.
- Read server env vars through `env()` in `src/lib/env.ts`, inside the function
  that needs them. Never at module scope: `next build` runs without your
  secrets, so a module-scope read throws during the build. Do not sprinkle
  `process.env.X` through feature code.
- If a secret is ever exposed, rotate it first and clean history second. Never
  the other way round.

#### Authentication and authorisation

- Authorisation is checked on the server, on every request, in the handler that
  does the work. A hidden button is not access control.
- Never trust a user id, role, tenant id, or plan from the client. Derive them
  from the session on the server.
- Route Handlers and Server Actions each carry their own check. Middleware is a
  convenience layer, not the boundary.
- Sessions are httpOnly, `secure` in production, `sameSite=lax` or stricter.
- No custom crypto. Use the provider's primitives. No hand-rolled token
  formats, no `Math.random()` for anything security-relevant: `node:crypto`
  `randomUUID` or `randomBytes`.

#### Input and output

- Every external input is parsed with a Zod schema at the boundary: request
  bodies, query params, route params, webhook payloads, form data. Downstream
  code receives the parsed type, never the raw value. `src/lib/validate.ts` has
  `parseBody`, `parseQuery` and `parseForm`: each returns either the parsed data
  or the 400 response to return, so a handler cannot forget to reject.
- A validation error names the field and the problem, never the value. Echoing a
  rejected password, token or card number puts it in a log.
- Database access goes through the ORM's parameterised query builder. Raw SQL
  requires bound parameters: string interpolation into SQL is never acceptable.
- Never render unsanitised user HTML. `dangerouslySetInnerHTML` requires a
  sanitiser and a comment naming it.
- Redirects to a user-supplied URL must be validated against an allowlist of
  paths on this origin.

#### Response headers

- The security headers every route carries are in `next.config.ts`, not in
  `src/proxy.ts`: `headers()` applies to static assets and cached responses too,
  and the proxy does not run for those.
- A battery that needs a wider policy appends a rule at the `security-headers`
  slot **scoped to its own routes**. An entry matching `/:path*` silently undoes
  the block for the whole app.
- Adding a third-party script origin is a decision, not a formality. Say in the
  comment which battery needs it and why.

#### Webhooks

- Verify the signature against the raw request body before parsing it. If the
  framework has already parsed the body, you have already lost: read the raw
  body explicitly.
- Reject events older than a small window to blunt replay.
- Handlers are idempotent: record the provider's event id and no-op on a repeat.
- Return 2xx quickly. Do the slow part after acknowledging, or the provider will
  retry and you will process twice.

#### Dependencies and logging

- New dependencies need a reason. Prefer the platform, then the ORM/SDK already
  installed, then a new package.
- Pin ranges the lockfile can resolve reproducibly. Never install from a git URL
  or a tarball.
- Logs and error-tracking breadcrumbs carry no PII and no tokens. Log ids, not
  people.

### More rules

Too long to copy here. Read each one before you edit a file it applies to.

- `.agents/rules/sentry-no-pii.md`: No personal data in breadcrumbs, tags or extra (`**`)

## Scoped rules

- `drizzle/AGENTS.md` (1 rule)
- `scripts/admin/AGENTS.md` (1 rule)
- `scripts/billing/AGENTS.md` (1 rule)
- `src/AGENTS.md` (3 rules)
- `src/app/AGENTS.md` (7 rules)
- `src/app/(admin)/AGENTS.md` (1 rule)
- `src/app/(app)/AGENTS.md` (1 rule)
- `src/app/(app)/billing/AGENTS.md` (1 rule)
- `src/app/(better-auth)/AGENTS.md` (1 rule)
- `src/app/api/AGENTS.md` (3 rules)
- `src/app/api/admin/AGENTS.md` (1 rule)
- `src/app/api/agent/AGENTS.md` (2 rules)
- `src/app/api/auth/AGENTS.md` (1 rule)
- `src/app/api/chat/AGENTS.md` (1 rule)
- `src/app/api/webhooks/polar/AGENTS.md` (1 rule)
- `src/app/api/webhooks/resend/AGENTS.md` (1 rule)
- `src/app/pricing/AGENTS.md` (1 rule)
- `src/components/AGENTS.md` (6 rules)
- `src/components/admin/AGENTS.md` (2 rules)
- `src/components/ai/AGENTS.md` (1 rule)
- `src/components/app/AGENTS.md` (1 rule)
- `src/components/auth/AGENTS.md` (1 rule)
- `src/components/billing/AGENTS.md` (1 rule)
- `src/components/marketing/AGENTS.md` (1 rule)
- `src/components/site/AGENTS.md` (1 rule)
- `src/components/ui/AGENTS.md` (1 rule)
- `src/db/AGENTS.md` (4 rules)
- `src/lib/AGENTS.md` (4 rules)
- `src/lib/admin/AGENTS.md` (2 rules)
- `src/lib/ai/AGENTS.md` (4 rules)
- `src/lib/analytics/AGENTS.md` (3 rules)
- `src/lib/auth/AGENTS.md` (3 rules)
- `src/lib/billing/AGENTS.md` (2 rules)
- `src/lib/email/AGENTS.md` (1 rule)
- `tests/AGENTS.md` (1 rule)

These also cover files at the repo root. Read one before you edit a file it names:

- `.agents/rules/ai-server-boundary.md`: Model calls stay on the server, and they stream (`src/lib/ai/**`, `src/app/api/chat/**`, `src/app/api/agent/**`, `src/components/ai/**`, `vercel.json`)
- `.agents/rules/deployment.md`: Deployment rules (`next.config.ts`, `vercel.json`, `package.json`, `src/proxy.ts`, `src/app/**/route.ts`, `.env.example`)
- `.agents/rules/drizzle-migrations.md`: Every schema change ships with its generated migration (`src/db/**`, `drizzle/**`, `drizzle.config.ts`)
- `.agents/rules/sentry-capture.md`: Every captured exception carries a stable fingerprint hint (`src/**`, `sentry.server.config.ts`, `sentry.edge.config.ts`)

## Skills

Run one by name (`/name` in most agents, `$name` in Codex), or let the agent pick one
from its description:
`add-admin-action`, `add-admin-page`, `add-app-page`, `add-email-template`, `add-event`, `add-oauth-provider`, `add-product`, `add-table`, `add-tool`, `ask-product`, `db-branch`, `deploy-to-vercel`, `edit-pricing`, `eval-prompt`, `help`, `landing-copy`, `migrate`, `migrate-on-neon`, `new-component`, `preview-and-test-email`, `protect-route`, `qa-feature`, `scrub-pii`, `security-audit`, `setup`, `test-webhook`, `triage-errors`, `verify`, `write-spec`

## Subagents

Hand a task to one by name. What each one is for, and its prompt, is in
`.agents/agents/<name>.md`:
`db-inspector`, `designer`, `documentarian`, `pr-reviewer`, `product-analyst`, `security-auditor`, `system-manager`
src/app/(admin)/AGENTS.mdmarkdown84 lines
# src/app/(admin)

Rules for files under `src/app/(admin)`. The root `AGENTS.md` and every
`AGENTS.md` between it and this folder apply here too.

## Admin pages check the role themselves and read data on the server

Applies to: `src/app/(admin)/**`, `src/components/admin/**`, `src/lib/admin/actions.ts`, `src/app/api/admin/**`
Source: `admin-panel`

### Three checks, each for a different question

| Where | Call | What it stops |
|---|---|---|
| `src/app/(admin)/layout.tsx` | `requireRole("admin", returnTo)` | A non-admin ever seeing the shell |
| Every `page.tsx` | `requireRole("admin", "/admin/<path>")` | A stale layout: layouts do not re-render on client navigation |
| Every server action | `authorise()` in `src/lib/admin/actions.ts` | Anyone with curl: an action is a public POST endpoint |

```tsx
export default async function AdminReportsPage() {
  await requireRole("admin", "/admin/reports");
  // load data, render
}
```

The page's call is free: each auth battery wraps its session read in React
`cache`. Pass the page's own path so sign-in brings the admin back to it.

Every export of `src/lib/admin/actions.ts` starts with `authorise()`, before it
reads a form field. It runs `requireRole("admin")`, then re-reads the admin
from the provider, because a role removed a minute ago can still sit in a
cached cookie (Better Auth, 5 minutes) or an unexpired token (Clerk, Supabase).
The one exception is `stopImpersonationAction`: the impersonated session is not
an admin session, so it checks `adminProvider.getImpersonation()` instead.

A route handler under `src/app/api/admin/**` uses `requireApiRole("admin")`
(401 or 403, never a redirect) and catches with `authErrorResponse`.

Never:

- rely on the proxy: `/admin/:path*` is in its matcher so signed-out visitors
  bounce early, but it has no role check worth trusting;
- compare strings (`user.role === "admin"` misses Clerk's `owner`): use
  `requireRole`, or `navItemsFor` for what the UI shows;
- move a page out of `src/app/(admin)/admin/`: it loses the shell and the
  layout's check, and nothing warns you;
- render the shell for a refused user: `requireRole` answers with a 404 or the
  auth battery's no-access page, and the chrome would tell an outsider the
  page exists.

### Pages load, components render

A page is a Server Component. It calls the read helpers (`listUsers`,
`getUser`, `getUserStats` from `@/lib/admin/users`, `listAuditEntries` from
`@/lib/admin/audit`) and passes results down. Load independent data with
`Promise.all`. A slow section goes in its own async component inside
`<Suspense>` with a skeleton, as `/admin` does for its counts.

Components under `src/components/admin/**` take props. Two kinds load their
own data because a slot cannot pass them any: `ImpersonationBanner` (the
`app-banner` fill) and the billing summary (`AdminBillingStats`,
`AdminBillingCard`). Do not add a third without the same reason.

### Keep data on the server

- Modules in `src/lib/admin/` that reach a provider open with
  `import "server-only"`: `users.ts`, `audit.ts`, `user-store.ts`,
  `provider.ts`, `audit-store.ts`. Client components import only the pure
  ones (`types.ts`, `policy.ts`, `format.ts`, `query.ts`, `cursor.ts`) and the
  `"use server"` actions.
- Pick fields for client components: `UserActions` gets
  `{ id, name, email, role, banned }`, never a database row.
- Never send a session token to the browser. The page sends a session id;
  `findSessionToken` turns it into a token on the server.
- Filters and cursors live in the URL, parsed by `parseUserQuery` and
  `parseAuditQuery`. A value that does not parse means "no filter", never an
  error page.

### Look like the rest of the app

Use the kit (`@/components/ui/*`), `PageHeader` and `EmptyState` from
`@/components/app/*`, and token classes (`bg-surface-card`, `text-muted`,
`border-hairline`). No palette classes, no hex, no `dark:` for colour: the
panel must read well in every design, light and dark.
.agents/hooks/README.mdmarkdown107 lines
# Guard hooks

One copy of every guard lives here. Each agent's own hook config runs them
through `run.mjs`, which reads that agent's payload, runs the guard, and
answers in that agent's format. `guards.json` is the table it reads.

| Agent | Config |
|---|---|
| Claude Code | `.claude/settings.json` |
| Codex | `.codex/hooks.json` |
| Cursor | `.cursor/hooks.json` |
| GitHub Copilot | `.github/hooks/agentic-guards.json` |
| Antigravity | `.agents/hooks.json` |
| Gemini CLI | `.gemini/settings.json` |
| Windsurf | `.devin/hooks.v1.json` |

Notes:

- Not wired: OpenCode, JetBrains AI, Kiro. OpenCode runs hooks as
  plugins and its plugin API changed between v1 and v2. Junie reads hooks from user config
  only. Kiro does not document its tool names. The rules in `AGENTS.md` still apply there.
- Codex, Cursor and Gemini CLI run project hooks only in a folder you trust. Codex also asks you
  to review each hook once in `/hooks`.
- Outside Claude Code a rewrite becomes a block that names the command to run instead.
- Hiding a secret in command output works in Claude Code only. Everywhere else the check
  before the command is what stops it.
- A guard that fails to run lets the call through, with a warning. So does a repo with no
  dependencies installed yet.

Run `verify:hooks` to prove each guard still blocks what it claims to block.

## auto-lint

- Event: `PostToolUse`
- Tools: `Edit|Write|MultiEdit`
- Script: `.agents/hooks/auto-lint.ts`
- Claude Code runs: `bun "${CLAUDE_PROJECT_DIR:-.}/.agents/hooks/run.mjs" auto-lint --from claude`
- Contributed by: `nextjs-vercel`

Runs Biome on the file that was just edited, applies safe fixes, and reports anything it could not fix.

## block-destructive

- Event: `PreToolUse`
- Tools: `Bash`
- Script: `.agents/hooks/block-destructive.ts`
- Claude Code runs: `bun "${CLAUDE_PROJECT_DIR:-.}/.agents/hooks/run.mjs" block-destructive --from claude`
- Contributed by: `nextjs-vercel`

Blocks irreversible shell commands: recursive force deletes, DROP and TRUNCATE sent to a database, force pushes, git reset --hard, git clean, dd, and truncating redirects onto tracked files.

## enforce-doc-meta

- Event: `PostToolUse`
- Tools: `Edit|Write|MultiEdit`
- Script: `.agents/hooks/enforce-doc-meta.ts`
- Claude Code runs: `bun "${CLAUDE_PROJECT_DIR:-.}/.agents/hooks/run.mjs" enforce-doc-meta --from claude`
- Contributed by: `nextjs-vercel`

Checks that files written under docs/solutions/ and docs/plans/ carry the frontmatter those directories depend on, and reports exactly what is missing.

## enforce-typecheck

- Event: `PreToolUse`
- Tools: `Bash`
- Script: `.agents/hooks/enforce-typecheck.ts`
- Claude Code runs: `bun "${CLAUDE_PROJECT_DIR:-.}/.agents/hooks/run.mjs" enforce-typecheck --from claude`
- Contributed by: `nextjs-vercel`

Rewrites a bare tsc, however it is launched, into the project's typecheck script before it runs. Outside Claude Code it blocks the call and names that script instead.

## env-leak-detector

- Event: `PreToolUse`
- Tools: `Bash|Read|Grep`
- Script: `.agents/hooks/env-leak-detector.ts`
- Claude Code runs: `bun "${CLAUDE_PROJECT_DIR:-.}/.agents/hooks/run.mjs" env-leak-detector --from claude`
- Codex: runs on `Bash` only.
- Contributed by: `nextjs-vercel`

Blocks tool calls that would print, transmit or commit a secret: literal credential shapes, reads of local .env files by any command or by the Read and Grep tools, echo of secret variables, environment dumps, and live values from your .env files.

## env-leak-detector-write

- Event: `PostToolUse`
- Tools: `Edit|Write|MultiEdit|Bash|Read|Grep`
- Script: `.agents/hooks/env-leak-detector-write.ts`
- Claude Code runs: `bun "${CLAUDE_PROJECT_DIR:-.}/.agents/hooks/run.mjs" env-leak-detector-write --from claude`
- Codex: runs on `Edit`, `Write`, `MultiEdit` only.
- Cursor: runs on `Edit`, `Write`, `MultiEdit` only.
- GitHub Copilot: runs on `Edit`, `Write`, `MultiEdit` only.
- Antigravity: runs on `Edit`, `Write`, `MultiEdit` only.
- Gemini CLI: runs on `Edit`, `Write`, `MultiEdit` only.
- Windsurf: runs on `Edit`, `Write`, `MultiEdit` only.
- Contributed by: `nextjs-vercel`

The second half of env-leak-detector: redacts live secret values from command, read and search output before the agent sees them (Claude Code only), and flags secrets written into files, private env vars read in client components, and secrets passed to log calls.

## guard-neon-sql

- Event: `PreToolUse`
- Tools: `Bash`
- Script: `.agents/hooks/guard-neon-sql.ts`
- Claude Code runs: `bun "${CLAUDE_PROJECT_DIR:-.}/.agents/hooks/run.mjs" guard-neon-sql --from claude`
- Contributed by: `neon`

Blocks raw DDL through psql, migrations that would really run through the Neon pooler, and schema pushes that skip migration files. The repo's own db:migrate scripts pass.

After you unzip

cd my-app
bun install
# then, in your AI agent ($setup in Codex):
/setup

The agentic layer

Everything an agent reads on its first run

Written once, then compiled for every agent. Every repo ships AGENTS.md and .agents/: rules, skills, subagents and guard hooks. Each agent you pick also gets the files it needs in its own format. Each entry below names where it came from: a battery, the design or the base stack.

Which agents get their own files

Only what an agent can’t read from AGENTS.md and .agents/.

Claude Code
Skills, subagents, guard hooks and the plugin in .claude/, MCP in .mcp.json.
Codex
Guard hooks, subagents and MCP in .codex/.
Cursor
Guard hooks, subagents and MCP in .cursor/.
GitHub Copilot
Guard hooks, custom agents and the plugin in .github/, MCP in .mcp.json.
Antigravity
Guard hooks and MCP in .agents/.
Gemini CLI
Reads AGENTS.md, guard hooks, subagents and MCP in .gemini/.
OpenCode
Subagents in .opencode/, MCP in opencode.json. No guard hooks.
JetBrains AI
Junie MCP in .junie/, an AI Assistant rule that points at AGENTS.md. No guard hooks.
Windsurf
Guard hooks in .devin/ for Devin Local (Windsurf and the Devin CLI), MCP in .mcp.json.
Kiro
Skills and MCP in .kiro/ (Kiro reads no .agents/skills). No guard hooks.

No files needed: Amp, Factory Droid, Warp, Cline, Kilo Code, Zed, Goose, Augment Code, Qwen Code, Crush and Jules. They read AGENTS.md as it is.

Agents (7)

Subagents in .agents/agents/, each with its own prompt. An agent with a subagent folder of its own gets a copy there, with the tools it may use.

  • db-inspector

    Read-only Neon Postgres inspector. Explains schema, data shape and query plans. Runs SELECT and EXPLAIN only, and refuses every statement that writes or changes schema.

    tools: Read, Grep, Glob, Bash, mcp__neon

    Neon
  • designer

    Owns the Midnight design system and its shadcn bridge. The only agent allowed to introduce a new visual pattern or a new token. Refuses to ship a raw colour or a single-mode change.

    tools: Read, Grep, Glob, Edit, Write

    Midnight
  • documentarian

    Keeps README, AGENTS.md, DESIGN.md, SETUP.md and docs/solutions/ true to the code. Writes solution docs from work that just landed.

    tools: Read, Grep, Glob, Edit, Write, Bash

    Next.js on Vercel
  • pr-reviewer

    Reviews a diff against this repo's rules before it becomes a PR. Convention-aware, blocking on correctness and security, advisory on taste.

    tools: Read, Grep, Glob, Bash

    Next.js on Vercel
  • product-analyst

    Read-only product analyst. Answers questions about user behaviour from the event catalogue and the PostHog project, and says plainly when the instrumentation cannot answer them.

    tools: Read, Grep, Glob, mcp__posthog

    PostHog
Show all 7
  • security-auditor

    Audits the repo or a diff for leaked secrets, broken auth boundaries, injection, unsafe dependencies and unsafe deploy configuration.

    tools: Read, Grep, Glob, Bash

    Next.js on Vercel
  • system-manager

    Maintains the agent layer itself: AGENTS.md, .agents/ (rules, skills, agents, hooks) and each agent's own folder. Adds a rule when a correction repeats.

    tools: Read, Grep, Glob, Edit, Write, Bash

    Next.js on Vercel

Skills (29)

Skills in .agents/skills/, the folder most agents read: the repeatable jobs for this selection. Run one as /name, or $name in Codex.

  • /add-admin-action

    Add an admin action (verify an email, reset a plan, delete an account) as a checked, validated, audited server action with a confirm dialog.

    .agents/skills/add-admin-action/SKILL.md

    Admin panel
  • /add-admin-page

    Add a page to /admin with the role check, a sidebar entry, loading and empty states, and data read through the admin ports.

    .agents/skills/add-admin-page/SKILL.md

    Admin panel
  • /add-app-page

    Add a page to the signed-in app (sidebar entry, session check, loading state), or a new tab under /settings.

    .agents/skills/add-app-page/SKILL.md

    Next.js on Vercel
  • /add-email-template

    Add a React Email template, preview it, wire it into a send, and check it renders and lands in a real inbox.

    .agents/skills/add-email-template/SKILL.md

    Resend
  • /add-event

    Add a product event end to end: catalogue entry, the question it answers, the capture call on the correct side of the network, and a check that it arrives.

    .agents/skills/add-event/SKILL.md

    PostHog
Show all 29
  • /add-oauth-provider

    Turn on Google, GitHub or Microsoft sign-in (env keys only), or add another OAuth provider to the list in src/lib/auth/providers.ts.

    .agents/skills/add-oauth-provider/SKILL.md

    Better Auth
  • /add-product

    Add or change a plan or price on Polar (monthly, yearly or one-time lifetime). Edit src/lib/pricing.ts, create the Polar product, wire its env var, and prove checkout and the webhook end to end.

    .agents/skills/add-product/SKILL.md

    Polar
  • /add-table

    Add a table to the Drizzle schema, generate and apply its migration, and wire the typed queries for it.

    .agents/skills/add-table/SKILL.md

    Drizzle ORM
  • /add-tool

    Add a tool the model can call (schema, execute, registry entry, surface and a test) without widening what a stranger's sentence can reach.

    .agents/skills/add-tool/SKILL.md

    AI bundle
  • /ask-product

    Answer a question about user behaviour from this repo's event catalogue and the PostHog project, with the caveats that make the number usable.

    .agents/skills/ask-product/SKILL.md

    PostHog
  • /db-branch

    Create, use, reset and delete Neon database branches, for a feature branch, a preview deploy, a migration rehearsal or a point-in-time investigation.

    .agents/skills/db-branch/SKILL.md

    Neon
  • /deploy-to-vercel

    Ship my-app to Vercel: local gates, environment variables per scope, preview verification, promotion and rollback.

    .agents/skills/deploy-to-vercel/SKILL.md

    Next.js on Vercel
  • /edit-pricing

    Add, change or remove a plan or a price (monthly, yearly or one-time lifetime) and wire it to the payment provider.

    .agents/skills/edit-pricing/SKILL.md

    Next.js on Vercel
  • /eval-prompt

    Change a prompt, a model or a schema safely. Build the eval suite first, measure the baseline, change one thing, and compare pass rates.

    .agents/skills/eval-prompt/SKILL.md

    AI bundle
  • /help

    Explain the agentic system in this repo (rules, skills, agents, hooks, solution docs and the CE loop) and where to go for help beyond it.

    .agents/skills/help/SKILL.md

    Next.js on Vercel
  • /landing-copy

    Rewrite the landing page, the metadata and the legal details for the real product from a short brief, by editing src/lib/site.ts only.

    .agents/skills/landing-copy/SKILL.md

    Next.js on Vercel
  • /migrate

    Generate, review and apply Drizzle migrations safely, including backfills, destructive changes and the deploy step.

    .agents/skills/migrate/SKILL.md

    Drizzle ORM
  • /migrate-on-neon

    Run a schema migration against Neon safely, on the direct URL, rehearsed on a branch first, with a recovery path when it fails halfway.

    .agents/skills/migrate-on-neon/SKILL.md

    Neon
  • /new-component

    Add a component to the Midnight kit. Prefer pasting from shadcn/ui, fix the two bridge classes, keep it token-only and verify it in both light and dark.

    .agents/skills/new-component/SKILL.md

    Midnight
  • /preview-and-test-email

    Diagnose an email problem (not sending, landing in spam, rendering wrong) in the order that finds the cause fastest.

    .agents/skills/preview-and-test-email/SKILL.md

    Resend
  • /protect-route

    Put an authentication or role check on a page, a route handler, a server action or a whole route group, at the right layer, without a redirect loop.

    .agents/skills/protect-route/SKILL.md

    Better Auth
  • /qa-feature

    Exercise a feature end to end (happy path, unhappy paths, auth boundaries, refresh and mobile) before anyone calls it done.

    .agents/skills/qa-feature/SKILL.md

    Next.js on Vercel
  • /scrub-pii

    Audit what this app actually sends to Sentry, extend the scrubbing layer for a new field or shape, and respond when something sensitive has already been sent.

    .agents/skills/scrub-pii/SKILL.md

    Sentry
  • /security-audit

    Run the standing security pass through the security-auditor agent (secrets, auth boundaries, injection, dependencies and deploy config) and turn findings into fixes.

    .agents/skills/security-audit/SKILL.md

    Next.js on Vercel
  • /setup

    Set up this repo after download. Fills .env.local, connects the MCP servers, sets up the database and services, and makes the product yours. Shows a plan first and acts only after a yes. Safe to run again.

    .agents/skills/setup/SKILL.md

    Next.js on Vercel
  • /test-webhook

    Exercise the Polar webhook endpoint locally. Forward real sandbox events with the Polar CLI, or sign a one-time order yourself; buy both kinds of price, refund one, prove replays are no-ops, and debug signature failures.

    .agents/skills/test-webhook/SKILL.md

    Polar
  • /triage-errors

    Work the Sentry issue list: rank by users affected, separate regressions from background noise, find the deploy that caused it, and fix or suppress with a reason.

    .agents/skills/triage-errors/SKILL.md

    Sentry
  • /verify

    Prove the repo is actually configured: every required env var present, every configured service reachable, and the guard hooks still blocking what they claim to block.

    .agents/skills/verify/SKILL.md

    Next.js on Vercel
  • /write-spec

    Turn a loose request into a written spec (problem, scope, behaviour, acceptance criteria) that /ce-plan can consume without guessing.

    .agents/skills/write-spec/SKILL.md

    Next.js on Vercel

Rules (30)

Each rule is in .agents/rules/ and in the AGENTS.md of the folder it covers, so an agent reads it where it applies, not in one long file it skims.

  • admin-access

    Admin pages check the role themselves and read data on the server

    src/app/(admin)/** · src/components/admin/** · src/lib/admin/actions.ts · src/app/api/admin/**

    Admin panel
  • admin-mutations

    Admin writes go through the provider port, and every one is audited

    src/lib/admin/** · src/components/admin/** · scripts/admin/**

    Admin panel
  • ai-prompt-safety

    Never interpolate untrusted text into a system prompt

    src/lib/ai/** · src/app/api/**

    AI bundle
  • ai-server-boundary

    Model calls stay on the server, and they stream

    src/lib/ai/** · src/app/api/chat/** · src/app/api/agent/** · src/components/ai/** · vercel.json

    AI bundle
  • ai-structured-output

    Every structured call carries a Zod schema

    src/lib/ai/** · src/app/api/**

    AI bundle
Show all 30
  • ai-tools

    Every tool validates its own input

    src/lib/ai/tools/** · src/lib/ai/agent.ts · src/app/api/agent/**

    AI bundle
  • app-shell

    Pages in the signed-in app

    src/app/(app)/** · src/components/app/** · src/components/ui/sidebar.tsx · src/lib/app-shell.ts · src/lib/nav.ts

    Next.js on Vercel
  • auth-server-boundary

    The auth server boundary and sign-in methods

    src/lib/auth/** · src/app/api/auth/** · src/app/(better-auth)/** · src/components/auth/**

    Better Auth
  • billing-core

    Billing is one shared layer with one provider adapter

    src/lib/pricing.ts · src/lib/billing/** · src/app/pricing/** · src/app/(app)/billing/** · src/components/billing/**

    Next.js on Vercel
  • code-style

    Code style and file conventions

    repo-wide

    Next.js on Vercel
  • deployment

    Deployment rules

    next.config.ts · vercel.json · package.json · src/proxy.ts · src/app/**/route.ts · .env.example

    Next.js on Vercel
  • drizzle-migrations

    Every schema change ships with its generated migration

    src/db/** · drizzle/** · drizzle.config.ts

    Drizzle ORM
  • drizzle-schema

    Schema and query conventions for Drizzle

    src/db/**

    Drizzle ORM
  • email-sending-discipline

    Every email goes through sendEmail, from a verified domain, with a reply-to

    src/lib/email/** · src/app/api/webhooks/resend/** · src/lib/auth/** · src/lib/billing/**

    Resend
  • event-naming

    Events are declared in the catalogue, named object_verb, past tense

    src/lib/analytics/** · src/app/** · src/components/**

    PostHog
  • git

    Git and change hygiene

    repo-wide

    Next.js on Vercel
  • identify-timing

    Identify before the first event that matters, reset on sign-out

    src/lib/analytics/** · src/app/** · src/components/**

    PostHog
  • landing-and-legal

    Landing page, legal pages and llms.txt

    src/lib/site.ts · src/lib/llms.ts · src/app/page.tsx · src/app/(legal)/** · src/app/llms.txt/** · src/components/marketing/** · src/components/site/**

    Next.js on Vercel
  • neon-connections

    One connection surface, and the right driver for the job

    src/db/** · src/app/api/**

    Neon
  • neon-migrations

    Schema changes go through ORM migration files on the direct URL

    src/db/**

    Neon
  • polar-billing-adapter

    Polar translates, the shared billing core writes the store

    src/lib/pricing.ts · src/lib/billing/** · scripts/billing/**

    Polar
  • polar-webhook-integrity

    Verify every Polar webhook, keep every handler idempotent

    src/app/api/webhooks/polar/** · src/lib/billing/provider.ts · src/lib/billing/polar-webhooks.ts · src/lib/billing/webhook.ts

    Polar
  • roles-are-server-side

    Roles are decided on the server, every time

    src/app/** · src/components/** · src/lib/auth/**

    Better Auth
  • security

    Security rules

    repo-wide

    Next.js on Vercel
  • sentry-capture

    Every captured exception carries a stable fingerprint hint

    src/** · sentry.server.config.ts · sentry.edge.config.ts

    Sentry
  • sentry-no-pii

    No personal data in breadcrumbs, tags or extra

    repo-wide

    Sentry
  • server-truth-and-pii

    Server events for anything a client can lie about, and never PII in properties

    src/lib/analytics/** · src/app/** · src/components/**

    PostHog
  • testing

    Testing rules

    tests/** · src/**/*.test.ts · src/**/*.test.tsx

    Next.js on Vercel
  • tokens-only

    Midnight: tokens only, and both modes every time

    src/components/** · src/app/**

    Midnight
  • ui-kit

    Build UI from the component kit

    src/components/** · src/app/**

    Next.js on Vercel

Hooks (7)

Guard hooks in .agents/hooks/, wired for Claude Code, Codex, Cursor, GitHub Copilot, Antigravity, Gemini CLI and Windsurf. Run verify:hooks to prove each one still blocks what it claims to.

  • auto-lint

    Runs Biome on the file that was just edited, applies safe fixes, and reports anything it could not fix.

    PostToolUse · Edit|Write|MultiEdit

    Next.js on Vercel
  • block-destructive

    Blocks irreversible shell commands: recursive force deletes, DROP and TRUNCATE sent to a database, force pushes, git reset --hard, git clean, dd, and truncating redirects onto tracked files.

    PreToolUse · Bash

    Next.js on Vercel
  • enforce-doc-meta

    Checks that files written under docs/solutions/ and docs/plans/ carry the frontmatter those directories depend on, and reports exactly what is missing.

    PostToolUse · Edit|Write|MultiEdit

    Next.js on Vercel
  • enforce-typecheck

    Rewrites a bare tsc, however it is launched, into the project's typecheck script before it runs. Outside Claude Code it blocks the call and names that script instead.

    PreToolUse · Bash

    Next.js on Vercel
  • env-leak-detector

    Blocks tool calls that would print, transmit or commit a secret: literal credential shapes, reads of local .env files by any command or by the Read and Grep tools, echo of secret variables, environment dumps, and live values from your .env files.

    PreToolUse · Bash|Read|Grep

    Next.js on Vercel
Show all 7
  • env-leak-detector-write

    The second half of env-leak-detector: redacts live secret values from command, read and search output before the agent sees them (Claude Code only), and flags secrets written into files, private env vars read in client components, and secrets passed to log calls.

    PostToolUse · Edit|Write|MultiEdit|Bash|Read|Grep

    Next.js on Vercel
  • guard-neon-sql

    Blocks raw DDL through psql, migrations that would really run through the Neon pooler, and schema pushes that skip migration files. The repo's own db:migrate scripts pass.

    PreToolUse · Bash

    Neon

Institutional memory

75 solution docs, seeded on day one

They ship inside the repo under docs/solutions/. They are published here too, so you can read them first.

Admin panel (8)

Show all 75

AI bundle (6)

Better Auth (10)

Drizzle ORM (5)

Midnight (4)

Neon (6)

Next.js on Vercel (15)

Polar (6)

PostHog (5)

Resend (5)

Sentry (5)

Use AI Product

The builder opens with these 9 batteries picked. Change anything, then download the zip.