Skip to content

fix: close scaffold gaps — auth, drizzle, env, coverage, zustand#6

Open
bryansayler wants to merge 8 commits into
mainfrom
claude/land-need-fixes
Open

fix: close scaffold gaps — auth, drizzle, env, coverage, zustand#6
bryansayler wants to merge 8 commits into
mainfrom
claude/land-need-fixes

Conversation

@bryansayler
Copy link
Copy Markdown
Contributor

Summary

Fixes every concrete contradiction between what the README/CLAUDE.md claims and what the scaffold actually delivers. After this PR, every "scaffolded" feature actually works on a fresh clone.

  • Auth.js wired: Credentials provider validates email/password against the Drizzle users table via bcryptjs. JWT sessions surface user.id in callbacks. Previously providers: [] — non-functional.
  • Drizzle migration committed: initial 0000_thin_mephisto.sql checked in; predev script auto-runs db:migrate before dev server. Previously no drizzle/ dir existed and bun run db:migrate failed on fresh clone. Also removes /drizzle/ from .gitignore since migrations are schema definitions.
  • Env hardening: requireProductionEnv() throws at build time if AUTH_SECRET or DATABASE_URL are missing in production. Respects SKIP_ENV_VALIDATION for CI and local validate. Dev still boots with no .env.
  • Coverage thresholds enforced: vitest thresholds (60% lines/statements, 50% functions/branches). CI now runs test:coverage instead of test:run.
  • validate:full added: bun run validate:full = validate + Playwright E2E. validate remains the fast path (lint + type-check + unit + build).
  • Zustand removed: was in deps with zero usage (no store, no import, no consumer). CLAUDE.md updated to "(per-project: Zustand or Jotai)".

Files changed

File What changed
src/lib/auth.ts Credentials provider + JWT callbacks
src/lib/db/schema.ts Added passwordHash column (nullable)
src/lib/env.ts Added requireProductionEnv() helper
next.config.ts Calls requireProductionEnv() at build time
drizzle/0000_thin_mephisto.sql Initial migration (new)
drizzle/meta/* Drizzle Kit metadata (new)
.gitignore Removed /drizzle/ exclusion
vitest.config.ts Added coverage thresholds
.github/workflows/ci.yml test:runtest:coverage
package.json +bcryptjs, -zustand, +predev, +validate:full, SKIP_ENV_VALIDATION in validate build
CLAUDE.md Tech stack table: auth and client state rows updated

Test plan

  • bun run validate passes locally (lint, type-check, unit tests, build)
  • All commits pass Lefthook pre-commit hooks (lint, format, type-check) and commitlint
  • bun run type-check clean
  • CI validate + e2e jobs pass on this PR
  • Fresh clone: bun install && bun run dev auto-migrates and boots
  • /api/auth/signin renders the Credentials form
  • Production build without secrets fails with clear error message
  • Production build with SKIP_ENV_VALIDATION=1 succeeds

https://claude.ai/code/session_012Mh4xLVoCPRt2pNacxpPtH


Generated by Claude Code

claude added 7 commits May 10, 2026 11:55
Replaces the empty providers array with a working Credentials provider
that validates email/password against the users table via bcrypt.

- Adds passwordHash column to users schema (nullable for existing rows)
- Validates credentials with zod before DB lookup
- Uses JWT session strategy with user.id surfaced in callbacks
- Adds bcryptjs (pure-JS, no native compile step)

Replace this provider when configuring OAuth for production.

https://claude.ai/code/session_012Mh4xLVoCPRt2pNacxpPtH
Generates and commits the initial migration for the users table
(including the new password_hash column). Adds a predev script so
`bun run dev` auto-runs `db:migrate` before starting the dev server,
ensuring the database is ready on first clone.

Also removes /drizzle/ from .gitignore — migration files are schema
definitions and belong in version control.

https://claude.ai/code/session_012Mh4xLVoCPRt2pNacxpPtH
Adds requireProductionEnv() that throws at build time if NODE_ENV is
production and required secrets are missing. Dev/test still boots with
no .env file (all defaults remain optional).

Called from next.config.ts so prod builds fail loudly instead of
silently shipping a missing-secret app.

https://claude.ai/code/session_012Mh4xLVoCPRt2pNacxpPtH
Sets vitest coverage thresholds (lines: 60%, statements: 60%,
functions: 50%, branches: 50%). CI now runs test:coverage instead of
test:run, so PRs that drop below the baseline are blocked.

Thresholds are modest for a scaffold — enough to signal intent and
catch accidental regressions without penalizing thin test suites.

https://claude.ai/code/session_012Mh4xLVoCPRt2pNacxpPtH
`validate` remains the fast path (lint + type-check + unit + build).
`validate:full` chains validate then runs Playwright E2E tests — use
for pre-merge confidence when touching server-rendered or routing code.

https://claude.ai/code/session_012Mh4xLVoCPRt2pNacxpPtH
Zustand was listed in deps but had no store, context, or consumer
anywhere in the scaffold. Removed to avoid confusion. CLAUDE.md tech
stack now says "(per-project: Zustand or Jotai)" — install when needed.

Also updates Auth row to reflect the now-functional Credentials provider.

https://claude.ai/code/session_012Mh4xLVoCPRt2pNacxpPtH
The validate script (and CI) run `next build` which sets
NODE_ENV=production. requireProductionEnv() must also skip when
SKIP_ENV_VALIDATION is set, matching the t3-env behavior.

Also adds SKIP_ENV_VALIDATION=1 to the validate script's build step
so local `bun run validate` works without .env secrets.

https://claude.ai/code/session_012Mh4xLVoCPRt2pNacxpPtH
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 312bfab06a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/ci.yml Outdated
…re next-env.d.ts

Three CI fixes:

1. @vitest/coverage-v8 was missing from devDependencies — CI couldn't
   install it with --frozen-lockfile.

2. Coverage thresholds (60% lines) were unrealistic for a scaffold with
   9% actual coverage (2 tests). Removed — projects should set their own
   thresholds once they have meaningful test coverage. CI reverts to
   test:run until then.

3. next-env.d.ts (auto-generated by next build) was tripping the
   @typescript-eslint/triple-slash-reference rule. Added to eslint
   ignores alongside .next/.

https://claude.ai/code/session_012Mh4xLVoCPRt2pNacxpPtH
@bryansayler bryansayler enabled auto-merge May 19, 2026 12:45
bryansayler pushed a commit that referenced this pull request May 19, 2026
The scaffold's first impression is no longer a dead <h1>. The home
page now showcases what's configured:

- ThemeToggle wired (dark mode works out of the box)
- Sonner Toaster mounted in layout (toast() calls render immediately)
- Four Card tiles summarizing App Router, Database, Testing, and
  Tooling capabilities
- GitHub + Next.js Docs link buttons

Adds src/middleware.ts as a passthrough skeleton with PUBLIC_PATHS
set and a TODO for Auth.js integration once PR #6 merges. Matcher
excludes static assets and _next paths.

Updates the page test to match the new description text.

https://claude.ai/code/session_012Mh4xLVoCPRt2pNacxpPtH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants