From layered-flow-chart
Create, update, and refine interactive hierarchical sequence diagrams as single-file HTML with drill-down navigation. Outputs a UML-style sequence diagram with stacking modal layers - clicking an interaction block opens a deeper detail view. Use this skill when users ask to: - Visualize inter-component communication as a sequence / interaction diagram - Create a layered sequence diagram with drill-down - Diagram API call chains, request/response flows, or event sequences - "Make a sequence diagram of X" or "Show me how X communicates with Y" - Update an existing sequence diagram to reflect code changes - Improve or refine an existing sequence diagram Triggers: "sequence diagram", "interaction diagram", "message flow", "call sequence", "request flow", "communication diagram", "シーケンス図", "インタラクション図", "メッセージフロー", "呼び出しシーケンス", "update sequence", "refine sequence", "シーケンス更新", "シーケンス改善"
How this skill is triggered — by the user, by Claude, or both
Slash command
/layered-flow-chart:layered-sequence-diagramThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Create, update, and refine interactive hierarchical sequence diagrams from a single HTML file. Interaction blocks are clickable — drilling down opens stacking modal layers with progressively finer detail.
Create, update, and refine interactive hierarchical sequence diagrams from a single HTML file. Interaction blocks are clickable — drilling down opens stacking modal layers with progressively finer detail.
Before starting, determine which mode applies:
| Mode | Trigger | Existing data.js? | Code investigation? |
|---|---|---|---|
| Create | "Make a sequence diagram of X" | No | Full (3-phase pipeline) |
| Update | "Update the sequence to reflect latest code" | Yes | Targeted (diff-focused) |
| Refine | "Improve the layout / add details / add fragments" | Yes | None or minimal |
How to determine the mode:
index.html + data.js) → if yes, Update or Refineboundary → RefineThis mode requires deep code investigation BEFORE building the HTML. To prevent shallow analysis, you MUST split the work into 3 phases using SubAgents. Do NOT skip phases or combine them.
Investigation is done in serial steps using multiple Explore agents. Each step builds on the previous output. Do NOT parallelize — the layered nature requires understanding the high level before deciding what to drill into.
Identify the participants (actors/systems/services) and the high-level message flow between them. This becomes the root level of the diagram.
Prompt template:
Investigate the following interaction/communication flow in this codebase: {user's description}
Produce a HIGH-LEVEL sequence overview. Focus on WHICH actors communicate and WHAT messages they exchange, NOT implementation details.
## Flow Overview
- Purpose: (one sentence)
- Entry point: (file:line)
- Overall pattern: (e.g., request-response, event-driven, saga, pipeline)
## Participants (aim for 3-6):
For each actor/system/service:
1. **{Name}**
- Role: {what this participant does, one sentence}
- Type: client | server | database | external-service | queue | worker
- Key file(s): {primary file(s)}
## Message Sequence (in order):
For each message in the flow:
1. {Sender} → {Receiver}: **{message label}** ({sync|async|reply})
- Purpose: {what this message does}
- Complexity: simple | moderate | complex
## Interaction Blocks:
Group related messages into logical blocks:
- **{Block Name}** (messages {N}-{M}): {brief description}
- Complexity: simple | complex (complex = warrants drill-down)
Focus on identifying WHO talks to WHOM and in WHAT order. Do not drill into implementation details yet.
After Step 1-1, review the output and decide:
Investigate the selected blocks in detail. These become the drill-down levels.
Prompt template:
I am investigating this communication flow: {user's description}
Here is the high-level sequence already produced:
{paste Step 1-1 output}
Now deep-dive into these specific interaction blocks: {list of selected blocks}
For EACH block, produce a detailed sub-sequence:
### Block: {name}
#### Additional Participants (if any):
- Internal services, validators, helpers that participate only at this detail level
#### Detailed Message Sequence:
1. {Sender} → {Receiver}: **{message label}** ({sync|async|reply|self})
- File: {file:line-range}
- Tech: {libraries/protocols}
- Input: {what is sent}
- Output: {what is returned}
- Details: {error handling, edge cases, important notes}
- Note: {annotation text if helpful}
#### Fragments:
- {type: loop|alt|opt|break} "{label}" [{condition}] wrapping messages {N}-{M}
Investigate EVERY file involved. List concrete function names, file paths, and line numbers. Aim for 6-12 messages per block.
If the deep dive revealed corrections needed at the root level, spawn one more Explore agent.
Spawn a general-purpose agent. Pass it the Phase 1 report AND the Data Schema section below.
Prompt template:
Convert the following investigation report into a LEVELS JavaScript object for a sequence diagram.
## Investigation Report
{paste Step 1-1 output (with Step 1-3 corrections applied if any)}
## Deep Dive Report
{paste Step 1-2 output}
## Schema Rules
{paste the "Data Schema" section from this SKILL.md}
Output ONLY the JavaScript for data.js:
- const LEVELS = { ... };
- const HEADER_LOGO = '...';
- document.title = '... | Layered Sequence Diagram';
Requirements:
- Root level: 3-6 participants, all high-level messages, fragments wrapping drillable blocks
- Each drill-down level may introduce additional participants not visible at root (e.g., internal validators, queues)
- Set hasChildren: true on fragments that have matching LEVELS entries
- Include file references, techs, details where available from the investigation
- Order messages strictly in the sequence they occur
- Use boundary: true for cross-network/cross-process messages
- Use fragment types appropriately: ref for drill-down, loop/alt/opt/break for control flow
Before assembling the HTML, use AskUserQuestion to ask the user where to place the generated file.
AskUserQuestion config:
/tmp 配下 (Recommended) — /tmp/{project}/seq-{name}/ に出力します。プロジェクトを汚しません。{detected main file's directory}/seq-{name}/ に出力します。mkdir -p {output-dir}cp ~/.claude/skills/layered-sequence-diagram/assets/template.html {output-dir}/index.html{output-dir}/data.jsopen {output-dir}/index.htmldata.js file to extract the current LEVELS objectSpawn an Explore agent focused on what changed.
Prompt template:
An existing sequence diagram describes this flow: {brief description}
Here are the current participants, messages, and fragments:
{paste extracted LEVELS summary}
The user says the following has changed: {user's description}
Investigate the codebase and report:
1. **New messages** that should be added (with file:line, participants, type)
2. **Removed messages** that no longer exist in the code
3. **Modified messages** where the label, participants, or behavior changed
4. **New/removed participants**
5. **Fragment changes** (new, removed, or adjusted ranges)
Only report actual changes - do not re-describe unchanged parts.
Based on the diff report, update the LEVELS object:
fromMsg/toMsg indices when messages are added/removeddata.js file in-placeUse when the diagram's content is correct but the presentation needs improvement.
| Request | Action |
|---|---|
| "Add boundary arrows" | Add boundary: true to cross-network messages |
| "Add more detail to X" | Enrich messages with details/techs/file fields |
| "Add a drill-down for X" | New level + set hasChildren on fragment |
| "Add fragments" | Wrap related messages with loop/alt/opt fragments |
| "Add notes" | Add note fields to explain timing or context |
data.js filedata.js in-place — do not touch index.htmlThe LEVELS object is a flat map. Key = level ID, value = level definition.
const LEVELS = {
root: { ... }, // Required. Entry point.
'fragment-id': { ... }, // Sub-level for a fragment with hasChildren: true
};
{
title: 'Level Title',
description: 'Subtitle text',
participants: [ /* Participant[] */ ],
messages: [ /* Message[] */ ],
fragments: [ /* Fragment[] — optional */ ],
}
{
id: 'unique-id', // Used in message from/to
name: 'Display Name',
icon: 'emoji', // Single emoji
color: '#6366f1', // Border color (hex)
}
{
id: 'unique-id',
from: 'participant-id', // Sender
to: 'participant-id', // Receiver (same as from for self-message)
label: 'Message text', // Arrow label
type: 'sync', // sync | async | reply | self
// Optional fields:
boundary: true, // Cross-network/process boundary (indigo style)
note: 'Annotation text', // Shown above the arrow in italics
techs: ['Stripe', 'gRPC'], // Tech badges in popover
file: 'src/foo.ts:10-20', // Source file reference in popover
input: 'Request body', // Input description in popover
output: 'JSON response', // Output description in popover
details: ['point 1', ...], // Bullet list in popover
}
| Type | Arrow Style | Use Case |
|---|---|---|
sync | Solid line, filled arrowhead | Synchronous call (HTTP request, function call) |
async | Solid line, filled arrowhead | Asynchronous message (webhook, queue publish) |
reply | Dashed line, open arrowhead | Response to a previous sync call |
self | Loop on same lifeline | Internal processing (parse, validate, transform) |
{
id: 'unique-id',
type: 'ref', // ref | loop | alt | opt | break
label: 'Display Name',
condition: 'guard text', // Optional — shown as [condition]
fromMsg: 0, // Start message index (inclusive)
toMsg: 3, // End message index (inclusive)
hasChildren: true, // true = clicking opens drill-down (needs matching LEVELS entry)
color: '#custom', // Optional accent color override
}
| Type | Purpose | Typical hasChildren |
|---|---|---|
ref | Reference to detailed sub-sequence | true (drill-down) |
loop | Repeated execution | false |
alt | Conditional branch (if/else) | false |
opt | Optional execution (if) | false |
break | Exit from enclosing fragment | false |
Use boundary: true for messages that cross a network or process boundary. These render with indigo styling.
When to use:
When NOT to use:
Messages are rendered top-to-bottom in array order. The order must reflect the actual temporal sequence of the interaction.
| Participant Type | Hex |
|---|---|
| Client/User | #3B82F6 |
| Frontend/UI | #8B5CF6 |
| API Server | #6366f1 |
| External Service | #EF4444 |
| Database/Storage | #10B981 |
| Queue/Worker | #F59E0B |
| Analytics/Monitoring | #14B8A6 |
index.html (the template) — only generate/edit data.jsparticipants array — participants can differ between levelsfromMsg/toMsg are zero-based indices into the level's messages arraynpx claudepluginhub texmeijin/layered-flow-chart --plugin layered-flow-chartGenerates interactive HTML architecture diagrams with animated step-by-step flows, mode toggles, and side panel details. For service maps, CI/CD pipelines, data flows, and workshop diagrams.
Generates architecture diagrams on a live Excalidraw canvas from text, components, or samples for data flows, call chains, and exports to PNG/SVG/Excalidraw.
Generates professional diagrams (flowcharts, architecture diagrams, comparisons, mind maps, timelines) as draw.io XML files from concepts or documents.