Backend · Skill

Configure Neon Postgres

configure-neon-postgres

Configures an existing Neon or Lakebase Postgres database. Covers pooled versus direct connections, migrations on a branch, branch-per-PR, scale-to-zero, restore, replicas, IP allow lists, and Lakebase search. Use when the database is already on Neon, the host contains -pooler, or the user mentions Neon branches, egress, a suspended Free compute, or the Neon serverless driver.

Works with: Any AI Not yet model-tested; testing Jan 2027

Paste it into ChatGPT, Claude, Gemini or any AI chat, then tell it about your project. How it works

Install in Claude Code, Cursor or Codex (optional)

Only for AI coding tools that read skill folders. Run one line in a terminal, in your project folder. It downloads this skill's text files from TheSkillVault and nothing else; you can read them first with “View raw SKILL.md”.

Claude Code (all your projects)

curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/configure-neon-postgres/raw' -o ~/'.claude/skills/configure-neon-postgres/SKILL.md' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/configure-neon-postgres/files/LICENSE.txt' -o ~/'.claude/skills/configure-neon-postgres/LICENSE.txt' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/configure-neon-postgres/files/NOTICE.txt' -o ~/'.claude/skills/configure-neon-postgres/NOTICE.txt'

Cursor (this project)

curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/configure-neon-postgres/raw' -o '.cursor/skills/configure-neon-postgres/SKILL.md' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/configure-neon-postgres/files/LICENSE.txt' -o '.cursor/skills/configure-neon-postgres/LICENSE.txt' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/configure-neon-postgres/files/NOTICE.txt' -o '.cursor/skills/configure-neon-postgres/NOTICE.txt'

Codex and other Agent Skills tools (this project)

curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/configure-neon-postgres/raw' -o '.agents/skills/configure-neon-postgres/SKILL.md' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/configure-neon-postgres/files/LICENSE.txt' -o '.agents/skills/configure-neon-postgres/LICENSE.txt' && curl -fsSL --create-dirs 'https://theskillvault.ai/api/skills/configure-neon-postgres/files/NOTICE.txt' -o '.agents/skills/configure-neon-postgres/NOTICE.txt'

Or connect the whole library over MCP

Add TheSkillVault to Cursor or add this to your app's MCP settings (read-only; help):

{
  "mcpServers": {
    "theskillvault": {
      "url": "https://theskillvault.ai/mcp"
    }
  }
}

Neon (Lakebase) is Postgres with separate storage and compute. You get branches, scale-to-zero, and a pooler. This skill is for a database that already exists. It does not pick a new auth provider. Login belongs in add-neon-auth.

When to use

  • You have a Neon DATABASE_URL and need the pooled or direct host.
  • You want a schema-only branch, a reset from parent, or a branch per pull request.
  • A Free project is suspended, or the bill shows high network transfer.
  • You are adding Lakebase vector or hybrid search.

When not to use

  • You are designing ordinary Postgres tables, types, and keys. Use design-postgres-tables.
  • A query is slow and the host is not Neon. Use optimise-slow-sql-queries.
  • You are installing Prisma itself. Use set-up-prisma-orm, then come back for the Neon URL.

Steps

  1. If a DATABASE_URL or a .neon file already points at the project, use it. Do not create a second project for schema work.
  2. Keep two URLs. The pooled host contains -pooler. The direct host does not. App traffic uses the pooled URL. Migrations, pg_dump, logical replication, LISTEN / NOTIFY, and anything that uses SET use the direct URL.
  3. Change schema only through migration files. Test the migration on a branch of production before you apply it to production. Run that migration on the direct URL.
  4. For a pull request, create a branch. A normal branch is a copy-on-write clone with its own compute. A schema-only branch copies structure without the rows. Reset-from-parent throws away the branch's changes and matches the parent again.
  5. Size compute with neon postgres computes update <id> --cu <min>-<max>. Scale-to-zero suspends an idle compute. The first query then waits a cold start. Storage stays. Free plans cannot change the suspend timeout.
  6. Read replicas are extra read-only compute on the same storage. Use them for reporting, not for migrations.
  7. Restrict networks with an IP allow list when the database must not be open to the internet. Logical replication uses the direct connection.
  8. For search, enable lakebase_vector only after the user agrees. Match the column dimension to the embedding model. Rank only rows that have a vector.

