CommunityImagemgithub.com

architecture-diagram

Use when asked to create or update an interactive architecture diagram or visual codebase map of this repo. Do not use for text-only architecture docs or Cursor canvases.

O que é architecture-diagram?

architecture-diagram is a Cursor agent skill that use when asked to create or update an interactive architecture diagram or visual codebase map of this repo. Do not use for text-only architecture docs or Cursor canvases.

Funciona com~Claude Code~Codex CLI✓Cursor
npx skills add https://github.com/kingdomseed/agent-skills/tree/HEAD/skills/architecture-diagram

Installed? Explore more Imagem skills: steipete/songsee, affaan-m/frontend-design, mattpocock/improve-codebase-architecture · View all 6 →

Perguntar na sua IA favorita

Abre um novo chat com esta habilidade de agente já pré-carregada.

Documentação

Architecture Diagram

Produce one self-contained interactive HTML file and a generated markdown twin from the same FILL data. Inline CSS and JS. Zero network dependencies. System font stacks. Opens via file://.

Copy template.html. Fill only the FILL block. Do not replace layout, drawBands, classifyEdge, or emitMarkdown with free-placed coordinates or hand-written twin prose.

Do not use a radial ring, hairball, or free 2D scatter as the scene. Those layouts hide layer separation.

Output

Write both files to:

<repo-root>/artifacts/<slice-name>-architecture.html <repo-root>/artifacts/<slice-name>-architecture.md

Those paths are exploration artifacts. Do not commit them.

The markdown twin is generated by emitMarkdown() from the FILL block. Never hand-edit the twin. Regenerate it after every FILL change. The template ships a sample FILL so the ledger and chapters can be proven. Overwrite that sample when authoring a real slice.

Layer bands (primary axis)

The scene is horizontal layer bands, top to bottom:

  1. Presentation
  2. Application (include this band only when the slice has Application types)
  3. Domain
  4. Data
  5. Storage / platform (platform storage, disk, network, plugins)

State-management and DI frameworks are not bands. Controllers and providers sit in the layer of their file, almost always Presentation. Composition roots wire Data outward.

These five bands are the default. When the repo uses a different architecture (hexagonal, MVC, feature modules), derive the band list and legal-dependency rules from its own architecture docs or code structure instead. A Current diagram that omits known violations is false.

Rules the template already enforces:

  • Every node sits in exactly one band. Position is derived from layer × owner. dx/dy only nudge inside that cell.
  • Band boundaries are drawn (tinted bands plus labels). An empty included band stays visible as empty.
  • Omit the Application band when the slice has no Application types. Then Presentation and Domain are adjacent. When the band is present, Presentation → Domain skips it and is a violation.
  • Domain, Data, Presentation, and Storage / platform stay in the list even when a band has no nodes.

Ownership columns (secondary axis)

Vertical columns or clusters per feature/owner. A node's place answers both "which layer" and "which owner" at a glance.

Questions ledger

QUESTIONS in the FILL block is the slice's decision ledger. Each row has id, question, status (open or resolved), answer, and decidedOn (ISO date, empty while open).

Open questions render in the inspector Questions panel. Resolved rows keep the answer and date in place. The markdown twin includes the same ledger.

When a decision lands (a spec open-decision becoming resolved), record the answer in this array. Do not leave it in chat or a separate doc.

Chapters (optional)

CHAPTERS is an optional ordered list of { id, caption, nodes } where nodes is a subset of node ids. The UI gains Prev / Next chapter controls that reveal the scene progressively, plus a Show all escape.

Use chapters when the slice exceeds roughly twenty nodes (large PR stacks, migrations). Omit the field, or leave it [], for small slices. Layer bands stay fixed across chapters so a node's cell stays meaningful.

When CHAPTERS is absent or empty, behavior matches a diagram with no chapter chrome.

Step inside (optional)

Author an inside scene on a node whose internals a top-level packet route cannot show. Omit the field on every other node. A node without inside stays byte-for-byte unchanged in behavior.

Pick one shape per node:

  • stages. An ordered pipeline of { id, label, what } (one-line what-happens). The scene is a left-to-right stage strip.
  • nodes / edges. A small nested mini-graph. Reuse the same band discipline. Each nested node has layer and owner. Position is still layer × owner.

Optional insidePackets on that same node. Those packets stay scoped to the inside scene, carry real payloads, and hop along stages or nested nodes. Click-to-pause-and-inspect matches top-level packets.

A node with inside shows a Go inside affordance (hover hint and inspector button). Entering swaps to the inside scene with a breadcrumb (the node name) and a Back control. Leaving restores the top-level camera exactly. Entering works regardless of which chapter revealed the node.

The markdown twin includes an Inside subsection per node that has one. emitMarkdown stays the only twin writer.

Done when a node with inside can be entered, an inside packet animates, Back restores the saved camera, the twin lists that subsection, and a node without inside has no enter control.

Edges

Legal call/write edges flow downward to the next present band.

Invalidation and reactive reads return upward, dashed.

Data implementing a Domain contract is legal dependency inversion. Draw it as implements (dotted, not alert). Any other implements is a violation.

Same-layer edges are compose (dashed ink), not layering violations.

