agentleFS
jabbott-iiijabbott-iii/Doctrina/skills/draw-diagrams/SKILL.md

draw-diagrams

Skill5 starsChanged 5 days agoMITView on GitHub

Draw formal architecture diagrams of the current project (C4 views, UML class, component, and sequence diagrams, data-flow, state, data-model, and deployment diagrams) as Mermaid in Markdown, or rebuild the ones whose sources changed since they were drawn.

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

12 rules. About 0 are common, 6 are distinctive, and 6 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈6

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 6

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Read the Diagrams folder. If it has no diagrams, this run creates the set.

    line 72
  2. Very specific:

    If $ARGUMENTS names a file or a view, work on that one only.

    line 74
  3. Distinctive:

    Read the project before you draw it: Read the sources that say what the project is and how it fits together:

    line 80
  4. Distinctive:

    Update the file's "Drawn from" line and its entry in the index.

    line 106
  5. Distinctive:

    If a diagram disagrees with the code in a way the change history doesn't explain, the diagram was already wrong: correct it, and say so.

    line 108
  6. Distinctive:

    Start every diagram file with its title, what it was drawn from, and its legend, then one numbered section for each view:

    line 113
  7. Very specific:

    Use C4's colors for each level: people #08427b, systems #1168bd, containers #438dd5, components #85bbf0 with dark text, and outside systems …

    line 163
  8. Very specific:

    Put a short description under each box's name (<br/>), so a reader learns what it is without leaving the diagram.

    line 165
  9. Distinctive:

    Write README.md in the Diagrams folder in this shape:

    line 175
  10. Very specific:

    Check accessibility: Every block has an accTitle and an accDescr, every view has a paragraph, and every legend explains every style used.

    line 208
  11. Very specific:

    Do the checks in "Before finishing" in writing.md.

    line 210
  12. Very specific:

    Follow the Git access level in commits.md, and leave the changes uncommitted unless the user asked for a commit and that level allows it.

    line 214

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

Draw or rebuild the architecture diagrams

Requested: $ARGUMENTS (empty means every diagram).

This skill keeps a folder of diagrams that show how the project is built: what it is, what it deals with, its parts and how they depend on each other, its main types, and how it behaves. The first run creates the folder; later runs rebuild only what changed. Bold names are values from the "Project details" of the adopted rules: Diagrams, Specs, Decision log, Task IDs, and Docs folder from roadmap-and-docs.md, and Git access from commits.md. The text follows writing.md.

The diagrams live where the Diagrams value says. Without that value, use diagram/ at the repository's root, and say so in the report.

Conventions

These hold for every diagram, so readers learn them once:

  • Mermaid in Markdown, and nothing else. GitHub draws Mermaid blocks, they diff as text, and no image goes stale beside its source. Don't commit generated images.
  • The code wins. Draw what the code has, under its real names. When a diagram and the code disagree, the code is right, and the diagram changes.
  • Built is solid; planned is dashed. A part the roadmap plans but the code lacks is drawn with a dashed border or a dotted arrow, and labeled with the task that builds it (planned M5.2), in the Task IDs format. Name a planned part as its spec in the Specs does. Without a roadmap, draw only what is built.
  • Class diagrams show only types that exist. List planned types in prose instead.
  • Every file says what it was drawn from: the commit, the version or roadmap task, the date, and the sources read. A rebuild depends on this line.
  • Every diagram can be read without seeing it. Give each Mermaid block an accTitle and an accDescr, and say in the paragraph above it what the reader should notice. Never show meaning by color alone: planned parts are dashed and labeled as well as pale.
  • Keep each diagram readable. Aim for 25 boxes or fewer, and split a larger view into several.
  • Follow writing.md for every title, label, and paragraph.

The diagram set

Draw the views that inform this project, and skip the ones that would be empty:

FileViewsDraw it when
README.mdWhat each file shows, how to read them, and how they are kept trueAlways
c4-architecture.mdC4 views: 1. system context, 2. containers, 3. the components inside each containerAlways
class-diagrams.mdUML class diagrams of the main types, by area, with an overview firstThe code has types worth relating
component-diagrams.mdUML component diagrams: each part with the interfaces it provides and requiresParts meet through interfaces
sequence-diagrams.mdUML sequence diagrams of the main flows: startup, a request, the main loop, a buildThere are flows across parts
data-flow-and-state.mdData-flow diagrams, and state diagrams of the state machinesData moves through stages, or something has states
data-model.mdEntity-relationship diagrams of what is storedThe project keeps a database or a file format
deployment.mdWhere each part runs: devices, servers, stores, and CIParts run in more than one place

Choose the Mermaid diagram type for each view:

ViewMermaid type
C4 views, data flow, and component diagramsflowchart, in C4's colors (Mermaid's own C4 diagrams are experimental)
Class diagramsclassDiagram
Sequence diagramssequenceDiagram
State diagramsstateDiagram-v2
Data modelserDiagram
Deploymentflowchart, with a subgraph for each place parts run

1. Find what is being asked

  1. Read the Diagrams folder. If it has no diagrams, this run creates the set; otherwise it rebuilds them.
  2. If $ARGUMENTS names a file or a view, work on that one only.
  3. Tell the user in one or two sentences whether you are creating or rebuilding, and which diagrams. Then make a task list whose last item is "Verify and report".

