auth-login
Skill2 starsChanged 35 days agoMITView on GitHub
Add user sign-in to an app-foundation site — "Sign in with Google" plus a 6-digit code by email — with Better Auth, users stored in the site's own Postgres (auth_* tables), no per-user fees. Use when the user says "add login", "sign in with Google", "email code login", or a later skill (orders, membership, admin) requires auth-login.
- Reads credentials
- Installs packages
1 other project uses a version of this.
Adopted by
Most recently taken up by
- fossasia/visdomtheir own version, first seen Oct 8, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- fossasia/visdom★ 10ksame name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository20 other files it gives its agents.
- AGENTS.mdAGENTS.md
- skills/app-foundation/template/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- skills/app-foundation/template/CLAUDE.mdCLAUDE.md
- app-foundationSkill
- db-backupSkill
- db-connectSkill
- deploy-cloudflareSkill
- domain-setupSkill
- email-sendSkill
- env-secretsSkill
- file-uploadSkill
- github-vercel-deploySkill
- launch-kitSkill
- ops-dashboardSkill
- pay-checkoutSkill
- pay-subscriptionSkill
- pay-webhookSkill
- uptime-alertSkill
- warehouse-siteSkill
The file
Files
auth-login
Goal: visitors can sign in with Google, or with a code emailed to them (no passwords to forget or leak). Users live in the project's own database, so later systems (orders, membership…) reference auth_users.id. Follow ../../STACK.md: this skill owns the user tables; no other skill creates its own.
The owner may not be a programmer:
- Agreeing to Google's terms, and copying the Google Client secret and
BETTER_AUTH_SECRETinto Vercel, are the owner's actions. Never ask for these in the chat, never type them yourself. - Creating the Google Cloud project and filling in non-secret forms needs the owner's OK first.
Why Better Auth, and why not WeChat (yet)
- Open source (MIT), runs inside the site, users in your own Postgres, no monthly-active-user pricing. Works on Vercel and Cloudflare.
- Google sign-in with only email/name/avatar (openid, email, profile) needs no Google verification. The "Push to production?" dialog says verification is needed only with a logo, more than 10 domains, or sensitive/restricted scopes.
- WeChat website login needs, per WeChat Open Platform docs: a developer account on the WeChat Open Platform, the developer qualification certification, a reviewed website app, and a separately reviewed WeChat-login permission; the callback domain must match the one approved. Better Auth has a WeChat provider, so it can be added later without changing the user tables. Don't quote fees or eligibility unless checked on the official site that day.
Steps
1. Prepare the code
node <skill-dir>/scripts/apply.mjs --dir "<project>" --jsonIt adds:
src/db/schema/auth.ts,src/lib/auth.ts(getAuth(),getCurrentUser()),src/lib/auth-client.ts/api/auth/[...all],/login,/account,/privacy(a template the owner should read)- the
better-authdependency, an.env.exampleblock,stack.json→installed, and a git save point
It also runs drizzle-kit generate --name auth_login when node_modules exists. If manual says so, run npm install && npm run db:generate -- --name auth_login and commit drizzle/. Push. The next build creates the tables (db-connect runs migrations before every build).
2. Secret for sessions (owner)
Open https://<domain>/login. While it isn't configured, it lists what's missing and has a Generate button that makes a random BETTER_AUTH_SECRET in the owner's own browser. The owner pastes it into Vercel → Settings → Environment Variables (Sensitive).
3. Google Cloud (you click with the owner's OK; owner does terms and secrets)
- console.cloud.google.com → New Project (e.g.
my-shop-login). Free, no card. - Google Auth Platform → Get started: App name = site name; support email; Audience External; contact email. The User Data Policy checkbox is the owner's click.
- Clients → Create client → Web application → Authorized redirect URI:
https://<domain>/api/auth/callback/google(exact, https). - The "OAuth client created" dialog shows the Client ID and Client secret. The owner copies them into Vercel as
GOOGLE_CLIENT_IDandGOOGLE_CLIENT_SECRET(Sensitive). Don't read them out. - Branding: Application home page
https://<domain>, privacy policyhttps://<domain>/privacy; the authorized domain is the registrable domain (e.g.example.com). Don't upload a logo (that triggers verification). Save. - Audience → Publish app → Confirm → status In production, so any Google account can sign in.
4. Deploy and test
Redeploy (Vercel uses new variables only on a new deployment). Then:
/login→ Continue with Google → lands on/accountwith name, email and avatar.- Sign out →
/login→ email → Send code → the code arrives (Resend,tag: login-code) → enter it →/account. - Same email both ways = same user (account linking).
- Asking for codes too fast shows "Too many requests" (one code per 60 s per visitor; codes expire in 5 min; 3 wrong tries invalidate a code). Each code is one email, and Resend free allows 100/day.
Using it in code
import { headers } from "next/headers";
import { getCurrentUser } from "@/lib/auth";
const user = await getCurrentUser(await headers()); // null when signed out
if (!user) redirect("/login?next=/orders");New users emit auth.user_created (subjectId = user id) into core_events. Other systems react to it; they never write auth_* tables.
Tell the user (short)
"Your site now has sign-in: Google, or a 6-digit email code. Users are stored in your own database, free at any number of users." Mention /account and that /privacy is a template to read.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

