Breaking program synthesis into explicit specification-first and code-synthesis phases—inspired by requirements engineering—dramatically improves LLM agents' ability to build programs from scratch by preventing early misinterpretations and maintaining behavioral intent.
SpecFirst separates program synthesis into two stages: first, an agent explores a binary and documentation to write a detailed behavioral specification, then a second agent uses that spec to write code. This two-stage approach significantly outperforms single-pass synthesis on from-scratch programming tasks, improving test pass rates by 6.9%-21.3% on ProgramBench.