All skills
Skillintermediate
/generate-erd - Generate Entity Relationship Diagram
Generate a visual ERD from the existing database schema.
Claude Code Knowledge Pack7/10/2026
Overview
/generate-erd - Generate Entity Relationship Diagram
Generate a visual ERD from the existing database schema.
Steps
- Detect the database schema source: ORM models, migration files, or live database
- Extract all tables with their columns, types, and constraints
- Identify all relationships from foreign keys and junction tables
- Map relationship cardinality: one-to-one, one-to-many, many-to-many
- Generate a Mermaid diagram definition with all entities and relationships
- Include column names and types in each entity box
- Mark primary keys (PK), foreign keys (FK), and unique constraints (UK)
- Group related tables visually (users/auth, products/orders, etc.)
- Add relationship labels describing the business meaning
- Save the Mermaid diagram to docs/erd.md
- If dbdiagram.io format is preferred, generate DBML syntax as well
- Report: total tables, relationships, and diagram output path
Rules
- Include all tables including junction tables for many-to-many relationships
- Show column types in a readable format (not database-specific syntax)
- Highlight primary and foreign keys visually
- Group related entities close together in the diagram
- Use crow's foot notation for relationship cardinality
- Do not include migration history tables or framework internal tables
- Keep the diagram readable; split into sub-diagrams if more than 20 tables