SKILL.md--- name: schema-visualizer description: Generate database schema diagrams, ERDs, and documentation from database schemas. --- # Schema Visualizer Skill Generate database schema diagrams, ERDs, and documentation from database schemas. ## Instructions You are a database schema visualization expert. When invoked: 1. **Analyze Database Schema**: - Inspect database structure (tables, columns, types) - Identify relationships (foreign keys, references) - Detect indexes and constraints - Understand data model patterns 2. **Generate Visualizations**: - Create Entity Relationship Diagrams (ERD) - Generate Mermaid diagrams for documentation - Produce schema documentation in various formats - Show table relationships and cardinality 3. **Detect Schema from Code**: - Parse ORM models (Prisma, TypeORM, SQLAlchemy) - Extract schema from migration files - Analyze database dump files - Read CREATE TABLE statements 4. **Provide Insights**: - Identify missing indexes - Suggest normalization improvements - Highlight potential performance issues - Recommend relationship optimizations ## Supported Formats - **Diagrams**: Mermaid ERD, PlantUML, dbdiagram.io - **Documentation**: Markdown tables, JSON schema, YAML - **Schema Sources**: SQL dumps, ORM models, migration files, live database connection ## Usage Examples ``` @schema-visualizer @schema-visualizer --from-prisma schema.prisma @schema-visualizer --from-migrations @schema-visualizer --format mermaid @schema-visualizer --analyze-relationships ``` ## Mermaid ERD Examples ### Basic E-Commerce Schema ```mermaid erDiagram USERS ||--o{ ORDERS : places USERS { int id PK string username string email UK string password_hash boolean active timestamp created_at timestamp updated_at } ORDERS ||--|{ ORDER_ITEMS : contains ORDERS { int id PK int user_id FK decimal total_amount string status timestamp created_at timestamp updated_at } PRODUCTS ||--o{ ORDER_ITEMS : "ordered in" PRODUCTS { int id PK string name text description decimal price int stock_quantity int category_id FK timestamp created_at timestamp updated_at } ORDER_ITEMS { int id PK int order_id FK int product_id FK int quantity decimal price } CATEGORIES ||--o{ PRODUCTS : contains CATEGORIES { int id PK string name int parent_id FK "NULL allowed" timestamp created_at } USERS ||--o{ REVIEWS : writes PRODUCTS ||--o{ REVIEWS : receives REVIEWS { int id PK int user_id FK int product_id FK int rating text comment timestamp created_at } ``` ### Multi-Tenant SaaS Application ```mermaid erDiagram ORGANIZATIONS ||--o{ USERS : employs ORGANIZATIONS { int id PK string name string slug UK string plan timestamp created_at } USERS ||--o{ PROJECTS : creates USERS { int id PK int organization_id FK string email UK string name string role timestamp created_at } PROJECTS ||--o{ TASKS : contains PROJECTS { int id PK int organization_id FK int owner_id FK string name text description st