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
In this repository5 other files it gives its agents.
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
- Very specific: line 26
Use the folder the user names.
- Very specific: line 33
Never leave a build script, a .drawio or a preview in the project root, and never write outside the project you were pointed at.
- Distinctive: line 98
Every message takes the next row, so write the calls in the order they happen.
≈ “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.
Files
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 atUse 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 flow | the same journey when the waiting does not matter — numbered steps between boxes |
| architecture diagram | what the system is made of |
| flowchart | what 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
- Every call that blocks has
blocking=Trueand a matchingreply(). The activation bar is the diagram's whole point: it shows the window in which the caller can do nothing else. - Replies are
reply(), not anothercall()pointing back. They are dashed with an open head, which is what a reader expects. - 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. - 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.
| participant | 190 × 56, pitch 260 |
| row pitch | 52 |
| activation bar | 12 wide, on the lifeline |
| self-call | bulges 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.svgcheck_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 call | It reads as a new request. Use reply(). |
| Everything blocking | Then the diagram says nothing about waiting. Mark only what really waits. |
| A bar that never closes | A blocking call with no reply — say what comes back, or drop blocking=True. |
| Participants in arbitrary order | Left 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 participants | Past 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.
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
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.

