agentleFS
WaniWani-AIWaniWani-AI/sdk/.claude/skills/visualize-flow/SKILL.md

visualize-flow

Skill18 starsChanged 5 months agoMITView on GitHub

Generate a Mermaid diagram from a Waniwani flow definition. Use when the user wants to visualize, diagram, or document a flow's structure and branching logic.

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 3 are distinctive, and 4 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈3

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 4

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Read the entire flow source file.

    line 19
  2. Very specific:

    Use graph TD (top-down) layout.

    line 36
  3. Distinctive:

    Add a legend comment at the top explaining the shapes.

    line 51
  4. Distinctive:

    START((START)) --> ask_email ask_email{{"ask_email<br/>field: email"}} --> analyze_email analyze_email["analyze_email"] -->|"company …

    line 76
  5. Distinctive:

    Always read the FULL flow file before generating the diagram — don't guess at structure

    line 89
  6. Very specific:

    Use END_NODE as the mermaid node ID for END (since END can conflict with mermaid keywords)

    line 92
  7. Very specific:

    If a node has a field in its config or interrupt signal, include it in the node label

    line 93

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Visualize Flow

Generate a Mermaid flowchart diagram from a Waniwani SDK flow file.

Arguments

The user may provide a file path as an argument. If not provided, search for flow files using **/flows/**/*.ts patterns and ask the user which one to visualize.

Steps

1. Find and read the flow file

Read the entire flow source file. The flow is defined using the createFlow builder pattern with chained .addNode(), .addEdge(), .addConditionalEdge(), and .compile() calls.

2. Extract the graph structure

Parse the source code to identify:

Nodes — Each .addNode("name", ...) call. Classify by what the handler returns:

  • Widget node — handler returns showWidget({ tool, data }) (or the legacy positional form showWidget(tool, { data })). Look for { tool: ... } (object form) or the second positional arg (legacy form).
  • Interrupt node — handler returns interrupt({ question, field }).
  • Action node — handler returns a plain object like {} or { key: value }. These run silently and auto-advance.

Direct edges — Each .addEdge(from, to) call. START and END are sentinel constants ("__start__" and "__end__").

Conditional edges — Each .addConditionalEdge("from", ["target_a", "target_b"], (state) => { ... }) call. The second argument lists the branch targets verbatim — use it directly. Read the condition body only if you also want to label which state values lead to which target (e.g., state.country === "FR").

3. Generate Mermaid diagram

Use graph TD (top-down) layout. Apply these shape conventions:

Node TypeMermaid ShapeExample
STARTDouble circleSTART((START))
ENDDouble circleEND_NODE((END))
WidgetStadium/pillname(["name (widget)<br/>field: fieldName"])
InterruptHexagonname{{"name (interrupt)<br/>field: fieldName"}}
Action/RouterRectanglename["name (action)"]

Edge conventions:

  • Direct edge: A --> B
  • Conditional edge: A -->|"label"| B — use the condition as label (e.g., country = FR, status = unregistered, default)
  • Dead-end edges to END: style with a different arrow if desired

Add a legend comment at the top explaining the shapes.

4. Output

Print the full Mermaid diagram as a fenced code block, then copy it to clipboard using pbcopy:

cat <<'EOF' | pbcopy
graph TD
    ...
EOF

Confirm to the user that the diagram has been copied.

Example Output

For a simple 3-step flow:

```mermaid
%% Flow: demo_qualification
%% Legend: (()) = terminal, ([]) = widget, {{}} = interrupt, [] = action

graph TD
    START((START)) --> ask_email
    ask_email{{"ask_email<br/>field: email"}} --> analyze_email
    analyze_email["analyze_email"] -->|"company email"| ask_role
    analyze_email["analyze_email"] -->|"generic email"| ask_company
    ask_company{{"ask_company<br/>field: companyName"}} --> ask_role
    ask_role{{"ask_role<br/>field: role"}} --> ask_use_case
    ask_use_case{{"ask_use_case<br/>field: useCase"}} --> complete
    complete(["complete (widget)"]) --> END_NODE((END))
```

Important Notes

  • Always read the FULL flow file before generating the diagram — don't guess at structure
  • For conditional edges, read the actual condition function to extract all branches and labels
  • Include ALL nodes and ALL edges — missing nodes means the diagram is incomplete
  • Use END_NODE as the mermaid node ID for END (since END can conflict with mermaid keywords)
  • If a node has a field in its config or interrupt signal, include it in the node label
  • Escape special characters in mermaid labels if needed (quotes, parentheses)

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.