• We're back
  • SDD?
  • Specs
  • Murder
  • Haikus
  • Double edge
  • Design aspects
  • Improvement resistance
  • Solution domains
  • Archive
  • 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:

    There is also a LLM-unique failure mode that gets more risky without oversight:

    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:

    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

    First version: 2026-11-15

    by Peter Lindsten and Gemini.