Token导航 LogoToken导航

Agent Skill · 开发

netlify-database(网络化数据库)

用于辅助数据库表结构、查询语句、迁移脚本和数据维护任务。它适合让 Agent 分析 schema、编写 SQL、排查查询问题、整理索引或生成迁移建议。使用时需要明确数据库类型、连接环境和目标表,区分只读分析与写入变更;涉及删除、更新、迁移和批量导入时,应优先 dry-run、备份或事务保护,避免误操作。

netlify-database 是开发类 Agent Skill,可用宿主为 Codex、Claude、Cursor、Gemini CLI,通过GitHub 仓库获取,权限为需要联网;许可证信息还不明确,第三方扫描已通过,按安装量在开发类的 21,746 个 Skill 里排第 19,001。

总安装 303周安装 13GitHub Stars 16下载 106核验 2026-05-01

安装说明

本站只整理中文说明,不托管安装包,也不代用户安装。
GitHub
许可证
unknown

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:netlify-database(网络化数据库)
来源仓库:https://github.com/netlify/context-and-tools
仓库路径:skills/netlify-database
安装命令:
npx skills add https://github.com/netlify/context-and-tools --skill netlify-database
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/netlify/context-and-tools --skill netlify-database

这个 Skill 是做什么的

开发类 Skill 面向写代码、改代码和排查问题,一般会读写仓库文件,部分还会执行构建或测试命令。

用于辅助数据库表结构、查询语句、迁移脚本和数据维护任务。它适合让 Agent 分析 schema、编写 SQL、排查查询问题、整理索引或生成迁移建议。使用时需要明确数据库类型、连接环境和目标表,区分只读分析与写入变更;涉及删除、更新、迁移和批量导入时,应优先 dry-run、备份或事务保护,避免误操作。

适用于数据库管理与 SQL 开发支持类任务,提升数据操作安全性。可结合来源仓库、安装命令和原始 README 继续核验具体用法。netlify-database 属于开发类 Skill,可作为该场景下的辅助能力补充。

来源仓库内路径:skills/netlify-database

上手步骤

4 步
  1. 1

    确认自己的宿主工具

    公开资料标注支持 Codex、Claude、Cursor、Gemini CLI;先确认自己用的是其中之一,再按对应工具的 Skills 目录放置。

  2. 2

    拿到安装命令

    可以直接复制的命令是 npx skills add https://github.com/netlify/context-and-tools --skill netlify-data…;命令里的占位符换成自己的路径或密钥再执行。

  3. 3

    安装后重启宿主

    命令执行完要完全退出宿主工具再打开,让新装的 Skill 被重新扫描到,否则列表里可能看不到。

  4. 4

    按最小权限试用

    它需要需要联网,先在测试目录或测试账号里跑,确认没问题再放到正式项目。

常见问题

6 条

netlify-database 怎么安装?

在终端执行 npx skills add https://github.com/netlify/context-and-tools --skill netlify-database。装完完全退出宿主工具再打开,让它重新扫描本地 Skill。

netlify-database 支持哪些 AI 工具?

公开资料标注支持 Codex、Claude、Cursor、Gemini CLI。其他工具只要能读取本地 Skill 目录,一般也能手动放进去,但要自己确认触发方式是否一致。

netlify-database 需要什么权限?

权限级别是需要联网。该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

netlify-database 是免费的吗?

公开资料没有标注明确许可证,收费和商用限制都无法确认。正式使用前请到来源仓库核对授权说明。

netlify-database 用的人多吗?

公开数据是累计安装 303 次,近一周安装 13 次,下载 106 次,GitHub 16 星。这些数字来自第三方目录统计,只能当作热度参考,不代表质量或安全性。

netlify-database 安全吗?

第三方扫描结果为通过,但这只覆盖已知的静态检查项,不能替代自己读一遍源码和安装命令。

值得选的地方和要先想清楚的地方

值得选的地方

  • 同时适配 4 种工具,换客户端不用重新找替代品。
  • 第三方扫描已通过,常见的高风险行为没有命中。

先想清楚的地方

  • 许可证没有明确标注,能不能商用、能不能再分发都不确定。
  • 第三方目录整理,版本更新和行为细节以来源仓库为准。

适不适合你

更适合

  • 已经在用 Codex,想直接扩展它能力的人。
  • 需要处理开发类任务、又不想每次都手写提示词的人。

不太适合

  • 需要明确授权才能用到公司项目里的场景。
  • 需要厂商级技术支持和 SLA 的生产系统。

