prompt-to-mermaid
npx skills add https://github.com/saturn-imanshu/prompt-to-mermaid-skill --skill prompt-to-mermaid
Agent 安装分布
Skill 文档
Prompt to Mermaid
Turn vague ideas into clear requirements and a Mermaid diagram that serves as a machine-readable spec for implementation.
Process Flow
digraph prompt_to_mermaid {
"Entry point" [shape=diamond, label="How invoked?"];
"User describes idea" [shape=doublecircle];
"Superpowers handoff" [shape=doublecircle, label="From brainstorming\nor writing-plans"];
"Requirements clear?" [shape=diamond];
"Ask ONE clarifying question" [shape=box];
"Write requirements summary" [shape=box];
"Read existing design/plan doc" [shape=box];
"Ask: Generate Mermaid diagram?" [shape=diamond];
"Auto-detect diagram type" [shape=box];
"Generate Mermaid diagram" [shape=box];
"User approves diagram?" [shape=diamond];
"Revise diagram per feedback" [shape=box];
"Save .mmd file + show inline" [shape=box];
"Prompt user to load diagram" [shape=doublecircle];
"User declines" [shape=doublecircle, label="Skip â continue\nnormal flow"];
"Entry point" -> "User describes idea" [label="standalone"];
"Entry point" -> "Superpowers handoff" [label="from superpowers"];
"User describes idea" -> "Requirements clear?";
"Requirements clear?" -> "Ask ONE clarifying question" [label="no"];
"Ask ONE clarifying question" -> "Requirements clear?";
"Requirements clear?" -> "Write requirements summary" [label="yes"];
"Write requirements summary" -> "Auto-detect diagram type";
"Superpowers handoff" -> "Read existing design/plan doc";
"Read existing design/plan doc" -> "Ask: Generate Mermaid diagram?";
"Ask: Generate Mermaid diagram?" -> "Auto-detect diagram type" [label="yes"];
"Ask: Generate Mermaid diagram?" -> "User declines" [label="no"];
"Auto-detect diagram type" -> "Generate Mermaid diagram";
"Generate Mermaid diagram" -> "User approves diagram?";
"User approves diagram?" -> "Revise diagram per feedback" [label="no"];
"Revise diagram per feedback" -> "User approves diagram?";
"User approves diagram?" -> "Save .mmd file + show inline" [label="yes"];
"Save .mmd file + show inline" -> "Prompt user to load diagram";
}
Superpowers Integration
This skill has two entry modes: standalone and superpowers handoff.
When to offer the Mermaid prompt
If superpowers skills are available in the session, offer diagram generation at both of these points:
-
After
superpowers:brainstormingâ the design doc is approved and about to hand off towriting-plans. Ask:“Would you like to generate a Mermaid diagram from this design before moving to the implementation plan?”
-
After
superpowers:writing-plansâ the implementation plan is complete. Ask:“Would you like to generate a Mermaid diagram from this plan? It can serve as a visual reference during implementation.”
If the user says no, continue the normal superpowers flow without interruption.
Fast path (skip Phase 1)
When invoked from a superpowers handoff:
- Do NOT run Phase 1. Requirements are already clarified in the design doc or plan.
- Read the existing
docs/plans/*.mddocument to extract actors, flows, and decisions. - Jump directly to Phase 2 (diagram generation).
- The existing plan doc serves as the requirements summary â no need to rewrite one.
Phase 1: Requirement Clarification Loop
How to clarify:
- Read the user’s initial description carefully
- Identify ALL ambiguities: unclear actors, undefined flows, missing edge cases, unspecified data, vague scope
- Ask one question at a time â prefer multiple-choice (via AskUserQuestion) when possible
- After each answer, re-evaluate: are there remaining ambiguities?
- Continue until you can describe the system without any “it depends” or “presumably”
What to clarify (checklist):
- Actors: Who/what interacts with the system?
- Actions: What does each actor do? What triggers each action?
- Data flow: What data moves between components? In what format?
- Decision points: Where does the flow branch? What determines each branch?
- Edge cases: What happens on failure, timeout, invalid input?
- Scope boundary: What is explicitly OUT of scope?
Exit criterion: You can write a requirements summary with zero assumptions. If you’re guessing, you’re not done asking.
Once clarification is complete, write a concise Requirements Summary as a numbered list. Present it to the user for confirmation before proceeding.
Phase 2: Mermaid Diagram Generation
Dispatch parallel sub-agents
Once requirements are confirmed, use the Task tool to dispatch TWO parallel sub-agents:
Sub-agent 1 (Explore): Analyze the requirements summary and determine the optimal Mermaid diagram type:
flowchart TDâ process flows, feature workflows, decision treessequenceDiagramâ multi-actor interactions, API call chains, request/response flowsstateDiagram-v2â lifecycle states, status transitions, mode switchingerDiagramâ data models, entity relationships, database schemasclassDiagramâ component architecture, module dependencies, inheritance
Sub-agent 2 (Explore): If there is an existing project codebase, scan for existing Mermaid files, architecture docs, or README diagrams to ensure consistency with existing conventions.
Generate the diagram
After sub-agents complete, generate the Mermaid diagram following these rules:
Selecting diagram type: Pick the type that best represents the PRIMARY relationship in the requirements:
- Processes with decisions â flowchart
- Time-ordered interactions between actors â sequenceDiagram
- An entity moving through states â stateDiagram-v2
- Data entities and their relationships â erDiagram
- Components with methods/properties â classDiagram
Diagram construction rules:
- Every node/actor must map to a requirement. No orphan nodes. No decorative elements.
- Node labels: max 5 words. Use verb phrases for actions (“Validate Input”), noun phrases for entities (“User Service”).
- Edge labels: describe WHAT triggers the transition or WHAT data flows. Never leave edges unlabeled if the relationship isn’t obvious.
- Decision nodes (flowchart): always show all branches explicitly. Label each branch with the condition.
- Group related nodes using subgraphs (flowchart) or boxes (sequence) when there are 3+ logically grouped items.
- Keep the diagram under 40 nodes. If larger, split into multiple diagrams and note how they connect.
- Use consistent direction: TD (top-down) for hierarchical flows, LR (left-right) for sequential processes.
- For sequenceDiagrams: show the happy path first, then alt/opt blocks for error cases.
- Use notes (note right of, note over) sparingly â only for information that doesn’t fit as a label.
- Validate syntax: ensure all node IDs are alphanumeric (no spaces), all strings are quoted where required, and all brackets are balanced.
Style conventions:
- Rounded nodes
()for start/end points - Stadium nodes
([])for user actions - Rectangle
[]for processes - Diamond
{}for decisions - Cylinder
[()]for databases/storage - Use
:::classNamefor highlighting critical paths only if needed
Iteration loop
- Present the generated Mermaid code inline in a code block
- Ask the user: “Does this diagram accurately represent your system? What would you change?”
- If changes requested â revise and present again
- Repeat until user approves
Phase 3: Save and Load
Once the user approves the diagram:
-
Save the file: Write to
docs/diagrams/<topic-slug>.mmdin the project root. Create directories if needed. Use a kebab-case slug derived from the topic. -
Save the requirements summary: Write to
docs/diagrams/<topic-slug>-requirements.mdalongside the diagram. -
Prompt the user to load it:
Your Mermaid diagram has been saved to
docs/diagrams/<file>.mmd.To use this as a spec for implementation, load it into your next Claude session:
- Claude Code CLI: Start your message with
@docs/diagrams/<file>.mmdto add it to context- Or: Ask Claude to read the file at the start of your implementation session
This gives the AI a machine-readable blueprint of your system â much more precise than prose descriptions.
Red Flags â You’re Doing It Wrong
| Symptom | Problem |
|---|---|
| Generated diagram before asking questions | Skipped Phase 1. Requirements are assumptions. |
| Asked 5+ questions in one message | Overwhelms user. One question at a time. |
| Diagram has unlabeled edges | Missing data flow or trigger information. |
| Diagram has 40+ nodes | Too complex for one diagram. Split it. |
| Node labels are full sentences | Too verbose. Max 5 words per node. |
| User said “sure, looks fine” without engagement | Diagram may be too abstract. Ask about specific flows. |
| Saved file without user approval | Never persist without explicit “yes, this is correct.” |
| Ran Phase 1 after superpowers handoff | Fast path: design/plan doc IS the requirements. Skip to Phase 2. |
| Forced diagram generation without asking | Always ask. User may not want a diagram for every plan. |
| Blocked superpowers flow on “no” | If user declines, step aside. Don’t stall the pipeline. |
Common Mistakes
- Jumping to implementation: This skill produces a DIAGRAM, not code. Do not write implementation code.
- Choosing the wrong diagram type: A sequence diagram for a stateless process, or a flowchart for multi-actor interactions. Re-read the type selection rules.
- Over-engineering the diagram: Include what’s in the requirements. Nothing more. YAGNI applies to diagrams too.
- Forgetting error paths: If the requirements mention failure cases, they must appear in the diagram.
- Re-asking clarified requirements: When invoked from superpowers, the design doc already has the answers. Read it instead of interrogating the user again.