/hypervibe:add-auth [mode: admin | users]from hypervibe
Adds NextAuth (Auth.js) authentication to an existing T3 project. Detects current auth state and offers admin-only or user-credentials mode with optional OAuth providers.
Ships in hypervibe. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
/bootstrap carries no language signal by itself). If nothing in the conversation gives a signal, fall back to the OS locale (node -e "console.log(Intl.DateTimeFormat().resolvedOptions().locale)") before defaulting to English. ALWAYS reply in that language for every user-facing message: questions, progress, confirmations, summaries, errors - including any example text quoted in this skill, which is illustrative and must be translated, never sent verbatim.Lightweight orchestrator. Detects the current state via the // hypervibe:auth-modes <list> marker at the top of src/server/auth.ts, proposes a contextual menu based on what is already installed, and delegates to the right sub-skill (_setup-auth-admin / _setup-auth-users) for fresh installs. For UPGRADES (adding the second mode when one already exists), Claude drives the contextual editing of auth.ts itself - see the UPGRADE Section.
Read the marker in src/server/auth.ts:
if [ -f "<WEB_DIR>/src/server/auth.ts" ]; then
grep -E "^// hypervibe:auth-modes" "<WEB_DIR>/src/server/auth.ts" | head -1
fi
Parse:
existing_modes = []// hypervibe:auth-modes admin → ["admin"]// hypervibe:auth-modes users → ["users"]// hypervibe:auth-modes admin, users → ["admin","users"]auth.ts present WITHOUT marker → ["unknown"][] → fresh installNo menu. Skip to Step 1.
["admin"] → menu🔐 The admin login is already in place
- Also add a signup system for my users (both coexist)
- Change the admin password
- Start over from scratch (deletes auth.ts/password.ts/route.ts + AUTH_SECRET/ADMIN_* first)
- Something else
| Choice | Action |
|---|---|
| 1 | UPGRADE Section - Case A. |
| 2 | node "${CLAUDE_SKILL_DIR}/../../scripts/admin-password.mjs" rotate --project-dir "<WEB_DIR>" → a new password, written in a file of the user's downloads folder, only its hash pushed (ADMIN_PASSWORD_HASH_PROD). Give the user the file's path (file), never the password; it works once the site is deployed again. |
| 3 | List the files to delete manually, then ask to re-run. |
| 4 | Ask for clarification. |
["users"] → menu🔐 User signup is already in place
- Also add a separate admin login
- Add a Google sign-in
- Add a GitHub sign-in
- Enable password reset (forgot-password - only if email is configured)
- Start over from scratch
- Something else
| Choice | Action |
|---|---|
| 1 | UPGRADE Section - Case B. |
| 2 | Invoke add-google-auth. |
| 3 | Invoke add-github-auth. |
| 4 | _check-deps email ; if OK, UPGRADE Section - Case C. Otherwise point to /add-email. |
| 5 | List the files to delete (auth.ts, password.ts, auth router, /signin /signup /dashboard /account pages, NextAuth tables in the DB). |
| 6 | Ask for clarification. |
["admin","users"] → menu🔐 You have BOTH modes (admin + users)
- Change the admin password (same as admin case choice 2)
- Add Google (same as users case choice 2)
- Add GitHub (same as users case choice 3)
- Enable password reset (same as users case choice 4)
- Uninstall a mode - destructive, ask for explicit confirmation and guide manually
- Something else
["unknown"] → pre-existing auth not recognized⚠️ You already have a
src/server/auth.tsbut I do not recognize its origin (no hypervibe marker). Three options: (1) you tell me what you want to do and I guide you manually; (2) you confirm that I can overwrite and start over; (3) we stop.
If called from /bootstrap, the mode is already chosen → skip to Step 2. If standalone with an explicit arg (admin / users), use it. Otherwise AskUserQuestion:
What type of authentication does your project need?
- Just a protected admin interface (only you log in - content management, site admin)
- A system for your users (visitors create an account and sign in)
→ auth_mode = admin-credentials or user-credentials.
Why is email+pwd the baseline when there are users? It is the only 0-config system that works everywhere. OAuth (Google, GitHub) is a convenience added on top, never a replacement.
Invoke _detect-project-root → PROJECT_NAME, WEB_DIR, IS_MONOREPO, IS_NEXTJS. Abort if not Next.js.
If auth_mode = user-credentials: _check-deps db → if db_ok = false, propose /add-db then re-check.
auth_mode = admin-credentials → invoke _setup-auth-admin with WEB_DIR, IS_MONOREPO, PROJECT_NAME.auth_mode = user-credentials → invoke _setup-auth-users.The sub-skill handles the script + UserMenu (users mode) + CLAUDE.md + summary. When it hands control back, you are done - the orchestrator has nothing to add.
No script - the risk of corrupting the existing auth.ts is too high. Claude reads the existing file, reads the reference templates in ${CLAUDE_SKILL_DIR}/../../templates/auth/, and patches contextually. Check pnpm tsc --noEmit at the end to validate.
Template paths in this section are relative to the PLUGIN ROOT, not to this skill's folder. Always resolve them through
${CLAUDE_SKILL_DIR}/../../templates/…, exactly as written below. Dropping that prefix makes the path resolve insideskills/add-auth/, where notemplates/folder exists, and the read fails with "No such file or directory".
users on top of an existing adminReference templates: ${CLAUDE_SKILL_DIR}/../../templates/auth/users/{auth.ts, password.ts, schema-additions.ts, schema-additions-reset-tokens.ts, auth-router*.ts, route.ts}.
Steps (all driven by Claude):
_check-deps db (DB required) ; _check-deps email (optional for reset).auth.ts: marker → // hypervibe:auth-modes admin, users. Import DrizzleAdapter, schema tables, eq, db. Module augmentation Session.user.id. authorize(credentials, request): the limit on sign-in attempts FIRST, before both paths (the TooManyAttempts class and its two lines, as both templates write them: never in the API route, whose 429 freezes the sign-in form), then the admin path (check email === ADMIN_USERNAME, getAdminPasswordHash), users path as FALLBACK (db.query.users.findFirst → verifyPassword). Keep isAdmin(). Add jwt/session callbacks: the users template's ones, with its account check (the session ends when the account is gone or its password changed after sign-in), the admin let through before that read (if (token.id === "admin") return token;: the admin has no row in the database, and the check would end its session at once).password.ts: add hashPassword() (from the users template). Keep getAdminPasswordHash + verifyPassword.setup-auth-users.mjs does in the patchSchema step: add the missing imports (text, integer, primaryKey, index, timestamp pg-core, sql drizzle-orm, AdapterAccount type next-auth/adapters), append the 4 NextAuth tables (+ password_reset_tokens if email_ok).pnpm db:push, after node "${CLAUDE_SKILL_DIR}/../../scripts/neon/schema-drift.mjs" from <WEB_DIR> (read-only): --force only on exit 0; on exit 3 stop and show the user what the push would delete.protectedProcedure (and rateLimitedProcedure if missing). Take inspiration from the setup-auth-users.mjs addProtectedProcedure step.src/server/api/routers/auth.ts from the right template (auth-router.ts or auth-router-with-reset-{provider}.ts).root.ts: import + auth: authRouter,.src/app/api/auth/[...nextauth]/route.ts from the template (admin and users are identical).FORGOT_PASSWORD_LINK substituted), signup, dashboard, account (+ forgot/reset if email_ok).layout.tsx for the user-menu (best-effort, like _setup-auth-users Step 2).pnpm tsc --noEmit - check that it compiles.admin on top of an existing usersReference templates: ${CLAUDE_SKILL_DIR}/../../templates/auth/admin/{auth.ts, password.ts} (for the snippets to integrate).
H=$(printf '%s' "Admin1234!" | node "<path>/hash-password.mjs") && [ -n "$H" ] && printf 'ADMIN_USERNAME=admin\nADMIN_PASSWORD_HASH_DEV=%s\n' "$H" | node "<path>/push-env-vars.mjs" --target=all --stdin.node "<path>/admin-password.mjs" rotate --project-dir <app folder>. It generates it, writes it with the identifier and the sign-in page in a file of the user's downloads folder, and pushes only ADMIN_PASSWORD_HASH_PROD. Its JSON gives the file's path (file), never the password: never read that file. Never hash-password.mjs --generate here: it prints the password where you read it.password.ts - add getAdminPasswordHash() from the admin template. Keep hashPassword + verifyPassword.auth.ts: marker → // hypervibe:auth-modes admin, users. Import getAdminPasswordHash from ~/lib/password. In authorize(), after the limit on sign-in attempts (its first lines, kept as they are) and BEFORE the DB lookup, add the admin path:
if (process.env.ADMIN_USERNAME && email === process.env.ADMIN_USERNAME) {
const hash = getAdminPasswordHash();
if (await verifyPassword(password, hash)) return { id: "admin", email, name: "Admin" };
return null;
}
Add export async function isAdmin() { return (await auth())?.user?.id === "admin"; }. In the jwt callback, let the admin through before the account check of the users template (if (token.id === "admin") return token; right after the sign-in branch): the admin has no row in the database, and the check would end its session at once.
4b. The admin gate: node "${CLAUDE_SKILL_DIR}/../../scripts/admin-gate.mjs" --web-dir <WEB_DIR>. It writes src/server/require-admin.ts, the check every admin page calls on its first line, and the middleware in front of /admin (src/middleware.ts, or src/proxy.ts from Next.js 16), never over a middleware the project already has: with "status":"existing" in its last line, merge by hand when that is safe or tell the person, as _setup-auth-admin says. Every admin page created later starts with await requireAdmin(): a check in a layout alone lets the page's content leave with its redirect._setup-auth-admin Step 2, its "Admin structure" line included) in addition to the users sections.pnpm tsc --noEmit - check.users (email already OK)passwordChangedAt column: if the users table of schema.ts has none (a project made before this version), add it from ${CLAUDE_SKILL_DIR}/../../templates/auth/users/schema-additions.ts (the reset router writes it, and the build fails without it), and the account check of the jwt callback from ${CLAUDE_SKILL_DIR}/../../templates/auth/users/auth.ts if src/server/auth.ts lacks it.
1b. Append password_reset_tokens to schema.ts from ${CLAUDE_SKILL_DIR}/../../templates/auth/users/schema-additions-reset-tokens.ts.pnpm db:push.src/server/api/routers/auth.ts with the auth-router-with-reset-{resend,brevo}.ts template (depending on the detected provider)./forgot-password/page.tsx and /reset-password/page.tsx from the templates.<span></span> (placeholder for FORGOT_PASSWORD_LINK) with the <Link href="/forgot-password" ...>Forgot password?</Link>.pnpm tsc --noEmit + summary.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub flavien-ia/hypervibe-craft --plugin hypervibe90 skills in this plugin
/accessibilityAccessibility audit of a Next.js app: reads the code (images, buttons, links, form fields, keyboard, focus, zoom, motion), measures the live pages with PageSpeed Insights, explains each problem plainly, then applies the fixes the user approves./add-2faAdd two-factor authentication (2FA TOTP) to an existing T3 project's login. Orchestrator - asks which authenticator app the user wants, detects whether the project uses admin auth (single fixed login) or user accounts, and delegates to the right setup. Admin mode - 2FA is mandatory for the single admin, secret + backup codes stored in the Bitwarden vault. User mode - 2FA is optional per user, each user enables it from their account page, secrets + backup codes stored per-user in the database. Requires the project to already have hypervibe auth (`/add-auth`)./add-agent-dashboardAdd a monitoring screen for AI agents in the project admin: cost, run history, turn-by-turn traces, and a button to launch a run by hand. Installed when an agent is created, safe to re-run./add-aiAdd AI to an existing Next.js project: chat assistant, content processing, or generation. Estimates the cost from live prices and provisions a spending-capped key before writing any code. Model-independent through OpenRouter./add-analyticsAdd Google Analytics (GA4) to an existing Next.js project. Includes RGPD cookie consent banner./add-automationRoute an automation need to the right shape: scheduled task, event-triggered pipeline, background worker, autonomous agent, or a personal recurring mission. Start here when you are not sure which one you want.Other plugins' skills for the same job