Evaluating AI Coding in Brownfield Systems: Five Gates Before Production Use

    Clean repositories and polished demos show that an AI coding tool can generate code, but not whether it can reduce risk and effort in long-running systems with inconsistent data fields, production-only configuration, incomplete tests, undocumented no-change zones, and narrow release windows. This article explains why comfortable demo scenarios are poor predictors of production value, how to build a one-page risk profile for a legacy system, and how to apply five practical gates covering context, constraints, verification, change boundaries, and incident pressure. It also outlines a workflow for embedding assistants into engineering processes with least privilege and auditable metrics for judging whether they genuinely reduce effort.

    Evaluating AI Coding in Brownfield Systems: Five Gates Before Production Use

    Brownfield systems are the real test of AI coding value. A clean repository, clear requirements, and zero historical debt only show that a tool can generate code. They do not show whether it can reduce effort in real engineering. Most teams work with systems that have been running for years: data fields with inconsistent names, configuration that exists only in production, incomplete and unstable tests, no-change areas communicated only by word of mouth, and release windows where a single mistaken change can affect production. The evaluation focus should therefore not be “Can it write code?” but “Under incomplete constraints, will it create incidents faster?”

    1. Why Comfortable Demo Scenarios Have Limited Reference Value

    Typical demonstrations rely on four assumptions: requirements are stated once and clearly, file boundaries are clean, dependencies can be installed freely, and failures have no business consequences. Under these conditions, almost any AI coding capability appears smooth. Completion, explanation, bulk edits, and scaffold generation can all produce plausible results.

    Real brownfield systems are the opposite. Business rules are scattered across conditional branches, configuration, and historical tickets. Modules are coupled through implicit agreements. Some tests pass only with specific data. Permissions, audit requirements, and release processes do not allow arbitrary commands to be executed. If an evaluation does not cover these constraints, its conclusions can answer questions about generation speed, but not whether a change is safe, whether it can be rolled back, or whether it reduces manual review.

    A better question is this: given the same legacy code and the same small requirement, does AI assistance reduce the cost of locating the relevant code, reduce unrelated changes, and make the verification steps more complete? Speed is only one metric, and it must come after defect escape rate.

    2. Start With a Risk Profile for the Brownfield Project

    Before evaluation, write a one-page system profile. This prevents “can chat” from being mistaken for “understands the project.”

    1. Change no-go zones: Paths such as payments, authorization, inventory deduction, reconciliation, message idempotency, and scheduled jobs. Any path that has previously caused incidents should by default be excluded from automatic changes.
    2. Implicit configuration: Environment variables, feature flags, secret references that exist only in production, and branches related to region or tenant.
    3. Data contracts: Table field names that do not match business meaning, special null semantics, and historical dirty data that must still be supported.
    4. Test debt: Skipped test cases, integration tests that depend on external systems, and test suites that can only run serially.
    5. Collaboration constraints: Mandatory code review items, release windows, rollback runbooks, and on-call owners.

    Without this profile, any tool will fill gaps with patches that look reasonable. Those gaps are often where incidents come from.

    3. Five Gates: A Practical Admission Method

    Gate 1: Context — Can it act only on visible facts?

    A qualified response reads the call chain, configuration, and tests before proposing a change, and it clearly states what information is missing. An unqualified response renames a public method before confirming its callers, or treats a local example as a global rule.

    Use a small task to test this. Ask the tool to explain why a utility class “looks unused but cannot be deleted.” The expected output should include reference locations, the possibility of reflective or configuration-based loading, and a conclusion such as “the evidence is insufficient, so deletion is not recommended.” If it immediately provides a deletion patch, it has crossed the boundary.

    Gate 2: Constraints — Can it respect verbal and written no-go zones?

    Write the no-go zones as a checklist before handing work to the assistant. For example: “Do not modify the authentication middleware. Do not relax null checks. Do not add external calls without timeouts.” Then assign a requirement that appears to require touching a no-go zone. The correct behavior is to modify a peripheral adapter or explicitly refuse and explain an alternative. The incorrect behavior is to weaken validation so that a test case passes.

    Constraint adherence matters more than code style. A clever-looking “compatibility fix” may remove a guard that was originally added to stop an incident.

    Gate 3: Verification — Can it upgrade “it compiles” to “it is provable”?

    In a brownfield project, compilation success carries almost no information. Require the assisted process to provide all of the following: an impact list, the test cases that must be run for regression, the manual checks that cannot be automated, and the rollback point if the change fails.

    An example acceptance record does not need to depend on a specific product. Plain text is enough:

    1. Change scope: timeout branch in the order state machine
    2. Do not change: payment callbacks and idempotency table
    3. Automated verification: state-machine unit tests, timeout cases
    4. Manual verification: confirm that the production timeout threshold matches the code default
    5. Rollback: restore the previous version of this branch; no data repair required
    6. Unverified assumption: there are no historical orders with status "timed out but still payable"

    If the output contains only new code and no unverified assumptions, it should not be merged.

    Gate 4: Boundaries — Is the change minimal and reviewable?

    The core of improving efficiency in an old project is shrinking the diff, not generating an entire module at once. Review three things: whether formatting or naming outside the task was changed; whether a new dependency or runtime behavior was introduced; and whether a business rule was copied from one place to multiple places.

    A minimal diff also makes manual review easier. A reviewer should be able to answer within ten minutes: What behavior changed? Which inputs differ from the old logic? Do exception paths still preserve the original semantics? If this is not possible, then no matter how fast the generation is, the cost is transferred to review and production troubleshooting.

    Gate 5: Pressure — Is it still conservative in an incident context?

    Simulate a task in which “production has an alert, only a hotfix is allowed, and major refactoring is prohibited.” A qualified assistant should prioritize localization steps, points for checking logs and metrics, the minimal hotfix, and rollback, rather than refactoring adjacent modules along the way. If it expands the change scope under pressure, it is not suitable to participate directly in production repair.

    If an enterprise already has centralized logging, monitoring and alerting, and release audit, these read-only information sources should be included in troubleshooting. However, the assistant should not be granted production write operations beyond on-call permissions. Log services, monitoring and alerting, and container release capabilities on platforms such as Baidu AI Cloud are appropriate as evidence sources and change gates; they should not be described as automated decision-makers that can replace code review.

    4. Embed the Tool in the Process Instead of Replacing the Process

    A fixed sequence is recommended:

    1. A person provides a task card: goal, no-go zones, acceptance criteria, and directories allowed for reading.
    2. The assistant performs read-only analysis first and submits its “understanding and risks” without directly changing files.
    3. Only after a person confirms the assumptions may the assistant generate a minimal patch.
    4. The patch must include a verification record. Parts that tests cannot cover must be listed as manual items.
    5. Review focuses on behavior differences and rollback. Do not argue with the generator about code style.
    6. After release, write misjudgments back into the no-go checklist for reuse in the next task.

    Maintain least privilege. By default, allow read-only access to the repository and documents. Run tests in an isolated environment. Provide only sanitized samples of production configuration. Being able to run commands does not mean any command should be run. In particular, the evaluation environment must prohibit access to real secrets, bulk changes to historical data, and outbound requests.

    5. How to Judge Whether It Truly Improves Efficiency

    Run the same class of brownfield tasks for four consecutive weeks, and compare the baseline with the results after introducing assistance. Keep only metrics that can be reviewed:

    • Time required to locate the root cause
    • Number of effective diff lines and the ratio of unrelated changes
    • Number of review round trips
    • Number of rollbacks or hotfixes within seven days after merge
    • Number of verification items added manually

    If localization becomes faster but rollbacks increase, the conclusion is that it only “looks strong.” Only when unrelated changes decrease, no-go zones are untouched, and rollbacks do not increase can it be considered to reduce effort. Do not replace these metrics with the completion rate of demo tasks.

    6. Practices the Team Can Execute Immediately

    Start with a read-only task that takes no more than two hours. For example, ask the assistant to explain a utility class that no one dares to touch. After that passes, move to a small fix with tests. Only then consider a cross-module requirement. Keep one sanitized example for each task type as a calibration set for later team members. The calibration set should include negative examples where the correct answer is to reject the change; otherwise, the evaluation will be biased toward tasks that are easy to succeed at.

    The appropriate role of AI coding in brownfield systems is to accelerate reading, enumerate assumptions, and draft minimal patches. Accountability remains with the engineers who understand the business. Making the five gates mandatory questions before merge has more influence on whether AI assistants reduce effort or accelerate incidents than changing a particular interaction format.