소스 정보
- 저장소
- BEKO2210/Firstbrain
- 최근 소스 활동
- 2026년 5월 17일 12:40
- 감지된 SKILL.md 언어
- 영어
- 스타
- 15
- 포크
- 2
설치 방법
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
소스 파일 검토
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
메뉴
기본적으로 소스를 먼저 확인하는 Prompt가 선택됩니다. 직접 명령으로 전환하거나 로컬 사본을 다운로드할 수도 있습니다.
설치 여부를 결정하기 전에 SKILL.md와 SkillsMP에 표시된 보조 파일을 읽어 보세요.
Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/BEKO2210/Firstbrain --skill neon-postgres명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
Arquitecto de Soluciones Principal y Consultor Tecnológico de Andru.ia. Diagnostica y traza la hoja de ruta óptima para proyectos de IA en español.
Security audit, hardening, threat modeling (STRIDE/PASTA), Red/Blue Team, OWASP checks, code review, incident response, and infrastructure security for any project.
Ingeniero de Sistemas de Andru.ia. Diseña, redacta y despliega nuevas habilidades (skills) dentro del repositorio siguiendo el Estándar de Diamante.
SOC 직업 분류 기준
SKILL.md 표시 중
| name | neon-postgres |
| description | Expert patterns for Neon serverless Postgres, branching, connection |
| type | skill |
| created | 2026-02-27T00:00:00.000Z |
| domain | software-development |
| category | database |
| risk | safe |
| source | vibeship-spawner-skills (Apache 2.0) |
| tags | ["skill","software-development","database","neon","postgres"] |
Expert patterns for Neon serverless Postgres, branching, connection pooling, and Prisma/Drizzle integration
Configure Prisma for Neon with connection pooling.
Use two connection strings:
The pooled connection uses PgBouncer for up to 10K connections. Direct connection required for migrations (DDL operations).
DATABASE_URL="postgres://user:password@ep-xxx-pooler.us-east-2.aws.neon.tech/neondb?sslmode=require"
DIRECT_URL="postgres://user:password@ep-xxx.us-east-2.aws.neon.tech/neondb?sslmode=require"
// prisma/schema.prisma generator client { provider = "prisma-client-js" }
datasource db { provider = "postgresql" url = env("DATABASE_URL") directUrl = env("DIRECT_URL") }
model User { id String @id @default(cuid()) email String @unique name String? createdAt DateTime @default(now()) updatedAt DateTime @updatedAt }
// lib/prisma.ts import { PrismaClient } from '@prisma/client';
const globalForPrisma = globalThis as unknown as { prisma: PrismaClient | undefined; };
export const prisma = globalForPrisma.prisma ?? new PrismaClient({ log: process.env.NODE_ENV === 'development' ? ['query', 'error', 'warn'] : ['error'], });
if (process.env.NODE_ENV !== 'production') { globalForPrisma.prisma = prisma; }
// Run migrations // Uses DIRECT_URL automatically npx prisma migrate dev npx prisma migrate deploy
Use Drizzle ORM with Neon's serverless HTTP driver for edge/serverless environments.
Two driver options:
npm install drizzle-orm @neondatabase/serverless npm install -D drizzle-kit
// lib/db/schema.ts import { pgTable, serial, text, timestamp } from 'drizzle-orm/pg-core';
export const users = pgTable('users', { id: serial('id').primaryKey(), email: text('email').notNull().unique(), name: text('name'), createdAt: timestamp('created_at').defaultNow().notNull(), updatedAt: timestamp('updated_at').defaultNow().notNull(), });
// lib/db/index.ts (for serverless - HTTP driver) import { neon } from '@neondatabase/serverless'; import { drizzle } from 'drizzle-orm/neon-http'; import * as schema from './schema';
const sql = neon(process.env.DATABASE_URL!); export const db = drizzle(sql, { schema });
// Usage in API route import { db } from '@/lib/db'; import { users } from '@/lib/db/schema';
export async function GET() { const allUsers = await db.select().from(users); return Response.json(allUsers); }
// lib/db/index.ts (for WebSocket - transactions) import { Pool } from '@neondatabase/serverless'; import { drizzle } from 'drizzle-orm/neon-serverless'; import * as schema from './schema';
const pool = new Pool({ connectionString: process.env.DATABASE_URL }); export const db = drizzle(pool, { schema });
// With transactions await db.transaction(async (tx) => { await tx.insert(users).values({ email: 'test@example.com' }); await tx.update(users).set({ name: 'Updated' }); });
// drizzle.config.ts import { defineConfig } from 'drizzle-kit';
export default defineConfig({ schema: './lib/db/schema.ts', out: './drizzle', dialect: 'postgresql', dbCredentials: { url: process.env.DATABASE_URL!, }, });
// Run migrations npx drizzle-kit generate npx drizzle-kit migrate
Neon provides built-in connection pooling via PgBouncer.
Key limits:
Use pooled endpoint for application, direct for migrations.
postgres://user:pass@ep-cool-name-pooler.us-east-2.aws.neon.tech/neondb
postgres://user:pass@ep-cool-name.us-east-2.aws.neon.tech/neondb
// Prisma with pooling // prisma/schema.prisma datasource db { provider = "postgresql" url = env("DATABASE_URL") // Pooled directUrl = env("DIRECT_URL") // Direct }
// Connection pool settings for high-traffic // lib/prisma.ts import { PrismaClient } from '@prisma/client';
export const prisma = new PrismaClient({ datasources: { db: { url: process.env.DATABASE_URL, }, }, // Connection pool settings // Adjust based on compute size });
// For Drizzle with connection pool import { Pool } from '@neondatabase/serverless';
const pool = new Pool({ connectionString: process.env.DATABASE_URL, max: 10, // Max connections in local pool idleTimeoutMillis: 30000, connectionTimeoutMillis: 10000, });
// Compute size connection limits // 0.25 CU: 112 connections (105 available after reserved) // 0.5 CU: 225 connections // 1 CU: 450 connections // 2 CU: 901 connections // 4 CU: 1802 connections // 8 CU: 3604 connections
Create instant copies of your database for development, testing, and preview environments.
Branches share underlying storage (copy-on-write), making them instant and cost-effective.
neon branches create --name feature/new-feature --parent main
neon branches create --name debug/yesterday
--parent main
--timestamp "2024-01-15T10:00:00Z"
neon branches list
neon connection-string feature/new-feature
neon branches delete feature/new-feature
// In CI/CD (GitHub Actions) // .github/workflows/preview.yml name: Preview Environment on: pull_request: types: [opened, synchronize]
jobs: create-branch: runs-on: ubuntu-latest steps: - uses: neondatabase/create-branch-action@v5 id: create-branch with: project_id: ${{ secrets.NEON_PROJECT_ID }} branch_name: preview/pr-${{ github.event.pull_request.number }} api_key: ${{ secrets.NEON_API_KEY }} username: ${{ secrets.NEON_ROLE_NAME }}
- name: Run migrations
env:
DATABASE_URL: ${{ steps.create-branch.outputs.db_url_with_pooler }}
run: npx prisma migrate deploy
- name: Deploy to Vercel
env:
DATABASE_URL: ${{ steps.create-branch.outputs.db_url_with_pooler }}
run: vercel deploy --prebuilt
// Cleanup on PR close on: pull_request: types: [closed]
jobs: delete-branch: runs-on: ubuntu-latest steps: - uses: neondatabase/delete-branch-action@v3 with: project_id: ${{ secrets.NEON_PROJECT_ID }} branch: preview/pr-${{ github.event.pull_request.number }} api_key: ${{ secrets.NEON_API_KEY }}
Automatically create database branches for Vercel preview deployments. Each PR gets its own isolated database.
Two integration options:
// vercel.json - Add migration to build { "buildCommand": "prisma migrate deploy && next build", "framework": "nextjs" }
// Or in package.json { "scripts": { "vercel-build": "prisma generate && prisma migrate deploy && next build" } }
// Environment variables injected by integration // DATABASE_URL - Pooled connection for preview branch // DATABASE_URL_UNPOOLED - Direct connection for migrations // PGHOST, PGUSER, PGDATABASE, PGPASSWORD - Individual vars
// Prisma schema for Vercel integration datasource db { provider = "postgresql" url = env("DATABASE_URL") directUrl = env("DATABASE_URL_UNPOOLED") // Vercel variable }
// For Drizzle in Next.js on Vercel import { neon } from '@neondatabase/serverless'; import { drizzle } from 'drizzle-orm/neon-http';
// Use pooled URL for queries const sql = neon(process.env.DATABASE_URL!); export const db = drizzle(sql);
Neon autoscales compute resources and scales to zero.
Cold start latency: 500ms - few seconds when waking from idle. Production recommendation: Disable scale-to-zero, set minimum compute.
// Handle cold starts in application // lib/db-with-retry.ts import { prisma } from './prisma';
const MAX_RETRIES = 3; const RETRY_DELAY = 1000;
export async function queryWithRetry( query: () => Promise ): Promise { let lastError: Error | undefined;
for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) { try { return await query(); } catch (error) { lastError = error as Error;
// Retry on connection errors (cold start)
if (error.code === 'P1001' || error.code === 'P1002') {
console.log(`Retry attempt ${attempt}/${MAX_RETRIES}`);
await new Promise(r => setTimeout(r, RETRY_DELAY * attempt));
continue;
}
throw error;
}
}
throw lastError; }
// Usage const users = await queryWithRetry(() => prisma.user.findMany() );
// Reduce cold start latency with SSL direct negotiation
postgres://user:pass@ep-xxx-pooler.aws.neon.tech/db?sslmode=require&sslnegotiation=direct
// Keep-alive for long-running apps // lib/db-keepalive.ts import { prisma } from './prisma';
// Ping database every 4 minutes to prevent suspend const KEEPALIVE_INTERVAL = 4 * 60 * 1000;
if (process.env.NEON_KEEPALIVE === 'true') {
setInterval(async () => {
try {
await prisma.$queryRawSELECT 1;
} catch (error) {
console.error('Keepalive failed:', error);
}
}, KEEPALIVE_INTERVAL);
}
// Compute sizing recommendations // Development: 0.25 CU, scale-to-zero enabled // Staging: 0.5 CU, scale-to-zero enabled // Production: 1+ CU, scale-to-zero DISABLED // High-traffic: 2-4 CU minimum, autoscaling enabled
Severity: HIGH
Severity: HIGH
Severity: HIGH
Severity: MEDIUM
Severity: MEDIUM
Severity: LOW
Severity: MEDIUM
Severity: HIGH
Severity: MEDIUM
Severity: ERROR
Direct database URLs should never be exposed to client
Message: Direct URL exposed to client. Only pooled URLs for server-side use.
Severity: ERROR
Connection strings should use environment variables
Message: Hardcoded connection string. Use environment variables.
Severity: WARNING
Neon requires SSL connections
Message: Missing sslmode=require. Add to connection string.
Severity: ERROR
Prisma needs directUrl for migrations through PgBouncer
Message: Using pooled URL without directUrl. Migrations will fail.
Severity: ERROR
directUrl should be non-pooled connection
Message: directUrl points to pooler. Use non-pooled endpoint for migrations.
Severity: WARNING
High pool sizes exhaust connections with many function instances
Message: Pool size too high for serverless. Use max: 5-10.
Severity: WARNING
Creating new clients per request wastes connections
Message: Creating client per request. Use connection pool or neon() driver.
Severity: WARNING
Branches should have cleanup automation
Message: Creating branch without cleanup. Add delete-branch-action to PR close.
Severity: WARNING
Scale-to-zero adds latency in production
Message: Scale-to-zero on production. Disable for low-latency.
Severity: ERROR
neon() HTTP driver doesn't support transactions
Message: HTTP driver with transaction. Use Pool from @neondatabase/serverless.