netlify-database
БесплатноБез исполняемых скриптовНе проверенUse this skill whenever a Netlify project needs a Postgres database. It covers Netlify Database setup, queries from Functions or Edge Functions, schema…
от netlify★ 58 звёзд на 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/databaseinstalled 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
Migration name format is <number>_<slug>:
- The slug may contain only
[a-z0-9_-]. - Migrations are sorted lexicographically. Use timestamp prefixes.
- A migration's name is its filename minus the extension.
Function example
// netlify/functions/users.ts
import type { Config } from "@netlify/functions";
import { getDatabase } from "@netlify/database";
const db = getDatabase();
export default async (req: Request) => {
if (req.method === "GET") {
return Response.json(await db.sql`SELECT * FROM users ORDER BY id DESC`);
}
if (req.method === "POST") {
const { name, email } = await req.json();
const [user] = await db.sql`INSERT INTO users (name, email) VALUES (${name}, ${email}) RETURNING *`;
return Response.json(user, { status: 201 });
}
return new Response("Method not allowed", { status: 405 });
};
export const config: Config = { path: "/api/users" };
-- netlify/database/migrations/20260301143000_create_users.sql
CREATE TABLE users (
id SERIAL PRIMARY KEY,
name TEXT NOT NULL,
email TEXT NOT NULL UNIQUE,
created_at TIMESTAMP DEFAULT NOW()
);
Drizzle
// drizzle.config.ts
import { defineConfig } from "drizzle-kit";
export default defineConfig({
dialect: "postgresql",
schema: "./db/schema.ts",
out: "netlify/database/migrations", // REQUIRED: the default "drizzle" dir is never applied
});
// db/schema.ts
import { pgTable, serial, text, timestamp } from "drizzle-orm/pg-core";
export const users = pgTable("users", {
id: serial().primaryKey(),
name: text().notNull(),
email: text().notNull().unique(),
createdAt: timestamp().defaultNow(),
});
// db/index.ts
import { drizzle } from "drizzle-orm/netlify-db";
import * as schema from "./schema";
export const db = drizzle({ schema });
After changing the schema:
- Run
npx drizzle-kit generate. - Commit the generated files under
netlify/database/migrations/. - Deploy.
API: @netlify/database
| Call | Returns |
|---|---|
getDatabase(options?) |
Client with sql and pool. Options: connectionString, debug. Picks the right connector per runtime. |
getConnectionString() |
Postgres URL for the current branch (production or preview), for your own driver. |
process.env.NETLIFY_DB_URL |
Same URL, available in builds, functions, edge functions, and agent runners. |
db.sql
db.sql is a tagged template (Waddler). Every ${} value is a bound parameter. The result is awaitable and resolves to T[].
const rows = await db.sql<User>`SELECT * FROM users`;
for await (const row of db.sql`SELECT * FROM users`.stream()) {}
for await (const chunk of db.sql`SELECT * FROM users`.chunked(100)) {}
db.sql`...`.toSQL(); // SQL + params, not executed
db.sql.identifier({ table: "users" }); // dynamic table/column na
Установить netlify-database в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл netlify-database?
Use this skill whenever a Netlify project needs a Postgres database. It covers Netlify Database setup, queries from Functions or Edge Functions, schema changes through migrations in netlify/database/migrations, Drizzle ORM wiring, local dev databases and tests, deploy-preview database branches, and moving off Neon, Supabase, RDS or the legacy @netlify/neon extension. Activate it when someone asks to add a database, store users or posts or orders, save form submissions, create or alter a table, add a column, write a migration, set up Drizzle, fix a failing migration deploy, seed or test against a local database, or switch an existing Postgres app onto Netlify. Use it even if the request never says Netlify Database explicitly.
Как установить скилл netlify-database?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл netlify-database запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
от Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
от Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
от Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
от Anthropic