2. Create the set

  1. Read the project before you draw it. Read the sources that say what the project is and how it fits together:
    • the architecture, the Specs, the Decision log, and the roadmap in the Docs folder;
    • the manifests that list the parts and their dependencies (Cargo.toml, settings.gradle.kts, package.json, pubspec.yaml, Package.swift, and the like);
    • the entry points, the main types and interfaces, the state types, the schemas and migrations, and the CI and release workflows.
  2. Propose the set. List the files and views you would draw from "The diagram set", with one line each on what it would show, and ask the user to confirm before you draw.
  3. Draw each file in the shape under "File shape", from the sources you read. Draw each edge from a source that states it: a dependency from a manifest or a dependency matrix, a call from the code, and an ownership from a field.
  4. Write the README.md index, in the shape under "The index".

3. Rebuild the set

  1. For each file, read its "Drawn from" line: the commit and the sources.
  2. See what changed since then: git diff --stat <commit>..HEAD -- <sources>, the roadmap tasks ticked since, and the decision records added or superseded since.
  3. For each view whose sources changed, redraw what changed, and only that:
    • parts and dependencies added or removed, from the manifests;
    • types renamed, added, or removed, and relations that changed;
    • flows and states that changed;
    • planned parts that are now built, redrawn solid, with the task label removed;
    • planned parts whose spec renamed or dropped them.
  4. Update the file's "Drawn from" line and its entry in the index. Leave a file whose sources didn't change as it is, and say so in the report.
  5. If a diagram disagrees with the code in a way the change history doesn't explain, the diagram was already wrong: correct it, and say so.

File shape

Start every diagram file with its title, what it was drawn from, and its legend, then one numbered section for each view:

# C4 architecture diagrams

<What these views show, in one or two sentences.>

Drawn from commit `<hash>` (<version or roadmap task>, <YYYY-MM-DD>). Sources: <the files and
folders read>. What the roadmap plans is drawn dashed and names the task that builds it.

## Legend

| Style | Means |
| :- | :- |
| Dark blue, rounded | A person |
| Blue box | Part of the system |
| Gray box | Outside the system |
| White box with a dashed border | Planned: not built yet, with its task |
| Solid arrow | Uses, reads, writes, or depends on, as labeled |
| Dotted arrow | A planned use, with its task |

## 1. System context

<What the reader should notice in this view.>

```mermaid
flowchart TB
    accTitle: System context
    accDescr: <One or two sentences that say what the diagram shows.>
    user(["<Person><br/>what they do"])
    subgraph scope["<System name>"]
        app["<Container><br/>what it is"]
    end
    ext["<External system><br/>what it provides"]
    later["<Planned container><br/>planned M5.2"]
    user -->|"uses"| app
    app -->|"calls"| ext
    app -.->|"planned M5.2"| later
    classDef person fill:#08427b,stroke:#052e56,color:#ffffff
    classDef system fill:#1168bd,stroke:#0b4884,color:#ffffff
    classDef external fill:#8a8a8a,stroke:#6b6b6b,color:#ffffff
    classDef planned fill:#ffffff,stroke:#888888,stroke-dasharray: 5 5,color:#555555
    class user person
    class app system
    class ext external
    class later planned
```
  • Use C4's colors for each level: people #08427b, systems #1168bd, containers #438dd5, components #85bbf0 with dark text, and outside systems gray.
  • Put a short description under each box's name (<br/>), so a reader learns what it is without leaving the diagram.
  • Label every arrow with what it does: "reads", "calls", "depends on".
  • Give a class diagram's legend its relationship notation instead: realization (<|..), ownership (*--), shared references (o--), associations (-->), dependencies (..>), and multiplicities.
  • Mark sequence and state diagrams of planned work as planned in their titles and notes.

The index

Write README.md in the Diagrams folder in this shape:

# Diagrams

Pictures of how <the project> is built, drawn from the code and the docs as of commit `<hash>`
(<version or roadmap task>, <YYYY-MM-DD>). Each file is Markdown with Mermaid blocks, which
GitHub draws.

| File | Shows |
| :- | :- |
| [`c4-architecture.md`](c4-architecture.md) | <The views it holds> |

## Reading them

<The conventions every file shares: built and planned, the colors, and where the design lives.>

## Keeping them true

When the code and a diagram disagree, the code is right. A change to something a diagram draws
updates the diagram in the same change. Run `/draw-diagrams` to rebuild the diagrams whose
sources changed.

4. Verify

  1. Check every name. Each box, type, and participant exists in the code under that name, or is labeled planned with a task that exists in the roadmap.
  2. Check every edge. Each dependency matches its manifest or dependency matrix, each call matches the code, and no edge is missing between parts the sources connect.
  3. Check that every block draws. Render each changed block with GitHub's preview or a Mermaid renderer, such as the Mermaid CLI (mmdc). If neither is available here, say so in the report.
  4. Check accessibility. Every block has an accTitle and an accDescr, every view has a paragraph, and every legend explains every style used.
  5. Do the checks in "Before finishing" in writing.md.

5. Commit only as the project allows

Follow the Git access level in commits.md, and leave the changes uncommitted unless the user asked for a commit and that level allows it. Either way, end the report with a copy-ready commit message, as commits.md describes.

6. Report

End with a summary that contains:

  • Mode: created or rebuilt, and the folder.
  • Diagrams: each file and view drawn or changed, with one line on what changed, and each one left as it was because its sources hadn't changed.
  • Drawn from: the commit, version or task, and date the diagrams now reflect.
  • Corrections: anything a diagram had wrong before this run.
  • Checks: how each check went, and which you couldn't run, and why.
  • Questions: anything the sources didn't settle, such as a part whose spec and code disagree.
  • Commit message: in a text block, as commits.md describes, with no attribution lines.

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.