Catalog
neondatabase/neon-postgres-branches

neondatabase

neon-postgres-branches

Choose and create the right Neon branch type for testing and development. Use when users ask about Neon branching, migration testing with real data, isolated test environments, schema-only branch workflows for sensitive data, or branch creation via Neon CLI or Neon MCP. Triggers include "Neon branch", "test migrations safely", "branch production data", "schema-only branch", "reset branch" and "sensitive data testing".

global
0installs0uses~2.4k
v1.0Saved May 9, 2026

Neon Postgres Branching

The outcome of this skill should be a created Neon branch (or a clear, actionable next step if creation cannot proceed). Choose the correct branch type, then execute branch creation via MCP or CLI.

  • Normal branch for realistic migration and query testing with real data.
  • Schema-only branch (Beta) for sensitive data workflows where structure is needed without copying rows.

Branch Type Decision

Use this decision rule first:

  1. If the user wants to test complex migrations, performance, or behavior against production-like data, choose a normal branch.
  2. If the user needs to avoid copying sensitive data, choose a schema-only branch.

If the request is ambiguous, ask one clarifying question: "Do you need realistic data for testing, or only schema structure because the data is sensitive?"

Tool Selection: CLI or MCP

Always support both Neon CLI and Neon MCP server. Prefer the tool the user already has installed and authenticated.

MCP link: https://neon.com/docs/ai/neon-mcp-server.md CLI link: https://neon.com/docs/reference/cli-quickstart

Selection order

  1. Check MCP first in MCP-enabled environments:
    • If Neon MCP tools are available and authenticated (for example, listing projects works), use MCP.
  2. If MCP is unavailable or not authenticated, check CLI:
    • Run neonctl --version to confirm CLI is installed.
    • Run neonctl projects list to confirm auth/context.
  3. If CLI is missing, direct installation via quickstart.
  4. If CLI is installed but not authenticated, guide the user through neonctl auth (or API key auth), then continue.
  5. If both MCP and CLI paths are unsuccessful, use the Neon REST API:

MCP branch flow

  1. Choose normal vs schema-only based on data sensitivity and migration-testing goals.
  2. Use branch tools (for example, create_branch) to create the branch.
  3. Validate with read tools (for example, describe_branch).
  4. For migration workflows, prefer branch-based migration flows before applying to main.

Create a Normal Branch (Preferred for Real-Data Migration Testing)

Use this when the user needs realistic testing conditions. Real production-like data can expose edge cases your seed or data migration scripts miss, which helps catch migration issues before going live.

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

Steps

  1. Use MCP if already available/authenticated; otherwise verify CLI with neonctl --version.
  2. Ensure project context is set (neonctl set-context --project-id <your-project-id>) or include --project-id on commands.
  3. Create branch:
neonctl branches create \
  --name <branch-name> \
  --parent <parent-branch-id-or-name> \
  --expires-at 2026-12-15T18:02:16Z
  1. Optionally fetch a connection string for the new branch:
neonctl connection-string <branch-name>

Create a Schema-Only Branch (Beta, Sensitive Data)

Use this when users must not copy production rows into the test branch.

Link: https://neon.com/docs/guides/branching-schema-only.md

Steps

  1. Use MCP if already available/authenticated; otherwise verify CLI with neonctl --version.
  2. Create schema-only branch:
neonctl branches create \
  --name <schema-only-branch-name> \
  --parent <parent-branch-id-or-name> \
  --schema-only \
  --expires-at 2026-12-15T18:02:16Z

If multiple projects exist, include:

neonctl branches create \
  --name <schema-only-branch-name> \
  --parent <parent-branch-id-or-name> \
  --schema-only \
  --project-id <your-project-id> \
  --expires-at 2026-12-15T18:02:16Z

Beta Support Guidance (Mandatory)

Schema-only branching is in Beta. If users report unexpected behavior, errors, or missing capabilities:

  1. Ask them to share feedback in the Neon Console:
  2. Recommend opening a support conversation in the Neon Discord:

