Skills.MD
# moai-platform-neon: Neon Serverless PostgreSQL Specialist
## Quick Reference
Neon Serverless PostgreSQL Expertise: Specialized knowledge for Neon serverless PostgreSQL covering auto-scaling, scale-to-zero compute, database branching, Point-in-Time Recovery, and modern ORM integration.
### Core Capabilities
Serverless Compute provides auto-scaling PostgreSQL with scale-to-zero for cost optimization.
Database Branching enables instant copy-on-write branches for dev, staging, and preview environments.
Point-in-Time Recovery offers 30-day PITR with instant restore to any timestamp.
Connection Pooling provides built-in connection pooler for serverless and edge compatibility.
PostgreSQL 16 ensures full PostgreSQL 16 compatibility with extensions support.
### Quick Decision Guide
Need serverless PostgreSQL with auto-scaling: Use Neon.
Need database branching for CI/CD: Use Neon branching.
Need edge-compatible database: Use Neon with connection pooling.
Need instant preview environments: Use Neon branch per PR.
Need vector search: Consider Supabase with pgvector instead.
### Context7 Documentation Access
To fetch the latest Neon documentation:
Step 1: Resolve the library ID using mcp__context7__resolve-library-id with library name "neondatabase/neon".
Step 2: Fetch documentation using mcp__context7__get-library-docs with the resolved Context7 ID, specifying topics like "branching", "connection pooling", or "auto-scaling".
---
## Module Index
This skill is organized into focused modules for progressive disclosure:
### Core Modules
Database Branching at modules/branching-workflows.md covers copy-on-write branches for development, preview environments, and CI/CD integration with GitHub Actions.
Auto-Scaling and Compute at modules/auto-scaling.md covers compute unit configuration, scale-to-zero settings, and cost optimization strategies.
Connection Pooling at modules/connection-pooling.md covers serverless connection pooling for edge runtimes, WebSocket configuration, and pool sizing.
PITR and Backups at modules/pitr-backups.md covers point-in-time recovery, branch restoration, and backup strategies.
### Supporting Files
Reference Guide at reference.md provides API reference, environment configuration, and provider comparison.
Code Examples at examples.md provides complete working examples for common integration patterns.
---
## Implementation Guide
### Setup and Configuration
Package Installation requires @neondatabase/serverless from npm. Optionally install drizzle-orm for Drizzle ORM integration or @prisma/client and prisma for Prisma ORM integration.
Environment Configuration requires DATABASE_URL for direct connection used for migrations, formatted as postgresql://user:pass@ep-xxx.region.neon.tech/dbname?sslmode=require. DATABASE_URL_POOLED provides pooled connection for serverless and edge, formatted as postgresql://user:pass@ep-xxx-pooler.region.neon.tech/dbname?sslmode=require. NEON_API_KEY provides the Neon API key for branching operations. NEON_PROJECT_ID provides the project identifier.
### Serverless Driver Usage
For basic query execution, import neon from @neondatabase/serverless. Create the sql function by calling neon with the DATABASE_URL environment variable. Execute simple queries using tagged template literals with the sql function. For parameterized queries that are SQL injection safe, include variables inside the template literal. The driver supports transaction operations using sql.transaction with an array of SQL statements.
### Drizzle ORM Integration
For schema definition, import table and column types from drizzle-orm/pg-core. Define tables using pgTable with column definitions. Use uuid for UUIDs with primaryKey and defaultRandom, text for strings with notNull and unique modifiers, timestamp for dates with defaultNow, and jsonb for JSON columns.
For Drizzle client setup, import neon from @neondatabase/serverless, drizzle from drizzle-orm/neon-http, and the schema module. Create the sql function with neon and the DATABASE_URL. Export the db instance created with drizzle passing sql and the schema. Execute queries using db.select().from(schema.tableName).
### Prisma ORM Integration
For Prisma with Neon Serverless Driver, import Pool and neonConfig from @neondatabase/serverless, PrismaNeon from @prisma/adapter-neon, and PrismaClient from @prisma/client. Set neonConfig.webSocketConstructor to the ws module. Create a Pool with the DATABASE_URL connection string. Create an adapter with PrismaNeon passing the pool. Export the prisma instance created with PrismaClient passing the adapter.
---
## Provider Decision Guide
### When to Use Neon
Serverless Applications benefit from auto-scaling and scale-to-zero that reduce costs significantly.
Preview Environments benefit from instant branching that enables per-PR databases with production data.
Edge Deployment benefits from connection pooling that provides edge runtime compatibility.
Development Workflow benefits from branching from production for realistic development data.
Cost Optimization benefits from paying only for active compute time with scale-to-zero.
### When to Consider Alternatives
Need Vector Search: Consider Supabase with pgvector or dedicated vector database.
Need Real-time Subscriptions: Consider Supabase or Convex for real-time features.
Need NoSQL Flexibility: Consider Firestore or Convex for document storage.
Need Built-in Auth: Consider Supabase for integrated authentication.
### Pricing Reference
Free Tier provides 3GB storage and 100 compute hours per month.
Pro Tier provides usage-based pricing with additional storage and compute.
Scale-to-Zero incurs no charges during idle periods.
---
## Works Well With
- moai-platform-supabase for alternative when RLS or pgvector needed
- moai-lang-typescript for TypeScript patterns for Drizzle and Prisma
- moai-domain-backend for backend architecture with database integration
- moai-domain-database for general database patterns and optimization
---
Status: Production Ready
Version: 2.1.0
Generated with: MoAI-ADK Skill Factory v2.0
Last Updated: 2026-01-11
Technology: Neon Serverless PostgreSQL
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「moai-platform-neon」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次