skills/efcore-d2-db-diagram/SKILL.md
Generate D2 database diagrams from Entity Framework Core models. USE FOR: EF Core database diagram, Entity Framework Core ERD, DbContext diagram, C# entity relationship diagram, PostgreSQL schema visualization, generate .d2 file from EF Core entities, Fluent API mapping diagram, migrations-based database diagram, table relationships, owned types, many-to-many join tables, indexes and constraints. DO NOT USE FOR: runtime debugging, database migration execution, schema deployment, SQL performance tuning, or draw.io diagrams.
npx skillsauth add williamlimasilva/.copilot efcore-d2-db-diagramInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use this skill when the user wants to generate a database / ERD diagram from an Entity Framework Core codebase.
Typical requests:
DbContext, DbSet<T>, IEntityTypeConfiguration<T>, Fluent API and migrations..d2 file renderable to SVG/PNG with the d2 CLI.Create a readable D2 entity-relationship diagram that reflects the actual EF Core persistence model, not only the raw C# class shape.
The diagram must prioritize:
Output is .d2 source code. It can be rendered to SVG or PNG via the d2 CLI.
.d2 files to SVG/PNG.
d2 input.d2 output.svgd2 --layout=elk input.d2 output.svgd2 fmt input.d2DbContext classes.DbSet<T> declarations.OnModelCreating and all IEntityTypeConfiguration<T> classes..d2 file using the database model, not raw class nesting.d2 fmt before delivery.d2 --layout=elk schema.d2 schema.svg when possible.Ask these questions for every new diagram and every regeneration unless the user already answered them in the same request.
Which DbContext should be diagrammed? (auto-detect/all/specific name)Display columns? (all/key-only/none)Display column types? (Yes/No)Display nullable/required markers? (Yes/No)Display indexes and unique constraints? (Yes/No)Display enum values? (Yes/No)Display owned types? (inline/separate/hide)Display many-to-many join tables? (explicit/compact/hide)Display audit/technical tables? (Yes/No)Display migration-only tables not present as entities? (Yes/No)Which grouping mode? (bounded-context/schema/namespace/flat)Which layout engine? (elk/dagre/tala)Which output format? (d2/svg/png)Default values, when the user asks for a quick generation:
auto-detectkey-onlyYesYesYesNoinlineexplicitNoYesbounded-contextelkd2Load these on demand when needed:
| Reference | When to load |
|---|---|
| references/efcore-model-extraction.md | Rules for reading DbContext, DbSet, Fluent API, configurations and migrations |
| references/d2-erd-style.md | D2 syntax and visual conventions for ERD diagrams |
| references/relationship-rules.md | How to infer one-to-one, one-to-many, many-to-many and owned relationships |
| references/grouping-modes.md | Rules for bounded-context, schema, namespace and flat grouping |
| references/quality-gate.md | Final checklist before delivering the generated diagram |
Use this priority order when sources disagree:
OnModelCreating or IEntityTypeConfiguration<T>.Detect and represent:
DbContext and DbSet<T>.ToTable.ToTable("Table", "schema").HasKey, [Key], conventions and migrations.HasForeignKey, navigation properties and migration operations.Cascade, Restrict, NoAction, SetNull, ClientSetNull.OwnsOne, OwnsMany and [Owned].UsingEntity and implicit EF Core join tables.HasIndex, IsUnique and migrations.HasAlternateKey.Represent each persisted table as a D2 node with shape: sql_table when possible.
Use this content convention:
Clients: {
shape: sql_table
constraint: primary_key
Id: uuid {constraint: primary_key}
Name: text
Status: enum
}
If sql_table is unavailable or causes validation issues, fallback to a rectangle with structured text.
Use directional edges from dependent table to principal table.
Labels must include relationship cardinality and FK name when known:
Offers.ClientId -> Clients.Id: "N:1 FK_Offers_Clients_ClientId"
Use these cardinality labels:
1:11:NN:1N:NownedOwned types default to inline rendering.
Inline example:
Clients: {
shape: sql_table
Id: uuid {constraint: primary_key}
Address.Street: text
Address.ZipCode: text
Address.City: text
}
If the user chooses separate, represent owned types as visually subordinate tables and use an owned relationship.
Default to explicit join tables because EF Core creates real tables.
For implicit many-to-many relationships, create a generated join table node and mark it as implicit join.
Hide technical tables by default unless requested.
Examples:
__EFMigrationsHistoryIf technical tables are hidden, mention them in the summary after the diagram.
bounded-context: group by detected domain area or folder/module.schema: group by database schema, e.g. public, auth, billing.namespace: group by C# namespace.flat: no containers, all tables at the same level.Use consistent styles:
cascade.Before delivering the diagram, verify:
DbSet<T> entities are considered.d2 fmt.When the user asks for a skill installation, provide this folder structure:
.github/
skills/
efcore-d2-db-diagram/
SKILL.md
references/
efcore-model-extraction.md
d2-erd-style.md
relationship-rules.md
grouping-modes.md
quality-gate.md
When the user asks to generate a diagram, provide:
.d2 source file content.development
Build production RAG pipelines and persistent agent memory using Pinecone as the vector database backend. ALWAYS USE THIS SKILL when the user mentions Pinecone, wants to index documents for semantic search, build a retrieval-augmented generation system, store agent memory across sessions, implement hybrid search, or connect an LLM to a searchable knowledge base — even if they don't say "Pinecone" explicitly. Also use when the user asks about vector databases for RAG, namespace isolation for multi-tenant agents, embedding pipelines, or scaling a knowledge base beyond what local storage can handle. DO NOT use for local-only vector stores (Chroma, FAISS, pgvector) or pure keyword search with no semantic component.
development
Perform an AWS Well-Architected Framework review of the current workload IaC and architecture, generating findings and GitHub issues for improvements.
devops
Query AWS resources using natural language. Covers EC2, S3, RDS, Lambda, ECS, EKS, Secrets Manager, IAM, VPC, networking, messaging, and more. Strictly read-only — no writes, deletes, or mutations.
devops
Analyze AWS resource health, diagnose issues from CloudWatch logs and metrics, and create a remediation plan for identified problems.