Layering violations are the loudest signal. An edge that skips a band or points the wrong way uses the alert color (#7a2e1c). Clicking it explains the skipped bands or the illegal direction in the inspector. Do not mark a Current reversing import (Application → Presentation) as legal.

classifyEdge overwrites a hand-set legal that fails these rules.

Interaction

Required chrome:

  • Pan (drag), zoom (scroll and +/-), Reset view.
  • Click a node. Inspector shows What it does, How it's built (real file paths and line counts), and a Condition list of known problems on current-state nodes. State where each fact came from.
  • Click an edge. Inspector shows endpoints, layers, classification, and the skip/direction reason.
  • Animated data packets. 3–5 per state. Each is a real payload (actual key names and values from the code) moving hop by hop on real routes. Click a packet to pause it and show payload, route, and legality per state. Global pause/resume. Optional Trace one step.
  • Optional CURRENT / TARGET toggle. An entity present in both states keeps the same layer+owner cell so the eye tracks what changed. Demolished types may stay as dashed ghosts in that cell.
  • Hover tooltips. Footer legend with control hints. Top stats bar with the slice's headline numbers.
  • Questions panel lists the QUESTIONS ledger. Optional chapter Prev / Next / Show all when CHAPTERS is non-empty.
  • Go inside a box that has inside. Breadcrumb and Back while inside. Back restores the camera saved on enter.

Aesthetic

Keep the family look from the cream/paper reference:

  • Paper #d8d0b0 / #cfc6a4, olive ink #1a1912, muted #5c5848, inverse #efe8cc, alert rust #7a2e1c, ok #2a4a32
  • Repeating paper hatch on the page. SVG hatch on isometric box sides
  • Small-caps monospaced labels (ui-monospace, Menlo, Consolas)
  • Left component sidebar, top stats bar, right inspector with WHAT-IT-DOES / HOW-IT'S-BUILT tabs, footer control hints

Grounding

Build from verified facts, not memory. Never invent keys, paths, or counts.

Workspace search skips dot-prefixed folders such as .worktrees/. Use plain rg in a shell there.

Workflow

  1. Read the repo's architecture docs if it has them. Done when the slice's layer list is chosen (Application in or out) and documented violations are noted.

  2. Inventory the slice from source (or a grounding doc plus source check). Record every node (path, wc -l line count, layer, owner), every edge (import or call site with file:line), and every packet payload (key and value as they appear in code). Done when that facts table exists and every row has a source locator.

  3. Assign each node one layer and one owner. List included bands. List owner columns. Done when no node lacks layer or owner, and an empty included band is still on the layer list.

  4. Copy template.html to the output path. Fill SLICE, OWNERS, NODES, EDGES, PACKETS, COPY, SIDE, OVERVIEW, STATS, QUESTIONS, optional CHAPTERS, and optional per-node inside / insidePackets. Leave layout code unchanged. Done when the output HTML exists and a diff against the template is data-only below the FILL marker.

  5. Emit the markdown twin from the same FILL object via emitMarkdown(). Write it beside the HTML. Never hand-edit it.

    node -e '
    const fs = require("fs"); const vm = require("vm");
    const html = fs.readFileSync(process.argv[1], "utf8");
    const js = html.split("<script>")[1].split("</script>")[0];
    const g = { location: { hash: "" } };
    g.globalThis = g;
    vm.runInNewContext(js, g);
    fs.writeFileSync(process.argv[2], g.__ARCH.markdown());
    ' slice-architecture.html slice-architecture.md
    

    Done when a second emit from the unchanged FILL block is byte-identical (cmp silent).

  6. Run Verification. Done when every check below has its proof.

Verification

  1. Well-formed HTML. Done when python3 -c "from html.parser import HTMLParser; p=HTMLParser(); p.feed(open(path).read()); print('html-ok')" prints html-ok.
  2. JS parses. Done when the inline script extracted from the file passes node --check and prints nothing.
  3. Render. Done when the file is opened via file:// and a screenshot shows labeled layer bands (empty bands still drawn), the Questions panel, and chapter controls when CHAPTERS is present. If browser tooling is unavailable, say so and keep checks 1–2 and 4–10.
  4. Node inspector. Done when every visible node has been selected and the inspector shows real What / How / source text. Fail on TODO, TBD, placeholder, lorem, replace me, or empty What/How.
  5. Packet routes. Done when each consecutive hop pair is a drawn edge in that state, and window.__ARCH.check() returns {ok:true}.
  6. Size. Done when wc -c on the file is under 250000.
  7. Violations. Done when every skip or wrong-way edge is rust, clickable, and the inspector names the skipped bands or illegal direction.
  8. Markdown twin. Done when the .md file was written by emitMarkdown(), lists every node, edge, packet, question, and Inside subsection from FILL, and a second emit is byte-identical.
  9. Questions ledger. Done when one open and one resolved QUESTIONS row both render in the HTML Questions panel and appear in the twin with answer and date on the resolved row.
  10. Chapters. Done when, with CHAPTERS present, the first chapter's nodes render alone (other nodes hidden, bands still drawn), and with the field absent or [] the chapter chrome is hidden and every state-visible node renders.
  11. Step inside. Done when headless enter shows the inside scene, an inside packet is live, Back restores the camera saved on enter, and window.__ARCH.insideProof() reports entered and cameraRestored.
  12. Inside twin. Done when the markdown lists an Inside subsection for every node that has inside, stages appear in order, inside packets include payloads, and a second emit is byte-identical.
  13. Absent inside. Done when a node without inside has no Go inside control, and selecting it still shows only What / How.

Habilidades Relacionadas