design-a-schema

design-a-schema is a skill for Claude Code, Codex from lonormaly/builders-stack. It costs 91 tokens per session (989 once invoked), scanned A, original, MIT.

A skill for designing or changing database tables with Drizzle in the project’s database library. Drizzle is a TypeScript tool for defining database structures and queries.

In plain words
What is it for?
Use it when adding tables or columns, choosing keys and relationships, setting constraints, or adding indexes for slow queries.
Why use it?
It helps prevent duplicated data, missing rules and slow lookups before they become harder to fix.

Skill for Claude CodeCodex

Install

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.

agentmods
npx agentmods add skills/lonormaly/builders-stack/design-a-schema
Any agent
npx skills add lonormaly/builders-stack --skill design-a-schema
Clone the repo
git clone --depth 1 https://github.com/lonormaly/builders-stack

Made for: Claude Code, Codex.

Wrote 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.

agentmods badge for design-a-schema

README.md
[![agentmods](https://agentmods.dev/badge/skills/lonormaly/builders-stack/design-a-schema.svg)](https://agentmods.dev/skills/lonormaly/builders-stack/design-a-schema)
Your own site
<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>
Per session 91 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 989 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce 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

Measured 4d ago against content hash 785af60a6973, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

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.

agents/skills/design-a-schema/SKILL.md · 68 lines

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 NULL on everything that is logically required.
  • Foreign keys for every real relationship, with an explicit onDelete (cascade for owned children, restrict/set null otherwise). See session/account in auth-schema.tsonDelete: "cascade" on user.id.
  • unique on natural keys (email, slug). check constraints 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 JOIN or 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) serves WHERE 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.

Read the full file on GitHub · 68 lines

Changes

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.

  1. 4d ago First seen · 68 lines · 91 tokens per session scan A 785af60a6973

Subscribe to this mod's changes

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.

Related

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…

vobase/vobase · 116 tokens

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…

vobase/vobase · 95 tokens

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.

aegntic/cldcde · 53 tokens

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.

aegntic/cldcde · 41 tokens

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.

aegntic/cldcde · 49 tokens

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.

vobase/vobase · 41 tokens