Prisma and the direct URL

Prisma 7 removed datasource.directUrl from the schema. Do not add it back. Point the Prisma 7 CLI URL in prisma.config.ts at the direct host (no -pooler). The running app keeps the pooled URL. Prisma 6 and earlier still use url plus directUrl in the schema. See set-up-prisma-orm. A pooled migration fails in odd ways: a prepared statement that already exists, a search_path that vanishes, or SQLSTATE 25006.

select id, title, embedding <=> $1::vector as distance
from documents
where embedding is not null
order by distance
limit $2;

A null embedding is not a neighbour. The same filter belongs on every vector arm of a hybrid query. The distance operator must match the index operator class. Do not rank with a boolean range operator.

Free plan

Running out of CU-hours or public network transfer suspends the compute. Data stays. Postgres then fails with SQLSTATE 53000. The HTTP driver fails with status 402. Fix the queries that transfer too much data before you raise the quota, or the project hits the cap again. Ask the user before any plan change.

Gotchas

  • neon inspect db checks (table-sizes, locks, outliers, bloat) are read-only candidates. An unused index is not permission to drop it. Cache stats reset when compute suspends.
  • EXPLAIN (ANALYZE, BUFFERS, PREFETCH, FILECACHE) runs the statement. Use it only on a read you are willing to execute.
  • Do not install the separate neon-postgres egress eval skill. It is not this guide.

Safety

  • Never paste a connection string, token, or password into chat or git. Keep them in .env.
  • Ask before CREATE EXTENSION, a plan change, or a restore onto a shared branch.
  • A branch still holds a copy of production rows. Treat it as private data.

Portability

Works with any language that speaks Postgres. node-postgres, @neondatabase/serverless, Drizzle, and Prisma are all fine. On Vercel or Cloudflare, follow that host's pool helper. Another Postgres host does not have Neon branches. Use design-postgres-tables there.

Done when

  • App traffic uses the pooled host and migrations use the direct host.
  • Schema changes are migration files, tried on a branch first.
  • Vector queries exclude null embeddings.
  • No secret is written into the repo.

Example prompt

"Point this app at the Neon pooler, run the next migration on a schema branch with the direct URL, and do not add a Prisma 7 directUrl."

---

Modified from the original neon-postgres skill in neondatabase/agent-skills. Credit: Neon, Apache-2.0. The upstream LICENSE copyright line is the unfilled template. Original: https://github.com/neondatabase/agent-skills/blob/067f9fb2df21953b216867d60ec500ddaf3e5647/skills/neon-postgres/SKILL.md. Changes by TheSkillVault are listed above and in NOTICE.txt. See LICENSE.txt.

Bundled files

Licence

Adapted from andrelandgraf (Neon, neondatabase/agent-skills, neon-postgres) (Neon, Apache-2.0. Upstream LICENSE keeps the unfilled template line Copyright [yyyy] [name of copyright owner].), Apache License 2.0. true. Modified from the original by TheSkillVault on 2026-11-18. Rewritten as a house skill for an existing Neon database. Dropped the parent neon skill, the egress-eval skill, and the long reference pack. Prisma 7 no longer uses schema directUrl. Vector ranking now skips null embeddings. Not the original file.

Licence: Apache License 2.0. Attribution when you reuse it: Based on work by andrelandgraf (Neon, neondatabase/agent-skills, neon-postgres) (Neon, Apache-2.0. Upstream LICENSE keeps the unfilled template line Copyright [yyyy] [name of copyright owner]., Apache License 2.0), https://github.com/neondatabase/agent-skills/blob/067f9fb2df21953b216867d60ec500ddaf3e5647/skills/neon-postgres/SKILL.md; adapted by TheSkillVault, https://theskillvault.ai