agentleFS
Filip-PodstavecFilip-Podstavec/claude-leverage/skills/process-diagram/SKILL.md

process-diagram

Skill68 starsChanged 4 months agoMITView on GitHub

USE WHEN documenting a non-obvious workflow prose explains poorly, or when user describes a multi-step process and asks for a visualization. Generates a mermaid sequenceDiagram or flowchart, optional insertion into target markdown between idempotent markers, `mmdc` validation in a 3-retry loop.

The file

We split this skill into the rules it gives an agent

10 rules. About 0 are common, 3 are distinctive, and 7 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.

  • 7

    Very specific

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

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

    If a SKILL.md or command file with the workflow's name exists in skills/ or commands/, Read it for the participants and steps.

    line 49
  2. Distinctive:

    If the user describes the workflow in conversation, use that.

    line 51
  3. Very specific:

    Avoid Mermaid reserved IDs: end, class, subgraph.

    line 63
  4. Very specific:

    Write the mermaid to a temp file (mktemp).

    line 67
  5. Distinctive:

    If non-zero: read the error message, fix the specific issue, retry.

    line 69
  6. Very specific:

    If mmdc is not on PATH: skip validation with a one-line warning.

    line 72
  7. Very specific:

    Never silently change marker IDs: If the user says /process-diagram security-review and the existing block is <!-- …

    line 93
  8. Distinctive:

    Refuse to invent a flow: If the user gives only a workflow name and no description, and you cannot find a SKILL/command file to read for …

    line 97
  9. Very specific:

    Cap retries at 3: If mmdc keeps complaining, surface to the user rather than burning a context window on infinite tweak loops.

    line 101
  10. Very specific:

    Auto-update existing diagrams when code changes: Run the skill explicitly when the workflow shifts.

    line 119

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 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

/process-diagram

What it does

Produces a Mermaid diagram for a named workflow (the flow of /security-review, how a hook intercepts a Bash call, how the SessionStart bare-repo-nudge decision tree resolves, etc.) and optionally inserts it into a target markdown file between idempotent markers:

<!-- process-diagram:<name>:start -->
```mermaid
sequenceDiagram
    ...
<!-- process-diagram:<name>:end -->

## Workflow

1. **Parse arguments.**
   - First positional arg: the workflow name (snake_case). Becomes the
     diagram's identifier in the markers.
   - `--into <path>`: target markdown file to insert into. If omitted,
     just print the diagram to the user.
   - `--type sequence|flowchart`: override the auto-pick. Default rule:
     sequence diagrams for inter-component flows (actors talking to each
     other), flowcharts for decision logic / state transitions.

2. **Resolve the workflow.** Three sources, in order:
   - If a SKILL.md or command file with the workflow's name exists in
     `skills/` or `commands/`, Read it for the participants and steps.
   - If the user describes the workflow in conversation, use that.
   - Otherwise, ask the user for participants and the 3–10 steps. Do not
     hallucinate a flow.

3. **Generate the mermaid.**
   - For `sequenceDiagram`: list participants first (`participant U as User`,
     `participant M as Main session`, …), then the message arrows. Use
     `->>` for sync, `-->>` for response, `Note over` for annotations.
   - For `flowchart`: use `flowchart LR` (or `TB` if the user prefers).
     Wrap labels containing special characters (parens, colons, slashes)
     in double quotes — Mermaid's parser bails on bare ones (per the
     known issue documented in `docs/specs/research/research_visualization.md`).
   - Avoid Mermaid reserved IDs: `end`, `class`, `subgraph`. Pick
     descriptive IDs (`User`, `MainSession`, `SecurityReviewer`).

4. **Validate with mmdc if available.**
   - Write the mermaid to a temp file (`mktemp`).
   - Run `mmdc -i <tmp.mmd> -o <tmp.svg> 2>&1`.
   - If non-zero: read the error message, fix the specific issue, retry.
     Cap at 3 retries — if still failing, surface the mermaid + error to
     the user and let them decide.
   - If `mmdc` is not on PATH: skip validation with a one-line warning.

5. **Insert or print.**
   - With `--into <path>`: scan the target for existing markers with the
     same `<name>`. If found: `Edit` to replace the entire block
     atomically (both markers stay byte-identical, body changes). If not
     found: append after the first H1 heading.
   - Without `--into`: print the fenced mermaid block to the user.

## Examples

/process-diagram security-review /process-diagram bare-repo-nudge --into hooks/README.md /process-diagram stack-check-pipeline --type flowchart --into docs/specs/2026-05-24-pivot/05-stack-freshness.md


## Hard rules

- **Never overwrite content outside the markers.** Idempotence is the
  whole point of the markers.
- **Never silently change marker IDs.** If the user says
  `/process-diagram security-review` and the existing block is
  `<!-- process-diagram:security-flow:start -->`, ask which one to update;
  do not duplicate.
- **Refuse to invent a flow.** If the user gives only a workflow name and
  no description, and you cannot find a SKILL/command file to read for
  it, ASK for the participants and steps. Hallucinated diagrams are
  worse than no diagram.
- **Cap retries at 3.** If `mmdc` keeps complaining, surface to the user
  rather than burning a context window on infinite tweak loops.

## Common mermaid traps (and how to avoid)

| Failure | Fix |
|---------|-----|
| Label has `(parens)` and parser bails | Wrap label in `"..."` |
| Label has `:` or `/` | Wrap label in `"..."` |
| Node ID is `end` or `class` | Pick a different ID (e.g., `EndNode`) |
| Arrow type mismatch (`-->>` in flowchart) | Sequence uses `->>` / `-->>`; flowchart uses `-->` / `-.->` |
| Stale syntax (`graph TB` instead of `flowchart TB`) | Prefer `flowchart` for new diagrams |

## What this skill does NOT do

- **Generate diagrams from code AST.** That's `/repo-map` territory
  (architecture overview from directory structure + AGENTS.md hints), or
  dedicated tools (madge for JS/TS dep graphs).
- **Auto-update existing diagrams when code changes.** Run the skill
  explicitly when the workflow shifts; the `docs-sync` skill can flag
  drift.

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.