• Projects
  • Service
  • About
  • branding.bz
  • Podcast
  • Tips
  • FAQ
  • Recruit
  • Download
  • Contact
  • branding.bz(ブランド構築SaaS)
  • DESIGN NOW(デザインメディア)
  • X
  • LinkedIn
  • Spotify
  • Facebook

213-0011 神奈川県川崎市高津区久本3-6-7-303

© 2026 ID INC. All rights reserved

claude-skills/スキル
SKILLOfficialdatabase

neon-postgres

プラグイン
neon
ソース
GitHub で見る ↗
説明

Neonの背後にあるLakebase Postgresデータベース(データ保存・管理用システム)の使い方とベストプラクティス(実績のある効果的な方法)ガイドです。セットアップ、接続方法とドライバ(ソフトウェア部品)、接続プーリング(複数の接続をまとめて管理すること)と直接接続、ブランチ機能、スキーママイグレーション(テーブル構造の変更)、自動スケーリング、スケール・トゥ・ゼロ(使わない時は自動で停止)、インスタントリストア(即座のデータ復元)、読み取り専用レプリカ(複製)、接続プーリング、IPアドレス制限リスト、論理レプリケーション(データベース間の同期)などをカバーしています。 次のような場合に使用: ユーザーが「Lakebase Postgres」「Neonのセットアップ」「Neonへの接続」「Neonプロジェクト」「DATABASE_URL」「サーバーレスPostgres」「Neon CLI」「neon」「Neon MCP」「Neon Auth」「@neondatabase/serverless」「@neondatabase/neon-js」「スケール・トゥ・ゼロ」「Neon自動スケーリング」「Neon読み取りレプリカ」「Neon接続プーリング」または「スキーママイグレーション」について質問している場合。

原文を表示

Guides and best practices for working with Lakebase Postgres, the database behind Neon. Covers setup, connection methods and drivers, pooled vs direct connections, branching, schema migrations, autoscaling, scale-to-zero, instant restore, read replicas, connection pooling, IP allow lists, and logical replication. Use when users ask about "Lakebase Postgres", "Neon setup", "connect to Neon", "Neon project", "DATABASE_URL", "serverless Postgres", "Neon CLI", "neon", "Neon MCP", "Neon Auth", "@neondatabase/serverless", "@neondatabase/neon-js", "scale to zero", "Neon autoscaling", "Neon read replica", "Neon connection pooling", or "schema migrations".

ユースケース
  • Neonのセットアップ方法を学ぶとき
  • データベースへの接続方法を確認するとき
  • スキーマ変更を実施するとき
  • 接続プーリングを設定するとき
  • 自動スケーリングを構成するとき
本文(日本語訳)

最初に確認: Neon の全般的な概要、使用開始方法、開発のベストプラクティスなどについては、親スキルの neon を使用してください。

neon スキルがインストールされていない場合は、https://neon.com/docs/ai/skills/neon/SKILL.md から取得するか、以下のコマンドでインストールしてください:

npx skills add neondatabase/agent-skills --skill neon

Lakebase Postgres

Lakebase Postgres は Neon の中核となるデータベースです。lakebase アーキテクチャ(クラウドオブジェクトストレージの上に直接構築された OLTP)で動作し、ストレージとコンピュート(処理能力)を分離することで、自動スケーリング、ブランチング、インスタント復元、スケール・ツー・ゼロ(未使用時にリソースをゼロまで削減)を実現します。Postgres と完全互換であり、Postgres をサポートする任意の言語、フレームワーク、ORM で動作します。

Neon を経由してアクセスしても Databricks を経由してアクセスしても、同じデータベースです。このスキルでは Neon 経由のアクセスについて説明します。

セットアップの流れ

1. 組織とプロジェクトを選択する

CLI(デフォルト)または MCP サーバを使用して、組織とプロジェクトを一覧表示します。ユーザーが既存のプロジェクトを選択するか、新規作成できるようにします。既にリンク済みのプロジェクトやブランチがあれば、.neon ファイルを確認してください。

