Part II: Engineering Oversight and the Discipline of Stopping
Chapter 6: A Core Discipline: Rebuilding from a Known Baseline
Imagine a late-night debugging session. You step through a function the assistant generated; no sooner have you worked out one condition than you find another branch relying on an assumption changed long ago. An earlier implementation version and its corresponding acceptance material sit preserved nearby, while explaining the current implementation already requires flipping back through the conversation again and again. In this teaching scenario, you estimate that the effort to keep reading and patching has already exceeded the effort to restate the constraints and rebuild from a known baseline. This estimate is not a universal law of costs, and it cannot decide the rollback for you; it reminds you to put the two routes side by side, rather than continue only because you have already debugged for so long. From here the chapter discusses the choice to rebuild and its boundaries.
In the traditional mode of development, a programmer's first reaction to a bug is often to start the debugger, step through, locate the defect, and fix it by hand. That is because traditional code was typed out by you, line by line, and you understand the full reasoning behind it. But when the workflow switches to AI-assisted programming, this instinctive habit significantly amplifies risk in an AI development workflow and can easily drag a project down. Hence the most central, most counterintuitive discipline in this book: "rebuilding from a known baseline."
First, we need to examine the engineering economics of compute and human effort.
When you face a long section of AI-generated code riddled with logical flaws and hard to read, with no clear reasoning context of your own, trying to fine-tune it or debug it by hand is usually a poor trade. The generation cost of a large model (compute) is at present extremely cheap, while the architect's mental bandwidth (human effort) is extremely expensive. Reading and straightening out the "spaghetti code" the AI produced, and guessing at its muddled chain of reasoning at the time, often costs no less mental effort than rewriting it yourself — sometimes more. It is like trying to carve fine detail into a block of hardened, poor-quality concrete with a carving knife: painful, and pointless. With generation costs greatly reduced today, the cost of discarding a stretch of wrong code is usually far below the cost of repairing a drifted implementation.
So when you find the AI's code will not run or its logic has drifted, treat "manual patching" as the exception rather than the default, and prefer the following "three-step correction method":
Step one: the design-level correction prompt (point out the design flaw).
When you find an error, absolutely do not respond only at the bricklayer's level — "the variable name on line 42 is misspelled" or "that if is missing a condition." Speak in the architect's language and make a design-level correction, naming the structural defect. For example: "Your last implementation coupled database operations with network requests, violating the single-responsibility principle. Move the data logic into the Repository layer and rewrite it there." In this way you give the AI one or two chances to correct itself.
Step two: pause the implementation.
Two corrections in a row failing to solve the problem, or new anomalies appearing after a modification, can serve as triggers to pause the current attempt and recheck the material and the plan. These counts are a convention for making engineering decisions, not a measurement of the model's internal mechanisms; these phenomena alone cannot prove the model's internal reasoning state or the reason the attempt failed.
At this point, be wary of the sunk-cost fallacy: do not add a third or fourth round of argument. Pause the current attempt, and stop further investment in this wrong branch.
Step three: rebuild from a known baseline (rollback).
After the pause, first recheck the defect, the differences between versions, and the plan, then decide whether to roll back and rebuild. If rollback is chosen, carry out the complete rollback process described below; the selected node has its basis only within the original acceptance conditions and scope. After revisiting the blueprint (the prompt), have the AI implement again from that node, and verify anew against the new criteria.
So that this kind of "rebuilding" can happen at any time without psychological burden, Git takes on a brand-new mission in the AI development workflow.
In the past, Git was often used as a collaboration tool for merging code before the team clocked out each day. In architect mode, Git is no longer just version control; it is your "time machine and high-frequency safety net."
This demands an extremely high-frequency commit discipline: whenever you pass the acceptance criteria and baseline even the smallest "structural milestone" (for instance, merely getting a User Model data-migration script to run through), do not wait — immediately run a commit, preserve the current version, and link the corresponding acceptance criteria, evidence references, and unresolved items. A commit preserves state; it does not automatically prove the state correct, nor does it supply verification for uncovered scope.
Before executing a rollback, first preserve the uncommitted work, raw output, and failure evidence that need to be kept, and confirm and record the explicit target version supported by acceptance material and its acceptance scope. The current commit may be only work in progress; do not assume by default that it is an accepted baseline. For operations that will discard or overwrite content, check whether existing authorization covers the target and the scope of impact; where there is no such authorization, first explain the operation you intend to perform and its impact, obtain the authorization, and only then execute the rollback operation corresponding to that target. Afterwards, check the actually restored state against the original acceptance scope. A version rollback cannot prove that the database, external services, or material outside version control has also been restored.
Rollback provides a specific, traceable starting version for reimplementation. Before issuing further architectural instructions, you still need to check the recovery results, the acceptance basis, and unresolved items; the rollback action itself cannot be taken as renewed verification.
Rebuilding provides the starting point for reimplementation; it cannot replace a new round of acceptance. Record the target version, the operational authorization, the recovery check, and the unresolved items clearly, and the next step can follow. The chapter that follows, on managing core deliverables, explains how to keep this basis in a blueprint that can be maintained over time.