Development¶
Repository layout¶
.claude-plugin/ plugin and marketplace manifests
commands/ /explain-project, /architecture-history, /update-communications
skills/
explore-project/ how to explore, what to ask, the brief template
project-deck/ deck template, build and diagram scripts, guides
architecture-explorer/ explorer template, build and check scripts, references
architecture-history/ arch-history.mjs (versions, diffs, blame), history-core.js, the demonstration history
user-stories/ stories page template, build-stories.mjs, check-stories.mjs, extract-feedback.mjs
update-communications/ update-communications.mjs (recover, migrate, rebuild old pages), migrations.mjs
ontology/ the C4 ontology (c4.ttl, c4-data.ttl, c4-view.ttl, c4-history.ttl), SHACL shapes, alignments, guides, example extension
mcp/ the remote MCP server and its MCP Apps view, Dockerfile, Hugging Face Space, tests
examples/
image-annotation-tool/ test fixture and its generated output
docs/ this site (MkDocs Material); docs/landing is the home page, docs/img the screenshots used here and in the README
mkdocs.yml site configuration
INSTALL.md install steps for people and for agents
CHANGELOG.md what each release changed; its sections are the release notes
.github/ CI, docs and release workflows, release.mjs (checks, assets, notes), Dependabot
Test a change against the example¶
examples/image-annotation-tool/ is the test fixture. After changing a skill or a template,
run the plugin on it from a local clone:
cd examples/image-annotation-tool
claude --plugin-dir ../..
> /c4-model-agentic-plugin:explain-project
For explorer template changes, a rebuild of the existing model is enough. The example page has the model's real git
history embedded, so rebuild the history first (it reads git log, it does not change the repository):
node skills/architecture-history/scripts/arch-history.mjs timeline \
--project examples/image-annotation-tool --resolution all
node skills/architecture-explorer/scripts/build-explorer.mjs \
examples/image-annotation-tool/communications/architecture-explorer/model.js \
examples/image-annotation-tool/communications/architecture-explorer/index.html \
--root examples/image-annotation-tool \
--history examples/image-annotation-tool/communications/architecture-history/history.json
node skills/architecture-explorer/scripts/screenshot.mjs \
examples/image-annotation-tool/communications/architecture-explorer/index.html shots
The example's history (examples/image-annotation-tool/communications/architecture-history/) is demonstration
data: node skills/architecture-history/scripts/make-demo-history.mjs <dir> builds its repository (fictional authors,
the example growing one function at a time) in a new directory outside this one, and
arch-history.mjs timeline --resolution merges --pr 7 --demo --out <this repository>/examples/image-annotation-tool/communications/architecture-history
run there regenerates it. Rebuild the example explorer after it (above). See
History and diffs.
After a change to arch-history.mjs, run node skills/architecture-history/scripts/check-timeline-options.mjs: it
builds the demonstration repository in a temporary directory and checks how timeline combines --resolution,
--refs and --pr (the merge line with and without pull request #7, two refs plus the pull request, a merged pull
request recorded on its merge), and validates each dataset when a SHACL engine is found (pass
--rete-module mcp/node_modules/rete-graph/dist/index.js after npm ci in mcp/, or have pyshacl). It exits 1 when a
check fails; --keep keeps the directory.
check-model.mjs can also check the template on its own (node skills/architecture-explorer/scripts/check-model.mjs
skills/architecture-explorer/templates/explorer.html): it should report only the placeholder-model warning. On the
example it also prints a DATA line for the Data view (7 schemas, 30 entities, 140 fields, 75 lines, 0 across a card).
The schema importer is scripts/schema-import-core.mjs, shared by import-schema.mjs and the MCP server's
import_schema. After a change to it, run its tests (cd mcp && npm test, or only
node --test test/schema-import.test.mjs: the example's migration, vocabulary, JSON-LD context and COCO schema, and the
fixtures in mcp/test/fixtures/schema-import/), and check that the example still matches its migration:
cd examples/image-annotation-tool
node ../../skills/architecture-explorer/scripts/import-schema.mjs db/migrations \
--check communications/architecture-explorer/model.js # OK … 6 entities compared (schema db ↔ pg)
After a change to the template's Mermaid export (<script id="mermaid">), run
node skills/architecture-explorer/scripts/check-mermaid.mjs. Without arguments it checks the template's placeholder
model and the example: every view in flowchart TB, LR and C4 reads back to the same boxes, parents and arrows with
nothing to change (90 diagrams); 70 scripted edits (renames, new and moved boxes, arrows relabelled, dashed and
removed, and the merged or lifted arrows and type changes that must be refused) give exactly the expected changes and
skips and leave a valid model; and, with Chrome or Edge and Node 22, mermaid.js 11.17.2 draws all 168 diagrams
without an error. The render step loads mermaid.js from jsDelivr: offline, pass --mermaid <file> or --no-render;
--shots <dir> saves PNGs. model-to-mermaid.mjs writes the text of any view (--level, --open, --syntax,
--direction, --all) from a model, a page or a graph, as the page's Mermaid panel does.
Icons: scripts/icon-library.mjs is the icon code the scripts share (build-explorer.mjs, check-model.mjs,
suggest-icons.mjs, check-roundtrip.mjs, and the MCP server). It resolves tabler: and si: references from a
local npm package (simple-icons, @tabler/icons), else a disk cache per pinned version (%LOCALAPPDATA%\c4-model-agentic-plugin\Cache\icons
on Windows, ~/Library/Caches/c4-model-agentic-plugin/icons on macOS, $XDG_CACHE_HOME/c4-model-agentic-plugin/icons
elsewhere; --icon-cache <dir> or C4_ICON_CACHE to choose), else jsDelivr at the pinned versions (Tabler Icons
3.51.0, Simple Icons 16.37.0). --no-fetch keeps a build or a suggestion run off the network (the MCP server:
C4_ICONS_NO_FETCH=1); icons not in the cache then draw as placeholders and check-model.mjs warns. The built-in
glyphs are the template's <script id="icons"> block. node skills/architecture-explorer/scripts/suggest-icons.mjs
<model.js> [--apply-to copy.js] [--all] [--json] [--no-fetch] proposes an icon per box and schema with the reason; on
the example it finds 13 logos, 20 word matches and 38 type defaults for 71 boxes and schemas, and keeps the 25 icons
already there.
After a change to the RDF mapping (<script id="rdf">) or to the ontology, check that the graph still recreates the
pages, for the example and the placeholder model (Turtle and JSON-LD need the rete-graph npm package; screenshots
need Chrome or Edge; with a data layer they include the Data view):
node skills/architecture-explorer/scripts/check-roundtrip.mjs \
examples/image-annotation-tool/communications/architecture-explorer/model.js \
skills/architecture-explorer/templates/explorer.html
and that the exported graph still passes the shapes:
pyshacl -s ontology/c4-shapes.ttl -df turtle examples/image-annotation-tool/communications/architecture-explorer/architecture.ttl.
The MCP server reads the template at startup, so a template change also deserves its tests (Node 20+, Chrome or Edge):
cd mcp && npm ci && npm test (C4_MCP_OFFLINE=1 skips the live GitHub test). They write screenshots of the view to
mcp/test/output/; see mcp/README.md.
Screenshots in these docs¶
The images in docs/img/ are taken with screenshot.mjs at 1500 × 900 in the light theme, from URL states, and
saved as 256-colour PNGs to keep them small (Pillow: Image.open(f).convert('RGB').quantize(256,
method=Image.Quantize.FASTOCTREE); the default median cut shifts small areas such as the flow colours in a legend):
- the explorer ones from the example's model, built without
--history(so the panel shows the introduction), for example"level=2&theme=light","level=2&flows=annotate,review&theme=light"or"view=dynamic&scenario=annotate&style=seq&at=2&step=1&theme=light". A menu, the image viewer or edit mode is opened by a copy of the page, in a temporary folder, with a short script that clicks the button (or callsARCH_EXPLORER.api.openImages) oncedata-explorer="ready"; - the history ones from the example built with its history (demonstration data: the nine versions of the merge
line and the open pull request #7),
"level=1&ver=<#7>&cmp=<v1.0>&theme=light","level=2&ver=<#7>&hist=open&hx=<#7>&theme=light"and"level=3&sel=api&zoom=api&ver=<#7>&cmp=<v1.0>&beyond=0&theme=light", where<#7>and<v1.0>stand for the short SHAs of the pull request and the release (they change whenever the example's model does); - the Data view ones (
explorer-data*.png) the same way but at twice the resolution (Chrome's--force-device-scale-factor=2, 3000 × 1800), because the cards' text is small:"view=data&theme=light","view=data&entity=tasks&theme=light","view=data&flows=upload,export&dzoom=pg&theme=light", and"view=data&entity=images&theme=light"with the panel scrolled to its Used in heading by a page copy; explorer-icons.png("level=2&icons=brand&theme=light") andexplorer-connections.png("level=2&labels=box&rel=2&theme=light") the same way, from a page built from the example's model (its library icons come from the cache or jsDelivr at build time);explorer-mermaid.pngthe same way,"level=2&mmd=flowchart&panel=closed&theme=light"(the preview needs the network: the page loads mermaid.js from jsDelivr when the panel opens);history-data-*.pngfrom the same page, also at twice the resolution:"view=data&entity=images&ver=<#5>&cmp=<v0.1>&dzoom=pg&theme=light"(three columns added) and"view=data&ver=<v1.0>&cmp=<#6>&dzoom=pg&theme=light"(a table renamed);mcp-widget.pngismcp/test/output/widget-01-inline-map-level2.pngfrom the MCP tests;- the deck ones from the example deck;
stories-*.pngfrom the example's user stories page, at 1600 × 900 and 1.5 × in the light theme, driven over the Chrome DevTools protocol the waycheck-stories.mjsdoes: a note by a fictional "Demo reader" (the captions say DEMO DATA), drawn while recording with Chrome's fake microphone, then given a transcript by importing it as JSON (headless Chrome has no speech recognition); the replay is paused just after the arrow's time. The overview is taken about 2.2 s after its cards scroll into view, so the cards with two screens show their second; the canvas one adds a second Demo reader note on the phone view, then shows All views, zooms on the annotator's lane with the wheel and hovers the phone view.
Build these docs¶
The site is MkDocs with the Material theme. These keep it from duplicating the repository:
- Reference pages include the skills' guides with
pymdownx.snippets(--8<-- "skills/..."), so they are edited in one place. docs/hooks.pycopies the example's generated explorer, deck and user stories page into the built site underdemo/. The pages under Example show them in a frame, under an example bar (docs/overrides/example.html).- The empty explorer is a built page,
docs/playground/index.html, made fromdocs/playground/model.js(an empty model) withnode skills/architecture-explorer/scripts/build-explorer.mjs docs/playground/model.js docs/playground/index.html --no-rdf. Rebuild it whenever the template changes:mcp/test/agent-tools.test.mjsfails while it is out of date. The hook publishes it full screen atexplorer/(the guide isexplorer-guide/) with a small script that sends old guide links (explorer/#mermaid) on toexplorer-guide/#mermaid. WithWEBMCP_ORIGIN_TRIALset in the build's environment (orextra.webmcp_origin_trialinmkdocs.yml), it adds that WebMCP origin-trial token to the empty explorer and the example's pages (Agents in the page). - The agent tools' reference is generated:
node skills/architecture-explorer/scripts/list-tools.mjs --writewritesskills/architecture-explorer/references/agent-tools.mdfrom the template's tools, and Agents in the page and Reference → Agent tools include it. - The ontology is published from
ontology/: the hook adds everyontology/**/*.ttlto the site as is (/ontology/c4.ttl), and generates the term pages (core, data, view, history) from the Turtle files with rdflib, so the namespace IRIs land on a section per term. Each of those pages names its Turtle file in an HTML comment (terms:and the path), which the hook replaces with the terms.
Preview locally, from the repository root:
Build exactly as the publishing workflow does:
Publishing on GitHub Pages¶
.github/workflows/docs.yml builds the site on every push to main and deploys it to GitHub Pages; pull requests
only build it. One-time setup: in the repository's Settings → Pages, set Source to GitHub Actions.
Continuous integration¶
.github/workflows/ci.yml runs on every push to main and every pull request, in three jobs:
| Job | What it checks |
|---|---|
| Scripts, models and built pages | The versions agree (.claude-plugin/plugin.json, mcp/package.json, CHANGELOG.md); every script parses; the explorer template and the example's model validate (check-model.mjs, the example with --root and --strict); the Mermaid and RDF round trips; the example's user stories; and the committed explorer pages (docs/playground/index.html, the example's index.html, .jsonld, .ttl) are exactly what build-explorer.mjs builds now. It also packages the release assets as a dry run (the release-preview artifact). |
| Pages and agent tools in headless Chrome | npm test in mcp/ (the server, the widget, the WebMCP tools, the agent tools, the deck) and check-stories.mjs on the example's user stories page. Screenshots are kept as the screenshots artifact. |
| MCP server image | mcp/Dockerfile builds and the container answers /healthz. |
When the built-pages check fails, rebuild and commit:
node skills/architecture-explorer/scripts/build-explorer.mjs docs/playground/model.js docs/playground/index.html --no-rdf
E=examples/image-annotation-tool/communications
node skills/architecture-explorer/scripts/build-explorer.mjs $E/architecture-explorer/model.js $E/architecture-explorer/index.html --root examples/image-annotation-tool --history $E/architecture-history/history.json
The user stories page is checked but not compared byte for byte: it carries the time it was built.
.github/dependabot.yml opens grouped pull requests for the actions and the MCP server's packages every week, and for
its base image and the docs' Python packages every month.
Releases¶
A release is a version tag. .github/workflows/release.yml runs on a pushed vX.Y.Z tag (or by hand on a tag:
Actions → Release → Run workflow, "Use workflow from: Tags"). It runs the CI checks, checks that the tag matches
the version, then publishes:
- a GitHub release whose notes are the version's section of
CHANGELOG.md, with what each download is and how to install it, and these assets, each with a build provenance attestation (gh attestation verify <file> -R caviri/c4-model-agentic-plugin):c4-model-agentic-plugin-X.Y.Z.zip: the plugin as Claude Code loads it (claude --plugin-dir);example-image-annotation-tool-X.Y.Z.zip: the example's pages, to open from disk;empty-explorer-X.Y.Z.html: an empty explorer, to start a model in the browser;SHA256SUMS.txt;
- the MCP server's image,
ghcr.io/caviri/c4-explorer-mcp:X.Y.Z(andX.Y, andlatestfor a final release). The first push creates the package as private: make it public in the package's settings.
A tag with a suffix (v0.2.0-rc.1) makes a pre-release and leaves latest alone. Running the workflow again on the
same tag replaces the assets and the notes.
To cut a release:
- Set the version in
.claude-plugin/plugin.jsonandmcp/package.json(the same one). - In
CHANGELOG.md, give the version's section its date (## [0.2.0] - 2027-01-15), and add the link at the bottom. -
Check and preview the assets locally:
-
Commit, then tag and push the tag:
The same commit always packages to the same bytes: entries are sorted and dated with the commit's date.