Docs & Code Guide

How to detect stale architecture diagrams: five signals you can check today and one you can automate

A diagram does not announce that it has gone stale. It keeps rendering, confident and wrong, until a new engineer builds a mental model from it or an incident review finds the queue it never mentioned. Staleness does leave evidence, though. Here are five signals you can check by hand in a few minutes, and one you can wire into CI so the check runs itself.

7 min readFor engineers who suspect the architecture page is lying

See it as a diagram

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

203/20003 credits left
Try:

No account needed · Editable canvas, not a picture

Signal 1: the diagram is older than the infrastructure

The cheapest check is two dates. When the diagram lives in the repo, compare its last commit against the last commit touching the infrastructure directory: git log -1 --format=%cs -- docs/architecture.png against the same command for infra/ or terraform/. When it lives on a wiki, compare the page history against your deploy log or the merge dates of recent infrastructure PRs.

One infra change since the last diagram edit proves nothing, because plenty of changes are invisible at diagram altitude. Three or more merges that added, removed, or renamed a component since the diagram was touched is a different story. The date gap does not tell you what is wrong, only that nobody has looked since things moved.

Signal 2: node names that no longer grep

Every label on an architecture diagram should correspond to something findable in the codebase: a service directory, a Terraform resource, a Helm release, a topic name. Pick five node labels and grep the repo for each. A diagram node called billing-worker while grep -r billing-worker returns nothing is a confirmed lie: the service was renamed, merged into another, or deleted, and the diagram kept it alive.

Run the check in reverse too. List the directories under services/ or the entries in your service catalog, and look for names the diagram does not carry. Missing components are more dangerous than ghost ones, because a reader cannot be confused by a box that is not there. They simply never learn the component exists.

Signal 3: component counts that disagree with the source of truth

Counting is cruder than grepping but faster at scale. terraform state list | wc -l gives you what Terraform manages. kubectl get deployments -A gives you what actually runs. Your service catalog gives you what the org believes it owns. Count the boxes on the diagram and compare. Exact equality is not the goal, a diagram legitimately abstracts. A diagram showing 12 services in front of a catalog listing 31 has stopped abstracting and started omitting.

The same check works per zone: if the diagram shows two components in the ingestion layer and the pipeline code defines six sources, the stale region is localized, which also tells you where to start fixing.

The automatable signal: diff the component list in CI

The count check becomes a real gate once the diagram maintains a machine-readable component list next to it, one name per line. A CI job then diffs that list against what Terraform reports and fails the build when they diverge. Scope the state query to the resource types that appear on the diagram, ECS services, Cloud Run services, Kubernetes deployments, whatever your unit of box is.

Be honest about what this verifies: presence, not correctness. The gate catches an added or deleted service, which in practice is most diagram drift. It cannot catch a wrong arrow. Treat a red build as a prompt to regenerate the diagram, not as proof the picture is otherwise fine.

# ci/check-diagram-components.sh
# Fails when the diagram's component list drifts from Terraform state.
terraform state list \
  | grep -oP 'aws_ecs_service\.\K\w+' \
  | sort -u > /tmp/live-services.txt

sort -u docs/architecture-components.txt > /tmp/documented-services.txt

if ! diff -u /tmp/documented-services.txt /tmp/live-services.txt; then
  echo "Architecture diagram no longer matches Terraform state." >&2
  exit 1
fi

Signal 5: no last-verified badge, or an old one

A last-verified badge is a visible line on the diagram or the page around it: verified against production on 2026-08-01 by a named person. It is deliberately distinct from last-edited. An edit can be a typo fix; verification is a human attesting that the picture still matches the system. The badge gives readers a trust signal and gives you a number to gate on: a freshness check in CI can fail when the badge date is older than 90 days, the same pattern as the freshness gates in a docs pipeline.

The absence of any badge is itself the signal. A diagram that has never recorded a verification has, statistically, never had one.

The five manual signals in one pass

Compare diagram date to infra change dates, grep five node labels, list catalog entries missing from the diagram, compare component counts per zone, and check the last-verified badge. Fifteen minutes, and you know whether the diagram deserves trust.

When a signal fires: repair once, not per copy

Detection is only useful if repair is cheap, and repair has two halves. The first is redrawing. With Datadef's MCP server (registry name io.datadef/mcp), an agent like Claude Code or Cursor connected to your repo can update the diagram from what the code actually contains: run it after the CI gate goes red, on a schedule, or during review. To be precise, Datadef does not watch your repository and nothing detects code changes by itself. The regeneration is one agent call or one CI command away, which is exactly why the detection signals above matter. Connecting an agent needs an API key, available on paid plans.

The second half is propagation, and that one is automatic. A diagram embedded by URL in your README, Notion, or Confluence follows its source: Datadef serves the image with a five minute cache lifetime, so the repaired diagram shows up everywhere it is embedded within minutes. The embed URLs exist only for projects shared public, a real trade-off for confidential architectures. For the decision of when redrawing is worth it at all, see when to regenerate an architecture diagram, and for the wider problem beyond diagrams, stale documentation.

FAQ

How do I know if an architecture diagram is outdated?

Check five signals: whether the diagram was last touched before recent infrastructure merges, whether its node labels still grep to anything in the repo, whether its component count matches Terraform state or the service catalog, whether whole regions omit components the code defines, and whether it carries a recent last-verified badge. Any two of these failing together is near-certain staleness.

Are there tools that automatically flag stale docs when code is updated?

For links and metadata, yes: CI link checkers and freshness gates fail builds on broken links or old last-reviewed dates. For diagram content, no mainstream tool watches your repo and flags divergence out of the box. The practical equivalent is a CI job that diffs the diagram's component list against terraform state list or the service catalog, plus an agent-invoked regeneration step. Datadef's MCP server supports that loop, but it is invoked by your CI or your agent, not by automatic repo watching.

Can CI detect a stale architecture diagram automatically?

Partially. A CI job can diff a machine-readable component list kept next to the diagram against terraform state list or kubectl get deployments, and fail when a service appears or disappears. That catches presence drift, which is most drift. It cannot verify that arrows and groupings are still right; that needs regeneration or human review.

What is a last-verified badge on a diagram?

A visible date and name recording the last time a human confirmed the diagram matches the running system, kept separate from the last-edited date. It gives readers a trust signal and gives CI a number to gate on, for example failing when the verification is older than 90 days.

How quickly do architecture diagrams go stale?

As fast as the architecture changes. A team merging infrastructure changes weekly can invalidate a hand-drawn diagram within a sprint or two. The mitigation is not drawing more often but making regeneration cheap enough to run after every meaningful change.