agentleFS
aliefauzanaliefauzan/Orthogram/skills/drawing-sequence-diagrams/SKILL.md

drawing-sequence-diagrams

Skill2 starsChanged 2 months agoMITView on GitHub

Use when drawing a sequence diagram — the order of messages between a browser, services, a queue, a database, over time, with who waits for whom — as a .drawio / draw.io file. Also called a message flow, call flow, protocol or handshake diagram, and for fixing one whose replies, activation bars or self-calls are missing

The file

We split this skill into the rules it gives an agent

3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

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

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

    Use the folder the user names.

    line 26
  2. Very specific:

    Never leave a build script, a .drawio or a preview in the project root, and never write outside the project you were pointed at.

    line 33
  3. Distinctive:

    Every message takes the next row, so write the calls in the order they happen.

    line 98

≈ “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

Drawing sequence diagrams

A .drawio sequence diagram in the same visual language as the other drawing-* skills: light page, white cards with hairline borders, Google's palette on the arrows.

Build it with seq_drawio.py (this directory). Look at it with preview.py.

Where the files go

Everything this skill produces lives in one folder, never loose in the project root:

docs/diagrams/
  login-sequence.py             # the script that builds it
  login-sequence.drawio         # the diagram
  login-sequence.preview.svg    # what you looked at

Use the folder the user names. Otherwise put it under docs/diagrams/ when the project has a docs/ directory, and diagrams/ at the project root when it does not — the build script, the .drawio, and any preview or PNG together. write() creates the folder if it is missing, so f.write("docs/diagrams/login-sequence.drawio") is all it takes, and preview.py writes the SVG beside its input.

Never leave a build script, a .drawio or a preview in the project root, and never write outside the project you were pointed at. One folder, named files — a diagram whose script sits next to it can be regenerated; one scattered across a repository root cannot be found again.

What this draws, and what it does not

sequence diagram (this skill)the order of messages, and who is blocked waiting for whom
step flowthe same journey when the waiting does not matter — numbered steps between boxes
architecture diagramwhat the system is made of
flowchartwhat is decided

Reach for this one when the answer to "why is this slow" or "what happens if that times out" is in the picture. If nothing waits for anything, a step flow says the same thing in less space.

The output contract

  1. Every call that blocks has blocking=True and a matching reply(). The activation bar is the diagram's whole point: it shows the window in which the caller can do nothing else.
  2. Replies are reply(), not another call() pointing back. They are dashed with an open head, which is what a reader expects.
  3. A message that nobody waits for is send() — a queue publish, a webhook, an audit event. Drawn amber and open-headed so it does not read as a request.
  4. Participants are declared left to right in the order they first act. Crossing arrows are information; crossing them for no reason is not.

The pieces

from seq_drawio import Sequence

s = Sequence("Login with federated identity", "browser · api · idp")
br  = s.actor("Browser", "the person", "onprem/client/users.png")
api = s.actor("Session API", "FastAPI", "gcp/compute/run.png")
idp = s.actor("Entra ID", "token issuer")

s.call(br, api, "POST /login", blocking=True)
s.call(api, idp, "authorise (PKCE)", blocking=True)
s.call(idp, idp, "check MFA")            # same participant: a self-call
s.reply(idp, api, "id_token + groups")   # closes the bar opened above
s.reply(api, br, "Set-Cookie: session")
s.send(api, audit, "audit event")        # nobody waits
s.note(idp, "tokens live 60 minutes", row=3)
s.frame("alt · MFA required", rows=[1, 3])
s.write("docs/diagrams/login.drawio")

call() and reply() pair up on their own: a reply closes the most recent blocking call still open on that participant, and the bar is drawn between them. A bar that never closes means a call you said would block and never answered — usually a missing reply(), occasionally a real bug in the design.

A self-call's label sits beside the loop rather than on it: a plate in the middle covers the leg that makes it read as a loop at all.

frame() boxes a run of rows for an alt, a loop, an opt. Name the condition, not the shape: "alt · MFA required" beats "alt".

Rows are time

Every message takes the next row, so write the calls in the order they happen. Row pitch is 52 — enough for a label above the arrow and clear space between. The lifeline runs to the last row.

participant190 × 56, pitch 260
row pitch52
activation bar12 wide, on the lifeline
self-callbulges 46 to the right, 30 tall, and takes that much extra room from the rows below it

Before handing it over

S=~/.claude/skills/drawing-sequence-diagrams
python3 "$S/preview.py" docs/diagrams/login.drawio             # writes docs/diagrams/login.preview.svg
rsvg-convert -w 1400 -o docs/diagrams/login.png docs/diagrams/login.preview.svg

check_routing.py works here but has little to say: sequence messages run between fixed points on lifelines rather than between boxes, so there are no corridors to get wrong. Read the picture instead — for a bar that never closes, a reply with no call, a participant that receives everything and sends nothing.

Common mistakes

A reply drawn as a callIt reads as a new request. Use reply().
Everything blockingThen the diagram says nothing about waiting. Mark only what really waits.
A bar that never closesA blocking call with no reply — say what comes back, or drop blocking=True.
Participants in arbitrary orderLeft to right in the order they first act, or every arrow crosses.
A label naming the target"call the API" on an arrow into the API says nothing. Say what is sent: "POST /login".
Ten participantsPast about six lifelines nobody can follow a row. Split the diagram at a boundary.

preview.py writes a plain SVG — open it in any browser if you have no rsvg-convert. The PNG step is for pasting into a document, not for looking at it.

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.