Spec-driven development is just bad Metaprogramming
Metaprogramming, noun: programming programs that program programs.
Code generation, noun: automatic creation of code.
Macro, noun: a metaprogramming "function", execution of which is called expansion.
Hygienic macro, noun: a macro that doesn't "leak", you would never know it was a macro after expansion.
The concepts of metaprogramming and code generation are related but distinct. Metaprogramming typically refers to macros, decorators, or similar constructs where code is generated just-in-time (at macro expansion time, just before compilation or interpretation), whereas generated code in traditional code generation is largely treated as normal source code and is committed to version control as any other. Depending on the details, it might be editable (often called templating or snippets) or meant purely for regeneration.
Metaprogramming technically encompasses feeding source code into a compiler, or any configuration that yields executable code - though because that is so fundamental to software development, it is rarely what we mean by the term today.
Metaprogramming is a tool that carries immense power and immense risk. In languages like Lisp or Rust, macros let you eliminate boilerplate and build domain-specific abstractions when standard functions, interfaces and classes fall short. Overuse leads to problematic code however - potentially letting the code look like a completely different language.
Good metaprogramming is deterministic, hygienic, and structured around
Abstract Syntax Trees (ASTs).
Bad metaprogramming looks like raw string interpolation treated blindly as
source code, leaving obscure side effects hidden layers deep.
While all AI coding is technically code generation, certain workflows cross directly into metaprogramming.
Spec-driven development
This style of agentic development closely aligns with the definition of unhygienic, non-deterministic metaprogramming.
When you use an AI agent in spec-driven development, handing it a prompt and letting it iterate autonomously until the test suite turns green, it mirrors the worst characteristics of bad code generation:
-
Token Streams Over ASTs: The agent doesn't know your domain or module boundaries. It may attempt to find out, or infer - but it comes down to a guess. It predicts a sequence of tokens that statistically resembles a plausible diff.
-
Uncontrolled Expansion: In Lisp (or Rust for that matter), a macro expands precisely according to its rules, hygienic or not as the case may be. Autonomous agents are, by nature, unhygienic. Agents have a hard time knowing when to stop and naturally drift towards their model mean which seems to include lots of unit tests - for things that don't need them. Keeping duplication low is also not their strong suit. And worse, since agents work over state, this compounds over time if not mitigated.
There is also a LLM-unique failure mode that gets more risky without oversight:
- Talking Around Bad Design: A model can reason itself around a bad design, particularly when it was told not to touch it. A human developer might push back on requirements: "No we can't do that in a reasonable amount of time". Models are trained to be instruction following, and harnesses purposely aim for "just get it done".
I've seen advocates say "just regenerate from spec" when confronted with dead-ends like the agentic harness unable to make progress - or slow to a crawl. This is where the metaprogramming analogy really is correct.
Guided iterative development
In an iterative workflow, you aren't invoking a macro expansion that compiles down to a program. You are participating in a stateful dialogue where human intent is continuously re-injected into the process:
-
Conversational Steering: Rather than delegating complete system design, the dynamic often resembles working with a collaborator who types at blistering speed but lacks a long-term memory of the project's history.
-
Supplying the Constraints: Every time you interject - "Keep that state out of the core," "Introduce a test boundary here" or "Don't pull in a new dependency for this" - you are manually supplying the architectural guardrails that the model would otherwise ignore, particularly when pushed to its limits.
Here, the tool acts less like a broken compiler and more like an interactive drafting partner. Whether that partnership scales cleanly is another question entirely, but the mechanics are fundamentally interactive rather than programmatic.
Conclusion
The "just regenerate" style is actually just terrible metaprogramming. As for Spec-driven development at large? Rather you than me.
Spec-driven development has not been properly figured out since it was dreamed up in the 1950s.
A model trained well
Superior coding speed
Yet the bugs remain