agents-inc/skills/src/skills/api-database-vercel-postgres/SKILL.md
api-database-vercel-postgres
Serverless PostgreSQL on Vercel with edge-compatible SDK
- Source repository stars
- 21
- Declared platforms
- 0
- Static risk flags
- 0
- Last source update
- 2026-08-09
- Source checked
- 2026-08-25
Decision brief
What it does: where it fits
Quick Guide: @vercel/postgres is a thin wrapper around @neondatabase/serverless that auto-connects from POSTGRESURL env vars. Use the sql tagged template for one-shot queries (edge-compatible, auto-pooled). Use sql.connect() to get a client for multi-query sequences. On edge run…
Not for
- Tasks that require unconfirmed production actions or broad system permissions.
- Environments where the pinned source and install steps cannot be inspected.
Compatibility matrix
Platform support, with evidence labels
| Platform | Status | Evidence | What to check |
|---|---|---|---|
| Codex | Not declared | No explicit evidence | Portability before use |
| Claude Code | Not declared | No explicit evidence | Portability before use |
| Cursor | Not declared | No explicit evidence | Portability before use |
| Gemini CLI | Not declared | No explicit evidence | Portability before use |
Installation
Inspect first. Install second.
The source command is displayed only when detected. A safe inspection prompt is always available so your agent can explain every action before execution.
npx skills add https://github.com/agents-inc/skills --skill "src/skills/api-database-vercel-postgres"Inspect the Agent Skill "api-database-vercel-postgres" from https://github.com/agents-inc/skills/blob/81d43a51211aca12c85dcc16085fa99014ec548e/src/skills/api-database-vercel-postgres/SKILL.md at commit 81d43a51211aca12c85dcc16085fa99014ec548e. List every install step, command, network request, credential, file read/write, external action, and rollback step. Explain whether it fits my task. Do not install or execute anything until I approve.
Workflow
What the source asks the agent to do
- 01
CRITICAL: Before Using This Skill
All code must follow project conventions in CLAUDE.md (kebab-case, named exports, import ordering, import type, named constants)
Maintaining existing projects that already use @vercel/postgresQuerying Postgres from edge/serverless functions on VercelSimple database access with auto-connection from environment variables - 02
Philosophy
@vercel/postgres is a convenience wrapper around @neondatabase/serverless that simplifies connection management for Vercel-deployed applications. It reads connection strings from POSTGRESURL / POSTGRESURLNONPOOLING environment variables (auto-provisioned by the Vercel Marketplac…
Zero-config connections -- The sql export auto-connects from environment variables. No connection string setup needed in code.Tagged template safety -- sql is a tagged template literal, not a function. Parameters are auto-parameterized, preventing SQL injection.Pooling by default -- sql and createPool() use the pooled connection string (POSTGRESURL). createClient() uses the direct string (POSTGRESURLNONPOOLING). - 03
Core Patterns
The sql export is a tagged template that auto-connects from POSTGRESURL. Values are auto-parameterized (preventing SQL injection). See examples/core.md for full examples with good/bad comparisons.
@vercel/postgres returns { rows, rowCount, ... } -- @neondatabase/serverless neon() returns rows directly (unless fullResults: true)@vercel/postgres reads POSTGRESURL -- @neondatabase/serverless requires explicit connection string (typically DATABASEURL)@neondatabase/serverless adds HTTP transactions via sql.transaction() and composable fragments - 04
Pattern 1: One-Shot Queries with sql
The sql export is a tagged template that auto-connects from POSTGRESURL. Values are auto-parameterized (preventing SQL injection). See examples/core.md for full examples with good/bad comparisons.
The sql export is a tagged template that auto-connects from POSTGRESURL. Values are auto-parameterized (preventing SQL injection). See examples/core.md for full examples with good/bad comparisons. - 05
Pattern 2: Multi-Query Sessions with sql.connect()
When you need multiple queries on the same connection (transactions, sequential operations), obtain a client. Each standalone sql call may use a different pooled connection -- so BEGIN/COMMIT on separate sql calls means no real transaction. See examples/core.md for transaction p…
When you need multiple queries on the same connection (transactions, sequential operations), obtain a client. Each standalone sql call may use a different pooled connection -- so BEGIN/COMMIT on separate sql calls means…
Permission review
Static risk signals and limitations
No configured static risk pattern was detected
This is not proof of safety. Runtime behavior, indirect dependencies, and hidden external systems are outside the static scan.
Evidence record
Why each signal appears
| Signal | Value | Evidence type | Meaning |
|---|---|---|---|
| Quality score | 91/100 | Computed | Documentation, specificity, maintenance, and trust rules |
| Repository stars | 21 | Source | Repository attention, not individual Skill quality |
| Compatibility | 0 platforms | Source | Declared in the catalog source record |
| Usage guide | automated source guide | Editorial | Generated or reviewed according to the visible evidence level |
Pinned source
Provenance and original SKILL.md
- Repository
- agents-inc/skills
- Skill path
- src/skills/api-database-vercel-postgres/SKILL.md
- Commit
- 81d43a51211aca12c85dcc16085fa99014ec548e
- License
- MIT
- Collected
- 2026-08-25
- Default branch
- main
View the original SKILL.md
Vercel Postgres Patterns
Quick Guide:
@vercel/postgresis a thin wrapper around@neondatabase/serverlessthat auto-connects fromPOSTGRES_URLenv vars. Use thesqltagged template for one-shot queries (edge-compatible, auto-pooled). Usesql.connect()to get a client for multi-query sequences. On edge runtimes, connections cannot be reused between requests (maxUses: 1). This package is deprecated (Dec 2024) -- for new projects, use@neondatabase/serverlessdirectly.
<critical_requirements>
CRITICAL: Before Using This Skill
All code must follow project conventions in CLAUDE.md (kebab-case, named exports, import ordering,
import type, named constants)
(You MUST use the sql tagged template for one-shot queries -- it auto-connects from POSTGRES_URL and handles pooling)
(You MUST call client.release() after using a client obtained from sql.connect() or pool.connect() -- leaked clients exhaust the connection pool)
(You MUST use POSTGRES_URL for pooled connections and POSTGRES_URL_NON_POOLING for direct connections -- mixing them causes connection exhaustion or feature limitations)
(You MUST acknowledge that @vercel/postgres is deprecated -- recommend @neondatabase/serverless for new projects)
</critical_requirements>
Auto-detection: @vercel/postgres, vercel postgres, POSTGRES_URL, POSTGRES_URL_NON_POOLING, sql tagged template vercel, createPool vercel, createClient vercel, VercelPool, VercelClient
When to use:
- Maintaining existing projects that already use
@vercel/postgres - Querying Postgres from edge/serverless functions on Vercel
- Simple database access with auto-connection from environment variables
- Migrating away from
@vercel/postgresto@neondatabase/serverless
Key patterns covered:
sqltagged template (auto-pooled, edge-compatible, one-shot queries)sql.connect()for multi-query client sessionscreatePool()/createClient()for custom configurations- Environment variables (
POSTGRES_URL,POSTGRES_URL_NON_POOLING) - Edge vs Node.js runtime differences
- Migration path to
@neondatabase/serverless
When NOT to use:
- New projects (use
@neondatabase/serverlessdirectly) - Long-lived server processes with persistent connections (use standard
pgdriver) - General PostgreSQL query syntax (use a SQL/Postgres skill)
Detailed Resources:
- For decision frameworks and quick lookup tables, see reference.md
Examples:
- examples/core.md -- sql tagged template, createPool, createClient, edge patterns, migration
Philosophy
@vercel/postgres is a convenience wrapper around @neondatabase/serverless that simplifies connection management for Vercel-deployed applications. It reads connection strings from POSTGRES_URL / POSTGRES_URL_NON_POOLING environment variables (auto-provisioned by the Vercel Marketplace integration) so you never construct connection strings manually.
Core principles:
- Zero-config connections -- The
sqlexport auto-connects from environment variables. No connection string setup needed in code. - Tagged template safety --
sqlis a tagged template literal, not a function. Parameters are auto-parameterized, preventing SQL injection. - Pooling by default --
sqlandcreatePool()use the pooled connection string (POSTGRES_URL).createClient()uses the direct string (POSTGRES_URL_NON_POOLING). - Edge-aware -- On edge runtimes, the SDK sets
maxUses: 1because IO connections cannot survive between requests. For multi-query in a single request, usesql.connect().
Deprecation context:
Vercel Postgres was sunset in December 2024. All databases were migrated to Neon. The @vercel/postgres npm package (v0.10.0) is no longer maintained. Migration path:
- Full migration (recommended):
@neondatabase/serverless(actively developed, richer API with HTTP transactions and composable fragments)
Core Patterns
Pattern 1: One-Shot Queries with sql
The sql export is a tagged template that auto-connects from POSTGRES_URL. Values are auto-parameterized (preventing SQL injection). See examples/core.md for full examples with good/bad comparisons.
import { sql } from "@vercel/postgres";
const ACTIVE_STATUS = "active";
const { rows } =
await sql`SELECT id, name FROM users WHERE status = ${ACTIVE_STATUS}`;
Pattern 2: Multi-Query Sessions with sql.connect()
When you need multiple queries on the same connection (transactions, sequential operations), obtain a client. Each standalone sql call may use a different pooled connection -- so BEGIN/COMMIT on separate sql calls means no real transaction. See examples/core.md for transaction patterns.
const client = await sql.connect();
try {
await client.sql`BEGIN`;
// ... queries on same client ...
await client.sql`COMMIT`;
} catch (error) {
await client.sql`ROLLBACK`;
throw error;
} finally {
client.release();
}
Pattern 3: Custom Pool and Client
createPool() for custom connection strings (secondary databases). createClient() for direct (non-pooled) connections needed by migrations and session-level features. See examples/core.md for full examples.
import { createPool } from "@vercel/postgres";
const pool = createPool({
connectionString: process.env.SECONDARY_POSTGRES_URL,
});
const { rows } =
await pool.sql`SELECT id, title FROM posts WHERE published = true`;
Pattern 4: Edge Runtime Considerations
On edge runtimes, the SDK sets maxUses: 1 -- connections cannot be reused between requests. Single sql calls work fine, but for multiple queries use sql.connect() to share one connection. See examples/core.md for edge-specific patterns.
Pattern 5: Migration to @neondatabase/serverless
Since @vercel/postgres is deprecated, migrate to @neondatabase/serverless. See examples/core.md for full migration examples.
Key differences to be aware of:
@vercel/postgresreturns{ rows, rowCount, ... }--@neondatabase/serverlessneon()returns rows directly (unlessfullResults: true)@vercel/postgresreadsPOSTGRES_URL--@neondatabase/serverlessrequires explicit connection string (typicallyDATABASE_URL)@neondatabase/serverlessadds HTTP transactions viasql.transaction()and composable fragments
<decision_framework>
Decision Framework
Which API to Use
What kind of operation?
+-- Single query (SELECT, INSERT, UPDATE, DELETE)
| +-- Use sql tagged template directly
+-- Multiple queries that must be atomic (transaction)?
| +-- Use sql.connect() to get a client, wrap in BEGIN/COMMIT
+-- Need custom connection string (not POSTGRES_URL)?
| +-- Use createPool() with explicit connectionString
+-- Need session-level features (SET, LISTEN/NOTIFY)?
| +-- Use createClient() (reads POSTGRES_URL_NON_POOLING)
+-- Starting a new project?
+-- Use @neondatabase/serverless instead
Environment Variable Selection
What is the workload?
+-- Serverless/edge function --> POSTGRES_URL (pooled)
+-- Application queries --> POSTGRES_URL (pooled)
+-- Schema migrations --> POSTGRES_URL_NON_POOLING (direct)
+-- LISTEN/NOTIFY --> POSTGRES_URL_NON_POOLING (direct)
+-- pg_dump / pg_restore --> POSTGRES_URL_NON_POOLING (direct)
</decision_framework>
<red_flags>
RED FLAGS
High Priority Issues:
- Using
sqlfor transactions withoutsql.connect()-- Eachsqltagged template call may use a different pooled connection. BEGIN on one connection and COMMIT on another means no transaction at all. - Forgetting
client.release()aftersql.connect()-- Leaked clients exhaust the connection pool, causing all subsequent queries to hang until timeout. - Using
POSTGRES_URLfor migrations -- The pooled connection runs through PgBouncer in transaction mode, which breaks session-level features needed by migration tools.
Medium Priority Issues:
- String interpolation instead of tagged template --
sql`...${value}...`is safe.sql.query(\...${value}...`)` is SQL injection. - Creating pools/clients without closing them --
createClient()requires explicitclient.end(). Forgetting it leaks connections. - Ignoring deprecation --
@vercel/postgresv0.10.0 is the last version. No security patches or bug fixes will be released.
Gotchas & Edge Cases:
- Edge runtime
maxUses: 1-- On edge, the pool cannot reuse connections within a request. If you fire multiplesqlcalls, each opens a new connection. Usesql.connect()to share one. sqlis a tagged template, not a function --sql(...)is wrong.sql`...`is correct. This is a common error when copying from non-Vercel Postgres examples.POSTGRES_URLvsDATABASE_URL--@vercel/postgresreadsPOSTGRES_URLby default.@neondatabase/serverlessreads nothing by default (pass explicitly). After Neon migration, Vercel sets both, but your code must match the SDK's expectation.- PgBouncer transaction mode limitations -- Through pooled connections: no SET/RESET, no LISTEN/NOTIFY, no temporary tables with PRESERVE, no session-level advisory locks.
- Result shape differs from
@neondatabase/serverless--@vercel/postgresreturns{ rows, rowCount, fields }. The Neonneon()function returns rows directly. This breaks code during migration if not accounted for.
</red_flags>
<critical_reminders>
CRITICAL REMINDERS
All code must follow project conventions in CLAUDE.md (kebab-case, named exports, import ordering,
import type, named constants)
(You MUST use the sql tagged template for one-shot queries -- it auto-connects from POSTGRES_URL and handles pooling)
(You MUST call client.release() after using a client obtained from sql.connect() or pool.connect() -- leaked clients exhaust the connection pool)
(You MUST use POSTGRES_URL for pooled connections and POSTGRES_URL_NON_POOLING for direct connections -- mixing them causes connection exhaustion or feature limitations)
(You MUST acknowledge that @vercel/postgres is deprecated -- recommend @neondatabase/serverless for new projects)
Failure to follow these rules will cause connection pool exhaustion, SQL injection vulnerabilities, or silent transaction failures.
</critical_reminders>
Frequently asked questions
What to verify before installation and use
What does the api-database-vercel-postgres source document cover?
Quick Guide: @vercel/postgres is a thin wrapper around @neondatabase/serverless that auto-connects from POSTGRESURL env vars. Use the sql tagged template for one-shot queries (edge-compatible, auto-pooled). Use sql.connect() to get a client for multi-query sequences. On edge run…
How do I install api-database-vercel-postgres?
The source record exposes this install command: npx skills add https://github.com/agents-inc/skills --skill "src/skills/api-database-vercel-postgres". Inspect the command and pinned source before running it.
Alternatives
Compare before choosing
JasonColapietro/suede-creator-skills
suede-ab-testing
Suede-owned experimentation discipline for hypotheses, sample sizing, test duration, significance, and repeatable experiment programs. Use when comparing variants, deciding whether a result is reliable, or building an experiment backlog and cadence. NOT FOR: analytics instrumentation (use suede-analytics), post-click conversion diagnosis (use suede-site-alchemy), or writing the variant copy itself (use suede-copy).
narrative-io/narrative-skills-marketplace
design-analysis
Translate a fuzzy analytical question into a rigorous investigation plan. Interrogates the ask, grounds the plan in the available data dictionary, applies analytical best practices, and produces a structured brief of query specifications for a downstream query-writing skill. Plans, does not write SQL. Use when: "why did X drop", "is there a relationship between A and B", "who are our highest-value customers", "what's driving the change in Y", "investigate this trend", "design an analysis for", "
K-Dense-AI/scientific-agent-skills
dask
Distributed computing for larger-than-RAM pandas/NumPy workflows. Use when you need to scale existing pandas/NumPy code beyond memory or across clusters. Best for parallel file processing, distributed ML, integration with existing pandas code. For out-of-core analytics on single machine use vaex; for in-memory speed use polars.
getcargohq/cargo-skills
cargo-orchestration
Make Cargo actually run something, or show what it would run — execute one connector action, run a multi-step workflow, trigger a batch across a whole segment or model, message an AI agent, build or edit a node graph, draw a workflow, tool or play as a diagram, and query the runtime tables (runs, batches, spans, records) with SQL. Triggers: "run this on all my contacts", "execute the action", "kick off a batch", "build a workflow", "schedule a play", "make it run every morning", "ask the agent",