开发类 Skill 对比

6 个同类
Skill总安装GitHub 星权限许可证扫描
skill-vetter

技能审查员 · OpenClaw

8,779,018986操作浏览器MIT-0通过
ontology

本体论 · OpenClaw

6,636,960576只读MIT-0通过
entra-app-registration

内部应用程序注册 · Codex、Claude

6,631,872764接触敏感数据未明确通过
entra-app-registration

内部应用程序注册 · Codex、Claude

3,757,680201接触敏感数据未明确通过
nano-banana-pro

纳米香蕉专业版 · OpenClaw

3,526,898364接触敏感数据MIT-0有提醒
netlify-database

网络化数据库 · 本页

30316需要联网未明确通过

按安装量取同分类前几名;数字来自第三方目录统计,只作热度参考,不代表质量结论。

SKILL.md 原文

Netlify Database

Netlify Database is the managed Postgres product built into the Netlify platform. It is GA and is the default choice for any dynamic data in a Netlify project.

Install @netlify/database and Netlify auto-provisions a Postgres database for the site at deploy time. Each deploy preview gets its own isolated branch forked from production data. No Neon account, connection-string wiring, or claim flow — the database is a first-class Netlify primitive.

Database vs Blobs

Use Netlify Database for anything dynamic:

  • Any user-generated or app-generated records (posts, comments, orders, sessions, audit logs)
  • Structured data that will grow, be queried, or be joined
  • Key-value-style data read or written by application code at runtime

Use Netlify Blobs only for file and asset storage: images, documents, exports, uploads, cached binary artifacts. Do not use Blobs as a dynamic data store — reach for Database instead. See netlify-blobs/SKILL.md.

CRITICAL: Install Drizzle from the @beta dist-tag

The Netlify Database adapter for Drizzle ORM currently only exists on the beta release line of drizzle-orm. Install both drizzle-orm and drizzle-kit from the @beta dist-tag:

npm install drizzle-orm@beta
npm install -D drizzle-kit@beta

The default latest versions do not include the drizzle-orm/netlify-db adapter and will fail. If drizzle-kit generate errors about being outdated, or the drizzle-orm/netlify-db import fails to resolve, the install is missing @beta.

The @beta tag only affects the installed version — imports are written as drizzle-orm, drizzle-orm/pg-core, and drizzle-orm/netlify-db without modification.

CRITICAL: Use the Netlify CLI for database operations

The CLI ships a complete database surface under netlify database (alias: netlify db) that replaces hand-rolled scripts and direct API/UI work. Reach for these commands first before writing custom tooling. Requires Netlify CLI 26.0.0+ — if a netlify database subcommand isn't recognized, run npm install -g netlify-cli@latest.

Full reference is in Netlify CLI commands below.

CRITICAL: Never apply migrations to a Netlify-hosted database

The only database you ever apply migrations to yourself is the local development DB. For any Netlify-hosted database — production or a deploy preview branch — Netlify applies migrations automatically during the deploy. Your job is to create migration files and commit them. The deploy does the rest.

This means:

  • Use netlify database migrations apply for the local DB. Do NOT run drizzle-kit migrate against NETLIFY_DB_URL in any context.
  • Do NOT run drizzle-kit push at all. Generate a migration and let the deploy apply it.
  • Do NOT run raw DDL (CREATE, ALTER, DROP, TRUNCATE) via netlify database connect, psql, or any other direct connection. Schema changes go through migration files; out-of-band DDL drifts the migration history from the actual schema.
  • Do NOT export NETLIFY_DB_URL from a preview or production context and run a client against it. Migrations drift the moment anything touches the schema out-of-band.

The one documented exception is a one-time data import during a provider switch — see references/migration-from-extension.md. Outside that specific flow, the rule is absolute: schema changes go through migration files, migration files get applied by the deploy.

Not the legacy "Netlify DB" extension

The older Netlify DB extension (Beta) is deprecated. It is a separate product and must not be confused with Netlify Database. Do not recommend or install it for new projects.

Netlify Database (GA, recommended)Netlify DB extension (deprecated Beta)
Package@netlify/database@netlify/neon
Env varNETLIFY_DB_URLNETLIFY_DATABASE_URL
Setupnetlify database init or install the package — auto-provisioned at deployHistorically netlify db init on older CLI versions, with a claim into the user's Neon account; that flow is no longer reachable from the current CLI
StatusGADeprecated; new creation blocked as of April 2026

