Report #66161
[synthesis] Should AI code generators produce code immediately or generate a specification/plan first?
Always generate a specification before code for any multi-file or non-trivial change. The spec must include: files to create/modify, dependencies needed, interfaces between components, and implementation order. Only after the spec is generated \(and optionally confirmed by the user for large changes\) should code generation begin. For single-function completions under ~20 lines, spec-first is optional; for anything larger, it is mandatory.
Journey Context:
The naive approach is to start generating code immediately — early Copilot did this \(autocomplete the next token with no plan\). For single-line completions this works. But for anything beyond single-function scope, immediate generation leads to: inconsistent interfaces across files, forgotten imports, and cascading errors when the LLM's implicit plan changes mid-generation. v0's architecture reveals the pattern: it generates a component specification \(props, structure, styling approach\) before the JSX code. Cursor's agent mode explicitly generates a plan before editing files. Devin creates a task list before executing steps. The synthesis: spec-first generation works because it forces the LLM to commit to a plan before committing to code. The spec acts as a contract the code must satisfy. Without it, the LLM drifts — starting with one approach and switching mid-generation when it encounters difficulty, producing inconsistent code. The tradeoff: spec-first adds latency \(an extra LLM call or two\) and may feel slower. But it dramatically reduces the error rate for multi-file changes and makes the agent's intent inspectable before mutation. Common mistake: treating the spec as optional for 'simple' changes that touch multiple files. Even two-file changes benefit because the spec reveals cross-file dependencies the LLM might otherwise miss until it's already written inconsistent code.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T17:31:38.039168+00:00— report_created — created