$npx -y skills add neondatabase/agent-skills --skill neon-postgresGuides and best practices for working with Neon Serverless Postgres. Covers setup, connection methods, branching, autoscaling, scale-to-zero, read replicas, connection pooling, Neon Auth, and the Neon CLI, MCP server, REST API, TypeScript SDK, and Python SDK. Use when users ask a
| 1 | # Neon Serverless Postgres |
| 2 | |
| 3 | Guide the user through any Neon-related task: setup, connections, branching, and advanced features. Deliver a working Neon connection, a completed feature configuration, or a specific answer from the official Neon docs. |
| 4 | |
| 5 | Neon is a serverless Postgres platform that separates compute and storage 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. |
| 6 | |
| 7 | ## Neon Documentation |
| 8 | |
| 9 | The Neon documentation is the source of truth for all Neon-related information. Always verify claims against the official docs before responding. Neon features and APIs evolve, so prefer fetching current docs over relying on training data. |
| 10 | |
| 11 | ### Fetching Docs as Markdown |
| 12 | |
| 13 | Any Neon doc page can be fetched as markdown in two ways: |
| 14 | |
| 15 | 1. **Append `.md` to the URL** (simplest): https://neon.com/docs/introduction/branching.md |
| 16 | 2. **Request `text/markdown`** on the standard URL: `curl -H "Accept: text/markdown" https://neon.com/docs/introduction/branching` |
| 17 | |
| 18 | Both return the same markdown content. Use whichever method your tools support. |
| 19 | |
| 20 | ### Finding the Right Page |
| 21 | |
| 22 | The docs index lists every available page with its URL and a short description: |
| 23 | |
| 24 | ``` |
| 25 | https://neon.com/docs/llms.txt |
| 26 | ``` |
| 27 | |
| 28 | Common doc URLs are organized in the topic links below. If you need a page not listed here, search the docs index: https://neon.com/docs/llms.txt. Don't guess URLs. |
| 29 | |
| 30 | ## What Is Neon |
| 31 | |
| 32 | Use this for architecture explanations and terminology (organizations, projects, branches, endpoints) before giving implementation advice. |
| 33 | |
| 34 | Link: https://neon.com/docs/introduction/architecture-overview.md |
| 35 | |
| 36 | ## Getting Started |
| 37 | |
| 38 | Use this section when guiding a user through first-time Neon setup. |
| 39 | |
| 40 | ### Check Status Quo |
| 41 | |
| 42 | Before starting setup, inspect the user's codebase and environment: |
| 43 | |
| 44 | - Existing database connection code |
| 45 | - Existing Neon MCP server or Neon CLI configuration |
| 46 | - Existence of a `.env` file and `DATABASE_URL` environment variable |
| 47 | - Existing ORM (Prisma, Drizzle, TypeORM) configuration |
| 48 | |
| 49 | ### Self-Driving Setup With Neon's CLI or MCP Server |
| 50 | |
| 51 | Offer to inspect existing connected Neon projects or create new ones using the Neon CLI or MCP server. If neither is set up yet, run init with the `--agent` flag. Use `npx -y` to skip the package install prompt. Auth is handled automatically. If the user is not logged in, it opens their browser for OAuth and waits for completion before proceeding. |
| 52 | |
| 53 | ```bash |
| 54 | npx -y neon@latest init --agent <agent-name> |
| 55 | ``` |
| 56 | |
| 57 | Supported `--agent` values: `cursor`, `copilot`, `claude`, `claude-desktop`, `codex`, `opencode`, `cline`, `gemini-cli`, `goose`, `zed`. |
| 58 | |
| 59 | This installs the Neon extension (for Cursor/VS Code) or MCP server (for other agents), creates an API key, and adds the `neon-postgres` agent skill to the project. |
| 60 | |
| 61 | If `init` is not suitable, the individual steps can be run non-interactively: |
| 62 | |
| 63 | - **Extension:** `cursor --install-extension databricks.neon-local-connect` |
| 64 | - **MCP server:** `npx -y add-mcp https://mcp.neon.tech/mcp -g -n Neon -y -a <agent-name>` |
| 65 | - **Agent skill:** `npx skills add neondatabase/agent-skills --skill neon-postgres --agent <agent-name> -y` |
| 66 | |
| 67 | For full CLI installation options, see https://neon.com/docs/cli/install.md |
| 68 | |
| 69 | ### Setup Flow |
| 70 | |
| 71 | **1. Select Organization and Project** |
| 72 | |
| 73 | Use MCP server or CLI to list organizations and projects. Let the user select an existing project or create a new one. |
| 74 | |
| 75 | **2. Get Connection String** |
| 76 | |
| 77 | Use MCP server or CLI to get the connection string. Store it in `.env` as `DATABASE_URL`. Read the file first before modifying to avoid overwriting existing values. |
| 78 | |
| 79 | **3. Pick Connection Method & Driver** |
| 80 | |
| 81 | Refer to the connection methods guide to pick the correct driver based on deployment platform: https://neon.com/docs/connect/choose-connection.md |
| 82 | |
| 83 | **4. User Authentication with Neon Auth (if needed)** |
| 84 | |
| 85 | Skip for CLI tools, scripts, or apps without user accounts. If the app needs auth: use MCP server `provision_neon_auth` tool, then see the auth overview (https://neon.com/docs/auth/overview.md) for setup. For auth + database queries, see the JavaScript SDK reference (https://neon.com/docs/reference/javascript-sdk.md). |
| 86 | |
| 87 | **5. ORM Setup (optional)** |
| 88 | |
| 89 | Check for existing ORM (Prisma, Drizzle, TypeORM). If none, ask if they want one. For Drizzle integration, see https://neon |