How to turn AI-written code into code you understand
A book excerpt argues that code which runs is not necessarily code the developer understands. Without understanding, a developer cannot explain how the code works, find where a bug comes from, or estimate the cost of a spec change. Such unexplained code builds up "comprehension debt[1]" that lowers the productivity of the whole project. The author notes that understanding can be skipped for urgent work, tight deadlines, or code used only once.
The article describes three steps, using an internal user-management tool where AI added a name search to the user list. The first step is to grasp the overall flow, from the input change event to the list update. The second step is to test hypotheses about each function's role, such as why the input is stored in searchQuery, and check them with AI. The third step is to explain the mechanism in your own words and consider which parts would change if the specification changed. The author suggests asking AI to present the flow as a flowchart or a sequence diagram[2].
In the example, the search filters a temporary result and does not rewrite the original user list. Because of this, the developer can change or clear the keyword and filter the original list again. The article concludes that a working result is the start of understanding, not the end of the work.
Sources
-
JPgihyo.jp JA
AIが書いたコードを、「わかる」コードに変える





