| name | neondb |
| description | Manage Neon serverless Postgres databases. Create projects, branches, databases, and execute queries. Perfect for agent workflows needing persistent storage with branching (like git for databases), scale-to-zero, and instant provisioning. |
| homepage | https://neon.tech |
| metadata | {"openclaw":{"emoji":"🐘","requires":{"bins":["neonctl"]},"install":[{"id":"brew","kind":"brew","package":"neonctl","bins":["neonctl"],"label":"Install neonctl (Homebrew)"},{"id":"npm","kind":"node","package":"neonctl","bins":["neonctl"],"label":"Install neonctl (npm)"}]}} |
NeonDB
Neon is serverless Postgres — scales to zero, branches like git, instant provisioning. Perfect for AI agents needing databases without ops overhead.
Why Neon for Agents?
- Instant databases — Create in seconds, no server setup
- Branching — Fork your database like git (test without affecting prod)
- Scale-to-zero — Pay nothing when idle
- Connection pooling — Built-in, no PgBouncer needed
- Generous free tier — 0.5 GB storage, 190 compute hours/month
Quick Start
1. Install CLI
brew install neonctl
npm i -g neonctl
2. Authenticate
neonctl auth
export NEON_API_KEY=your_api_key_here
3. Create Your First Project
neonctl projects create --name "my-agent-db"
Core Commands
Projects (top-level container)
neonctl projects list
neonctl projects create --name "project-name"
neonctl projects delete <project-id>
neonctl projects get <project-id>
Branches (database snapshots)
neonctl branches list --project-id <project-id>
neonctl branches create --project-id <project-id> --name "dev-branch"
neonctl branches create --project-id <project-id> --name "restore-test" --parent main --timestamp "2024-01-15T10:00:00Z"
neonctl branches reset <branch-id> --project-id <project-id> --parent
neonctl branches delete <branch-id> --project-id <project-id>
neonctl branches schema-diff --project-id <project-id> --base-branch main --compare-branch dev
Databases
neonctl databases list --project-id <project-id> --branch <branch-name>
neonctl databases create --project-id <project-id> --branch <branch-name> --name "mydb"
neonctl databases delete <db-name> --project-id <project-id> --branch <branch-name>
Connection Strings
neonctl connection-string --project-id <project-id>
neonctl connection-string <branch-name> --project-id <project-id>
neonctl connection-string --project-id <project-id> --pooled
neonctl connection-string --project-id <project-id> --extended
Roles (database users)
neonctl roles list --project-id <project-id> --branch <branch-name>
neonctl roles create --project-id <project-id> --branch <branch-name> --name "app_user"
Executing Queries
Using psql
neonctl connection-string --project-id <project-id> | xargs psql
psql "$(neonctl connection-string --project-id <project-id>)"
Using the connection string in code
CONNECTION_STRING=$(neonctl connection-string --project-id <project-id> --pooled)
psql "$CONNECTION_STRING" -c "SELECT * FROM users LIMIT 5;"
Context (Avoid Repeating Project ID)
Set context to avoid passing --project-id every time:
neonctl set-context --project-id <project-id>
neonctl branches list
neonctl databases list
neonctl connection-string
Agent Workflow Examples
Create org database with branches
neonctl projects create --name "website-org-db" -o json
neonctl branches create --name "dev" --project-id <id>
neonctl connection-string main --project-id <id> --pooled
neonctl connection-string dev --project-id <id> --pooled
Create leads table
psql "$(neonctl cs --project-id <id>)" <<EOF
CREATE TABLE leads (
id SERIAL PRIMARY KEY,
business_name VARCHAR(255) NOT NULL,
category VARCHAR(100),
location VARCHAR(255),
phone VARCHAR(50),
email VARCHAR(255),
website VARCHAR(255),
status VARCHAR(50) DEFAULT 'identified',
priority VARCHAR(20) DEFAULT 'medium',
notes TEXT,
created_at TIMESTAMP DEFAULT NOW(),
updated_at TIMESTAMP DEFAULT NOW()
);
CREATE INDEX idx_leads_status ON leads(status);
CREATE INDEX idx_leads_category ON leads(category);
EOF
Branch for experiments
neonctl branches create --name "schema-experiment" --project-id <id>
psql "$(neonctl cs schema-experiment --project-id <id>)" -c "ALTER TABLE leads ADD COLUMN score INT;"
neonctl branches delete schema-experiment --project-id <id>
Output Formats
neonctl projects list -o json
neonctl projects list -o yaml
neonctl projects list -o table
Environment Variables
export NEON_API_KEY=your_key
export NEON_PROJECT_ID=your_project_id
Common Patterns
Check if neonctl is configured
neonctl me -o json 2>/dev/null && echo "Authenticated" || echo "Need to run: neonctl auth"
Quick database query
psql "$(neonctl cs)" -c "SELECT COUNT(*) FROM leads WHERE status='contacted';"
Export to CSV
psql "$(neonctl cs)" -c "COPY (SELECT * FROM leads) TO STDOUT WITH CSV HEADER" > leads.csv
Import from CSV
psql "$(neonctl cs)" -c "\COPY leads(business_name,category,location) FROM 'import.csv' WITH CSV HEADER"
Troubleshooting
"Connection refused"
- Check if branch compute is active (scale-to-zero may have paused it)
- Use
--pooled connection string for serverless workloads
"Permission denied"
- Verify API key:
neonctl me
- Re-authenticate:
neonctl auth
Slow first connection
- Normal for scale-to-zero. First connection wakes the compute (~1-2 seconds)
- Use connection pooling to maintain warm connections
Links