Docs & Code Guide

When to regenerate an architecture diagram: event triggers beat calendars

Update the diagram every quarter is a policy that fails in both directions: after a big migration the diagram is wrong for ten weeks, and in a quiet quarter the review is wasted motion. The better policy keys regeneration to events, and it only became practical when regenerating stopped costing an afternoon. Here is the trigger list, the CI wiring, and which diagrams deserve which triggers.

7 min readFor teams deciding when diagram updates should happen, not just how

See it as a diagram

Everything below, as a diagram you can edit. Describe yours and see it in seconds.

233/20003 credits left
Try:

No account needed · Editable canvas, not a picture

Why event triggers beat calendars

Architecture changes arrive in bursts: a migration week rewires half the system, then months pass quietly. A calendar samples that process at fixed intervals, so it is almost always wrong, stale right after the burst and redundant during the quiet. An event trigger fires exactly when the truth changed, which is the only moment the diagram needs attention.

Calendars keep one job: the floor. A quarterly check catches the slow drift no single event announces, renamed teams, deprecated services still drawn as alive, and confirms the trigger wiring itself still works. If you want the cadence question answered on its own, how often should architecture diagrams be updated covers it; this page is about designing the triggers.

The trigger list

Five events cover most drift. First, a merge touching infrastructure paths: Terraform, Kubernetes manifests, Dockerfiles, compose files, CI deploy configs. These files are where topology actually changes, and a path filter makes the trigger mechanical.

Second, a new service, detectable as a new deployable unit: a fresh Dockerfile, a new Terraform module, a new entry in the deploy pipeline. New nodes are the single most common thing missing from old diagrams. Third, an incident postmortem: if the diagram was wrong or unhelpful during the incident, fixing it is a natural action item while the gap is fresh.

Fourth, the start of an onboarding cohort: new hires are the readers most damaged by a stale diagram and least able to detect it, so regenerate the overview before they calibrate on fiction. Fifth, the quarterly floor for anything no event has touched.

Wire the merge trigger with a path filter

The merge trigger is the one worth automating, and CI path filters make it precise: the job runs only when a push to main touches the paths where topology lives. The job checks out the repo and asks an agent connected to the Datadef MCP server to update the diagram from what the repository now declares.

To be precise about the mechanics: Datadef does not watch repositories and nothing auto-detects the change. The CI job is what invokes the agent, and the agent reads the repo and calls the diagram tools. Connecting an agent requires a Datadef API key, available on paid plans. The MCP diagram server guide covers the setup; the workflow below assumes the repo carries an .mcp.json declaring the server.

# .github/workflows/architecture-diagram.yml
name: architecture-diagram
on:
  push:
    branches: [main]
    paths:
      - 'terraform/**'
      - 'k8s/**'
      - 'docker-compose*.yml'
      - 'services/*/Dockerfile'
jobs:
  regenerate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - name: Update the diagram from the repo
        run: >
          claude -p "Read this repository's Terraform, manifests, and compose
          files, then update our platform diagram through the Datadef MCP
          server so it matches what this commit deploys."
        env:
          ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }}

Which diagrams deserve which triggers

Not every diagram earns every trigger. The system overview, the one in the README and the onboarding doc, wants the new-service trigger, the onboarding trigger, and the quarterly floor; per-merge regeneration would churn it for changes readers of an overview never see. The infrastructure and network views want the path-filtered merge trigger, because their whole value is matching what is deployed. A Terraform-derived diagram is the cleanest case: its source of truth is exactly the filtered path set.

Incident and failover views want the postmortem trigger plus any merge touching the components they draw, because their failure mode is the most expensive: being wrong during an outage. The rule underneath: the more a diagram is consulted under pressure, the more event-driven its updates must be.

Cheap regeneration changes the whole calculus

Event triggers were always the right policy; they were just unaffordable. When updating meant an engineer rearranging boxes for an afternoon, firing that cost on every infra merge was absurd, so teams rationally batched updates into quarterly sessions and lived with the drift between them.

One-command regeneration inverts the math. When the update is an agent call, the marginal cost of a trigger firing approaches the cost of reviewing a diff, so you can afford to fire liberally and let humans review the output rather than produce it. It also simplifies the drift question itself: instead of wondering whether the diagram is stale, regenerate and compare. Detecting stale diagrams covers that comparison in detail.

Regeneration is not auto-sync

A trigger is something you wire: a CI job, a scheduled run, or a habit tied to postmortems. Datadef gives you the one-command update; the trigger list above is what makes sure the command actually runs.

FAQ

When should an architecture diagram be updated?

On events rather than on a schedule: a merge that touches infrastructure paths such as Terraform or Kubernetes manifests, the addition of a new service, an incident postmortem that exposed a wrong or missing view, the start of an onboarding cohort, and a quarterly floor for anything untouched by events. The events catch bursts of change; the floor catches slow drift.

Can a diagram update itself when the code changes?

Not by itself. Datadef does not watch repositories and nothing auto-detects code changes. What works is wiring the update into CI or an agent workflow: a path-filtered job invokes an agent connected to the Datadef MCP server, the agent reads the repository and updates the diagram. The update is one command away, but something has to issue the command.

Which file paths should trigger a diagram regeneration in CI?

The paths where topology actually changes: Terraform or other IaC directories, Kubernetes manifests, Dockerfiles, docker-compose files, and deploy pipeline configs. A CI path filter on pushes to main scoped to those paths fires on real architecture changes and stays quiet for application code.

Should every merge regenerate the diagram?

No. Filter to merges touching infrastructure paths, and route triggers per diagram: infra views regenerate on those merges, the system overview on new services and quarterly, incident views after postmortems and on changes to the components they draw. Regenerating everything on every merge produces churn without accuracy gains.

How do I know whether a diagram is currently stale?

The direct method is to regenerate it from the current source and compare the result to the published version; anything that moved is drift. This is practical once regeneration is one agent command. Indirect signals, last-edit dates older than the last infra merge, or components mentioned in incidents but absent from the diagram, tell you which diagrams to test first.