Ship It With AI Mihai Cvasnievschi

Map it first: architecture review

6 min read

By the end you can produce a corrected architecture map of a codebase nobody remembers, and use the run as an initial diagnostic before choosing a bounded next task.

TL;DR


The workflow

Make the agent read the code first, then correct what it wrote and commit the result.

Many teams own a codebase that fits one description: the author left, the README describes a build that no longer works, the code earns money and nobody wants to touch it. An agent can shorten the first investigation, but producing a map is not the same as becoming productive or understanding the business. The case below took minutes of agent work and a domain expert's review; other repositories take longer.

The prompt asks for nine sections, from purpose and data model to risks and unknowns, with file-and-line citations throughout; the full text is Appendix B.1. Choose the sections and depth the investigation needs. A document can look complete while its central business interpretation is wrong. If the codebase outgrows one context window, independent module investigations can justify subagents, with the orchestrator assembling the parts and checking their shared boundaries.


The case

The agent did not decide the rewrite was unnecessary. It gave the domain experts enough structure to decide faster.

A banking team owned a customer onboarding system: about sixty thousand lines of Java, written between 2018 and 2024 by a rotating cast of contractors. The team had been assembled in 2024 from three acquisitions, and nobody had been there for the original build. The README described a 2020 architecture, and the documentation listed two of the build's three steps. They were weighing a complete rewrite, estimated at eighteen months, because "nobody understands it well enough to maintain it confidently."

I asked for fifteen minutes and a terminal. I pasted the review prompt with two additions: the domain (customer onboarding, regulated banking) and a request to flag anything that looked compliance-sensitive. Eighteen minutes later there was a thirteen-page document, wrong in three places:

The corrected document went into the repository, and the team chose targeted work instead of the broad rewrite proposal. They replaced two modules the following quarter, including the deprecated dependency. The eighteen-month proposal and three-month replacement describe elapsed schedules, not comparable labor totals. Without the original staffing assumptions and a credible counterfactual, this account does not establish person-months saved or isolate the agent's effect from the experts' judgment.

Case note What this account establishes
Provenance Author-reported, anonymized banking engagement
Evidence The account, its three corrected mistakes and reported investigation times; original artifacts are not published
Comparison An estimated broad rewrite schedule versus the targeted work the team chose; staffing is unspecified
Limitations Avoided effort is an unmeasured counterfactual; experts corrected the map and chose the alternative
Transfer Use a reviewed map to challenge scope, then estimate the alternatives explicitly

Correct it

The agent's map is a draft, and the 45-minute estimate assumes a reviewer who knows the domain.

I had never seen that codebase, but I had built onboarding systems before, so I knew what a deduplication service and a regulated-banking compliance path usually look like. The agent's mistakes looked wrong to me. A reviewer new to both the codebase and the domain has no such prior: the misidentifications still look plausible, they cannot tell which to flag, and the correction takes hours, not 45 minutes. The workflow still works; the human side of it costs more.

Check the map against five things:


Commit it

The corrected document is the entry point for all later work.

Put it at docs/architecture.md. New hires read it first, senior engineers consult it before touching an unfamiliar part, and the agent opens it on demand, when a task touches a module it has not seen, instead of re-deriving the architecture. AGENTS.md holds a pointer to the file, not the layout (Chapter 6).


Delete with evidence

A removal is a claim; prove it before the agent deletes anything.

The map also makes cleanup safer, the work the Prologue's Slopfix sells. For each candidate, gather static references, runtime use (logs, metrics, flags, scheduled jobs), any fallback kept for incidents, and the owner's confirmation. Then open one small pull request per removal with the evidence linked, reviewed by the team that owns the code. OpenAI's account of its own cleanup with GPT-6 models, over 1,400 merged pull requests deleting more than 800,000 lines, names the traps: reflection that defeats static analysis, an unused path kept to mitigate future incidents, and proposals that added more complexity than they removed.


Review as diagnostic

An incoherent map is a reason to pause autonomous changes and investigate the cause. The run is an initial diagnostic, not a verdict on the codebase.

Time-box the first investigation, then decide whether another pass is likely to resolve a specific gap. Chapter 8's kill signals are the systematic rubric; a single map does not replace it.


When it breaks


Do this Monday


Go deeper