Getting Started
Requirements
Section titled “Requirements”- Node.js 18+ for the DiaScope package
d2installed and available on yourPATH
Install the CLI
Section titled “Install the CLI”npm install -g diascope1. Write a D2 diagram
Section titled “1. Write a D2 diagram”You can optionally annotate the diagram with # @step comments to mark narrative beats.
# @step step-01Client -> Server: POST /api/data
# @step step-02Server -> Database: SELECT ...
# @step step-03Database -> Server: result rowServer -> Client: 200 OK2. Scaffold the story file
Section titled “2. Scaffold the story file”diascope init auth-flow.d2By default this writes auth-flow.story.yaml.
3. Fill in the narration
Section titled “3. Fill in the narration”meta: title: "Auth Flow" d2_source: auth-flow.d2
steps: - id: step-01 tag: "01" title: "Client sends authenticated request" body: | The client attaches a short-lived JWT in the Authorization header. Tokens expire after 15 minutes and must be refreshed before expiry. nodes: - Client - Server4. Build a shareable HTML file
Section titled “4. Build a shareable HTML file”diascope build auth-flow.d2 auth-flow.story.yaml -o auth-flow.htmlopen auth-flow.htmlLocal package workflow
Section titled “Local package workflow”If you are working from the repository instead of the published package:
npm installnpm run buildnode dist/cli/index.js build auth-flow.d2 auth-flow.story.yaml -o auth-flow.html