阅读材料: 第13部分:维护现有项目

模块「第13部分:维护现有项目」中第 1 / 5 节课
您正在未登录状态下查看课程。 请登录,以保存进度并参加测试。

Part 13. Supporting an Existing Project

SDD is useful not only for new projects. In an existing project, specifications can be recovered from code, README, TODO, issue tracker, changelog, tests, and architectural documents. This is not "rewrite old code". It is adding a layer of intent that was previously missing.

In a learning scenario, you can take a ready-made AgentClinic MVP, delete specs/, and pretend it is an existing project. Qwen Code's task is to recover the project constitution, then continue the normal SDD cycle.

Process for an Existing Project

Existing project
  README.md
  TODO.md
  source code
  tests
  package.json

Recovery
  specs/mission.md
  specs/tech-stack.md
  specs/roadmap.md

Continuation
  feature specification
  implementation
  verification
  replanning

Prompt for Recovering Project Constitution

/clear
We are adding specification-driven development to an existing project.

Read @README.md, @TODO.md, @package.json and look at the source tree.
Do not rewrite the application.

Prepare the project constitution:
- specs/mission.md
- specs/tech-stack.md
- specs/roadmap.md

Before writing files, ask me exactly three groups of questions:
1. Gaps in mission and target audience.
2. Assumptions and unknowns in the technology stack.
3. Roadmap priorities based on TODO.md and current code.

If Qwen Code described the project inaccurately, correct the constitution before the next feature.

What to Look for in an Existing Project

Ask the agent to collect facts, not guesses:

Study the project and make a list of facts only:
- discovered runtime and framework;
- package.json scripts;
- database or storage layer;
- routes and pages;
- tests;
- TODO items;
- risky areas.

Separate facts from assumptions.
Do not modify files.

This protects against invented architecture.

Example tech-stack.md for an Existing Project

# Technology Stack

## Discovered

- TypeScript.
- Hono routes.
- JSX rendered on server.
- SQLite via better-sqlite3.
- Tests on Vitest.

## Found Conventions

- Routes are in src/routes.
- Components are in src/components.
- Database migrations are in src/db/migrations.
- Tests are in tests.

## Unknown

- Deployment target is not documented.
- CI configuration not found.

- Linting and formatting policy not found.

## Constraints

- Do not add a new framework while attaching SDD to an existing project.
- Preserve behavior of existing routes unless the feature specification requires otherwise.

Roadmap from TODO

If you have:

# TODO

- Add feedback form.
- Add about page.
- Add customer testimonials.
- Add map to about page.

Convert to small phases:

## Phase 1: feedback form

- [ ] Add feedback table.
- [ ] Add /feedback route.
- [ ] Add form and list.
- [ ] Add validation tests.

## Phase 2: about page content

- [ ] Add static about page.
- [ ] Add clinic history and short staff bios.
- [ ] Add link in navigation.

## Phase 3: map on about page

- [ ] Choose map embedding method.
- [ ] Add address.
- [ ] Ensure graceful behavior when map is unavailable.

Feature Specification for an Existing Project

After the constitution, continue the normal cycle:

Find the next uncompleted phase in @specs/roadmap.md.
Create a feature specification for it.

Use existing code conventions; do not add new architecture.
Before writing files, ask me about boundaries, decisions, and context.

Special Risks of SDD in an Existing Project

  • The agent may treat accidental old code as an architectural rule.
  • README may be outdated.
  • TODO may not reflect current priority.
  • Tests may entrench bugs.
  • You cannot "clean up" the project in a feature branch without explicit permission.

Therefore, specifications for existing projects must distinguish between "observed", "decided", and "unknown".

Practice

  1. Take an existing small project.
  2. Ask Qwen Code to collect a list of facts only.
  3. Create the constitution through an interview.
  4. Form a roadmap from TODO and gaps.
  5. Implement one small existing project feature through a feature specification.

Review Questions

  1. Why must a recovered constitution separate facts from assumptions?
  2. What sources can be used for a roadmap of an existing project?
  3. Why can't you refactor old code "along the way" if it is not in the specification?
我的笔记
0 / 10000

笔记保存在当前浏览器中。在其他设备上将不会显示。

课程菜单

课程

基于 Qwen Code CLI 的规范驱动开发
进度 0 / 135