AI-written code drifts from the design when the agent builds the part in front of it without checking that part against the whole: a component goes unbuilt, gets half built, never gets mentioned, or appears where the design never put it. You find drift by matching each part the design gives your repository to the code that builds it, then listing what the code holds that the design doesn't.
This post names the four kinds of drift, gives you a check you can run by hand, and shows what an automated version of the same check reports. Why an agent departs from a design in the first place, and the fixes for that, are covered in the use case on keeping Claude Code on your architecture. This post starts after the code exists.
What drift is
The term is older than coding agents. In 1992, Dewayne Perry and Alexander Wolf separated two problems in Foundations for the Study of Software Architecture: architectural erosion, which comes from violations of the architecture, and architectural drift.
"Architectural drift is due to insensitivity about the architecture." (Dewayne Perry and Alexander Wolf)
In their account, drift costs a system its coherence and clarity, and that makes the architecture easier to violate later.
Generated code mostly drifts in this sense. An agent rarely sets out to break a decision. It writes code that works for the task it was given, without weighing what that code does to the rest of the design. Each change can pass its tests and still move the system away from the design, one reasonable step at a time.
For this post, drift is any difference between the design you agreed on and the code in the repository that nobody decided on. A difference someone decided on is a change to the design, and the design should say so.
Why it happens with generated code
Three things about how a coding agent works make drift likely once code starts to pile up.
Each session sees a slice. Claude Code's documentation says each session begins with a fresh context window. Whatever the agent knew about the design last time, it knows now only if something loads it again. The task in front of it is usually one endpoint or one feature, and a local problem gets a local fix: a counter inside the service, a cache next to the handler, a direct call where the design had a queue.
The agent's summary is not an inventory. At the end of a task the agent tells you what it did. That summary follows the task, not the design, so a part it skipped or only stubbed doesn't appear in it, and nothing prompts you to notice the gap.
Names change on the way into code. The design says "Notification worker"; the code has jobs/mailer.ts. When the names don't match, you can't tell by reading whether a part was built, renamed or replaced, and neither can the agent.
None of this shows in a single pull request. Drift shows when you compare the whole design with the whole repository.
Four kinds of drift: missing, partial, unreported, built outside the design
Every difference falls into one of four kinds. Naming them matters because each one asks for a different response.
- Missing. The design has a part, and the code doesn't build it yet. It is drift when someone believes it is done. Schedule it, or take it out of the design.
- Partial. The part exists but doesn't do what the design says: the worker is there but nothing puts jobs on its queue, or the store exists but nothing reads it. Half a component isn't a built one, so count it. Finish it, or record that the design asks for less.
- Unreported. Nobody has said whether the part was built. Unknown is not the same as missing, and it hides longest, because no one is asked about it. Find out.
- Built outside the design. The code holds a part or a connection the design doesn't: a new store, a second queue, a service calling another directly. This kind changes the architecture without a decision. Add it to the design with a reason, or take it out of the code.
One difference looks like drift and isn't: a part the design gives to another repository. If your design spans a web repository, an API repository and a worker repository, the API repository not building the worker is correct. Decide which parts each repository covers before you check, or every check reports the other repositories' parts as missing.
Connections count too, and so does their direction. If the design says the API puts jobs on a queue and the worker reads them, a worker that calls the API directly is a connection built outside the design, even though both parts exist.
Check for drift by hand
You need the design, the repository and a text file. Check one repository at a time.
- List the parts this repository covers. Copy each component and data store from the design that belongs here, by its design name.
- Find the code for each part. Write the file that builds it and a line from that file that shows it. If you can't name a file, the part is missing or unreported, not built.
- Mark each part. Built, partial or not started. A partial part gets one line saying what is absent.
- List the connections. For each connection in the design, write the caller, the callee, and the file where the caller's client lives.
- List what the design doesn't have. Look at what was added since the design was agreed. In git,
git diff --name-only --diff-filter=A <commit>..HEADlists the files added between that commit and now. Check the dependency manifest too: a new database driver or queue client usually means a new part or connection. - Decide each difference. Fix the code, or change the design. Don't leave a difference unrecorded.
Here is an inventory for a task-management API whose design puts rate limiting in the API gateway. The example is invented.
# Drift check: api repository, against design version 4 Covers: API gateway, Task API, Tasks database, Notification worker | Part | Status | Evidence | | ------------------- | ----------- | ---------------------------------------------- | | API gateway | built | gateway/routes.ts: "registerRoute(" | | Task API | partial | services/tasks/handler.ts: no tenant check yet | | Tasks database | built | db/migrations/001_tasks.sql | | Notification worker | not started | none | Connections - Task API -> Tasks database: built (services/tasks/repo.ts) - Task API -> Notification queue: not started Not in the design - Rate-limit Redis (services/tasks/limiter.ts) - Task API -> Rate-limit Redis Out of scope: Web app, Search index (other repositories) Two lines in that file need a decision. The Redis instance does a job the design gave to the gateway, inside a service instead. The Task API is half built, and no session summary would have said so.
The check follows the same steps every time, so it is worth automating once you have run it by hand and agree with what it finds.
What an automated check reports
SkeletIQ runs this check as the check_drift tool, which your coding agent calls over MCP after it builds part of a released design.
The agent sends the inventory: each component it covers as implemented, partial or not started, the evidence for each as a file plus a quote or symbol, and anything in the code that the design doesn't contain. It can declare which components this repository covers. The evidence is checked on your machine, and only the path and the outcome are sent. A component the agent calls built, with no evidence that checks out, is listed as unverified, and the report is not in sync. The comparison itself is deterministic: no model decides whether you drifted.
For the inventory above, the report reads like this:
Drift found: Not started (1): Notification worker (notification_worker) Half built (1): Task API (task_api) In the code but not the design: Rate-limit Redis Connections the design does not have: Task API → Rate-limit Redis 2 component(s) are outside this repository's declared scope. That is not drift — they are built elsewhere, or not yet. Checked against /home/you/api Version 4 (released). A component the agent never mentions is listed under "You did not mention". A component id belongs to one design version, so after the design is regenerated an old id comes back with up to three suggestions, and the report asks you to confirm with a person instead of mapping it.
For a design imported from code, the connector also scans the repository on your machine by default and starts no process. From the scan it sends the parts the design doesn't have (each one's name, kind and technology), the connections the design doesn't have (the two ends and the protocol), the ids of the design's parts it found and of the ones it could not find, the commit it scanned, and whether the scan was cut short or left files unread. The file paths behind each finding stay on your machine. The report counts and names the extra parts and connections it sent, and scan: false turns the scan off.
What a drift check must never do
A drift check is worth running only if you and the agent can trust its answers. That rules out a few shortcuts.
- Never change the design to match the code. A check that updates the design turns every drift into a decision nobody made. It reports, and a person decides.
- Never report another repository's parts as missing. A check that fails a correct build teaches the agent to ignore it. Scope comes first.
- Never guess which part an old name meant. When a part is renamed or re-created, offer candidates and let a person confirm. A wrong match gives a confident answer about the wrong part.
- Never count a claim as proof. "Built" without a file and a line that shows it is a claim. Report it as unverified.
- Never hide a cut. If a list is truncated, say how many items were left out, so a partial list doesn't read as a complete one.
- Never ship your source code to answer the question. Matching a part to its file needs a path and a yes or no, not the file's contents.
What to do next
- Write down which design parts each repository covers.
- Run the by-hand check once on your main repository, and decide every difference it finds.
- End each agent task with an inventory: every part it touched, its status, and the file that shows it.
- Turn a difference you never want to see again into a test or a dependency rule.
- To have your agent run the check against a released design, connect it over MCP.

