neon-serverless

neon-serverless is a cursor rule for Cursor from neondatabase/ai-rules. It costs 0 tokens per session (2,128 once invoked), scanned A, original, MIT.

A guide for using Neon's serverless database driver, which connects applications to hosted PostgreSQL through web-friendly connection methods. Serverless environments run code on demand instead of keeping one server running continuously.

In plain words
What is it for?
Querying Neon from Vercel Edge Functions, Cloudflare Workers, AWS Lambda, Google Cloud Functions, and similar serverless applications.
Why use it?
It helps developers choose and configure database connections for edge functions and serverless APIs while keeping connection credentials in environment variables.

Cursor rule for Cursor ✓ vendor

Written for Cursor: a Cursor rule (.mdc). Also seen: positional $N argument.

Good fit Querying Neon from Vercel Edge Functions, Cloudflare Workers, AWS Lambda, Google Cloud Functions, and similar serverless applications.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/neondatabase/ai-rules/neon-serverless
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/neondatabase/ai-rules

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for neon-serverless

README.md
[![agentmods](https://agentmods.dev/badge/rules/neondatabase/ai-rules/neon-serverless/github.svg)](https://agentmods.dev/rules/neondatabase/ai-rules/neon-serverless)
Your own site
<a href="https://agentmods.dev/rules/neondatabase/ai-rules/neon-serverless"><img src="https://agentmods.dev/badge/rules/neondatabase/ai-rules/neon-serverless/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for neon-serverless

Your own site · 80×15
<a href="https://agentmods.dev/rules/neondatabase/ai-rules/neon-serverless"><img src="https://agentmods.dev/badge/rules/neondatabase/ai-rules/neon-serverless.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 2,128 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.02128
Opus 5.5 $0.00000 $0.00851
Sonnet 5.5 $0.00000 $0.00426
Haiku 4.5 $0.00000 $0.00213

Measured 1mo ago against content hash 614e037a299c, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

neon-serverless scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 1mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

neon-serverless.mdc · 295 lines

How it starts

The opening of the file, as written. The whole thing — 295 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Neon Serverless Driver Guidelines

Overview

This guide provides specific patterns and best practices for connecting to Neon databases in serverless environments using the @neondatabase/serverless driver. The driver connects over HTTP for fast, single queries or WebSockets for node-postgres compatibility and interactive transactions. Follow these guidelines to ensure efficient connections and optimal performance.

Installation

Install the Neon Serverless driver with the correct package name:

# Using npm
npm install @neondatabase/serverless

# Using JSR
bunx jsr add @neon/serverless

Note: The driver version 1.0.0 and higher requires Node.js v19 or later.

For projects that depend on pg but want to use Neon's WebSocket-based connection pool:

"dependencies": {
  "pg": "npm:@neondatabase/serverless@^0.10.4"
},
"overrides": {
  "pg": "npm:@neondatabase/serverless@^0.10.4"
}

Avoid incorrect package names like neon-serverless or pg-neon.

Connection String

Always use environment variables for database connection strings to avoid exposing credentials.

// For HTTP queries
import { neon } from '@neondatabase/serverless';
const sql = neon(process.env.DATABASE_URL!);

// For WebSocket connections
import { Pool } from '@neondatabase/serverless';
const pool = new Pool({ connectionString: process.env.DATABASE_URL! });

Never hardcode credentials in your code:

// AVOID: Hardcoded credentials
const sql = neon('postgres://username:[email protected]/neondb');

Querying with the neon function (HTTP)

The neon() function is ideal for simple, "one-shot" queries in serverless and edge environments as it uses HTTP fetch and is the fastest method for single queries.

Parameterized Queries

Use tagged template literals for safe parameter interpolation. This is the primary defense against SQL injection.

const [post] = await sql`SELECT * FROM posts WHERE id = ${postId}`;

Read the full file on GitHub · 295 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 1mo ago First seen · 295 lines · 2,128 tokens per session scan A 614e037a299c

Subscribe to this mod's changes

neon-serverless is a cursor rule published in the GitHub repository neondatabase/ai-rules (86 stars, last pushed 4mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,128 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.