db-connect
Skill2 starsChanged 35 days agoMITView on GitHub
Connect a free Postgres database (Neon, created from the Vercel dashboard) to an app-foundation project so the site can save data; tables are created automatically on every deploy. Use when the user says "connect a database", "make my site save data", or another skill requires db-connect.
- Reads credentials
- Commits and pushes
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
- auth-loginSkill
- db-backupSkill
- 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
We split this skill into the rules it gives an agent
9 rules. About 0 are common, 5 are distinctive, and 4 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈5
Distinctive · estimate
This author's own choices. Worth a look.
4
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 17
Never: ask them to paste the database URL or password into the chat.
- Distinctive: line 18
Never type it into a form yourself.
- Distinctive: line 37
If it exits 3, the project isn't an app-foundation project.
- Very specific: line 53
If manual in the output isn't empty, the owner had changed one of those files.
- Very specific: line 74
If it shows Failed, the build stops on purpose.
- Distinctive: line 88
Don't ask them to paste it into the chat.
- Very specific: line 96
Add src/db/schema/<system>.ts and export it from src/db/schema/index.ts.
- Very specific: line 97
Run npm run db:generate and commit the new files in drizzle/.
- Distinctive: line 100
Never edit the production database by hand.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
db-connect
Goal: the project gets a real Postgres database. The database is free, doesn't get paused when idle, and is standard Postgres, so it can move to another provider later. Every deploy creates or updates the tables before the site goes live. Follow ../../STACK.md.
The user is probably not a programmer:
- Never ask them to paste the database URL or password into the chat.
- Never type it into a form yourself. The Vercel integration sets it for them.
Why Neon via Vercel
| Neon (default) | Supabase | |
| Free plan when idle | auto-suspends after 5 min, wakes on the next request | project paused after 7 days without activity |
| Free storage | 1 GB per project | 500 MB |
Both are standard Postgres. Moving between them changes DATABASE_URL only. Creating Neon from the Vercel dashboard needs no separate sign-up, and Vercel injects the connection variables into the project automatically.
Steps
1. Check the project
node <skills>/app-foundation/scripts/create.mjs --check --dir "<project>"If it exits 3, the project isn't an app-foundation project. Offer to install app-foundation (episode 002) first.
2. Prepare the code
node <skill-dir>/scripts/apply.mjs --dir "<project>" --jsonIt's safe to run twice. It adds:
scripts/db-migrate.mjs, and makesnpm run buildrun it first- a database check in
/api/healthand/status - a
/db-testpage - the first migration (the
core_eventstable), if the project has none yet
It also records db-connect in stack.json and makes a git save point.
If manual in the output isn't empty, the owner had changed one of those files. Merge the change by hand, keeping their edits.
3. Create the database (the owner clicks; you guide)
The project must already be on Vercel (episode 001). Open the project in Vercel, in the browser tool if you have one, then walk the owner through:
- Storage tab → Create Database → choose Neon → Continue.
- Accept the terms. This creates their Neon account, so it must be the owner's click.
- Choose the Free plan, a region close to their users, and a name.
- Connect to project: tick Development, Preview, Production → Connect.
Afterwards, the project's Settings → Environment Variables list should include DATABASE_URL and DATABASE_URL_UNPOOLED. You may confirm the names exist; never read or show the values.
4. Deploy
Push the commit from step 2 with git push, or click Redeploy in Vercel if it was already pushed. Environment variables only apply to new deployments. The build log should show:
[db-migrate] Database is up to date (… ms).If it shows Failed, the build stops on purpose. The usual causes are the database not being connected to that environment, or a typo in a migration. Show the error line to the owner in plain words.
5. Verify
- Open
https://<project>.vercel.app/api/healthand check thatdatabase.statusis"connected". - Open
/db-test, press Save a test row, reload, and confirm the row is still there. - Open
/statusand check that it says Connected with a latency in ms.
6. Local development (optional)
To make npm run dev use the same database:
- In Vercel → Storage → the database → .env.local tab → Copy.
- The owner pastes it into the project's
.env.localfile themselves. It is git-ignored.
Don't ask them to paste it into the chat.
Tell the owner (short)
"Your site now has a free database. Anything the site saves stays saved, even after redeploys. Tables are created automatically every time you deploy." Then suggest the next step: domain-setup, episode 004, which binds their own domain (needed later for sending email and email-code login).
For skills that add tables later
- Add
src/db/schema/<system>.tsand export it fromsrc/db/schema/index.ts. - Run
npm run db:generateand commit the new files indrizzle/. - The next deploy applies them.
Never edit the production database by hand.
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.