Reset from parent

Use this when a child branch has drifted and the user wants a clean refresh from the parent branch's latest schema and data.

Link: https://neon.com/docs/guides/reset-from-parent.md

What it does

  • Fully replaces the child branch schema and data with the parent's latest state.
  • Does not merge; local changes on the child branch are lost.
  • Keeps the same connection details, but active connections are briefly interrupted during reset.

When to recommend it

  • Development or staging branch is too far behind production.
  • User wants to start a new feature from a clean parent-aligned state.
  • Team wants to refresh staging from production for consistent testing baselines.

Hard constraints and blockers

  • Only child branches can be reset (root branches and schema-only root branches cannot be reset from parent).
  • If the target branch has children, reset is blocked until those child branches are removed.
  • After a parent branch is restored from snapshot, reset-from-parent may be unavailable for up to 24 hours.
  • Reset-from-parent always uses the current parent state; use Instant restore for point-in-time recovery needs.

CLI usage

neonctl branches reset <id|name> --parent --preserve-under-name <backup-branch-name>

If project context is not already set, include project ID:

neonctl branches reset <id|name> --parent --preserve-under-name <backup-branch-name> --project-id <project-id>

--preserve-under-name keeps the pre-reset state as a backup branch for rollback, but adds one extra branch to clean up later.

Optional context setup to avoid repeating --project-id:

neonctl set-context --project-id <project-id>

Console and API usage

  • Console: Open the target child branch, then select Reset from parent from Actions.
  • API: Use the restore endpoint for the branch and set source_branch_id to the parent branch ID.

Notes and Caveats

  • Schema-only branches are for structure-only cloning and sensitive/compliant data controls.
  • Schema-only branches are independent root branches (no parent branch and no shared history), so reset-from-parent does not apply.
  • For migration testing that depends on real-world row shapes, volumes, and edge cases, prefer normal branches.
  • Root branch allowances and per-branch storage limits can cap how many schema-only branches users can create.
  • If a user is unsure, default recommendation is:
    • Normal branch for migration validation.
    • Schema-only branch for compliance and privacy constraints.

Useful Workflow Patterns

If the user asks for process recommendations (not just a single command), suggest these:

  • One branch per PR: Create branch when PR opens, delete when merged/closed, keep migration tests isolated.
  • One branch per test run: Create branch at pipeline start, run migrations/tests, delete at end for deterministic CI.
  • One branch per developer: Isolated dev environments with production-like shape; avoid team collisions on shared test data.
  • PII-aware branching: If production has sensitive data, derive dev/PR branches from an anonymized branch or use schema-only branches.
  • Ephemeral lifecycle hygiene: Set branch expiration and automate cleanup so old branches do not accumulate avoidable storage/history cost.

Post-creation environment update prompt

After branch creation, ask whether the user wants to update local environment credentials to point at the new branch.

  • Ask: "Do you want me to update your .env DATABASE_URL to this new branch connection string?"
  • If yes, write the new branch connection string to the requested env file/key.
  • If no, leave credentials unchanged and share the connection string for manual use.
  • Never overwrite an existing env key without explicit confirmation.

Examples

Example 1: Migration testing with realistic data

User input: "I need to test a risky migration against production-like data."

Agent output shape:

  1. Recommend a normal branch and explain why.
  2. Share docs link: https://neon.com/docs/introduction/branching
  3. Check the available/authenticated tool path first (MCP, otherwise CLI with neonctl --version).
  4. Provide commands:
    • neonctl branches create --name migration-test --parent main --expires-at 2026-12-15T18:02:16Z
    • neonctl connection-string migration-test

Example 2: Sensitive data development workflow

User input: "We cannot copy production data because of compliance."