2. 接続文字列を取得する

CLI(デフォルト)、neon env pull、または MCP サーバを使用して接続文字列を取得します。これを .env ファイルに DATABASE_URL として保存します。既存の値を上書きしないよう、修正する前にファイルを読み込んでください。

プール済み接続と直接接続の使い分け

用途 接続タイプ
Web アプリケーション、サーバーレス関数 プール済み(-pooler 付き)
スキーママイグレーション 直接接続
pg_dump / pg_restore 直接接続
論理レプリケーション 直接接続
テンポラリテーブル を使用する長時間分析 直接接続
SET やセッション状態が必要な管理作業 直接接続
LISTEN / NOTIFY 直接接続

3. 接続方法とドライバを選択する

スキーマ管理とマイグレーション(データベース構造の変更)を簡単にするため、常に Neon を Drizzle などの ORM(オブジェクト・リレーショナル・マッピング:データベースをプログラムで操作するツール)と組み合わせて使用してください。接続方法ガイドを参照して、ランタイム(実行環境)がコードをどう扱うかに基づいて正しいドライバを選択してください: https://neon.com/docs/connect/choose-connection.md

推奨事項:

  • ORM として Drizzle を使用する(https://neon.com/docs/guides/drizzle.md を参照)
  • Vercel 上では、Vercel Fluid コンピュートで node-postgres(npm install pg)を使用し、import { attachDatabasePool } from "@vercel/functions"; をインポートする
  • Cloudflare 上では、Cloudflare Hyperdrive で node-postgres を使用する
  • Neon Functions 上では、node-postgres を使用する(関数は長時間実行され、リクエスト間でプールが再利用される)
  • サーバーレスおよびエッジ環境(例:Netlify 使用時)では @neondatabase/serverless ドライバを使用する — HTTP トランスポート(単発クエリ用)、WebSocket(トランザクション対応): https://neon.com/docs/serverless/serverless-driver.md

4. スキーマをセットアップする

スキーマとマイグレーションをコードとして管理します。データベースに対してその場限りのスキーママイグレーションを実行することは避けてください。管理が困難になるためです。

ORM を使用している場合は、その ORM のベストプラクティスに従ってスキーマとマイグレーションを管理してください。例えば Drizzle を使用している場合、特別な指示がない限り、スキーマとマイグレーション管理には Drizzle のみを使用してください。

ブランチング

次のような場合に使用: ユーザーが独立した環境、スキーママイグレーションのテスト、プレビューデプロイメント、またはブランチのライフサイクル自動化を計画している場合。

要点:

  • ブランチはインスタント(瞬時)なコピー・オン・ライト(参照のみで実データはコピーしない)クローンです。
  • 各ブランチには独自のコンピュートエンドポイントがあります。
  • neon CLI または MCP サーバを使用してブランチを作成、検査、比較します。

参考資料: https://neon.com/docs/introduction/branching.md

ブランチ作成の詳細なワークフロー(通常ブランチとスキーマのみブランチ、親からのリセット、CLI/MCP の選択)については、neon-postgres-branches スキルを使用してください。インストールされていない場合は、https://neon.com/docs/ai/skills/neon-postgres-branches/SKILL.md から取得するか、以下のコマンドでインストールしてください:

npx skills add neondatabase/agent-skills --skill neon-postgres-branches

マイグレーション

本番環境に適用する前に、本番データに近いデータを用いて本番ブランチでマイグレーションをテストします。

マイグレーション実行時は、プール済みではなく 直接接続(非プール) の接続文字列を使用してください。neon connection-string はデフォルトで直接接続文字列を返します。ホスト名に -pooler サフィックスが含まれていないことを確認してください。

自動スケーリング

次のような場合に使用: ユーザーがワークロードに応じてコンピュートを自動的にスケールさせる必要があり、CU(コンピュートユニット:処理能力の単位)のサイジングとランタイム動作についてのガイダンスが必要な場合。

参考資料: https://neon.com/docs/introduction/autoscaling.md

スケール・ツー・ゼロ

次のような場合に使用: アイドル時のコストを最適化し、サスペンド(一時停止)・レジューム(再開)の動作、コールドスタート(初回起動の遅延)のトレードオフについて検討する場合。

要点:

  • アイドルコンピュートはデフォルトで 5 分後に自動サスペンドされます。タイムアウトは設定可能で、サスペンション無効化は Launch および Scale プランでのみ可能です。
  • サスペンド後の最初のクエリは通常、コールドスタートペナルティ(数百ミリ秒程度)があります。
  • コンピュートが一時停止中もストレージは活動状態です。

参考資料: https://neon.com/docs/introduction/scale-to-zero.md

インスタント復元

次のような場合に使用: ユーザーがポイント・イン・タイム・リカバリ(特定の時点へのデータ復元)が必要な場合、または従来のバックアップ復元ワークフローなしでデータ状態を復元したい場合。

要点:

  • インスタント復元の履歴ウィンドウはプランの上限に依存します。
  • ユーザーは過去の特定時点からブランチを作成できます。
  • タイムトラベルクエリ(過去のデータ状態を検索する機能)を履歴検査ワークフローに使用できます。

参考資料: https://neon.com/docs/introduction/branch-restore.md

リードレプリカ

次のような場合に使用: ストレージを重複させずに読み取り専用のコンピュートが必要な、読み取り負荷の高いワークロード。

要点:

  • レプリカは同じストレージを共有する読み取り専用のコンピュートエンドポイントです。
  • 作成は高速で、スケーリングはプライマリ(主)コンピュートから独立しています。
  • 一般的な用途: 分析、レポーティング、読み取り負荷の高い API。

参考資料: https://neon.com/docs/introduction/read-replicas.md

接続プーリング

次のような場合に使用: ユーザーがサーバーレスまたは高い同時接続環境にいて、安全でスケーラブルな Postgres 接続管理が必要な場合。

要点:

  • Neon のプーリングは PgBouncer を使用します。
  • プール済み接続を使用するため、エンドポイントホスト名に -pooler を追加します。
  • プーリングはバースト的な同時接続を持つサーバーレスランタイムで特に重要です。

参考資料: https://neon.com/docs/connect/connection-pooling.md

IP 許可リスト

次のような場合に使用: ユーザーが信頼されたネットワーク、IP アドレス、または CIDR 範囲(ネットワークアドレス表記)によってデータベースアクセスを制限する必要がある場合。

参考資料: https://neon.com/docs/introduction/ip-allow.md

論理レプリケーション

次のような場合に使用: CDC(変更データキャプチャ:データベースの変更を追跡する)パイプライン、外部 Postgres 同期、またはレプリケーションベースのデータ移動を統合する場合。

要点:

  • Neon はネイティブ論理レプリケーションワークフローをサポートします。
  • 外部 Postgres システムとの間でのレプリケーションに便利です。

参考資料: https://neon.com/docs/guides/logical-replication-guide.md

よくある落とし穴

プール済み接続と直接接続: マイグレーション、ダンプ、レプリケーションは直接 URL を使用する

Neon は同じデータベースに対して 2 つの接続文字列を提供します: プール済み(ホスト名に -pooler サフィックス付き)と 直接接続/非プール(-pooler サフィックスなし)。neon env pull はこれらを DATABASE_URL と DATABASE_URL_UNPOOLED として出力します。正しいものを選択してください:

  • プール済み(DATABASE_URL) — アプリケーションの通常のクエリトラフィック。特にサーバーレスとリクエストごとの接続ワークロード。
  • 直接接続(DATABASE_URL_UNPOOLED) — スキーママイグレーション(Prisma Migrate、Drizzle Kit、Alembic など)、pg_dump / pg_restore、論理レプリケーション、LISTEN/NOTIFY、SET やその他のセッション状態に依存するもの。

プール済み接続を経由したマイグレーション、ダンプ、レプリケーション実行は失敗することがあり、プーリングだとは名前から分からない形で失敗します。Prisma Migrate の prepared statement "s0" already exists エラー、次のクエリが relation "mytable" does not exist と報告するように持続しない SET search_path、またはプール済みバックエンド(以前のクライアントから引き継いだ読み取り専用トランザクション)が偶発的に書き込みに失敗する SQLSTATE 25006 などです。マイグレーションツールは通常両方の文字列を一度に受け取ります。Prisma の directUrl を url と一緒に使う場合は、DATABASE_URL と直接接続を入れ替えてアプリケーションのプーリングを失わないよう、そこを直接接続に指定してください。https://neon.com/docs/connect/connection-pooling.md を参照。

原文(English)を表示

FIRST: Use the parent neon skill for a Neon overview, getting started with Neon, Neon development best practices, and more.

If the neon skill is not installed, fetch it from https://neon.com/docs/ai/skills/neon/SKILL.md or install it with:

npx skills add neondatabase/agent-skills --skill neon

Lakebase Postgres

Lakebase Postgres is the database at the core of Neon. It runs on the lakebase architecture — OLTP built directly on cloud object storage — which decouples storage from compute to offer autoscaling, branching, instant restore, and scale-to-zero. It's fully compatible with Postgres and works with any language, framework, or ORM that supports Postgres.

It is the same database whether you reach it through Neon or through Databricks; this skill covers the Neon access path.

Setup Flow

1. Select the organization and project

Use the CLI (default) or MCP server to list organizations and projects. Let the user select an existing project or create a new one. Check the .neon file for an existing linked project or branch.

2. Get the connection string

Use the CLI (default), neon env pull, or the MCP server to get the connection string. Store it in .env as DATABASE_URL. Read the file first before modifying it, to avoid overwriting existing values.

When to use pooled vs direct connections

Use case Connection type
Web applications, serverless functions Pooled (-pooler)
Schema migrations Direct
pg_dump / pg_restore Direct
Logical replication Direct
Long-running analytics with temp tables Direct
Admin tasks needing SET or session state Direct
LISTEN / NOTIFY Direct

3. Pick the connection method and driver

Always pair Neon with an ORM such as Drizzle for easy schema management and migrations. Refer to the connection methods guide to pick the correct driver based on how the runtime treats your code: https://neon.com/docs/connect/choose-connection.md.

Recommendations:

  • Drizzle as ORM (see https://neon.com/docs/guides/drizzle.md)
  • On Vercel, use node-postgres (npm install pg) with Vercel Fluid compute and import { attachDatabasePool } from "@vercel/functions";
  • On Cloudflare, use node-postgres with Cloudflare Hyperdrive
  • On Neon Functions, use node-postgres, as the functions are long-running and reuse the pool across requests.
  • Use the @neondatabase/serverless driver for serverless and edge environments (for example, when using Netlify) — HTTP transport for one-shot queries, WebSocket for transaction support. Link: https://neon.com/docs/serverless/serverless-driver.md

4. Set up the schema

Manage schemas and migrations as code. Avoid running ad hoc schema migrations against your database, since they're hard to manage.

If you're using an ORM, follow your ORM's best practices to manage schemas and migrations. For example, if using Drizzle, only use Drizzle for schema and migration management unless instructed otherwise.

Branching

Use this when the user is planning isolated environments, schema migration testing, preview deployments, or branch lifecycle automation.

Key points:

  • Branches are instant, copy-on-write clones (no full data copy).
  • Each branch has its own compute endpoint.
  • Use the neon CLI or MCP server to create, inspect, and compare branches.

Link: https://neon.com/docs/introduction/branching.md

For detailed branch creation workflows (normal vs schema-only branches, reset-from-parent, CLI/MCP selection), use the neon-postgres-branches skill. If it isn't installed, fetch it from https://neon.com/docs/ai/skills/neon-postgres-branches/SKILL.md or install it with:

npx skills add neondatabase/agent-skills --skill neon-postgres-branches

Migrations

Test a migration on a branch of production, against production-like data, before applying it to production.

Use a direct (non-pooled) connection string when you run the migration, not a pooled one. neon connection-string returns the direct string by default; make sure the hostname does not include the -pooler suffix.

Autoscaling

Use this when the user needs compute to scale automatically with workload and wants guidance on CU sizing and runtime behavior.

Link: https://neon.com/docs/introduction/autoscaling.md

Scale to Zero

Use this when optimizing idle costs and discussing suspend/resume behavior, including cold-start trade-offs.

Key points:

  • Idle computes suspend automatically after a default of 5 minutes; the timeout is configurable, and suspension can only be disabled on the Launch and Scale plans.
  • First query after suspend typically has a cold-start penalty (around hundreds of ms)
  • Storage remains active while compute is suspended.

Link: https://neon.com/docs/introduction/scale-to-zero.md

Instant Restore

Use this when the user needs point-in-time recovery or wants to restore data state without traditional backup restore workflows.

Key points:

  • History windows for instant restore depend on plan limits.
  • Users can create branches from historical points-in-time.
  • Time Travel queries can be used for historical inspection workflows.

Link: https://neon.com/docs/introduction/branch-restore.md

Read Replicas

Use this for read-heavy workloads where the user needs dedicated read-only compute without duplicating storage.

Key points:

  • Replicas are read-only compute endpoints sharing the same storage.
  • Creation is fast and scaling is independent from primary compute.
  • Typical use cases: analytics, reporting, and read-heavy APIs.

Link: https://neon.com/docs/introduction/read-replicas.md

Connection Pooling

Use this when the user is in serverless or high-concurrency environments and needs safe, scalable Postgres connection management.

Key points:

  • Neon pooling uses PgBouncer.
  • Add -pooler to endpoint hostnames to use pooled connections.
  • Pooling is especially important in serverless runtimes with bursty concurrency.

Link: https://neon.com/docs/connect/connection-pooling.md

IP Allow Lists

Use this when the user needs to restrict database access by trusted networks, IPs, or CIDR ranges.

Link: https://neon.com/docs/introduction/ip-allow.md

Logical Replication

Use this when integrating CDC pipelines, external Postgres sync, or replication-based data movement.

Key points:

  • Neon supports native logical replication workflows.
  • Useful for replicating to/from external Postgres systems.

Link: https://neon.com/docs/guides/logical-replication-guide.md

Gotchas

Pooled vs direct connections: use the direct URL for migrations, dumps, and replication

Neon gives you two connection strings for the same database: a pooled one (hostname with the -pooler suffix) and a direct/unpooled one (no -pooler suffix). neon env pull writes them as DATABASE_URL and DATABASE_URL_UNPOOLED. The pooled connection routes through PgBouncer in transaction mode, which doesn't support session-level operations. Choose the right one:

  • Pooled (DATABASE_URL) — your application's normal query traffic, especially serverless and connection-per-request workloads.
  • Direct (DATABASE_URL_UNPOOLED) — schema migrations (Prisma Migrate, Drizzle Kit, Alembic, and others), pg_dump / pg_restore, logical replication, LISTEN/NOTIFY, and anything relying on SET or other session state.

Running migrations, dumps, or replication over the pooled connection can fail, and never in a way that names pooling: prepared statement "s0" already exists from Prisma Migrate, a SET search_path that doesn't persist past its own transaction so the next query reports relation "mytable" does not exist, or a write intermittently hitting a read-only transaction (SQLSTATE 25006) that a pooled backend inherited from an earlier client. Migration tools generally take both strings at once — Prisma's directUrl alongside url — so point that at the direct one rather than swapping DATABASE_URL and losing pooling for the application. See https://neon.com/docs/connect/connection-pooling.md.

原文・著作権は Anthropic および各プラグイン作者に帰属します。日本語訳は Claude API による自動翻訳です。