netlify-database

netlify-database is a cursor rule for Cursor from netlify/context-and-tools. It costs 153 tokens per session (3,687 once invoked), scanned C, original, MIT.

Instructions for adding managed Postgres, a relational database, to Netlify applications. It covers migrations, database access from Netlify runtimes, Drizzle ORM, local development, preview branches, and moving an existing Postgres project.

In plain words
What is it for?
Use it when creating tables, running SQL from Functions or Edge Functions, setting up migrations, connecting Drizzle, or developing locally with Netlify.
Why use it?
It provides the expected package, file locations, connection handling, and current API so database setup does not rely on outdated instructions.

Cursor rule for Cursor

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

Good fit Use it when creating tables, running SQL from Functions or Edge Functions, setting up migrations, connecting Drizzle, or developing locally with Netlify.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/netlify/context-and-tools/netlify-database
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/netlify/context-and-tools

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 netlify-database

README.md
[![agentmods](https://agentmods.dev/badge/rules/netlify/context-and-tools/netlify-database/github.svg)](https://agentmods.dev/rules/netlify/context-and-tools/netlify-database)
Your own site
<a href="https://agentmods.dev/rules/netlify/context-and-tools/netlify-database"><img src="https://agentmods.dev/badge/rules/netlify/context-and-tools/netlify-database/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 netlify-database

Your own site · 80×15
<a href="https://agentmods.dev/rules/netlify/context-and-tools/netlify-database"><img src="https://agentmods.dev/badge/rules/netlify/context-and-tools/netlify-database.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 153 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 3,687 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 2 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.00153 $0.03687
Opus 5.5 $0.00061 $0.01475
Sonnet 5.5 $0.00031 $0.00737
Haiku 4.5 $0.00015 $0.00369

Measured 11d ago against content hash 7e3cefea4909, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade C, and why

netlify-database scanned grade C with 2 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 11d 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.

Hidden instructionshighPrompt injection

Directives inside HTML comments, invisible characters or bidirectional overrides are read by the model and not by the person reviewing the file.

<!-- system: agent-context/database/system.md — human-owned, merged by ctx-gen; edit system.md, not this section -->

Makes network callslowCapability

Not a fault in itself. Listed so you know the mod talks to something, and to what.

`--prod`); if a preview also fails, report and stop. Never curl
cursor/rules/netlify-database.mdc · 331 lines

How it starts

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

Netlify Database

Managed Postgres built into Netlify. Netlify provisions the database, applies migrations on deploy, and creates a database branch for every deploy preview and agent run.

Use this, not that

// ✅ Modern: auto-configured, branch-aware
import { getDatabase } from "@netlify/database";
const db = getDatabase();
const users = await db.sql`SELECT * FROM users WHERE id = ${id}`;

// ✅ Drizzle: native adapter, connection configured automatically
import { drizzle } from "drizzle-orm/netlify-db";
export const db = drizzle({ schema });
// ❌ Legacy Neon extension: do not write new code with it
import { neon } from "@netlify/neon";   // reads NETLIFY_DATABASE_URL

Netlify Database reads NETLIFY_DB_URL. It does not read NETLIFY_DATABASE_URL.

Install

npm install @netlify/database                              # required: its presence triggers provisioning
npm install drizzle-orm@beta && npm install -D drizzle-kit@beta   # Drizzle: @beta is mandatory
npm install -g netlify-cli                                  # CLI 26.0.0+, Node 20.12.2+

Or run netlify database init --yes. It is non-interactive: it installs packages, scaffolds a starter migration, and verifies connectivity.

⚠️ No @netlify/database installed means no database. Automatic provisioning only happens when the package is in the project. Without it, nothing is provisioned on deploy.

⚠️ Costs credits. Netlify Database is available on Credit-based plans only. An active database consumes credits for compute and bandwidth. Storage is currently free. Every active deploy preview uses one branch toward the plan's branch limit.

File layout

netlify/database/migrations/          # auto-applied on deploy; do not move
├── 20260301143000_create_users.sql            # SQL-file format
└── 20260318091500_add_posts/migration.sql     # subdirectory format
netlify/functions/*.ts                # query from here or from edge functions
drizzle.config.ts                     # if using Drizzle
db/schema.ts, db/index.ts             # Drizzle schema and client

Read the full file on GitHub · 331 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. 11d ago Changed · -58 lines · +47 tokens per session 7e3cefea4909
  2. 2mo ago Changed 6eeb21c806bb
  3. 3mo ago First seen · 389 lines · 106 tokens per session scan C 12322745c9d2

Subscribe to this mod's changes

netlify-database is a cursor rule published in the GitHub repository netlify/context-and-tools (58 stars, last pushed today), licensed MIT. It adds 153 tokens to every session and 3,687 once invoked, about $0.0006 per session on Opus 5.5. A static security scan graded it C with 2 findings (hidden instructions, makes network calls). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

netlify-database compared with cursor rules from other repositories

netlify-database next to 6 cursor rules from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
netlify-databasenetlify/context-and-toolsCursor rule58todayMITC153Cursor
aws-rds-best-practicesbeettlle/pi-spineCursor rule3todayMITA0Cursor
aws-rds-best-practicesbeettlle/CursorRulesCursor rule215d agononeA0Cursor
rds-proxyGoranErhartic/cursor-development-rulesCursor rule209mo agoMITA18Cursor
planning-and-delegationprest/prestCursor rule4.6ktodayMITA912Cursor
integration-testsprest/prestCursor rule4.6ktodayMITA0Cursor
postgresqlPatrickJS/awesome-cursorrulesCursor rule41k6mo agoCC0-1.0A318Cursor