@llodev/django-schema-design
v0.2.0
Published
Design robust Django database schemas: model conventions, primary-key strategy (incremental, UUIDv4, UUIDv7 with insert-locality trade-offs), indexes (composite/covering/partial), constraints (unique/check/exclusion), and safe migrations. A knowledge skil
Maintainers
Readme
@llodev/django-schema-design
Design production-ready Django database schemas — primary-key strategy, indexes, constraints, and safe migrations — with the non-obvious trade-offs an expert learned the hard way, not basic ORM syntax.
Part of the @llodev/django-* family.
What you get:
- PK strategy that names the real axis — not "unique vs not" (all are unique) but random placement (UUIDv4) vs sequential placement (UUIDv7 / incremental), and why v4 as a hot-table PK fragments the index while v7 keeps insert locality.
- A domain-interrogation frame — identity, cardinality/ownership, lifecycle, access paths — to settle before any field exists.
- An indexes & constraints expert layer — composite column ordering, covering (
include) and partial indexes,Unique/Check/Exclusionconstraints, B-tree/GIN/GiST/BRIN selection, and when to denormalize instead of adding another index. - Migration safety — batched backfills, concurrent index creation on live tables, reversibility, and the staged PK-swap procedure.
- A
NEVERlist with the reasons experience teaches (FloatField money drift, sequential PK → IDOR, v4-on-hot-tables, in-place PK swaps, impliciton_delete).
Install
# npm (with skillpm or Claude Code marketplace)
npm i @llodev/django-schema-design
# Vercel CLI
npx skills add llodev/skills/skills/django-schema-designNo MCP, no config, no init — it's a pure knowledge skill. Once installed it activates on prompts like the ones below.
Use
| Prompt example | What the agent does |
| ------------------------------------------------------- | --------------------------------------------------------------------------- |
| "design Django models for invoices and line items" | Runs the domain frame + PK decision flow, emits models.py with rationale |
| "should this event table use UUID or auto increment?" | Applies the exposure + insert-locality axes → UUIDv7 with the reasoning |
| "migration to switch users to a UUID PK" | Staged, reversible add→backfill→repoint→swap procedure |
| "review this schema" | Checks PK choice, on_delete, constraints, index ordering against the list |
Contents
| File | Content |
| ---------------------------------------- | ----------------------------------------------------------------------- |
| SKILL.md | Domain frame, PK decision flow, NEVER list, and verification checklist. |
| references/pk-strategy.md | Incremental vs UUIDv4 vs UUIDv7, storage/collation, and PK migration. |
| references/indexing-and-constraints.md | Composite/covering/partial indexes, constraints, index types, EXPLAIN. |
License
MIT — see LICENSE.
