liveBook · Manning

AI-generated code

As explained in Build High Value Software Systems

Source code produced by an artificial-intelligence system from supplied inputs or instructions.

AI-generated code is source code produced by an AI assistant from a prompt or other supplied context. It can turn a small request into a working implementation quickly. That speed is useful for scaffolding and exploration, but it can also produce behavior nobody chose. A passing test shows that code works under the tested conditions; it does not establish that its business rules were requested. section 3.0 section 3.4.2

A plausible endpoint with an invented rule

An engineer asks an assistant to implement an order endpoint. The result returns 409 for cancelled orders, although nobody specified that behavior. The engineer accepts it, and a reviewer approves the reasonable-looking response. The team now owns a business rule that entered through the implementation rather than a decision. section 3.0

Listing 3.4 Abstraction-centric code
export class OrderService {
  constructor(
    private db: Database,
    private cache: CacheService,
    private validator: ValidationService
  ) {}
 
  async validate(order: Order): Promise<ValidationResult> { /* ... */ }
  async calculateTotals(order: Order): Promise<OrderTotals> {
    const tax = subtotal * 0.10; // Invented 10% tax rate
    // ...
  }
  async getById(id: string): Promise<Order | null> {
    const cached = await this.cache.get(`order:${id}`);
    // ...
  }
}

The order-service listing makes the review problem concrete: a 10% tax rate and caching sit inside otherwise plausible structure. Ask where each choice came from before judging whether the code looks complete. section 3.3.2

Keep generation inside a visible decision process:

  • For production behavior, give the prompt a specification or contract. State the intended outcome, not just an activity such as “add validation.” section 3.3 section 3.4.2
  • Before review, make the generated code compile and pass existing tests. In the pull request, record the problem, decisions made, and choices deliberately left out. section 3.4.2
  • Review the path from request to contract to implementation. Question extra status codes, validation, caching, dependencies, and abstractions instead of approving a polished diff on appearance alone. section 3.3.2
  • Treat suggested bug fixes as hypotheses. Diagnose the cause before asking AI to write the fix. section 8.4

A fix that hides the failure

An intermittent database test prompts an AI-suggested retry loop. The test passes, but the helper still starts an asynchronous insert without awaiting it. Adding `await` addresses the race condition; retrying merely makes the symptom less visible. section 8.4

The practical test is ownership: can a developer explain why the code behaves this way, maintain it later, and remove what is unnecessary? Compare a handwritten and an AI-assisted version of the same small change for assumptions, review effort, and ease of modification—not just speed or line count. Human review restores accountability only when it establishes that understanding. section 3.5 section 13.1.1

How Build High Value Software Systems covers it

How deep it goes
Works through prompt constraints, review checks, and a comparison exercise rather than model internals.
Examples
Uses an order endpoint with invented rules, a webhook-handler prompt, and a flaky database test patched with retries.
What it assumes
Assumes familiarity with prompts, code review, tests, and API changes while providing a Lean lens for judging their outcomes.
What you can do after
Evaluate/understand it by tracing generated decisions to intent, challenging extra behavior, and taking ownership before merging.
How it connects
Connects generated code to specifications, pull-request review, Lean waste, cognitive debt, and root-cause analysis.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build High Value Software Systems. The section links point to the parts of the book it draws on.