Set up the drift check with your agent
Hand one request to your coding agent and it draws the repository's diagrams from its own files, adds the GitHub Action that checks them on every pull request, and opens a pull request. The organisation's Drift tab in the portal gives you the request with your organisation in it, ready to copy for your agent.
- GitHub Actions
- Claude Code
- Codex
- Cursor
TL;DR
| Question | Answer |
|---|---|
| Where do I get the command? | In the portal, open the organisation, then Drift. Choose your agent and press Copy. |
| Which agents? | Claude Code with the Plotwork plugin, Claude Code, Codex, the Cursor CLI, Gemini CLI, and any other agent that can read a web page and edit files. |
| What does the agent do? | It names the sources in plotwork.config.json, draws the diagrams with the command line, checks them, writes .github/workflows/diagrams.yml, and opens a pull request. |
| Does it see my API key? | No. The agent is told never to ask for a key and never to write one into a file. You set the repository secret yourself. |
| Does anything leave my machine? | The command line draws on your machine and sends nothing. The agent reads this page. Only the Action's report, once the secret is set, reaches Plotwork. |
| What if I do not use an agent? | Follow the steps below yourself, or read Keep diagrams in sync in CI. |
1. Copy the command
The request is one sentence that points the agent at this page as Markdown. Each agent takes it its own way:
| Agent | Run |
|---|---|
| Claude Code, with the Plotwork plugin | Type /plotwork:setup-ci acme in Claude Code. The plugin's skill carries the steps itself. |
| Claude Code, with the Plotwork MCP server | Type /mcp__plotwork__set-up-drift-check acme, or pick Set up the drift check from the prompts. |
| Claude Code | claude "<the request>" in the repository's folder |
| Codex | codex "<the request>" |
| Cursor | cursor-agent "<the request>" |
| Gemini CLI | gemini -i "<the request>" |
| Any other agent | Paste the request into its chat. |
Replace acme with your organisation's address name. The Drift tab fills it in for you. The request holds no double quote, dollar sign or backtick, so it is safe inside the shell's double quotes.
2. Set the secret
The check runs on every pull request without a key. To have each run appear on the organisation's Drift tab, the Action needs an organisation key:
- In the portal, open the organisation, then Keys, and make a key.
- Set it as the repository secret
PLOTWORK_API_KEY, withgh secret set PLOTWORK_API_KEY(it asks for the value) or in the repository's Settings, Secrets and variables, Actions.
Never paste the key into the agent's chat.
Steps for an agent
An agent that reads this page follows these steps, in order.
-
Look before you write. Find the files Plotwork draws from: Terraform, OpenAPI documents, Compose files, Kubernetes manifests, SQL, Prisma or Drizzle schemas, GitHub Actions workflows and CSV data. Skip installed dependencies, build output and any file that holds secrets, such as
.env. Ifplotwork.config.jsonor.plotwork/config.jsonalready exists, add to it instead of replacing it. -
Name the sources. Write
plotwork.config.jsonat the repository root with"$schema": "https://docs.plotwork.dev/schemas/plotwork.config.json","defaults": { "scheme": "auto" }, and one entry insourcesfor each diagram:name,from(a path or a glob),format, andout(docs/diagrams/<name>.diagram, or adiagramfence of a Markdown page the repository already has, writtendocs/architecture.md#<name>).npx -y @buun_group/plotwork@0.2.0 import-source --helplists the formats. Draw one diagram for each stack, service map or schema; three diagrams people read beat a dozen they do not. -
Draw them. Run
npx -y @buun_group/plotwork@0.2.0 generate. Fix each problem it prints (a code such as S103 names the line of the settings file), then runnpx -y @buun_group/plotwork@0.2.0 generate --checkuntil it passes. Read the outline of each diagram withnpx -y @buun_group/plotwork@0.2.0 outline <file>and check it shows what the files say. -
Add the check. Write
.github/workflows/diagrams.ymlas below. Keep theuses:line exactly as written: it pins the release by its commit.yamlname: diagrams on: pull_request: push: branches: [main] permissions: contents: read jobs: drift: runs-on: ubuntu-latest steps: - uses: actions/checkout@v7 with: persist-credentials: false - uses: plotwork-official/plotwork-action@86ae8278fa771a422d9df60185182f14b8be4db9 # v1.1.0 with: command: generate mode: check report-drift: true env: PLOTWORK_API_KEY: ${{ secrets.PLOTWORK_API_KEY }} -
Leave the key to the person. The report to the organisation's Drift tab needs an organisation API key in the repository secret
PLOTWORK_API_KEY; the check itself runs without one. Never ask for the key in the chat and never write it into a file. Ask the person to make the key in the Plotwork portal, under the organisation's Keys and CI, and to set the secret themselves, withgh secret set PLOTWORK_API_KEY(it asks for the value) or in the repository's Settings, Secrets and variables, Actions. To sign CI in with no key, the organisation can trust the repository instead, under Keys and CI, Trusted publishers (https://docs.plotwork.dev/trusted-publishers (opens in a new tab)); tell the person it exists, and keep the key in the workflow unless they ask for that. -
Open a pull request. Commit the settings file, the diagrams and the workflow on a new branch, and open a pull request titled "Add Plotwork diagrams and the drift check" that lists each diagram and the files it is drawn from. Once it merges and runs with the secret set, the repository appears on the organisation's Drift tab.
See also
| Page | What it covers |
|---|---|
| Keep diagrams in sync in CI | Every input of the Action, and the workflow that redraws diagrams and opens a pull request |
| Diagrams as code | The sources of the settings file, overrides, and generated diagrams |
| The drift dashboard | What the Drift tab shows once runs report |
| Claude Code plugin | Installing the plugin and its skills |