Skip to main content
ClaudeWave
Skill990 estrellas del repoactualizado today

mermaid-diagram

This Claude Code skill generates Mermaid diagrams (flowcharts, sequence diagrams, state machines, ER diagrams, Gantt charts, and other visual formats) when users request process flows, architecture visualizations, or system designs. Use it when a user asks to "draw a diagram," create a flowchart, or visualize relationships or timelines, since Hope Agent's chat renders Mermaid syntax natively as inline SVG graphics without requiring external tools or setup.

Instalar en Claude Code
Copiar
git clone --depth 1 https://github.com/shiwenwen/hope-agent /tmp/mermaid-diagram && cp -r /tmp/mermaid-diagram/skills/mermaid-diagram ~/.claude/skills/mermaid-diagram
Después abre una sesión nueva de Claude Code; el skill carga automáticamente.

SKILL.md

# Mermaid Diagram

## When to Use

Trigger phrases: "draw a diagram", "flowchart for …", "sequence diagram", "architecture diagram", "ER diagram", "state machine", "gantt chart", "画一个流程图", "画个架构图".

**Mermaid is rendered natively** in Hope Agent chat (via Streamdown). Just emit a fenced ```mermaid block — the user sees the rendered SVG, no setup.

For diagrams Mermaid can't express (organic shapes, custom illustrations, hand-drawn style) consider drawing-tool skills (e.g. `excalidraw` from Hermes Agent or `drawio` from Anthropic marketplace) — those need to be installed via Quick Import.

## Pick the Right Diagram Type

| Intent | Mermaid type | Use when |
|--------|--------------|----------|
| Step-by-step process | `flowchart` | Decisions, branching, "if X then Y" |
| Time-ordered messages between actors | `sequenceDiagram` | API call traces, distributed protocols |
| State transitions of a single entity | `stateDiagram-v2` | UI state machines, workflow engines |
| Data model relationships | `erDiagram` | Database schema, entity relationships |
| Project schedule / timeline | `gantt` | Roadmaps, sprints |
| Pie / distribution | `pie` | Quick share-of-X visualization |
| Tree hierarchy (org chart, decomposition) | `flowchart TD` with subgraphs | Org / breakdown trees |
| Class hierarchy with methods | `classDiagram` | OO design, type relationships |
| User journey (steps + sentiment) | `journey` | UX flows |

If unsure, default to `flowchart`. It's the most flexible.

## Templates

### Flowchart (top-down)
```mermaid
flowchart TD
    Start([Start]) --> Decision{Condition?}
    Decision -->|Yes| ActionA[Do A]
    Decision -->|No| ActionB[Do B]
    ActionA --> End([End])
    ActionB --> End
```

### Sequence Diagram
```mermaid
sequenceDiagram
    participant U as User
    participant W as Web Server
    participant DB as Database

    U->>W: HTTP GET /api/items
    W->>DB: SELECT * FROM items
    DB-->>W: rows
    W-->>U: JSON response

    Note over U,DB: Round trip < 50ms
```

### State Diagram
```mermaid
stateDiagram-v2
    [*] --> Idle
    Idle --> Loading: fetch()
    Loading --> Success: 200 OK
    Loading --> Error: 4xx / 5xx
    Success --> Idle: reset()
    Error --> Idle: retry()
    Error --> [*]: give up
