Spec-Driven Development in Practice: A Post-Mortem from Spec to Code

    This article presents a practical retrospective on Spec-Driven Development (SDD) for AI-assisted programming. Moving beyond standard tutorials, it shares real-world experiences and pitfalls encountered while completing a full development cycle from specification to implementation. It covers the true essence of SDD as a working discipline rather than just documentation templates, details the time investment and specific roles of spec.md, design.md, and tasks.md, and highlights the necessity of human review during the development phase. Readers will gain actionable insights into managing AI context, setting milestone checkpoints, and reusing SDD methodologies effectively.

    1. Introduction: Why a Post-Mortem on SDD?

    Recently, I completed a long-term AI project development cycle entirely using the Spec-Driven Development (SDD) model. For the first time, I walked through the complete closed loop of “spec → design → tasks → develop.” While SDD has gained massive traction in the AI-assisted programming community recently, most discussions focus only on “how to do it right” rather than “what went wrong.” This article is not a tutorial; it is a retrospective. It documents the practical lessons learned, the pitfalls encountered, and the reusable methodologies developed after running the full process from scratch, intended as a reference for myself and peers.

    2. The Essence of SDD: A Working Discipline, Not Just a Template

    Many teams misunderstand SDD as simply “filling out four documentation templates” before starting work. This is the most common misconception. The essence of SDD is a working discipline that forces you to change your habits at three critical junctures:

    1. Before writing code, it forces you to clarify vague requirements. In traditional development, requirements often start as a “rough feeling” in the mind and are clarified gradually during coding. SDD requires you to make this state explicit—if you cannot articulate it clearly, you haven’t thought it through yet.
    2. Before taking action, it forces you to expose blind spots. Documents must be reviewed, walked through, and questioned. A single question from a peer can often reveal an unclear feature definition or a vague boundary.
    3. At each stage, it forces you to stop and validate. SDD naturally sets up milestones, preventing the scenario where you “sprint all the way to launch only to find the direction was wrong.”

    Admittedly, the philosophy of SDD is contrary to the traditional agile approach of “just get it running first.” It is not suitable for all projects: for exploratory prototypes or projects with rapidly changing requirements, forcing SDD will only add overhead. However, for engineers who prefer to “think clearly before acting,” and for AI-assisted development scenarios where models need explicit context, it is a game-changer.

    3. The Four Documents: Division of Labor and Time Investment

    The core of SDD is “write documents first, then write code.” In practice, I found that the nature, time investment, and iteration rhythm of the four documents are entirely different, and effort should not be distributed evenly.

    1. spec.md: The Anchor for Requirements

    The essence of spec.md is transforming vague requirements into precise descriptions. It feels like an assembly line process—sorting through feature points one by one and scrutinizing every word. My experience is:

    • Time investment: At least one full day, and do not write it in isolation. After writing, walk through it with a colleague; a walkthrough exposes problems far more efficiently than self-reviewing repeatedly.
    • Granularity control: Do not be overly ambitious with a single spec. An overly large spec will cause the AI’s context to bloat during the develop phase, scattering its attention and deviating from the goal. The correct approach is to break large requirements into multiple small specs, each focusing on a clear functional domain. This yields far better results than a massive, all-encompassing document.
    • Iteration rhythm: I iterated on it more than three times before it stabilized. This is not an issue of capability, but because each walkthrough exposes new issues. Do not aim to get it right on the first try, but ensure it is stable before starting the actual work.

    2. design.md: The Most Time-Consuming and Most Important

    design.md requires the largest time investment in the entire process. I spent about 1.5 to 2 days—and this was based on having a decent familiarity with the tech stack involved. Key tip: If the design document references technologies you are unfamiliar with, reading and understanding those technologies will consume significant additional time. This is not “writing documentation,” but “learning,” and must be separately accounted for in your scheduling. I validated design.md more than six times. The focus of validation includes: Are module boundaries clear? Is the data flow closed-loop? Are exception paths covered? Does the technology selection introduce unnecessary complexity?

    3. tasks.md: Translating Design into Executable Units

    The key to tasks.md lies in the granularity of the breakdown: each task should be the size that can be completed in “one conversation/one commit,” and must explicitly declare dependencies and acceptance criteria. Strive for low coupling between tasks so that the develop phase can proceed in parallel. It also makes it easier to locally redo a single failed task without polluting the overall project.

    4. The Develop Phase: Human Review is Indispensable

    Once in the coding phase, AI can generate implementations efficiently, but each completed task must undergo human review: Is the implementation faithful to the spec? Does it introduce implicit designs outside of the design doc? If deviation is found, prioritize going back to fix the document rather than letting the code “carry on with the mistake”—the document is the only trusted anchor.

    4. Reusable Lessons Learned

    1. Documents are contracts, not products. The value of the four documents lies in constraining all subsequent stages. Once you lower your standards here, SDD degrades into a “documentation performance.”
    2. Review density determines the quality ceiling. Walking through the spec three times and validating the design six times may seem inefficient, but it actually front-loads the cost of rework, making the total cost lower.
    3. Context management is the core capability of AI collaborative development. Small specs, clear task breakdowns, and explicit acceptance criteria are essentially all about constructing a controllable context for the model.
    4. The process should serve the project. Tailor the depth of documentation based on project scale to avoid formalism.

    5. Conclusion

    SDD is not a silver bullet; its value stems from the discipline of “forcing you to think clearly.” When you are willing to stop and validate at each stage, documentation is no longer a burden, but the most reliable asset throughout the development process. I hope this retrospective helps you avoid some detours.