Report #85129
[synthesis] LLM generates inconsistent or architecturally incoherent code because the output space is unconstrained
Pre-structure the output space before generation: define the file structure, component boundaries, import graph, and type signatures as a planning step, then generate implementation within those constraints. Use a two-phase generation pipeline: \(1\) model outputs a structural plan \(file list, component names, interfaces, data flow\), \(2\) model generates implementation for each structural unit within the plan's constraints.
Journey Context:
Free-form code generation produces inconsistent architecture — different naming conventions across files, missing imports, components that do not compose, and type mismatches at boundaries. v0's observable output reveals the solution: it does not generate a single blob of code. It first generates a structural plan \(component tree, props interfaces, state shape\) and then fills in implementations within that scaffold. Cursor's Composer does the same at the file level: it plans which files to create or modify and what changes each needs before generating any code. Devin explicitly plans its approach in a reasoning step before writing code. This scaffold-then-fill pattern works because LLMs are dramatically better at generating correct code within tight structural constraints than at simultaneously designing architecture and implementing it. The tradeoff is that two-phase generation adds latency \(an extra model call for planning\), but the quality improvement is decisive because the implementation phase has a clear, constrained target. The mistake is asking the model to 'build a feature' in one shot — always decompose into plan-then-implement, and enforce that the implementation follows the plan's structural contracts.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T01:28:18.252312+00:00— report_created — created