```

### ER Diagram
```mermaid
erDiagram
    USER ||--o{ ORDER : places
    ORDER ||--|{ ORDER_ITEM : contains
    PRODUCT ||--o{ ORDER_ITEM : "ordered as"
    USER {
        string id PK
        string email UK
        string name
    }
    ORDER {
        string id PK
        string user_id FK
        datetime created_at
    }
```

### Gantt
```mermaid
gantt
    title Q3 Roadmap
    dateFormat  YYYY-MM-DD
    section Auth
    Refactor middleware     :done,    a1, 2026-04-01, 2026-04-15
    OAuth migration         :active,  a2, 2026-04-15, 30d
    section Dashboard
    Search MVP              :         d1, 2026-05-01, 14d
    Analytics rewrite       :         d2, after d1, 21d
```

### Architecture (flowchart with subgraphs)
```mermaid
flowchart LR
    subgraph Frontend
        UI[React SPA]
    end
    subgraph Backend
        API[REST API]
        WS[WebSocket Hub]
    end
    subgraph Storage
        DB[(PostgreSQL)]
        Cache[(Redis)]
    end

    UI -->|HTTPS| API
    UI -->|WSS| WS
    API --> DB
    API --> Cache
    WS --> Cache
```

## Workflow

1. **Clarify intent** — if the user just says "diagram", ask via `ask_user_question`:
   - What's the diagram showing? (process / structure / relationships / timeline)
   - Who's the audience? (engineers / execs / customers)
   - Level of detail? (high-level overview / fine-grained)

2. **Pick the simplest type that fits** — flowchart > sequence > state. Don't reach for `classDiagram` if a flowchart works.

3. **Sketch nodes first, edges second** — list the entities (boxes), then connect them. Avoid dense edge spaghetti.

4. **Iterate small** — start with 5-7 nodes. Add detail only after the user confirms the structure.

5. **Verify renderability** — if you reference Mermaid syntax that's iffy (e.g. classDiagram with annotations), keep it minimal. The user will see if it doesn't render.

## Style Rules

- **One concept per diagram** — if you're tempted to add a second flow, split into two diagrams
- **Consistent shape vocabulary**:
  - `[Square]` = process / action
  - `(Round)` = entity / data
  - `{Diamond}` = decision
  - `([Stadium])` = start / end
  - `[(Cylinder)]` = database / storage
  - `((Circle))` = external system
- **Direction**: `TD` (top-down) for hierarchies, `LR` (left-right) for pipelines / data flows
- **Labels short** — node labels ≤ 4 words. Detail goes in surrounding prose.
- **Use `Note over`** in sequence diagrams to explain non-obvious behavior, not for narration

## Multi-Diagram Output

When asked for "a few diagrams" or "show me the system from different angles", output 2-3 separate ```mermaid blocks with prose between them explaining what each shows.

```
Here's the system at three levels:

**1. High-level data flow:**
\`\`\`mermaid
flowchart LR
    ...
\`\`\`

**2. Login sequence (zoom into auth):**
\`\`\`mermaid
sequenceDiagram
    ...
\`\`\`

**3. Database relationships:**
\`\`\`mermaid
erDiagram
    ...
\`\`\`
```

## Common Pitfalls

| Mistake | Fix |
|---|---|
| Single diagram with 30+ nodes | Split into 2-3 diagrams by concern |
| Mixing types (flowchart with class fields) | Pick one type; for hybrid views, do multi-diagram |
| All boxes look the same | Use shape vocabulary (decision = diamond, etc.) |
| Long node labels | Move detail to prose; keep nodes ≤ 4 words |
| Unicode quotes (`"smart quotes"`) breaking syntax | Use ASCII `"` everywhere in Mermaid blocks |
| Mermaid `;` line endings forgotten when used | Either use newlines OR `;` consistently, not mixed |
| Forgot fenced block tag | Block must be ```mermaid (not just ```) for HA chat to render |

## Limitations to Surface to User

- No floating positioning / pixel-perfect layouts (Mermaid auto-lays out)
- Limited styling (colo
code-reviewSkill

>

email-draftSkill

Use when the user asks to draft, polish, translate, or reply to an email. Produces a clean draft with subject line, greeting, body, and sign-off, plus a pre-send self-check.

feishuSkill

Use when the user mentions 飞书 / Feishu / Lark workspace operations: docx (云文档) read/write, bitable (多维表格) records / views / dashboards, drive (云盘) upload/download, wiki (知识库) link resolution, approval (审批) instance create/cancel/query, calendar (日历) event create/list/update + attendees, contact (联系人) user/department lookup, hire (招聘) job/talent/application listing. Trigger on phrases like 'OKR 周报', '把这份文档发到飞书云盘', '给团队拉个评审会议', '查 [姓名] 的联系方式', '撤销那条审批', '/wiki 链接', or any request that mentions a feishu / lark URL / token (doxcn.../bascn.../wikcn.../boxcn.../om_...).

ha-browserSkill

Hope Agent browser automation — the standard `status → tabs → snapshot → act` loop, stale-ref recovery rules, and what to do when login / 2FA / captcha / camera-prompt / dialog blocks progress. Load this skill whenever you reach for the `browser` tool. Trigger on: user asks the agent to open / control / click / scrape / log into / verify something in a web app ('open X and click Y', '打开 X 然后点击 Y', 'log into my Gmail', 'scrape this page', 'fill out the form on X'); user reports a flow that requires real browser context (cookies, JS-rendered content, OAuth).

ha-find-skillsSkill

Discover and install third-party skills from external registries when the user needs a capability that no currently-active skill covers. Trigger when: (1) the user explicitly asks 'find a skill for X', 'is there a skill that does X', 'install a skill to X', (2) the user requests a well-known integration (Slack, Notion, Trello, GitHub, Hue, Sonos, iMessage, weather, TTS, transcription …) that isn't in the active skill catalog, (3) you are about to hand-write ad-hoc shell / API code for a domain that almost certainly has a published skill. Do NOT trigger if an active skill already covers the need — scan the visible skill catalog first.

ha-logsSkill

Self-service diagnostics — query Hope Agent's local SQLite databases (logs / sessions / async jobs) directly via the `exec` tool to investigate problems, analyze usage, and locate root causes. Trigger on: user reports something broken / failing / slow / stuck / not responding ('X 不工作', 'X 报错', 'X 卡住', '为什么 X 失败', 'why did X fail', 'show me the logs', 'check what happened'); ad-hoc data analysis ('this week's token usage', '最近调用最多的工具', 'how many subagent runs failed', 'tool error rate', 'find sessions where X happened'); verifying a fix ('did the error stop after I changed Y'). Use BEFORE asking the user to paste log snippets — the data is on disk, query it directly. Read-only — SELECT only, never UPDATE/DELETE/INSERT/DROP.

ha-mac-controlSkill

Hope Agent native macOS desktop control — the standard `mac_control` status / diagnostics / apps / dock / spaces / snapshot / visual / windows / menu / clipboard / dialog loop, target-first action rules, no-blind-coordinate policy, and recovery for stale AX/window/menu/dialog state. Load whenever using `mac_control`, or when the user asks to control local Mac apps, Dock, Spaces, click/type/menu/window/dialog/clipboard, automate Finder/TextEdit/System Settings, visually locate UI, or says 控制 Mac, macOS 自动化, 点按钮, 打开应用, Dock, Space, 关闭窗口, 菜单点击, 视觉定位.

ha-self-diagnosisSkill

Self-understanding and issue reporting for Hope Agent itself. Use when the user asks how Hope Agent works internally, asks about its own source code/docs/runtime behavior, reports a bug/failure/slowness/crash, asks to diagnose logs, or asks to create/submit a GitHub issue for a bug, feature request, or improvement (including when there is no bug). Chinese triggers: 自查, 了解自己, 自我诊断, 排查 Hope Agent, 提交 issue, 需求 issue, 功能改进.