Skip to content
Development
Skill

/api-baas-neon

Serverless PostgreSQL with branching, autoscaling, and edge-compatible driver

From plugin
skills
26200 skills

Claude Code

$ npx -y skills add agents-inc/skills --skill api-baas-neon --agent claude-code

SKILL.md

api-baas-neon.SKILL.md
name: api-baas-neon
description: Serverless PostgreSQL with branching, autoscaling, and edge-compatible driver

Neon Serverless PostgreSQL Patterns

> **Quick Guide:** Use `@neondatabase/serverless` for edge/serverless database access. Prefer the `neon()` HTTP function for single queries (faster, stateless) and `Pool`/`Client` for interactive transactions. Use pooled connection strings (`-pooler` suffix) for serverless workloads, direct connections only for migrations. Branch your database for dev/preview environments using copy-on-write semantics. Always handle cold starts from scale-to-zero (200-500ms wake-up).

---

<critical_requirements>

CRITICAL: Before Using This Skill

**(You MUST use the `neon()` HTTP function for single queries in edge/serverless runtimes -- it is 2-3x faster than WebSocket for one-shot operations)**

**(You MUST close `Pool`/`Client` connections within the same request handler in serverless environments -- WebSocket connections cannot outlive a single request)**

**(You MUST use pooled connection strings (`-pooler` suffix) for serverless workloads -- direct connections exhaust the limited connection slots)**

**(You MUST handle scale-to-zero wake-up latency (200-500ms) with appropriate connection timeouts and retry logic)**

**(You MUST use `sql.unsafe()` only for trusted, known-safe strings like table/column names -- never for user input)**

</critical_requirements>

---

**Auto-detection:** Neon, @neondatabase/serverless, neon(), neonConfig, neon serverless driver, neon database, neon branch, neonctl, neon connection pooling, neon scale-to-zero, neon autoscaling, neon postgres, ep-\*-pooler

**When to use:**

  • Querying Postgres from edge/serverless functions (edge runtimes, serverless platforms)
  • Setting up connection strings (pooled vs direct) for different workloads
  • Creating database branches for dev, preview, or CI environments
  • Managing scale-to-zero behavior and cold start optimization
  • Running transactions in serverless contexts (HTTP batch or WebSocket)
  • Programmatic branch management via Neon API or neonctl CLI

**Key patterns covered:**

  • `neon()` HTTP queries with SQL tagged templates and composable fragments
  • `Pool`/`Client` WebSocket connections with proper lifecycle management
  • Pooled (`-pooler`) vs direct connection strings and when to use each
  • Database branching (dev branches, PR preview branches, schema-only branches)
  • Scale-to-zero behavior, cold start mitigation, and autoscaling
  • `sql.transaction()` for non-interactive HTTP transactions
  • Neon API and neonctl CLI for programmatic branch management