If an existing project is already using the @netlify/neon extension, keep it working and encourage the user to switch. See references/legacy-extension.md for recognition and coexistence, and references/migration-from-extension.md for the full switching process (also covers switching from other external Postgres providers).

Provisioning

The fastest path is netlify database init — an interactive setup that installs @netlify/database, lets the user pick Drizzle or raw SQL, writes drizzle.config.ts if needed, scaffolds a starter migration, applies it locally, and runs a sample query end-to-end:

netlify database init           # interactive
netlify database init --yes     # accept defaults — for CI/agents

If you'd rather wire things up by hand, install the package directly:

npm install @netlify/database

Either way, presence of @netlify/database in the dependency tree triggers provisioning on the next deploy. A database can also be created manually from the Netlify UI before first deploy.

Drizzle ORM (recommended path)

Drizzle is the recommended way to work with Netlify Database. Prefer Drizzle over writing raw SQL or hand-editing migration files — manual migrations are an edge case (see references/migrations.md).

Install

npm install @netlify/database drizzle-orm@beta
npm install -D drizzle-kit@beta

Schema file

Create db/schema.ts. Define all tables here using Drizzle's schema builder.

// db/schema.ts
import { boolean, pgTable, serial, text, timestamp, varchar } from "drizzle-orm/pg-core";

export const items = pgTable("items", {
  id: serial().primaryKey(),
  title: varchar({ length: 255 }).notNull(),
  description: text(),
  isActive: boolean("is_active").notNull().default(true),
  createdAt: timestamp("created_at").defaultNow(),
  updatedAt: timestamp("updated_at").defaultNow(),
});

export type Item = typeof items.$inferSelect;
export type NewItem = typeof items.$inferInsert;

Use snake_case strings for column names ("is_active", "created_at") to match Postgres conventions. Drizzle variable names can be camelCase.

Drizzle client

Create db/index.ts. The adapter on drizzle-orm/netlify-db picks the right driver for the runtime automatically.

// db/index.ts
import { drizzle } from "drizzle-orm/netlify-db";
import * as schema from "./schema";

export const db = drizzle({ schema });

The connection is configured automatically — no connection string needed. If your project uses native ESM with .js extensions on relative imports (from "./schema.js"), keep that style consistent here.

Drizzle Kit config

Create drizzle.config.ts at the project root. Set out to netlify/database/migrations — that's the directory the deploy applies migrations from:

// drizzle.config.ts
import { defineConfig } from "drizzle-kit";

export default defineConfig({
  dialect: "postgresql",
  schema: "./db/schema.ts",
  out: "netlify/database/migrations",
  migrations: { prefix: "timestamp" },
});

Default to migrations: {prefix: "timestamp"}. Drizzle Kit's default sequential indices (0000_, 0001_, …) collide whenever two pieces of work generate migrations in parallel — this happens to teams and to solo developers iterating on multiple branches. Timestamp prefixes keep filenames unique and order stable. If a project is already established on sequential prefixes, leave it alone, but expect collisions when working in parallel.

Package scripts

{
  "scripts": {
    "db:generate": "drizzle-kit generate",
    "db:migrate": "netlify database migrations apply"
  }
}
  • db:generate writes a new migration file under netlify/database/migrations/ from the current schema.
  • db:migrate applies pending migrations to the local development database only, via the CLI. Hosted migrations (preview branches, production) are applied by the deploy — never by this script.

Schema-change workflow

  1. Edit db/schema.ts.
  2. npm run db:generate — writes a new file into netlify/database/migrations/.
  3. Review the SQL.
  4. npm run db:migrate — applies it to the local development DB for testing.
  5. Commit the schema change and migration file together and push. The deploy applies the migration to the preview branch, then to production on publish.

Query patterns

import { db } from "./db";
import { items } from "./db/schema";
import { eq, desc } from "drizzle-orm";

// Select all
const all = await db.select().from(items);

// Select with condition
const [one] = await db.select().from(items).where(eq(items.id, id)).limit(1);

// Ordering and limit
const recent = await db.select().from(items).orderBy(desc(items.createdAt)).limit(10);

// Insert
const [created] = await db.insert(items).values({ title: "New" }).returning();

// Update
const [updated] = await db.update(items).set({ title: "Updated" }).where(eq(items.id, id)).returning();

// Delete
await db.delete(items).where(eq(items.id, id));

Full migration workflow, expand-and-contract for breaking schema changes, and production DML migrations are in references/migrations.md.

