From db-sqlserver
Use when reading ER diagrams committed in the project repo and building a structured knowledge base of entities, relationships, columns, keys, and constraints to inform code generation and review
How this skill is triggered — by the user, by Claude, or both
Slash command
/db-sqlserver:sqlserver-er-knowledgebaseThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Scan the project repository for committed ER diagram files, parse their content, and build a structured knowledge base that other skills can reference when generating or reviewing T-SQL, migrations, EF Core entities, and Dapper queries.
Scan the project repository for committed ER diagram files, parse their content, and build a structured knowledge base that other skills can reference when generating or reviewing T-SQL, migrations, EF Core entities, and Dapper queries.
| Format | Extensions / Patterns | Parser Strategy |
|---|---|---|
| DBML (dbdiagram.io) | *.dbml | Parse Table, Ref, Enum blocks |
| Mermaid erDiagram | *.mmd, *.mermaid, fenced blocks in *.md | Parse erDiagram section |
| PlantUML entity | *.puml, *.plantuml, *.pu | Parse entity and relationship lines |
| SQL DDL | *.sql (CREATE TABLE/ALTER TABLE) | Extract tables, columns, PKs, FKs, constraints |
| SSDT project | *.sqlproj + dbo/Tables/*.sql | Walk SSDT folder tree, extract DDL per file |
| EF Core models | *.cs with IEntityTypeConfiguration | Extract entity properties, relationships, keys |
| JSON schema | er-diagram.json, schema.json | Direct structured parse |
| Draw.io / diagrams.net | *.drawio, *.drawio.xml | Extract entity nodes and connector edges |
Scan the repo for ER diagram sources in priority order:
.db-agent.json for engines.sqlserver.erDiagram pathdocs/**/*.dbml, docs/**/*.mmd, docs/**/*.puml, docs/**/*.drawiodatabase/**/*.sql, **/*.sqlprojdocs/**/*.md files containing erDiagram fenced blocks**/Entities/*.cs, **/Models/*.cs, **/Configurations/*.cser-diagram.*, schema.* at repo rootReport which sources were found and which were used.
Build a structured representation with the following shape:
{
"metadata": {
"sources": ["docs/er-diagram.dbml", "database/dbo/Tables/*.sql"],
"generatedAt": "2026-04-09T12:00:00Z",
"entityCount": 12,
"relationshipCount": 15
},
"entities": [
{
"name": "Orders",
"schema": "dbo",
"description": "Customer purchase orders",
"columns": [
{
"name": "Id",
"type": "INT",
"nullable": false,
"isPrimaryKey": true,
"isIdentity": true
},
{
"name": "CustomerId",
"type": "INT",
"nullable": false,
"isForeignKey": true,
"references": { "entity": "Customers", "column": "Id" }
}
],
"indexes": [
{
"name": "IX_Orders_CustomerId",
"columns": ["CustomerId"],
"isUnique": false,
"includes": ["CustomerName", "Total"]
}
],
"constraints": [
{
"name": "CK_Orders_Total",
"type": "CHECK",
"expression": "[Total] >= 0"
}
]
}
],
"relationships": [
{
"name": "FK_OrderItems_Orders",
"from": { "entity": "OrderItems", "column": "OrderId" },
"to": { "entity": "Orders", "column": "Id" },
"type": "many-to-one",
"onDelete": "CASCADE",
"onUpdate": "NO ACTION"
}
],
"enums": [
{
"name": "OrderStatus",
"values": ["Pending", "Confirmed", "Shipped", "Delivered", "Cancelled"]
}
]
}
Table Orders {
Id int [pk, increment]
CustomerId int [ref: > Customers.Id]
Total decimal(18,2) [not null, default: 0]
Status OrderStatus [not null]
CreatedAt datetime2 [default: `SYSUTCDATETIME()`]
}
Enum OrderStatus {
Pending
Confirmed
Shipped
}
Ref: OrderItems.OrderId > Orders.Id [delete: cascade]
[pk] to isPrimaryKey: true[increment] to isIdentity: true[ref: > Table.Col] to inline FK relationship (many-to-one)[ref: - Table.Col] to one-to-one[ref: <> Table.Col] to many-to-manyRef: lines for explicit relationship definitionserDiagram
Orders ||--o{ OrderItems : contains
Customers ||--o{ Orders : places
Orders {
int Id PK
int CustomerId FK
decimal Total
string Status
}
||--o{ to one-to-many||--|| to one-to-one}o--o{ to many-to-manyCREATE TABLE for entity + columnsALTER TABLE ... ADD CONSTRAINT for FKs, CHECKs, UNIQUEsCREATE INDEX / CREATE UNIQUE INDEX for index definitions[dbo].[Orders]IDENTITY(seed, increment) for identity columnsProperty(e => e.Column) for column configHasOne/HasMany/WithOne/WithMany for relationshipsHasKey / HasAlternateKey for keysHasIndex for indexesToTable("name", "schema") for entity-to-table mappingWrite the parsed knowledge base to .er-knowledgebase.json in the project root (or path configured in .db-agent.json under engines.sqlserver.erKnowledgebasePath).
After building the knowledge base, output a summary:
ER Knowledge Base Built
=======================
Sources: docs/er-diagram.dbml, database/dbo/Tables/*.sql
Entities: 12
Columns: 87
Relationships: 15 (10 many-to-one, 3 one-to-many, 2 one-to-one)
Indexes: 8
Constraints: 5
Enums: 3
Warnings:
- OrderItems.ProductId references Products.Id but Products entity not found
- Customers.Email has no unique constraint (consider adding one)
When the knowledge base is available, other skills should use it to:
.sql files in the SSDT layoutWhen multiple ER sources exist and disagree:
The knowledge base should be rebuilt when:
.er-knowledgebase.json is missing or stalenpx claudepluginhub gagandeepp/software-agent-teams --plugin db-sqlserverGuides completion of development work by verifying tests, detecting environment, and presenting structured options for merge, PR, or cleanup.
Enforces test-driven development: write failing test first, then minimal code to pass. Use when implementing features or bugfixes.
Guides creation and editing of skills using test-driven development with pressure scenarios and subagents to verify agent compliance.