传统代码支持
Legacy support
Summary
Demonstrates introducing SDD to an existing legacy codebase (the AgentClinic MVP without specs). The agent reverse-engineers the constitution from existing code, README, and TODO files, then the standard SDD workflow proceeds normally.
Key Takeaways
- SDD works for brownfield projects: the agent can reverse-engineer a constitution from existing code and documentation
- Same workflow after constitution: once the constitution is established, the feature loop is identical to greenfield projects
- Specs as project memory: the constitution and feature specs become the persistent memory that doesn’t fade over time
视频信息:Legacy support
English Script
People say spec-driven development and even AI are only good for greenfield projects. But SDD is also good for existing legacy projects. In this lesson, we’ll introduce SDD to an existing project. To make it easy, we’ll start with a project you already know. The AgentClinic MVP. We’ll make it a legacy by starting on main without the specs folder in a new Claude Code session in a different project directory. We have some project background in the README.md file with some open work listed in TODO.md Your legacy project might have full product plans in issue trackers, spreadsheets, Word documents, etc.
Remember our workflow? We’ll start with the constitution step. We’ll use almost the same prompt from lesson four. This time, we’ll tell it to look for roadmap items in existing artifacts. In this case, a to-do file. Remember, the agent will discover and in a sense reverse engineer the SDD artifacts from the existing code base. The constitution will help align future code changes made by the agent with what past devs have already created. You can always add more context if you have it. For example, you might have been dropped into this project in order to improve its efficiency while implementing highly requested features. The process is the same, but the conversation might be richer as the agent has more artifacts, code, commits, documents, etc. You’ll see a lot of tool calls here as the agent explores the code base. Let’s look at the constitution for our legacy project. In the mission, we have an audience, the project idea, and some extra information about the project. The tech stack shows that Claude extracted the project file structure, framework versions, and the clarifications we were asked. In the roadmap, we can see the work is organized in phases, matching the to-do file. Let’s create a commit for the constitution files that we produced with a commit message. Remember that in SDD, specs are part of your versioning strategy.
Our legacy project is now placed on an SDD foundation. From now on, the workflow is exactly the same as we discussed in previous lessons. First, we grab the next feature on the roadmap and plan it in a conversation with the agent. We’ll be doing phase one feedback form. Very good. We now have a branch and specs for this feature. Let’s review the feature spec. The plan, the requirements, and the validation. Then we commit the feature spec. After we have made any corrections by chatting with the agent, we proceed to implement the feature. Once the agent is finished, we do our validation. To make sure the code is good and the feature works as expected. Our feature loop is done, we can commit. And then merge the branch to main. Now it’s time for replanning. Make sure you give time for this. Since you just added SDD into your project, you may find a lot of things to tune. We now have a legacy project rebased onto Spec-Driven Development without a bunch of manual work. This gives us a well-documented flow, working in steps, using engineering and staying in control. The spec is now the memory of the project, so it doesn’t fade.
传统代码支持
摘要
演示如何将 SDD 引入现有的传统遗留代码库(去除规格说明的 AgentClinic MVP)。智能体从现有代码、README 和 TODO 文件逆向工程生成项目章程,之后标准的 SDD 工作流正常运行。
关键要点
- SDD 同样适用于传统项目:智能体可以从现有代码和文档中逆向工程生成项目章程
- 章程确立后工作流一致:一旦建立了章程,功能循环与全新项目完全相同
- 规格说明即项目记忆:章程和功能规格说明成为不会随时间褪色的持久记忆
视频信息:传统代码支持
视频脚本(中文翻译)
人们常说规格驱动开发甚至 AI 编程只适用于全新项目(greenfield projects)。但 SDD 也非常适合现有的传统遗留项目。在本课中,我们将把 SDD 引入到一个现有项目中。为了简单起见,我们将从一个你已经了解的项目开始:刚刚的 AgentClinic MVP。为了把它变成一个”旧项目”,我们在一个新的不同目录中启动一次全新的 Claude Code 会话,并且只保留主分支代码,去除了 specs 文件夹。我们在 README.md 文件中有一些项目背景,并且在 TODO.md 中列出了一些待完成的工作。在你真实的遗留项目中,可能会在工单跟踪器、电子表格、Word 文档等地方存放完整的预定产品计划。
还记得我们的工作流吗?我们将从编写”章程”步骤开始。我们将使用几乎与第四课完全相同的提示词。这一次,我们将告诉它去现有的工件中寻找路线图项目。在这个例子中,就是一个待办(to-do)文件。请记住,智能体会去发现代码,并在某种意义上从现有代码库”逆向工程(reverse engineer)“出 SDD 的规范工件。章程将帮助智能体在未来所做的代码更改与过去开发人员已经创建的内容保持一致。如果你有更多的上下文,你总是可以加进去。例如,你可能被”空降”到这个项目中,任务是提高其效率,同时实现某些需求迫切的功能。流程都是一样的,但对话可能会更加丰富,因为智能体拥有了更多的现成工件、代码、提交记录、文档等等。你会在这里看到大量的工具调用,因为智能体正在探索代码库。让我们看看为我们传统项目生成的章程。在任务说明(mission)中,我们有受众、项目构想,以及一些关于项目的额外信息。技术栈表明 Claude 提取了项目文件结构、框架版本以及我们被问到并澄清的内容。在路线图中,我们可以看到工作按阶段组织,正好与 to-do 待办文件匹配。让我们为生成的章程文件创建一个附带提交信息的 commit。记住,在 SDD 中,规格说明是你的版本控制策略的一部分。
我们的传统遗留项目现在建立在了 SDD 的基础之上。从现在开始,工作流与我们在之前课程中讨论的完全一样。首先,我们抓取路线图上的下一个功能,并在与智能体的对话中进行规划。我们将执行第一阶段的任务:反馈表单。非常好。我们现在有了这个功能的一个分支和相关规格说明。让我们复习一下功能规格说明。包括:计划、需求和验证。然后我们提交这份功能规格说明。在通过与智能体聊天做出任何必要的更正后,我们开始实现该功能。一旦智能体完成了,我们进行我们的验证。确保代码质量过关并且功能按预期工作。我们的功能循环完成了,我们可以提交了。然后将分支合并回主分支(main)。现在是重新规划的时候了。一定要为此留出时间。由于你刚刚把 SDD 引入你的项目,你可能会发现有很多事情需要调整。我们现在将一个遗留项目成功重构到了基于规格驱动开发的基础之上,且没有进行一大堆手动工作。这为我们提供了一个有良好文档记录的流程,让我们分步骤工作,运用工程学思维并保持对项目的掌控。规格说明现在就是项目的记忆,因此它不会随着时间衰减而褪色。