agentleFS
aideploytutoraideploytutor/skill-deploy-share/skills/db-connect/SKILL.md

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

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
  1. Distinctive:

    Never: ask them to paste the database URL or password into the chat.

    line 17
  2. Distinctive:

    Never type it into a form yourself.

    line 18
  3. Distinctive:

    If it exits 3, the project isn't an app-foundation project.

    line 37
  4. Very specific:

    If manual in the output isn't empty, the owner had changed one of those files.

    line 53
  5. Very specific:

    If it shows Failed, the build stops on purpose.

    line 74
  6. Distinctive:

    Don't ask them to paste it into the chat.

    line 88
  7. Very specific:

    Add src/db/schema/<system>.ts and export it from src/db/schema/index.ts.

    line 96
  8. Very specific:

    Run npm run db:generate and commit the new files in drizzle/.

    line 97
  9. Distinctive:

    Never edit the production database by hand.

    line 100

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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 idleauto-suspends after 5 min, wakes on the next requestproject paused after 7 days without activity
Free storage1 GB per project500 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>" --json

It's safe to run twice. It adds:

  • scripts/db-migrate.mjs, and makes npm run build run it first
  • a database check in /api/health and /status
  • a /db-test page
  • the first migration (the core_events table), 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:

  1. Storage tab → Create Database → choose Neon → Continue.
  2. Accept the terms. This creates their Neon account, so it must be the owner's click.
  3. Choose the Free plan, a region close to their users, and a name.
  4. 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/health and check that database.status is "connected".
  • Open /db-test, press Save a test row, reload, and confirm the row is still there.
  • Open /status and check that it says Connected with a latency in ms.

6. Local development (optional)

To make npm run dev use the same database:

  1. In Vercel → Storage → the database → .env.local tab → Copy.
  2. The owner pastes it into the project's .env.local file 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

  1. Add src/db/schema/<system>.ts and export it from src/db/schema/index.ts.
  2. Run npm run db:generate and commit the new files in drizzle/.
  3. The next deploy applies them.

Never edit the production database by hand.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.