Quality Gates

Run All Gates

./scripts/gates.sh

For faster local iteration (skips next build):

./scripts/gates.sh --quick

Gate Order

Gates run sequentially. Failure stops execution immediately.

  1. bun run db:check — Drizzle schema ↔ migration file sync. Catches schema drift before it reaches production.
  2. bun run env:check — Verifies no raw process.env fallback patterns. All env access must go through lib/env/* modules.
  3. bun run lint — ESLint.
  4. bun run test — Vitest (all unit tests in tests/unit/).
  5. bun run build — Full Next.js production build. Catches type errors and import issues that lint misses.

When to Run

  • Before opening any PR
  • Before promotion to staging or production (the promote-deployment skill calls this automatically)
  • After any schema change to lib/schema.ts
  • After adding or modifying environment variable access
  • After any refactor touching multiple files

Quick Mode

Use --quick when iterating locally — it skips the build gate (which takes 30-60s). Always run the full suite before creating a PR.

If a Gate Fails

  • db:check: Run bunx drizzle-kit generate to sync migrations, then retry.
  • env:check: You have a raw process.env.X somewhere. Move it to the appropriate lib/env/*.ts module.
  • lint: Fix reported issues. bun run lint --fix for auto-fixable ones.
  • test: Read the failure output. Fix the test or the code. bun run test:watch for interactive mode.
  • build: Usually a type error. Check the build output for the file and line.