Native driver (when Drizzle isn't a fit)

When a project wants raw SQL, uses a different query builder (Kysely, etc.), or has a library that needs a pg.Pool, use the native driver exposed by @netlify/database.

npm install @netlify/database
import { getDatabase } from "@netlify/database";

const db = getDatabase();

// Tagged template — parameters are safely bound, not interpolated
const users = await db.sql`SELECT * FROM users WHERE active = ${true}`;

// Insert with RETURNING
const [user] = await db.sql`
  INSERT INTO users (name, email)
  VALUES (${name}, ${email})
  RETURNING *
`;

// Bulk insert
const rows = db.sql.values([
  ["Ada", "ada@example.com"],
  ["Bob", "bob@example.com"],
]);
await db.sql`INSERT INTO users (name, email) VALUES ${rows}`;

Transactions go through db.pool so BEGIN, the queries, and COMMIT/ROLLBACK all run on the same connection:

import { getDatabase } from "@netlify/database";

const db = getDatabase();
const client = await db.pool.connect();
try {
  await client.query("BEGIN");
  await client.query("INSERT INTO users (name, email) VALUES ($1, $2)", [name, email]);
  await client.query("INSERT INTO posts (author_id, title) VALUES ($1, $2)", [id, title]);
  await client.query("COMMIT");
} catch (e) {
  await client.query("ROLLBACK");
  throw e;
} finally {
  client.release();
}

For third-party tools that need a raw connection string, import getConnectionString from @netlify/database — but prefer getDatabase() for application code.

Manual migrations

With the native driver, scaffold migration files via the CLI:

netlify database migrations new -d "create users table"

This creates netlify/database/migrations/<prefix>_<slug>/migration.sql and prompts for the numbering scheme if it can't be detected from existing files. Open the file and write the SQL. The CLI auto-detects an existing scheme; for new projects it'll ask — choose timestamp unless you have a reason not to.

You can also write the file by hand if you prefer. Two layouts are supported:

  • Flat: netlify/database/migrations/<prefix>_<slug>.sql
  • Subdirectory: netlify/database/migrations/<prefix>_<slug>/migration.sql (what migrations new produces)

In both, <prefix> is digits (timestamp like 20260417143022 or sequential like 0001) and <slug> is lowercase letters, numbers, hyphens, or underscores. Files apply in lexicographic order. See references/migrations.md.

Once a migration has been applied to any database, never modify it — roll forward with a new migration instead.

Connection — don't reach for the env var

NETLIFY_DB_URL is set automatically across builds, functions, edge functions, and local dev. Use the getDatabase() / getConnectionString() helpers above rather than reading it directly — only reach for the raw env var for third-party tools that demand a bare string.

NETLIFY_DB_URL is intentionally different from the legacy extension's NETLIFY_DATABASE_URL. The two coexist so a project mid-migration doesn't break. Don't rename between them.

Preview branching

Each deploy preview runs against its own database branch forked from production data. Schema and data changes in a preview do not affect production until the branch is merged and published. This means:

  • Migrations run against the preview branch first — failures fail the preview, not production.
  • Ad-hoc edits in a preview (via the Netlify UI data browser or a direct client) do not propagate to production. Always express production changes as migrations.

Production data changes — write a DML migration

When a user asks for data changes that should land in production (seed data, backfills, one-off cleanups, CSV imports), do not connect to the production database and run queries. Generate a DML migration in netlify/database/migrations/ (SQL INSERT/UPDATE/DELETE, or a Drizzle-generated equivalent). Tell the user you created a data migration and that merging to production will apply it. Let them verify in the preview branch first.

If the request is ambiguous ("update this record"), confirm that the user wants a production migration rather than a preview-only edit. See references/migrations.md.

Netlify CLI commands for Netlify Database

The CLI ships a complete database surface under netlify database (alias: netlify db). Requires CLI 26.0.0+. Most commands accept --json for machine-readable output — useful when scripting or reading results from an agent.

netlify database init

Interactive bootstrap: installs @netlify/database (and Drizzle if chosen), writes drizzle.config.ts, scaffolds and applies a starter migration, and runs a sample query. Use --yes for non-interactive mode.

netlify database status

Reports whether the database is enabled, whether @netlify/database is installed, the connection string for the active branch, and the applied/pending/missing/out-of-order migrations. Defaults to the local development database — pass --branch <name> to target a remote preview or production branch.

netlify database status                          # local
netlify database status --branch my-feature      # remote branch
netlify database status --json
netlify database status --show-credentials       # include username/password in connection string

netlify database connect

Connects to the database. Defaults to an interactive REPL — for agent and script use, always pass --query for one-shot execution:

# List tables
netlify database connect --query "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'"

# Inspect columns
netlify database connect --query "SELECT column_name, data_type, is_nullable FROM information_schema.columns WHERE table_name = 'items'"

# JSON output
netlify database connect --query "SELECT * FROM items LIMIT 10" --json

# Get connection details only (no query)
netlify database connect --json

Never run DDL (CREATE, ALTER, DROP, TRUNCATE) through netlify database connect, psql, or any other direct connection. Schema changes go through migration files — out-of-band DDL drifts the migration history from the actual schema.

netlify database migrations new

Scaffolds a new migration file as netlify/database/migrations/<prefix>_<slug>/migration.sql. Auto-detects the numbering scheme from existing files; prompts when undetermined.

netlify database migrations new -d "add users table"
netlify database migrations new -d "add users table" --scheme timestamp

netlify database migrations apply

Applies pending migrations to the local development database. The CLI does not apply migrations to the local DB automatically when netlify dev starts — you run this command yourself when you're ready. Hosted databases (preview branches, production) are handled by the deploy.

netlify database migrations apply
netlify database migrations apply --to <name>   # apply up to a specific migration

netlify database migrations pull

Downloads migration files from a remote branch (defaults to production) and overwrites local files. Useful when local migration history has drifted from production — for example, after another contributor shipped a migration you don't have locally.

netlify database migrations pull                  # from production
netlify database migrations pull --branch staging # from a specific branch
netlify database migrations pull --branch         # from your current local git branch
netlify database migrations pull --force          # skip the overwrite confirmation

netlify database migrations reset

Deletes local migration files that have not yet been applied to the target database. Applied migrations and their data are left alone — the command can't undo something already applied.

Typical use: you generated a migration, realized it was wrong, and want to start over. Run reset, update db/schema.ts, then npm run db:generate produces a fresh migration.

netlify database migrations reset                  # against local dev DB
netlify database migrations reset --branch <name>  # against a remote branch

netlify database reset

Wipes the local development database — drops all schemas and tables. Only affects the local DB; never touches preview branches or production. Use this when you want to replay all migrations from scratch.

netlify database reset

Iterating on migrations

When a migration you generated needs to change, what you do depends on whether it's been applied anywhere yet:

  • Already applied to any database (local dev DB, a preview branch, or production) → treat as immutable. Roll forward with a new migration that applies the correction.
  • Only on disk (not yet applied anywhere) → don't edit the SQL or snapshot files by hand. Run netlify database migrations reset, update db/schema.ts, then re-run npm run db:generate. Hand-editing desyncs Drizzle Kit's internal state and tends to produce broken migrations on the next generate.

Local development

netlify dev runs the project against a local Postgres-compatible database — no remote connection, no risk of touching production. Use netlify database migrations apply to apply pending migrations locally, netlify database connect to query, and netlify database reset to wipe and replay. See references/local-dev.md.

Common mistakes

  1. Forgetting the @beta dist-tag. drizzle-orm and drizzle-kit must be installed as @beta. The latest releases lack the drizzle-orm/netlify-db adapter.
  2. Wrong migration output directory. Drizzle Kit defaults to drizzle/. Set out: "netlify/database/migrations" in drizzle.config.ts — migrations outside that directory are not applied by the deploy.
  3. Writing raw CREATE TABLE when using Drizzle. The schema file is the source of truth. Define tables in db/schema.ts and generate migrations.
  4. Running drizzle-kit migrate or push against a hosted DB. Never. The deploy applies migrations. For local, use netlify database migrations apply instead.
  5. Using netlify database connect to change schema. Schema changes go through migration files — never DDL through connect or any direct connection.
  6. Misunderstanding netlify database migrations reset. It only deletes unapplied files. It cannot undo an applied migration — for that, roll forward with a new migration.
  7. Assuming netlify dev applies migrations automatically. It doesn't — only the deploy does. Run netlify database migrations apply locally yourself.

平台分布

Codex

33.73%
按下载量换算36

Claude

29.84%
按下载量换算32

Cursor

17.83%
按下载量换算19

Gemini CLI

9.82%
按下载量换算10

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。目前只有一个公开来源,建议同时核对源仓库。

继续浏览同类 Skills