Agent output shape:

  1. Recommend schema-only branch and explain why.
  2. Share docs link: https://neon.com/docs/guides/branching-schema-only
  3. Check the available/authenticated tool path first (MCP, otherwise CLI with neonctl --version).
  4. Provide command:
    • neonctl branches create --name compliance-dev --parent main --schema-only --project-id <your-project-id> --expires-at 2026-12-15T18:02:16Z
  5. Mention Beta support path:

Further reading

Files1
1 files · 11.1 KB

Select a file to preview

Overall Score

86/100

Grade

A

Excellent

Safety

87

Quality

88

Clarity

85

Completeness

83

Summary

This skill guides AI agents to create and manage Neon PostgreSQL branches for testing and development. It provides decision logic for choosing between normal branches (with full data) and schema-only branches (structure only), and supports three execution paths: Neon MCP, Neon CLI, or REST API. The skill includes workflows for branch creation, reset operations, and environment configuration updates.

Static Analysis Findings

1 finding

Patterns detected by deterministic static analysis before AI scoring. Hover over any finding code for detailed information and remediation guidance.

Credential Exposure
SEC-020Direct .env File Access

Direct .env file access

SKILL.md.env

Detected Capabilities

Branch type decision logic (normal vs schema-only)Tool detection and authentication (MCP, CLI, REST API)Branch creation and configurationConnection string retrievalBranch reset operations with backup optionsEnvironment file updates (.env DATABASE_URL)Support workflow recommendations and patterns

Trigger Keywords

Phrases that MCP clients use to match this skill to user intent.

neon branch creationtest migrations safelyschema-only branchbranch production datareset branchsensitive data testingisolated dev environmentcompliance database branching

Risk Signals

INFO

Reference to .env file in context of DATABASE_URL updates

SKILL.md | 'Post-creation environment update prompt' section
INFO

No secrets exposure patterns detected in command execution

SKILL.md | All CLI examples

Referenced Domains

External domains referenced in skill content, detected by static analysis.

console.neon.techdiscord.ggneon.comwww.apache.org

Use Cases

  • Testing complex database migrations against production-like data before applying to main
  • Creating isolated development environments with real data without affecting production
  • Building schema-only branches for compliance and sensitive data workflows
  • Resetting drifted child branches to sync with parent branch state
  • Setting up per-PR or per-developer branch workflows with automatic cleanup

Quality Notes

  • Excellent decision tree structure: Branch Type Decision section immediately clarifies the choice between normal and schema-only branches with clear criteria and a fallback clarifying question for ambiguous requests.
  • Strong tool selection guidance with explicit priority order (MCP > CLI > API) and verification steps at each stage (version checks, auth tests), reducing risk of silent failures.
  • Comprehensive error handling and constraint documentation, particularly in 'Reset from parent' section which lists hard blockers and explains why they exist (e.g., 'child branches cannot be reset if they have children').
  • Well-structured examples that mirror real user intent ('migration testing', 'compliance') and show complete agent output shapes with commands, docs links, and follow-up prompts.
  • Explicitly addresses sensitive operations with user confirmation patterns (DATABASE_URL updates require 'Never overwrite...without explicit confirmation').
  • Beta feature support guidance is mandatory and documented with clear feedback channels (Neon Console, Discord), setting expectations for schema-only branching maturity.
  • Context signal clarity: skill explicitly mentions when MCP is preferred vs CLI, helping agents make tool choices in heterogeneous environments.
  • Workflow patterns section provides process recommendations beyond single commands, supporting team-scale and CI/CD use cases.
  • Minor: Some redundancy in tool selection order (explains MCP/CLI/API priority twice), but this reinforces importance.
  • Documentation links are comprehensive and specific (guides for branching, schema-only, reset, branch expiration, GitHub integration).
Model: claude-haiku-4-5-20251001Analyzed: May 9, 2026

Reviews

Add this skill to your library to leave a review.

No reviews yet

Be the first to share your experience.

Add neondatabase/neon-postgres-branches to your library

Command Palette

Search for a command to run...