database
Skill1 starsChanged 3 months agoMITView on GitHub
Build the data layer with Drizzle ORM + Neon Postgres exactly per the locked stack — schema derived from the brief's nouns, drizzle-orm/neon-http client wiring, drizzle.config.ts with dialect postgresql, the generate/migrate/push workflow, the deliberate 0.45-vs-1.0-rc version pin, an on-brand seed script, and direct query patterns inside React Server Components. Invoke during the backend phase whenever the brief needs persistent data (accounts, listings, orders, saved content) or the user says "database", "schema", "Drizzle", "Postgres", "Neon", "migration", or "store this".
- Reads credentials
- Installs packages
24 other projects use a version of this.
Adopted by
Most recently taken up by
- davidvornholt/mailboxtheir own version, first seen Oct 4, 2026
- msrv-tech/skillstheir own version, first seen Oct 2, 2026
- theopenco/llmgatewaytheir own version, first seen Oct 1, 2026
- AsiaOstrich/universal-dev-standardstheir own version, first seen Sep 30, 2026
- lecluse-net/galaristheir own version, first seen Sep 27, 2026
- yamanidev/claude-code-configurationtheir own version, first seen Sep 13, 2026
Used with
Projects with it also use payment, monitoring and 6 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
lightpointventuresSkillpayment
当用户想加支付、收款、集成 Stripe、做订阅付费时使用 — 集成支付系统,支持一次性和订阅
Also in 3 projects that use this
rogue-dev-studioSkillmonitoring
Claude monitoring and usage tracking tools (UV, claude-monitor, claude-usage-cli). Use when the project needs this capability or the user / team manifest asks for it. Use for specialized `monitoring` work when listed in TEAM.yaml or explicitly requested.
Also in 3 projects that use this
JohnJBorenSkillci-cd
CI/CD pipeline design, GitHub Actions, testing automation, and deployment strategies
Also in 3 projects that use this
GitHubSkillrefactor
Surgical code refactoring to improve maintainability without changing behavior. Covers extracting functions, renaming variables, breaking down god functions, improving type safety, eliminating code smells, and applying design patterns. Less drastic than repo-rebuilder; use for gradual improvements.
Also in 5 projects that use this
akornmeierSkilldocker
Guide for using Docker - a containerization platform for building, running, and deploying applications in isolated containers. Use when containerizing applications, creating Dockerfiles, working with Docker Compose, managing images/containers, configuring networking and storage, optimizing builds, deploying to production, or implementing CI/CD pipelines with Docker.
Also in 3 projects that use this
AnthropicSkillincident-response
Run an incident response workflow — triage, communicate, and write postmortem. Trigger with "we have an incident", "production is down", an alert that needs severity assessment, a status update mid-incident, or when writing a blameless postmortem after resolution.
Also in 3 projects that use this
Other versions24 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 24
- theopenco/llmgateway★ 1.7ksame name
- AsiaOstrich/universal-dev-standards★ 76same name
- msrv-tech/skills★ 57same name
- xiaobei930/cc-best★ 48same name
- lightpointventures/claude-code-starter★ 36same name
- neuron-one/GODMODE★ 33same name
- yamanidev/claude-code-configuration★ 9same name
- YepAPI/skills★ 8same name
- SecuringTheRealm/str-agentic-adventures★ 4same name
- davidvornholt/mailbox★ 2same name
14 more not listed
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository79 other files it gives its agents.
- ultrawebSkill
- analyticsSkill
- animejsSkill
- api-designSkill
- app-structureSkill
- assetsSkill
- authSkill
- award-canonSkill
- briefSkill
- buttonsSkill
- cardsSkill
- cartSkill
- checkpointSkill
- colorSkill
- command-paletteSkill
- component-apiSkill
- consentSkill
- content-cmsSkill
- copywritingSkill
- data-displaySkill
- data-fetchingSkill
- depthSkill
- directionSkill
- emailSkill
- faqSkill
- feature-sectionsSkill
- footerSkill
- formsSkill
- gate-accessibilitySkill
- gate-antislopSkill
- gate-codeSkill
- gate-contentSkill
- gate-performanceSkill
- gate-responsiveSkill
- gate-visualSkill
- handoffSkill
- heroSkill
- hidden-craftSkill
- i18nSkill
- iconsSkill
- identitySkill
- imagerySkill
- iterateSkill
- layout-gridSkill
- marginaliaSkill
- media-optimizationSkill
- micro-interactionsSkill
- mockupSkill
- motion-languageSkill
- navigationSkill
- overlaysSkill
- page-transitionsSkill
- paymentsSkill
- physicsSkill
- previewSkill
- pricingSkill
- print-craftSkill
- product-detailSkill
- retrofitSkill
- routingSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
3 rules. 0 are common, 0 are distinctive, and 3 are very specific to this project.
0
Common
Most of the 16 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 19
Write db/schema.ts: one pgTable per noun, relations, an index on every column you filter or join by.
- Very specific: line 21
Write and run db/seed.ts. Verify with a real query (db.query.<table>.findMany()) before building UI on top.
- Very specific: line 81
Every table gets createdAt with .defaultNow().
“Common” is measured: kept by at least 6 in 10 of the 16 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
database — the brief's nouns, typed
Stage: Phase 7 (Backend) - Reads: design/BRIEF.md, design/SITEMAP.md - Writes: db/schema.ts, db/index.ts, db/seed.ts, drizzle.config.ts, drizzle/ migrations
Standard
The schema reads like the brief: every table a noun from BRIEF.md, every column earning its place, relations explicit, timestamps everywhere. Queries run directly in server components or a thin db/queries.ts — never behind a fetch to your own API. The database rebuilds from the repo alone: drizzle-kit migrate + seed, and the site looks inhabited, not test-data-empty.
Process
- Extract the nouns. "A course platform with instructors and reviews" →
users,courses,enrollments,reviews. Zero persistent nouns → stop; a brochure site gets no database. - Install:
npm i drizzle-orm @neondatabase/serverlessandnpm i -D drizzle-kit. Pin deliberately: npmlatestis drizzle-orm 0.45.x while the official docs install@rc(1.0.0-rc). Choose 0.45.x for the stable line or the rc to match current docs — record the choice and reason in BRIEF.md's backend section, and pin drizzle-orm and drizzle-kit from the same line, never mixed. - Wire client and config (exact shapes below).
DATABASE_URLfrom the Neon dashboard connection string into.env— exactly that file, and gitignored; the env-loading rules below explain why.env.localsilently breaks drizzle-kit. - Write
db/schema.ts: onepgTableper noun, relations, an index on every column you filter or join by. - Iterate with
npx drizzle-kit push(schema straight to DB, no files) ONLY while the data is disposable. The moment data matters — and always before first deploy — switch tonpx drizzle-kit generate(emits SQL) +npx drizzle-kit migrate(applies it), and commitdrizzle/. - Write and run
db/seed.ts. Verify with a real query (db.query.<table>.findMany()) before building UI on top.
Locked wiring
// db/index.ts
import { neon } from "@neondatabase/serverless";
import { drizzle } from "drizzle-orm/neon-http";
import * as schema from "./schema";
export const db = drizzle({ client: neon(process.env.DATABASE_URL!), schema });// drizzle.config.ts
import { defineConfig } from "drizzle-kit";
export default defineConfig({
schema: "./db/schema.ts",
out: "./drizzle",
dialect: "postgresql", // mandatory — config fails without it
dbCredentials: { url: process.env.DATABASE_URL! },
});Commands are drizzle-kit generate / migrate / push — the old generate:pg variants are dead. The neon-http driver is stateless one-shot HTTP: ideal for serverless/RSC reads and single-statement writes; for interactive multi-statement transactions verify the websocket driver against current docs first.
Env loading for drizzle-kit — the one real trap in this wiring. drizzle-kit bundles dotenv and auto-loads .env from the project root before evaluating drizzle.config.ts — verified empirically on both this stack's pinned lines — so the config above needs no dotenv dependency and no import "dotenv/config" (the official Drizzle+Neon guide carries an explicit config({ path: '.env' }) from the dotenv package; for the config file it is belt-and-braces, load-bearing only for standalone scripts run under bare tsx). What IS load-bearing on the verified pins: drizzle-kit reads .env and nothing else — not .env.local, no NODE_ENV variants, no --env-file flag (discussed upstream, never shipped; re-check on a future major). Next.js loads .env.local for app code, so a project keeping secrets there — the create-next-app convention — has exactly one blind tool: drizzle-kit sees DATABASE_URL as undefined and every kit command fails while the app itself runs fine. Pick one and record it:
DATABASE_URLin.env(gitignored) and the auto-load does the rest — the wiring above as-is, and the default; orsecrets stay in
.env.local: load them with Next's own loader at the top ofdrizzle.config.ts— install it DECLARED,npm i -D @next/env(it resolves transitively fromnexttoday, but an undeclared import breaks under pnpm/Yarn PnP and Next layout changes; Next's own docs say install it for ORM/test config outside the Next runtime):import { loadEnvConfig } from "@next/env"; loadEnvConfig(process.cwd(), process.env.NODE_ENV !== "production"); // dev=true → .env.development/.env.local semanticsFull
.env.local/NODE_ENV semantics, no coupling to drizzle-kit's private file layout. One caveat: don't keep the SAME key in both.envand.env.local— drizzle-kit's earlier bundled load already populated it,@next/envwon't overwrite, and the two tools silently disagree.
Already-set process env always wins over the auto-loaded file, so CI- and host-provided variables are respected either way.
Schema rules
import { pgTable, text, integer, boolean, timestamp, uuid, index } from "drizzle-orm/pg-core";
export const courses = pgTable("courses", {
id: uuid("id").defaultRandom().primaryKey(),
slug: text("slug").notNull().unique(),
title: text("title").notNull(),
priceCents: integer("price_cents").notNull().default(0),
published: boolean("published").notNull().default(false),
authorId: text("author_id").notNull().references(() => users.id),
createdAt: timestamp("created_at").notNull().defaultNow(),
updatedAt: timestamp("updated_at").notNull().defaultNow().$onUpdate(() => new Date()),
}, (t) => [index("courses_author_idx").on(t.authorId)]);- Money is integer cents. Never float.
textovervarchar(n)— Postgres treats them identically; length limits live in zod at the boundary, not in DDL.- Every table gets
createdAtwith.defaultNow(); mutable tables addupdatedAtwith.$onUpdate(). - Anything routed by URL (SITEMAP.md dynamic segments) gets a unique
slug. - Closed value sets are
pgEnum, not free text. - Auth tables come from the Better Auth CLI (
ultraweb:auth) — merge them into this schema file and migrate through this workflow: one schema, one migration history.
RSC query patterns
// app/courses/page.tsx — server component: no fetch, no API hop
import { db } from "@/db";
export default async function CoursesPage() {
const courses = await db.query.courses.findMany({
where: (c, { eq }) => eq(c.published, true),
orderBy: (c, { desc }) => desc(c.createdAt),
limit: 24,
});
// render
}- Independent queries in one component go through
Promise.all— serial awaits add a full round trip each. - DB calls have no fetch-cache semantics; they run every request. To cache:
cacheComponents: truein next.config, wrap the query function with'use cache'+cacheTag("courses"), thenrevalidateTag("courses")after mutations (Next 16 also accepts a cacheLife profile as second arg). - Detail pages:
await paramsbefore touching the slug — params are Promises in Next 16. - An empty result is a designed state (
ultraweb:ui-states), never a blank div.
Seed script
// db/seed.ts — run with: npx tsx --env-file=.env db/seed.ts
import { db } from "./index";
import { courses } from "./schema";
await db.insert(courses).values([/* 8–12 rows per listed table */]);Seed data is what gate-visual screenshots. Write it in the brief's voice: real-sounding names, plausible prices, varied lengths — one short title, one two-liner, so layouts prove they survive both. Lorem in the seed becomes lorem on the site; banned either way.
Anti-patterns
from "pg",new Pool(— wrong driver; Neon serverless uses@neondatabase/serverlessdrizzle(sql)positional wiring from pre-2025 tutorials — the locked form isdrizzle({ client: neon(url) })generate:pg,push:pg— dead drizzle-kit commandsdefineConfigwithoutdialect: "postgresql"— hard errorDATABASE_URLonly in.env.local— drizzle-kit reads.envand nothing else; the config evaluates with undefined and every kit command dies whilenext devruns finedrizzle-kit pushagainst a database whose data you keepfetch("/api/inside an RSC that owns the db — self-HTTP round tripreal(,doublePrecision(for money- Seed rows named "Test 1", "Foo", or lorem anything
- drizzle-orm from
latestwith drizzle-kit fromrc(or vice versa) — one line, both packages
Worked example — Kaffeewerk Ost, single-origin shop schema
Moved to references/example.md — read only when this build's case is genuinely ambiguous; the sections above are the decision material.
Composes with
Moved to references/composes.md — the handoff map; load it when orchestrating this skill against its neighbors.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

