为什么选择规格驱动开发?
Why spec-driven development?
Summary
Compares vibe coding with spec-driven development (SDD). SDD brings engineering rigor to AI-assisted coding by decoupling specification (what/why) from implementation (how), providing three key benefits: controlling large code changes via small spec edits, eliminating context decay, and improving intent fidelity.
Key Takeaways
- Vibe coding scales poorly: quick results for small tasks, but leads to disposable code and mounting technical debt on large projects
- SDD creates a contract: specs serve as agreements between humans and agents, and between team members
- Agents vs. chatbots: coding agents access your codebase and dev tools, while chatbots only respond to prompts
Video: Why spec-driven development?
English Script
When you hear agentic coding, you might think Vibe coding. Let’s compare the two and see how Spec-Driven Development gives better results by bringing back engineering. Vibe coding gives quick results. You write a prompt describing what you want, like, create me a button and hope for the best. Then you look at the result. That’s a big button. It’s kind of close, but off on some important things. So you point out the mistakes to the agent, it tries again and so on until you are satisfied. As a result, you will end up with a long dialogue with the agent, the history of which will not even be saved. This approach works okay for a button, but it doesn’t scale to a large ongoing project. While high-level prompts are fast, they lead to disposable code and mounting technical debt. We need engineering. A well-maintained specification that creates a permanent technical artifact.
Spec-Driven Development is the professional response to the chaos of unsupervised AI generation. It is a paradigm shift where the Specification, explaining the what and why, is decoupled from the Implementation, the how. With specs, we get a contract between the humans, but also with the agent. Your main task as the human now shifts. Learn how to convert your intentions into clear specifications.
Spec-driven development with agentic coding assistance has three main benefits. First, you’re able to control large code changes with small changes to the spec. A few sentences in the spec outlining the look and feel of the app might translate to hundreds of lines of CSS. This spec-driven approach reduces the cognitive overhead needed for working with these ultra-fast coding agents. Second, specs eliminate the context decay problem that derails multi-turn agent sessions. As you work with your coding agent, its context window will fill up, often leading to more mistakes as the agent tries to cope with a full working memory. Specs persist between sessions and even agents, anchoring the agent to the core context needed to work in a code base and implement a feature. Third, specs improve intent fidelity, meaning that the agent is more likely to produce code that matches your goals. That’s because specs force you to define the problem, success criteria, constraints, user flows, and so on before the agent starts generating code.
Specs are a key differentiator between vibe coding, some slop, and engineering a viable software product. Whether you are starting a new project from scratch or want to implement the SDD approach into a project that has been running for years, specs help solve the drift and productivity problems. As a comparison, think of compilers, which convert understandable source code into machine code. SDD guides the agent and prompts, converting specs into source code. Even better, the specs are in a human language, making it easy for stakeholders.
Spec-driven development has taken off recently as a solution to concerns about productivity. Multiple SDD projects, tools built around spec authoring, conference talks on capturing intent. This is all part of a broader push to bring engineering, lessons learned from the software development life cycle, to agentic coding. Spec-Driven Development is used with Coding Agents, not simple chatbots. A chatbot can talk about code, but the chatbot doesn’t have access to your project’s code nor tools you have installed. It just responds to your prompts. Agents are different. They take your prompt, make a plan, and guide themselves to a result using reasoning along the way. Importantly, agents have access to your code base and your development tools. In the SDD workflow, we treat these agents as highly capable pair programmers. They provide the technical knowledge and the speed, and you, the senior architect, provide the blueprints. As we move forward in this course, remember, the agent is the muscle, but the SPEC is the brain. With practice, you ensure that the software produced is not just functional, but is aligned with your long-term goals.
为什么选择规格驱动开发?
摘要
对比凭感觉编程(Vibe Coding)与规格驱动开发(SDD)。SDD 通过将规格说明(做什么/为什么)与实现(怎么做)分离,将工程严谨性带回 AI 编程,提供三大关键优势:通过微小的规格编辑控制大规模代码变更、消除上下文衰减、提高意图还原度。
关键要点
- 凭感觉编程无法扩展:对小任务见效快,但在大型项目中会导致一次性代码和技术债务不断堆积
- SDD 创建契约:规格说明在人与人之间、人与智能体之间建立协议
- 智能体 vs 聊天机器人:编程智能体能访问代码库和开发工具,而聊天机器人只能响应提示词
视频:为什么选择规格驱动开发?
视频脚本(中文翻译)
当听到”智能体编程”时,你可能会想到”凭感觉编程(Vibe coding)“。让我们比较一下两者,看看”规格驱动开发(SDD)“如何通过回归软件工程来提供更好的结果。凭感觉编程见效很快。你写一个描述你想要的提示词,比如”给我建一个按钮”,然后祈祷它能做好。接着你查看结果,发现这是一个大按钮。有点接近了,但在一些重要细节上还有偏差。于是你向智能体指出错误,它再试一次,如此反复,直到你满意为止。结果就是,你最终会与智能体产生一段很长的对话,而这些对话历史甚至都不会被保存。这种方法对于做一个按钮来说没问题,但它无法扩展到大型且持续推进的项目中。虽然高层次的粗略提示词速度很快,但它们会导致产生一次性代码,并使得技术债务不断堆积。我们需要的是软件工程:一份维护良好、能创造永久技术工件的规格说明。
规格驱动开发是对无监督 AI 生成混沌状态的专业回应。这是一种范式转变,其中解释”是什么(what)“和”为什么(why)“的规格说明(Specification),与负责”怎么做(how)“的代码实现(Implementation)被分离开来。有了规格说明,我们就在人与人之间,以及人与智能体之间建立了一份契约。现在,作为人类的你,主要任务发生了转变:你要学习如何将你的意图转化为清晰的规格说明。
借助智能体编程助手进行规格驱动开发有三大优势。第一,你能够通过对规格说明的微小修改来控制大规模的代码变更。规格说明中勾勒应用程序外观和感觉的几句话,可能会转化为数百行 CSS 代码。这种规格驱动的方法减少了与这些超快编程智能体协同工作时所需的认知开销。第二,规格说明消除了经常导致多轮智能体对话偏离轨道的”上下文衰减”问题。当你与编程智能体工作时,它的上下文窗口会逐渐填满,当智能体试图处理塞满的工作记忆时,往往会导致更多的错误。规格说明能够在不同会话甚至不同智能体之间持久存在,将智能体锚定在处理代码库和实现功能所需的核心上下文上。第三,规格说明提高了”意图还原度”,这意味着智能体更有可能生成符合你目标的代码。这是因为规格说明迫使你在智能体开始生成代码之前,先定义好问题、成功标准、约束条件、用户流程等等。
规格说明是区分”凭感觉写出一堆垃圾代码”与”工程化打造可用软件产品”的关键分水岭。无论你是一个从零开始的新项目,还是想把 SDD 方法引入一个已经运行多年的旧项目,规格说明都能帮助解决代码脱节和生产力问题。打个比方,想想编译器,它将易于理解的源代码转换为机器码。SDD 则通过提示词引导智能体,将规格说明转换为源代码。更好的是,规格说明使用的是人类自然语言,这让项目干系人也能轻松理解。
规格驱动开发最近开始起飞,成为解决生产力担忧的方案。涌现出了多个 SDD 项目、围绕编写规格说明构建的工具,以及关于如何捕捉意图的会议演讲。这些都是将工程学精神——从软件开发生命周期中学到的经验——引入智能体编程这一宏大趋势的一部分。规格驱动开发是与”编程智能体(Coding Agents)“配合使用的,而不是简单的聊天机器人。聊天机器人可以谈论代码,但它无法访问你的项目代码,也无法使用你安装的工具。它只响应你的提示。智能体则不同。它们接受你的提示,制定计划,并在整个过程中运用推理引导自己达到结果。重要的是,智能体可以访问你的代码库和开发工具。在 SDD 工作流中,我们将这些智能体视为能力极强的结对程序员。它们提供技术知识和速度,而作为高级架构师的你,负责提供蓝图。随着我们在本课程中的深入,请记住:智能体是肌肉,但规格说明(SPEC)是大脑。通过不断实践,你将确保开发出的软件不仅功能完备,而且符合你的长期目标。