database-design

database-design is a skill for Claude Code, Codex from jamestorrevillas/dev-skills. It costs 77 tokens per session (922 once invoked), scanned A, original, MIT.

A guide for designing databases: organizing tables and relationships, choosing SQL or NoSQL, improving queries, adding indexes, and planning data migrations. A database schema is the structure that defines how stored data is organized.

In plain words
What is it for?
Use it to model one-to-one, one-to-many, and many-to-many relationships, choose indexes, design tables, optimize query patterns, and plan migrations.
Why use it?
It helps prevent duplicated or unclear data, slow queries, unsafe deletions, and database structures that are difficult to change.

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/jamestorrevillas/dev-skills/database-design
Any agent
npx skills add jamestorrevillas/dev-skills --skill database-design
Clone the repo
git clone --depth 1 https://github.com/jamestorrevillas/dev-skills

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 database-design

README.md
[![agentmods](https://agentmods.dev/badge/skills/jamestorrevillas/dev-skills/database-design.svg)](https://agentmods.dev/skills/jamestorrevillas/dev-skills/database-design)
Your own site
<a href="https://agentmods.dev/skills/jamestorrevillas/dev-skills/database-design"><img src="https://agentmods.dev/badge/skills/jamestorrevillas/dev-skills/database-design.svg" alt="Measured on agentmods" height="20"></a>
Per session 77 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 922 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.1 $0.00077 $0.00922
Opus 5 $0.00039 $0.00461
Sonnet 5 $0.00015 $0.00184
Haiku 4.5 $0.00008 $0.00092

Measured 5d ago against content hash cfcc9e597add, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-05, from the pricing page.

Security

Grade A, and why

database-design 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 5d 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.

.github/skills/database-design/SKILL.md · 125 lines

How it starts

The opening of the file, as written. The whole thing — 125 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Database Design

Schema Design Principles

  • Normalize first — eliminate redundancy, then denormalize only for proven performance needs
  • Name clearlyuser_id not uid, created_at not ts
  • Every table needs — a primary key, created_at, updated_at
  • Soft deletes — add deleted_at instead of hard deleting rows you might need to recover

Relationship Patterns

Relationship Implementation
One-to-One Foreign key on either table + UNIQUE constraint
One-to-Many Foreign key on the "many" side
Many-to-Many Junction/pivot table with two foreign keys

Indexing Strategy

Rule: Index columns you filter, sort, or join on frequently.

-- Index for common query patterns
CREATE INDEX idx_orders_user_status ON orders(user_id, status);
CREATE INDEX idx_posts_created ON posts(created_at DESC);

-- Partial index for active records only
CREATE INDEX idx_active_users ON users(email) WHERE deleted_at IS NULL;

When NOT to Over-Index

  • Every index slows down writes
  • Index columns with low cardinality (boolean, status with 3 values) only if queries are very frequent
  • Monitor query performance, add indexes based on actual slow queries

Query Optimization

N+1 Query Problem

// BAD — N+1: 1 query for posts + N queries for each author
const posts = await Post.findAll()
for (const post of posts) {
  const author = await User.findById(post.userId) // N queries!
}

// GOOD — 2 queries total using JOIN or eager loading
const posts = await Post.findAll({ include: [{ model: User }] })

Pagination

-- Offset pagination (simple but slow for large offsets)
SELECT * FROM posts ORDER BY created_at DESC LIMIT 20 OFFSET 100;

-- Cursor pagination (fast for large datasets)
SELECT * FROM posts WHERE created_at < :cursor ORDER BY created_at DESC LIMIT 20;

Use cursor pagination for large tables or infinite scroll.


SQL vs NoSQL Cheatsheet

SQL NoSQL
ACID transactions High write throughput
Complex queries, joins Flexible/variable schema
Data integrity critical Horizontal scale priority
Well-defined schema Unstructured or nested data
PostgreSQL, MySQL MongoDB, DynamoDB, Cassandra

Read the full file on GitHub · 125 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. 5d ago First seen · 125 lines · 0 tokens per session scan A cfcc9e597add

Subscribe to this mod's changes

database-design is a skill published in the GitHub repository jamestorrevillas/dev-skills (3 stars, last pushed 5mo ago), licensed MIT. It adds 77 tokens to every session and 922 once invoked, about $0.0004 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-31.

Related

Other skills, from other repositories

prompt-2-data

Generate comprehensive synthetic relational data for any specified subject with multiple normalized CSV files maintaining referential integrity.

fabioc-aloha/Alex_Skill_Mall · 23 tokens

database-design

Schema design, normalization, query optimization, and data modeling patterns.

fabioc-aloha/Alex_Skill_Mall · 15 tokens

sql-review

Use when user needs SQL reviewed — queries for injection risks, performance, and index strategy, or DDL/DML migration scripts for rollback safety, data-loss risk, lock impact, and backward compatibility. Triggers on: review SQL, slow query, review migration, SQL 審查, 看 migration. Produces severity-classified findings…

zexion7873/copilot-setting · 110 tokens

jpa-patterns

Designs and diagnoses JPA/Hibernate persistence in Spring Boot services: entity boundaries, repository patterns, projections, relationships, transaction scope, N+1 and lazy-loading issues, persistence-side performance tuning, and dependency or migration checks that materially affect data access tests or runtime…

gabrielrovesti/ai-agent-skills · 91 tokens

oracle-sql-diagnosis

Oracle SQL workflow for backend diagnosis, support analysis, and data validation. Use when the answer depends on proving behavior through queries, checking day-by-day availability or state, validating catalog/config rows, or separating code defects from data defects.

gabrielrovesti/ai-agent-skills · 53 tokens

fabric-lakehouse

Use this skill to get context about Fabric Lakehouse and its features for software systems and AI-powered functions. It offers descriptions of Lakehouse data components, organization with schemas and shortcuts, access control, and code examples. This skill supports users in designing, building, and optimizing…

fabioc-aloha/Alex_Skill_Mall · 66 tokens