‹ 首页

class-diagram

@athola · 收录于 1 周前

Generates a Mermaid class diagram showing types, inheritance, and composition. Use when visualizing class hierarchies or documenting a module public API.

适合你,如果需要可视化类层次或记录模块公共API

/ 下载安装
class-diagram.skill双击,或拖进 Claude 桌面版 / Cowork,即完成安装↓ .skill↓ .zip
用别的 agent?下载 .zip 解压,把文件夹放进它的技能目录
Claude Code~/.claude/skills/(项目级 .claude/skills/)
Codex CLI~/.codex/skills/
Cursor自动读取上面两处目录
其他工具见其文档的「skills」目录;两个下载是同一份文件,只是名字不同
/ 通过 npx 安装 校验哈希
npx oh-my-skill add athola/claude-night-market/class-diagram
/ 通过 bash 安装
curl -fsSL https://oh-my-skill.com/install.sh | bash -s -- athola/claude-night-market/class-diagram
/ 已经装过?验证本机副本,不用重装
npx oh-my-skill verify athola/claude-night-market/class-diagram
安装目标可用 --agent / --scope 或 --to 明确指定;省略时只会在唯一已存在的 agent 目录上自动选择,零命中或多命中会停止并提示。content_hash 缺失或不一致均拒装。
324GitHub stars
待重算上下文体积
镜像托管

怎么用

技能原文 SKILL.md作者撰写 · MIT · 0980a33

Class Diagram

Generate a Mermaid class diagram showing types, their relationships, and public interfaces from a codebase.

When To Use
  • Understanding class hierarchies and inheritance
  • Documenting public APIs of a module
  • Analyzing composition vs. inheritance patterns
  • Answering "what types exist and how do they relate?"
Workflow
Step 1: Explore the Codebase

Dispatch the codebase explorer agent:

Agent(cartograph:codebase-explorer)
Prompt: Explore [scope] and return a structural model.
Focus on classes, dataclasses, protocols, type aliases,
inheritance, and composition for a class diagram.
Extract: class names, methods (public only), attributes,
parent classes, and composed types.
Step 2: Generate Mermaid Syntax

Transform the structural model into a Mermaid class diagram.

Rules for class diagrams:

  • Use classDiagram diagram type
  • Show only public methods and key attributes
  • Use Mermaid relationship notation:
  • <|-- for inheritance
  • *-- for composition
  • o-- for aggregation
  • ..> for dependency/usage
  • Add stereotypes for special types:
  • <<protocol>> for Python protocols/interfaces
  • <<dataclass>> for dataclasses
  • <<enum>> for enums
  • <<abstract>> for abstract classes
  • Limit to 12-15 classes maximum
  • Group related classes with namespace
  • Omit private methods and dunder methods
  • Show return types for methods

Example output:

classDiagram
    class ResumeSession {
        +Path config_path
        +dict data
        +load() ResumeSession
        +to_pdf(Path) Path
        +to_html(Path) Path
    }

    class ResumeError {
        <<abstract>>
        +str message
        +str context
    }

    class ValidationError {
        +list~str~ fields
    }

    class RenderError {
        +str template
    }

    ResumeError <|-- ValidationError
    ResumeError <|-- RenderError
    ResumeSession ..> ResumeError
Step 3: Render via MCP

Call the Mermaid Chart MCP to render:

mcp__claude_ai_Mermaid_Chart__validate_and_render_mermaid_diagram
  prompt: "Class diagram of [scope]"
  mermaidCode: [generated syntax]
  diagramType: "classDiagram"
  clientName: "claude-code"

If rendering fails, fix syntax and retry (max 2 retries).

Step 4: Present Results

Show the rendered diagram with analysis notes:

  • Total classes and relationship count
  • Key inheritance hierarchies identified
  • Composition patterns noted
Exit Criteria
  • [ ] Mermaid classDiagram syntax generated with at least one class definition including public methods or attributes
  • [ ] mcp__claude_ai_Mermaid_Chart__validate_and_render_mermaid_diagram called with diagramType: "classDiagram" and returns without error
  • [ ] Analysis notes include total class count, identified inheritance hierarchies, and composition patterns
  • [ ] Private methods and dunder methods (__init__, __repr__, etc.) are absent from the generated diagram
  • [ ] Diagram contains at most 15 classes; if more exist in scope, aggregation is applied and noted
按 MIT 许可原样转载,未经改动 · 在 GitHub 查看 →

评论

登录即可评论;带「已验证安装」的,是发布者名下有本店的安装或持有记录。