skills/neon/SKILL.md
--- name: neon description: Manage Neon serverless Postgres — create project, branches (incl. per-PR preview), wire Drizzle + Neon HTTP driver for Cloudflare Workers, set DATABASE_URL via wrangler secret. Use when user wants Postgres (not SQLite/D1) — needs pgvector / PostGIS / JSONB / preview DB branches / strict types, or when wiring Neon into a TanStack Start + CF Workers app. category: database argument-hint: [install | project <list|create> | branch <list|create|delete> | push-secret] [--pr
npx skillsauth add RonanCodes/ronan-skills skills/neonInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
CLI-first Neon ops via the public API. Covers project/branch management and Drizzle + Neon HTTP driver wiring for TanStack Start on Cloudflare Workers. Chosen because CF Workers does not have native Postgres — Neon's HTTP driver (no TCP) is the idiomatic fit.
/ro:neon install # wire Drizzle + @neondatabase/serverless into current app
/ro:neon project list
/ro:neon project create <name> # creates project + default "main" branch, prints DATABASE_URL
/ro:neon branch list --project <id>
/ro:neon branch create <name> --project <id> # e.g. "preview-pr-42"
/ro:neon branch delete <name> --project <id>
/ro:neon push-secret --project <id> --branch main # write DATABASE_URL to current app's wrangler secret
NEON_API_KEY in ~/.claude/.env — create at https://console.neon.tech/app/settings/api-keyspush-secret: a TanStack Start app with wrangler.toml in the cwd| Need | Use |
|---|---|
| Default — simple CRUD, SQLite is enough, zero ops | D1 |
| pgvector (embeddings, RAG), PostGIS, JSONB ops, window funcs | Neon |
| Preview DB per PR / feature branch | Neon (free-tier branches are cheap, copy-on-write) |
| Strict types (CHECK, DOMAIN), PL/pgSQL | Neon |
| Multi-region reads | Neon (read replicas) |
pnpm add @neondatabase/serverless drizzle-orm
pnpm add -D drizzle-kit
drizzle.config.ts:
import { defineConfig } from "drizzle-kit";
export default defineConfig({
schema: "./src/db/schema.ts",
out: "./drizzle",
dialect: "postgresql",
dbCredentials: { url: process.env.DATABASE_URL! },
});
src/db/index.tsimport { neon } from "@neondatabase/serverless";
import { drizzle } from "drizzle-orm/neon-http";
import * as schema from "./schema";
export function createDb(env: { DATABASE_URL: string }) {
const sql = neon(env.DATABASE_URL);
return drizzle(sql, { schema });
}
The Neon HTTP driver works inside Workers because it uses fetch() — no TCP. Do not use @neondatabase/serverless's Pool / Client classes in Workers; only neon() + drizzle-orm/neon-http.
src/db/schema.tsimport { pgTable, serial, text, timestamp } from "drizzle-orm/pg-core";
export const users = pgTable("users", {
id: serial("id").primaryKey(),
email: text("email").notNull().unique(),
createdAt: timestamp("created_at").defaultNow().notNull(),
});
(Note: pg-core, not sqlite-core — this is the key diff vs a D1 app.)
wrangler.toml:
# DATABASE_URL is a secret, not a binding — do NOT put it here
# Set via: wrangler secret put DATABASE_URL
Access in Server Routes / Server Functions via env.DATABASE_URL (Workers env), or process.env.DATABASE_URL (local dev via .dev.vars).
.dev.vars:
DATABASE_URL=postgresql://user:[email protected]/main?sslmode=require
Then wrangler dev surfaces this as env.DATABASE_URL.
pnpm drizzle-kit generate # creates ./drizzle/*.sql
pnpm drizzle-kit migrate # applies against DATABASE_URL
For prod: apply against the prod branch's DATABASE_URL before wrangler deploy.
All calls go to https://console.neon.tech/api/v2/ with Authorization: Bearer ${NEON_API_KEY}.
Newer Neon accounts require org_id for the projects endpoint. Find it first:
curl -s "https://console.neon.tech/api/v2/users/me/organizations" \
-H "Authorization: Bearer ${NEON_API_KEY}" \
| jq '.organizations[] | {id, name, plan}'
Export as NEON_ORG_ID in the session or per-app env.
curl -s "https://console.neon.tech/api/v2/projects?org_id=${NEON_ORG_ID}" \
-H "Authorization: Bearer ${NEON_API_KEY}" \
| jq '.projects[] | {id, name, region_id, created_at, pg_version}'
Gotcha: calling /projects without ?org_id= returns {"code":"","message":"org_id is required, you can find it on your organization settings page"} — skill always passes the org id.
curl -s -X POST "https://console.neon.tech/api/v2/projects" \
-H "Authorization: Bearer ${NEON_API_KEY}" \
-H "Content-Type: application/json" \
-d "{
\"project\": {
\"name\": \"my-app\",
\"org_id\": \"${NEON_ORG_ID}\",
\"region_id\": \"aws-eu-central-1\",
\"pg_version\": 17
}
}" | jq '{id: .project.id, connection_uri: .connection_uris[0].connection_uri}'
pg_version: 17 is the current Neon default — bump this as Neon adds majors.
Region IDs: aws-eu-central-1 (Frankfurt), aws-us-east-1 (Virginia), aws-us-east-2 (Ohio), aws-ap-southeast-1 (Singapore). Pick closest to your CF Workers primary region.
The connection_uri in the response is your DATABASE_URL — push it to wrangler (push-secret below).
Branches in Neon are copy-on-write snapshots — cheap, instant, free tier includes 10 branches per project.
curl -s "https://console.neon.tech/api/v2/projects/${PROJECT_ID}/branches" \
-H "Authorization: Bearer ${NEON_API_KEY}" \
| jq '.branches[] | {id, name, primary, created_at, parent_id}'
curl -s -X POST "https://console.neon.tech/api/v2/projects/${PROJECT_ID}/branches" \
-H "Authorization: Bearer ${NEON_API_KEY}" \
-H "Content-Type: application/json" \
-d '{"branch": {"name": "preview-pr-42"}, "endpoints": [{"type": "read_write"}]}' \
| jq '{id: .branch.id, name: .branch.name, connection_uris: .connection_uris}'
curl -s -X DELETE "https://console.neon.tech/api/v2/projects/${PROJECT_ID}/branches/${BRANCH_ID}" \
-H "Authorization: Bearer ${NEON_API_KEY}"
Skill always confirms before delete — branches are not in a trash, deletion is immediate.
# Fetch the connection URI for the specified branch
CONN=$(curl -s "https://console.neon.tech/api/v2/projects/${PROJECT_ID}/connection_uri?branch_id=${BRANCH_ID}&database_name=neondb&role_name=neondb_owner" \
-H "Authorization: Bearer ${NEON_API_KEY}" | jq -r '.uri')
# Push to wrangler (prompts for confirm)
echo "$CONN" | wrangler secret put DATABASE_URL
Wire into CI so each PR gets its own branch:
# .github/workflows/pr-preview.yml
- name: Create preview DB branch
run: |
BRANCH_NAME="preview-pr-${{ github.event.pull_request.number }}"
curl -X POST ".../projects/${{ secrets.NEON_PROJECT_ID }}/branches" \
-H "Authorization: Bearer ${{ secrets.NEON_API_KEY }}" \
-d "{\"branch\":{\"name\":\"$BRANCH_NAME\"},\"endpoints\":[{\"type\":\"read_write\"}]}"
- name: Run migrations against branch
- name: Deploy to Workers preview with branch DATABASE_URL
- name: On PR close — delete branch
Global (~/.claude/.env):
NEON_API_KEY — this skill's management APIPer-app (.dev.vars + wrangler secret):
DATABASE_URL — Neon connection URI for the current branch. Format: postgresql://role:[email protected]/dbname?sslmode=requireCloudflare Workers don't support long-lived TCP sockets. The Neon HTTP driver makes each query a fetch() call, which works in the Workers runtime. For normal Postgres clients, you'd need Cloudflare Hyperdrive (their Postgres pooler), but the Neon HTTP driver skips the pooler — faster cold starts, simpler wiring.
DATABASE_URL is a secret. NEVER commit .dev.vars. NEVER put it in wrangler.toml. Always use wrangler secret put.push-secret./ro:new-tanstack-app --db neon — scaffolds with neon pre-wired (once orchestrator is built)/ro:cf-ship — ships after migrations are applieddevelopment
--- name: worktree description: Coordinate multiple agents on one repo via a worktree-lock pool, so two agents never clobber each other's working tree. Acquire the first free slot (main, then beta/gamma… worktrees, created on demand), work there on your own branch, release when you've pushed. Use before modifying any repo that might be in use by another agent (factory, dataforce, etc.), or whenever you're told a repo is being worked on. Backed by `ro worktree`. category: development argument-hin
testing
--- name: ship description: Ship a feature branch the local-CI-first way — run the full local gate, push, open a PR, squash-merge, then deploy, without waiting on GitHub Actions. Use when a branch is ready for main and you want it merged and deployed now. Reads CI policy from `ro ci` (default skips remote CI because GitHub Actions billing keeps hitting limits). Sibling to /ro:gh-ship (waits on GitHub checks) and /ro:cf-ship (the deploy half). Triggers on "ship it", "ship this", "merge and deploy
testing
--- name: setup-logging description: Set up (or audit) the observability stack in a TanStack Start + Cloudflare Workers app so it is "diagnosable by default" — structured logging (logtape) with a request context carrying trace_id + userId + tenant/orgId, a trace_id propagated FE→BE→logs→Sentry→PostHog, Cloudflare Workers observability enabled, and Sentry + PostHog wired. Two modes: `setup` (wire it into an app) and `audit` (check an existing app + report gaps). Use when scaffolding a new app, wh
development
Manage credentials INSIDE the active ~/.claude/.env file — read which token/account to use for a given app (Simplicity vs Dataforce vs Ronan-personal), add or update a secret WITHOUT it passing through the chat (an interactive Terminal window prompts for it), and track secrets that were exposed in a transcript so they get rotated. Sibling to /ro:context (which switches WHICH env file is active). Use when the user wants to add an API key/token/secret, asks "which credential do I use for X", needs the env organized/labelled, or a secret was pasted into the chat and should be rotated.