/create-code-diagram
Generate a comprehensive Mermaid class diagram of the entire project codebase. Shows every class, interface, entity, handler, service — and how they relate to each other (inheritance, implementation, dependency, composition).
This is for humans — when you want to see the full picture, understand the system, or debug your mental model of the architecture.
Ships as a global skill in core.
Usage
/create-code-diagram # writes .claude/docs/code-diagram.md
/create-code-diagram path/to/output.md # writes to the path you specifyRe-runnable. Each run overwrites the previous diagram. Always fresh.
What gets discovered
| Discovered | How |
|---|---|
| Classes, records, interfaces, enums, abstract classes | Codebase scan via codebase-memory-mcp if available, otherwise direct file scanning |
| Inheritance | class extends base |
| Interface implementations | class implements interface |
| Dependencies | Constructor injection, method parameters |
| Composition | Class has property of another class type |
| Mediator handlers | Which command/query each handler covers |
What gets organized
Discovered types are grouped by architectural layer:
%% Domain Layer
%% Application Layer — Interfaces
%% Application Layer — Features
%% Infrastructure Layer
%% API Layer — EndpointsFor each layer, the skill lists every type with its key members — properties for entities, methods for services and handlers.
Relationship arrows
| Relationship | Mermaid syntax | When |
|---|---|---|
| Inheritance | `Child -- | > Parent` |
| Implementation | Impl ..|> Interface | class implements interface |
| Dependency | ClassA --> ClassB | constructor injection, method call |
| Composition | ClassA *-- ClassB | has property of type ClassB |
| Association | ClassA o-- ClassB | collection of ClassB |
Output format
Default location: .claude/docs/code-diagram.md
# Code Diagram
> Auto-generated by /create-code-diagram on {date}
> Re-run `/create-code-diagram` to update after code changes.
## Full Project Diagram
{mermaid classDiagram block}
## Legend
{relationship-arrow table}
## Statistics
- Total types: {count}
- Classes: {count}
- Interfaces: {count}
- Records: {count}
- Relationships: {count}
- Generated: {timestamp}The output is pure Mermaid markdown — viewable in GitHub, VS Code Mermaid preview, or any markdown renderer that supports Mermaid (no external tools needed).
Sample diagram fragment
classDiagram
%% ═══════════════════════════════════════
%% DOMAIN LAYER
%% ═══════════════════════════════════════
class BaseEntity {
+Guid Id
+DateTime CreatedAt
+DateTime? UpdatedAt
+uint RowVersion
}
class IAuditableEntity {
<<interface>>
+string? CreatedBy
+DateTime? ModifiedAt
+string? ModifiedBy
}
class User {
+string Email
+string PasswordHash
+string? FirstName
+string? LastName
}
User --|> BaseEntity
User ..|> IAuditableEntity
%% ═══════════════════════════════════════
%% APPLICATION LAYER — FEATURES
%% ═══════════════════════════════════════
class PingHandler {
+Handle(PingQuery)
}
PingHandler --> IApplicationDbContextImportant rules
- Include EVERYTHING. Don't skip small classes or "obvious" relationships. The user wants the full picture.
- Group by layer. Domain → Application Interfaces → Application Features → Infrastructure → API/Socket/Worker.
- Show key members. Properties for entities, methods for services and handlers. Don't list every private field.
- Correct arrow types. Inheritance vs implementation vs dependency — use the right Mermaid syntax.
- Re-runnable. Running again overwrites the previous diagram.
- No external tools. Pure Mermaid markdown.
Related
- Concepts: Skill — where this fits in the skill ecosystem