Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add skills/lonormaly/builders-stack/design-a-schemanpx skills add lonormaly/builders-stack --skill design-a-schemagit clone --depth 1 https://github.com/lonormaly/builders-stackWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/lonormaly/builders-stack/design-a-schema)<a href="https://agentmods.dev/skills/lonormaly/builders-stack/design-a-schema"><img src="https://agentmods.dev/badge/skills/lonormaly/builders-stack/design-a-schema.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00091 | $0.00989 |
| Opus 5 | $0.00046 | $0.00495 |
| Sonnet 5 | $0.00018 | $0.00198 |
| Haiku 4.5 | $0.00009 | $0.00099 |
Grade A, and why
design-a-schema scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 68 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Design a schema
Get the data model right before the app is built on top of it — a bad schema is the most expensive thing to change later, and on Neon's free tier it's also what quietly eats your 0.5 GB and your compute. Normalize first, constrain always, index on purpose.
When to use
- Adding a table or column to
libs/db/src/schema.ts. - Choosing keys, foreign keys, uniqueness, or an index strategy.
- A query is slow and the cause is the schema (missing index, wrong shape), not the query text — pair with
optimize-a-query.
Normalize first (then denormalize with a reason)
- Default to 3NF. One fact in one place. A value that can be derived or looked up should not be copied into another row — copies drift (update anomalies).
- Denormalize only deliberately, with a comment saying why (a measured hot read path, a reporting rollup). Never "just in case."
- One row = one entity. Repeating groups (
tag1,tag2,tag3) become a child table with a FK.
Constrain at the database, not just the app
The DB is the last line of integrity — app validation can be bypassed, a bad migration can't.
NOT NULLon everything that is logically required.- Foreign keys for every real relationship, with an explicit
onDelete(cascadefor owned children,restrict/set nullotherwise). Seesession/accountinauth-schema.ts—onDelete: "cascade"onuser.id. uniqueon natural keys (email, slug).checkconstraints for enums/ranges Drizzle can express.
Index deliberately — the part everyone gets wrong
- Postgres does NOT auto-index foreign keys. Add an index on every FK column you
JOINor filter on. A missing FK index is the classic "fine in dev, dies under load" bug. - Composite index column order matters: put the equality-filtered column first, the range/sort column second. An index on
(user_id, created_at)servesWHERE user_id = ? ORDER BY created_at— the reverse order does not. - Partial indexes for queries that always filter (
WHERE deleted_at IS NULL) — smaller, cheaper. - Do NOT add speculative indexes. Every index slows writes and costs storage against the 0.5 GB free cap (see
run-lean-on-neon). Index what a real query needs; drop indexes nothing uses.
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 4d ago First seen · 68 lines · 91 tokens per session scan A 785af60a6973
design-a-schema is a skill published in the GitHub repository lonormaly/builders-stack (41 stars, last pushed 18d ago), licensed MIT. It adds 91 tokens to every session and 989 once invoked, about $0.0005 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.
Other skills, from other repositories
data-table
DiceUI data-table system for building production-ready data tables with server-side filtering, sorting, and pagination. Based on TanStack Table + nuqs URL state + Drizzle ORM backend. Use this skill whenever building, modifying, or debugging data tables — whether adding columns, filters, sort controls, server-side…
postgres-drizzle
Proactively apply when creating APIs, backends, or data models. Triggers on PostgreSQL, Postgres, Drizzle, database, schema, tables, columns, indexes, queries, migrations, ORM, relations, joins, transactions, SQL, drizzle-kit, connection pooling, N+1, JSONB, RLS. Use when writing database schemas, queries, migrations…
AgentDB Performance Optimization
Optimize AgentDB performance with quantization (4-32x memory reduction), HNSW indexing (150x faster search), caching, and batch operations. Use when optimizing memory usage, improving search speed, or scaling to millions of vectors.
AgentDB Vector Search
Implement semantic vector search with AgentDB for intelligent document retrieval, similarity matching, and context-aware querying. Use when building RAG systems, semantic search engines, or intelligent knowledge bases.
AgentDB Advanced Features
Master advanced AgentDB features including QUIC synchronization, multi-database management, custom distance metrics, hybrid search, and distributed systems integration. Use when building distributed AI systems, multi-agent coordination, or advanced vector search applications.
supabase-postgres-best-practices
Postgres performance optimization and best practices from Supabase. Use this skill when writing, reviewing, or optimizing Postgres queries, schema designs, or database configurations.