**When NOT to use:**

  • Traditional long-lived server connections (use standard `pg` driver with TCP)
  • Complex ORM-specific patterns (use your ORM's own skill)
  • General PostgreSQL query syntax (use a SQL/Postgres skill)

**Detailed Resources:**

  • For decision frameworks and quick lookup tables, see [reference.md](reference.md)

**Driver & Queries:**

  • [examples/core.md](examples/core.md) -- Driver setup, HTTP queries, WebSocket connections, transactions

**Branching & Operations:**

  • [examples/branching.md](examples/branching.md) -- Dev branches, PR previews, neonctl CLI, Neon API, CI/CD workflows

---

<philosophy>

Philosophy

Neon separates storage and compute for PostgreSQL, enabling serverless features impossible with traditional Postgres: scale-to-zero, instant branching, and autoscaling. The `@neondatabase/serverless` driver replaces TCP with HTTP and WebSockets, making Postgres accessible from edge runtimes that lack TCP support.

**Core principles:**

1. **HTTP for speed, WebSocket for sessions** -- The `neon()` function uses HTTP fetch (~3 round trips) for single queries. `Pool`/`Client` use WebSockets (~8 round trips) when you need sessions or interactive transactions. Pick the right transport for the job. 2. **Pooled by default** -- Pooled connections route through PgBouncer (transaction mode), handling up to 10,000 concurrent clients. Direct connections are limited by compute size (100-4,000) and should only be used for migrations or features requiring session state. 3. **Branches are cheap** -- Copy-on-write means a branch of a 500GB database allocates no extra storage until data diverges. Use branches freely for dev, preview, testing, and CI. 4. **Scale-to-zero is the default** -- Computes suspend after 5 minutes of inactivity. Cold starts take 200-500ms. Design for this with timeouts, retries, and connection pooling. 5. **SQL injection safety built in** -- The tagged template function parameterizes automatically. Since v1.0, calling `neon()` as a regular function is a type error, preventing accidental injection.

**When to use Neon serverless driver:**

  • Edge/serverless functions that cannot open TCP connections
  • Applications benefiting from database branching (preview environments per PR)
  • Cost-sensitive workloads that benefit from scale-to-zero
  • High-concurrency serverless apps needing connection pooling

**When NOT to use:**

  • Long-running server processes with persistent connections (use standard `pg` over TCP)
  • Workloads requiring session-level features through PgBouncer (LISTEN/NOTIFY, SET, temporary tables)
  • Databases larger than 16 CU that need always-on compute (scale-to-zero not available above 16 CU)

</philosophy>

---

<patterns>

Core Patterns

Pattern 1: HTTP Queries with `neon()`

The `neon()` function creates an HTTP-based query function using SQL tagged templates. It is the fastest path for single, non-interactive queries.

import { neon } from "@neondatabase/serverless";

const DATABASE_URL = process.env.DATABASE_URL!;
const sql = neon(DATABASE_URL);

// Tagged template -- parameters are auto-parameterized (safe from injection)
const userId = "abc-123";
const posts =
  await sql`SELECT id, title FROM posts WHERE author_id = ${userId}`;

**Why good:** Tagged template auto-parameterizes values preventing SQL injection, HTTP is ~3 round trips vs ~8

Read more
@agents-inc
Ships withskills

The official skills marketplace for Agents Inc. 230+ skills covering everything from React and Prisma to Redis, ElevenLabs, and infrastructure tooling. Pick the skills that match your stack and install them via Claude Code. Need more control?

Stars on GitHub

Momentum

stars in total
26
Star history of agents-inc/skills on GitHub, a chart by star-history.com

Other skills on skills.

ai-infrastructure-litellm

ai-infrastructure-lite…

LiteLLM proxy server setup, TypeScript client patterns via OpenAI SDK, model routing, fallbacks, load balancing, spend tracking,…

@agents-inc@agents-incInstall Skill
ai-infrastructure-modal

ai-infrastructure-moda…

Serverless GPU compute platform for AI model deployment — web endpoints, GPU functions, model serving, and TypeScript client…

@agents-inc@agents-incInstall Skill
ai-infrastructure-ollama

ai-infrastructure-olla…

Local LLM inference with the Ollama JavaScript client -- chat, streaming, tool calling, vision, embeddings, structured output,…

@agents-inc@agents-incInstall Skill

More skills from other plugins.

brainstorming
Auto-invoked

brainstorming

You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…

@obra@obraInstall Skill
ask-matt

ask-matt

Ask which skill or flow fits your situation. A router over the skills in this repo.

skills10d309k
@mattpocock@mattpocockInstall Skill
accessibility
Auto-invoked

accessibility

Design, implement, and audit accessible UI to WCAG 2.2 Level AA across Web, iOS, and Android — semantic ARIA roles and labels,…

ecc12d293k
@affaan-m@affaan-mInstall Skill
compiler-commit

compiler-commit

Use when you want to verify compiler changes and commit with the correct convention. Runs tests, lint, and format, then commits…

react1d252k
@facebook@facebookInstall Skill

Questions about api-baas-neon.

Which coding agents can use api-baas-neon?
api-baas-neon installs in Claude Code, Codex, Cursor, Gemini CLI, GitHub Copilot, OpenCode and Windsurf with the skills CLI, using each agent's flag shown on this page. Flowy's auto-invocation, which fires a skill when your prompt matches, runs in Claude Code only.