No history yet

Mapping Brownfield Systems

Charting the Unknown

Integrating an AI agent into a new, pristine project is one thing. But most software development happens in "brownfield" systems—complex, mature codebases with years of history, hidden logic, and technical debt. Before you can ask an agent to write a single line of code, you must first teach it to read the map of the existing territory.

The first and most critical phase is system discovery. The goal is to build a structured understanding of the project's reality, from its high-level architecture down to its trickiest dependencies. Rushing this step leads to "vibe coding," where changes are based on assumptions rather than facts. This is how agents, like human developers, introduce breaking changes. A methodical discovery process ensures the agent respects the historical decisions and constraints embedded in the codebase.

Giving Your Agent a Compass

You can't just drop an agent into a repository with a million lines of code and expect it to understand everything. That's like handing someone a library and asking for a summary. Instead, you provide tools for efficient exploration. The first step is repository indexing, which creates a searchable map of the codebase. Using , the agent can query the codebase based on concepts, not just keywords, to quickly find relevant files and functions.

A powerful technique is to deploy automated research sub-agents. These are specialized AIs given a single, focused task. You might launch one agent to identify all external API calls, another to trace the user authentication flow, and a third to map database schemas. Each agent reports its findings, and together they build a comprehensive picture, piece by piece, far more effectively than a single, generalist agent could.

The findings from these sub-agents are compiled into a high-level overview document, sometimes called a CLAUDE.md or SYSTEM_OVERVIEW.md. This document serves as the project's "North Star." It doesn't contain code; instead, it lists key architectural invariants—the fundamental rules and constraints of the system that must not be broken. It might state, for example, that "user data must never be logged in plain text" or "the billing module must operate independently of the user profile service."

This high-level map is the planning context. It's the strategic overview. The specific file an agent is editing is the execution context. An effective agent uses the planning context to guide its actions within the execution context, ensuring that small changes align with the big picture.

Identifying Hidden Dangers

Legacy systems are often littered with hidden risks. An AI agent's dispassionate analysis is perfect for uncovering them. One of the most common problems is the presence of —massive, unwieldy classes that do far too much. They might handle data access, business logic, and UI rendering all at once. An agent can be tasked to flag classes with an unusually high number of methods, lines of code, or dependencies, pointing you directly to these ticking time bombs.

Another hidden danger is tight coupling, where modules are so interconnected that a change in one causes unexpected failures in another. Agents can perform dependency analysis to create a visual map of these connections. This reveals which parts of the system are fragile and allows you to predict the ripple effect of a proposed change before it's ever made.

By the end of this discovery phase, you don't have new features. You have something far more valuable: a clear, structured understanding of the system's reality. This knowledge base, built with the help of AI agents, is the foundation for any safe and effective modification, ensuring your AI collaborator builds upon the past instead of demolishing it.

Ready to test your knowledge? Let's see what you've learned about mapping brownfield systems.

Quiz Questions 1/6

What is the primary goal of the 'system discovery' phase when integrating an AI agent into a brownfield project?

Quiz Questions 2/6

What is the main risk of skipping a thorough discovery phase, leading to what the text calls 'vibe coding'?

With a solid map in hand, you are now prepared to guide an AI agent in making deliberate, intelligent changes to your codebase. The discovery phase is complete.