Skip to content
Connect an agent

Use the CLI

Command line quick start

From an empty page to a diagram that CI keeps in step, in five steps. You need Node 22 or newer and a repository with a Markdown file.

TL;DR

QuestionAnswer
What do I install?Nothing. npx fetches the pinned release the first time and keeps it in its cache.
What do I write?A diagram fence in a Markdown file.
What draws it?npx -y @buun_group/plotwork@0.10.0 sync README.md, which writes one SVG that follows the reader's light or dark setting and the picture block under the fence.
What do I commit?The Markdown file and the SVGs it wrote.
What fails CI?sync --check, when the source changed and the picture did not.

1. Write a diagram

Add a fence to README.md:

Markdown
```diagramflow "Checkout" direction=downnode shop service "Shop"node pay service "Payments"node db database "Orders DB"shop -> pay : "charge"pay -> db : "record"```

The fence is the source. The language is in Writing diagrams, and the Language reference has every statement.

2. Check it

sh
npx -y @buun_group/plotwork@0.10.0 validate README.md

A mistake prints its line and column in the file, a code, and a hint that says how to fix it. The command exits 0 when every diagram is valid and 1 when one is not.

3. Draw it

sh
npx -y @buun_group/plotwork@0.10.0 sync README.md

sync writes assets/diagrams/checkout.svg beside the page, named after the diagram's title: one SVG that shows the light or the dark scheme to match the reader's setting. It folds the fence into a "Diagram source" block and writes a picture block under it, with a text description for a screen reader. GitHub, GitLab, and every Markdown viewer show the picture, and the fence stays in the page as the source. Markdown and GitHub shows what the block looks like.

Run sync again after any change to the source. A fence whose picture is already current is left alone.

For a light and a dark file instead, which GitHub picks between by its own theme setting, put a plotwork.config.json beside the page with { "defaults": { "scheme": "light-and-dark" } }. See One picture for both themes.

4. Commit both

sh
git add README.md assets/diagramsgit commit -m "docs: add the checkout flow"

5. Check it in CI

Add one step to your pipeline:

sh
npx -y @buun_group/plotwork@0.10.0 sync --check README.md "docs/**/*.md"

It writes nothing and exits 1 when a picture is missing or older than its source, or a diagram has a mistake, so a pull request that changes a diagram without redrawing it fails. Quote a glob so the command line expands it the same way in every shell. CI usage has the step for GitHub Actions, GitLab CI, Azure Pipelines, Jenkins, and CircleCI.

Next

ToRun
Set defaults, such as the direction of every flow, for the whole repositoryAdd plotwork.config.json. See Configuration.
Draw your Terraform, OpenAPI, or database schema and keep it in stepplotwork generate. See Diagrams as code.
Move Mermaid diagrams to Plotworkplotwork import README.md --write. See Migrating from Mermaid.
Change a picture you already haveplotwork read picture.svg > picture.diagram. See Editing an existing diagram.

See also

DocWhy
Overviewnpx or install, and what each command is for
Command referenceEvery command, option, and default
TroubleshootingWhen a step does not do what this page says