neon-postgres
Skill1 starsChanged 51 days agoMITView on GitHub
Patterns for working with Neon Postgres in this workspace — branching for schema work, pooled vs direct connections, the dual-driver createDb() factory, and the Neon docs as source of truth
- Reads credentials
29 other projects use a version of this.
Adopted by
Most recently taken up by
- namlxuit056/social-forextheir own version, first seen Nov 8, 2026
- figueroaignacio/ignaciofigueroa.devtheir own version, first seen Nov 8, 2026
- vercel/marketplace-skillstheir own version, first seen Nov 1, 2026
- matheus-rib1108/meu-kit-claude-codetheir own version, first seen Oct 17, 2026
- neondatabase/agent-skillstheir own version, first seen Oct 15, 2026
- xfstudio/skillstheir own version, first seen Oct 13, 2026
Used with
Projects with it also use neon-ai-gateway, neon-functions and 10 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
jaaklaSkillneon-ai-gateway
One API and one credential for frontier and open-source LLMs, built into your Neon branch and powered by Databricks. Use when a user wants to call an LLM, add AI/chat/an agent to their app, route between model providers (OpenAI, Anthropic, Google/Gemini, Meta, Alibaba, and more), or avoid juggling separate provider API keys and accounts — especially when they already use Neon and want AI requests to branch with their project. Works with the OpenAI SDK, Anthropic SDK, google-genai, the Vercel AI SDK, and Mastra by changing only the base URL. Triggers include "call an LLM", "add AI to my app", "chat completion", "model routing", "LLM proxy/gateway", "one API for all models", "use Claude/GPT/Gemini", "AI SDK", "Mastra agent", "Neon AI Gateway", and "log/rate-limit AI calls".
Also in 4 projects that use this
jaaklaSkillneon-functions
Long-running, serverless Node.js HTTP functions deployed onto your Neon branch, with DATABASE_URL injected automatically and compute that runs next to your data. Use when a user wants to host an API, an AI agent with long streaming responses, a WebSocket or server-sent-events (SSE) server, a webhook handler, a Discord bot, an MCP server, or any request/response workload that risks timing out on short, lambda-style serverless functions — and wants it to branch with their database. Also use for Function Triggers: a cron or an object-storage event that POSTs to a function. Triggers include "serverless function", "deploy an API", "long-running function", "streaming agent", "SSE server", "WebSocket server", "webhook handler", "MCP server", "cron", "function trigger", "scheduled function", "cron job", "object storage trigger", "on upload", "run code next to my database", "function that won't time out", "function logs", "Neon Functions", "Neon Compute", "DDoS protection", "rate limiting", and "production hardening".
Also in 4 projects that use this
xAISkillneon-postgres-branches
Choose and create the right Neon branch type for testing and development. Use when users ask about Neon branching, migration testing with real data, isolated test environments, schema-only branch workflows for sensitive data, or branch creation via Neon CLI or Neon MCP. Triggers include "Neon branch", "test migrations safely", "branch production data", "schema-only branch", "reset branch" and "sensitive data testing".
Also in 4 projects that use this
sayuru-akashSkillneon-postgres-egress-optimizer
Diagnose and fix excessive Postgres egress (network data transfer) in a codebase. Use when a user mentions high database bills, unexpected data transfer costs, network transfer charges, egress spikes, "why is my Neon bill so high", "database costs jumped", SELECT * optimization, query overfetching, reduce Neon costs, optimize database usage, or wants to reduce data sent from their database to their application. Also use when reviewing query patterns for cost efficiency, even if the user doesn't explicitly mention egress or data transfer.
Also in 4 projects that use this
VercelSkillnext-cache-components
Next.js 16 Cache Components - PPR, use cache directive, cacheLife, cacheTag, updateTag
Also in 3 projects that use this
SentrySkillnext-best-practices
Next.js best practices - file conventions, RSC boundaries, data patterns, async APIs, metadata, error handling, route handlers, image/font optimization, bundling
Also in 4 projects that use this
- +2 more from jaakla
Other versions29 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 29
- legions-developer/invoicely★ 923same name
- xai-org/plugin-marketplace★ 323same name
- mezotv/notra★ 256same name
- usenotra/notra★ 256same name
- neondatabase/agent-skills★ 111same name
- jaakla/openmapstack★ 76same name
- jaakla/openmapstack-skills★ 76same name
- coinacci/TravelMintNFT★ 69same name
- Xenonesis/code-guardian-report★ 49same name
- iyashjayesh/tokenchit★ 14same name
19 more not listed
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 repository13 other files it gives its agents.
- AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- add-permissionSkill
- downstream-syncSkill
- merge-prSkill
- new-featureSkill
- personalizeSkill
- pre-pushSkill
- process-feedbackSkill
- release-notesSkill
- testSkill
- trivialSkill
- upstream-syncSkill
The file
We split this skill into the rules it gives an agent
2 rules. 0 are common, 1 is distinctive, and 1 is very specific to this project.
0
Common
Most of the 29 edited versions we read keep these.
1
Distinctive
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 44
Delete the branch: when the feature ships.
- Very specific: line 50
Use the pooled host (-pooler suffix) for app code — Neon's PgBouncer multiplexes connections so a bursty serverless workload doesn't …
“Common” is measured: kept by at least 6 in 10 of the 29 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Neon Postgres in This Workspace
Both web apps use one shared Postgres — Neon in staging/production (serverless Postgres with autoscaling, branching, instant restore, scale-to-zero), Docker or native Postgres locally. All DB access goes through the shared createDb() factory in packages/db: a localhost/127.0.0.1/0.0.0.0 hostname in DATABASE_URL selects drizzle-orm/node-postgres (a real pg.Pool); any other hostname selects the Neon serverless driver. The check-driver-capability tripwire refuses a build whose code calls APIs the selected driver can't run (e.g. .transaction() on neon-http).
This skill captures the patterns most relevant to this codebase. For broader Neon questions, fall back to the official docs.
Environment Variables
| Variable | Purpose | Connection shape |
DATABASE_URL | Runtime app connection for both apps. | On Vercel: pooled Neon host (-pooler). Locally: local Postgres. |
DIRECT_DATABASE_URL | Drizzle Kit, migrations, scripts. | Direct (no -pooler suffix). |
Migration tools need a direct connection because they run DDL and inspect the schema; the app at runtime uses the pooled connection because serverless functions burst.
Migration Commands (run from the repo root)
pnpm db:generate # Diff packages/db/src/schema/ against packages/db/migrations/ and write a new migration. File-based only, never dials a DB.
pnpm db:migrate # Apply committed migrations in order (tracked in drizzle.__drizzle_migrations)
pnpm db:push # Apply the live diff directly — early iteration on a disposable branch only. Interactive terminal only (see below).
pnpm db:seed # Seed roles, features, bindings, off-by-default flags. Idempotent.The schema files are the source of truth; packages/db/migrations/ is what gets replayed. Every migration carries a -- MODULE: <name> header (personalization strips by module) and a -- VERIFY: <sql> predicate (the schema-prerequisite gate runs it against the deploy target).
db:push hard-refuses outside a real TTY — drizzle-kit push's destructive-statement confirmation has been directly observed to silently auto-apply (no prompt, no error) when stdin/stdout isn't a terminal. Never pipe, script, or run it from a non-interactive agent shell. DB-touching commands also refuse a non-local DATABASE_URL unless explicitly overridden — schema mistakes belong on disposable branches, not shared environments.
Branching Pattern for Schema Work
Neon's killer feature is branches — instant, copy-on-write clones of your database with their own compute endpoint. Use them for any non-trivial schema change you want to test against production-shaped data:
- Create a Neon branch off
main(Neon console, orneonctl branches create --name feature/<name>). - Grab the branch's connection strings (pooled + direct).
- Point
.env.localat the branch (DATABASE_URL+DIRECT_DATABASE_URL). - Iterate:
pnpm db:pushrepeatedly while shaping the schema (interactive terminal only), thenpnpm db:seedto confirm the seed still applies. - When the schema is right, commit a migration:
pnpm db:generate, add the-- MODULE:header and-- VERIFY:predicate, review, commit. - Apply to production via the db-sync workflow after merge (expand-only migrations).
- Delete the branch when the feature ships.
The point is that schema mistakes never touch production data. CI's e2e workflow uses the same mechanism — an ephemeral branch created and deleted per run.
Pooled vs Direct Connections
Use the pooled host (-pooler suffix) for app code — Neon's PgBouncer multiplexes connections so a bursty serverless workload doesn't exhaust the Postgres connection limit. Use the direct host for migrations.
The Edge runtime cannot import @repo/db regardless of which host is configured — it pulls in a Postgres driver. Each app's src/proxy.ts runs on Edge and must never import it; the server-only guard turns that mistake into a build failure rather than a runtime one.
Scale-to-Zero and Cold Starts
By default, Neon's compute suspends after a few minutes of inactivity and resumes on the next query. The first query after suspend has a noticeable cold-start penalty (hundreds of milliseconds). Storage stays active, so data is never paged out.
Useful Patterns
Querying
import { db } from "@repo/db";
import { users } from "@repo/db/schema";
import { eq } from "drizzle-orm";
const row = await db.query.users.findFirst({ where: eq(users.email, email) });Raw SQL escape hatch
db.execute(sql\SELECT count(*) FROM audit_events`)viadrizzle-orm's sqltag. Use sparingly — almost everything is expressible through the query builder — and neversql<Date>(thecheck:sql-date` tripwire bans it: the Neon serverless driver returns computed-expression timestamps as strings at runtime, so the type lies).
Two traps that have both cost real time:
- Alias every computed column.
SELECT to_regclass(a) IS NOT NULL, to_regclass(b) IS NOT NULLreturns two columns BOTH named?column?; node-postgres keys each row by column name, so they collapse into one and the second value is lost. - Never round-trip a timestamp through JavaScript for a keyset cursor. Postgres stores
timestamptzat microsecond precision; a JSDateholds milliseconds, so a row at.123456is neither< .123nor= .123and vanishes from later pages. Compare row values inside Postgres instead.
Neon Documentation
The Neon docs are the source of truth for platform behavior. Always verify against the docs before relying on a feature claim — Neon evolves.
- Docs index: https://neon.com/docs/llms.txt
- Branching: https://neon.com/docs/introduction/branching
- Connection pooling: https://neon.com/docs/connect/connection-pooling
- Scale to zero: https://neon.com/docs/introduction/scale-to-zero
- Instant restore: https://neon.com/docs/introduction/branch-restore
- Drizzle + Neon: https://neon.com/docs/guides/drizzle
- Neon CLI (
neonctl): https://neon.com/docs/reference/neon-cli
Any Neon doc page is available as Markdown by appending .md to the URL.
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.

