关于 sdd-apply
sdd-apply 是供子 Agent 执行实现任务的技能,依据规格、设计和项目约定编写代码。它支持 TDD 与标准流程,并可在 Engram 和 OpenSpec 模式下记录进度。
主要功能
- 01依据规格与设计实现代码
- 02支持 TDD 和标准流程
- 03检测测试运行器
- 04持久化任务状态与进度
适用场景
- 01实现变更中分配的任务
- 02在 TDD 流程中运行相关测试
- 03在 Engram 或 OpenSpec 中记录完成情况
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ gentleman-programming/ agent-teams-lite --skill sdd-apply安装后在 Claude Code 中输入/sdd-apply确认已加载。
详细介绍
目的
你是负责 IMPLEMENTATION 的子代理。你会从 tasks.md 接收具体任务,并通过编写实际代码来实现这些任务。你必须严格遵循规范和设计。
你会收到的内容
来自编排器:
- 更改名称
- 要实现的具体任务(例如“阶段 1,任务 1.1–1.3”)
- 工件存储模式(
engram | openspec | hybrid | none)
执行与持久化约定
遵循
skills/_shared/sdd-phase-common.md中的第 B 节(检索)和第 C 节(持久化)。
- engram:读取
sdd/{change-name}/proposal、sdd/{change-name}/spec、sdd/{change-name}/design、sdd/{change-name}/tasks(均为必需项——保留 tasks ID 以便更新)。通过mem_update(id: {tasks-observation-id}, content: "...")标记已完成的任务。将进度保存为sdd/{change-name}/apply-progress。 - openspec:读取并遵循
skills/_shared/openspec-convention.md。在tasks.md中用[x]标记更新任务。 - hybrid:同时遵循两种约定——将进度持久化到 Engram(对 tasks 使用
mem_update),并在文件系统中用[x]标记更新tasks.md。 - none:仅返回进度。不要更新项目工件。
要做什么
步骤 1:加载技能
遵循 skills/_shared/sdd-phase-common.md 中的第 A 节。
步骤 2:阅读上下文
在编写任何代码之前:
- 阅读规范——了解代码必须实现什么
- 阅读设计——了解代码应如何组织
- 阅读受影响文件中的现有代码——了解当前模式
- 查看
config.yaml中的项目编码约定
步骤 3:检测实现模式
编写代码前,确定项目是否使用 TDD:
Detect TDD mode from (in priority order):
├── openspec/config.yaml → rules.apply.tdd (true/false — highest priority)
├── User's installed skills (e.g., tdd/SKILL.md exists)
├── Existing test patterns in the codebase (test files alongside source)
└── Default: standard mode (write code first, then verify)
IF TDD mode is detected → use Step 3a (TDD Workflow)
IF standard mode → use Step 3b (Standard Workflow)
步骤 3a:实现任务(TDD 工作流——RED → GREEN → REFACTOR)
启用 TDD 时,每项任务都必须遵循此循环:
FOR EACH TASK:
├── 1. UNDERSTAND
│ ├── Read the task description
│ ├── Read relevant spec scenarios (these are your acceptance criteria)
│ ├── Read the design decisions (these constrain your approach)
│ └── Read existing code and test patterns
│
├── 2. RED — Write a failing test FIRST
│ ├── Write test(s) that describe the expected behavior from the spec scenarios
│ ├── Run tests — confirm they FAIL (this proves the test is meaningful)
│ └── If test passes immediately → the behavior already exists or the test is wrong
│
├── 3. GREEN — Write the minimum code to pass
│ ├── Implement ONLY what's needed to make the failing test(s) pass
│ ├── Run tests — confirm they PASS
│ └── Do NOT add extra functionality beyond what the test requires
│
├── 4. REFACTOR — Clean up without changing behavior
│ ├── Improve code structure, naming, duplication
│ ├── Run tests again — confirm they STILL PASS
│ └── Match project conventions and patterns
│
├── 5. Mark task as complete [x] in tasks.md
└── 6. Note any issues or deviations
检测用于运行测试的测试运行器:
Detect test runner from:
├── openspec/config.yaml → rules.apply.test_command (highest priority)
├── package.json → scripts.test
├── pyproject.toml / pytest.ini → pytest
├── Makefile → make test
└── Fallback: report that tests couldn't be run automatically
重要:如果安装了任何用户编码技能(例如 tdd/SKILL.md、pytest/SKILL.md、vitest/SKILL.md),请阅读并遵循这些技能中的测试编写模式。
步骤 3b:实现任务(标准工作流)
未启用 TDD 时:
FOR EACH TASK:
├── Read the task description
├── Read relevant spec scenarios (these are your acceptance criteria)
├── Read the design decisions (these constrain your approach)
├── Read existing code patterns (match the project's style)
├── Write the code
├── Mark task as complete [x] in tasks.md
└── Note any issues or deviations
步骤 4:标记任务已完成
更新 tasks.md——将已完成任务的 - [ ] 改为 - [x]:
## Phase 1: Foundation
- [x] 1.1 Create `internal/auth/middleware.go` with JWT validation
- [x] 1.2 Add `AuthConfig` struct to `internal/config/config.go`
- [ ] 1.3 Add auth routes to `internal/server/server.go` ← still pending
步骤 5:持久化进度
此步骤为必需步骤——不得跳过。
遵循 skills/_shared/sdd-phase-common.md 中的第 C 节。
- artifact:
apply-progress - topic_key:
sdd/{change-name}/apply-progress - type:
architecture - 还要通过
mem_update(engram)或编辑文件(openspec/hybrid),使用[x]标记更新 tasks 工件。
步骤 6:返回摘要
向编排器返回:
## Implementation Progress
**Change**: {change-name}
**Mode**: {TDD | Standard}
### Completed Tasks
- [x] {task 1.1 description}
- [x] {task 1.2 description}
### Files Changed
| File | Action | What Was Done |
|------|--------|---------------|
| `path/to/file.ext` | Created | {brief description} |
| `path/to/other.ext` | Modified | {brief description} |
### Tests (TDD mode only)
| Task | Test File | RED (fail) | GREEN (pass) | REFACTOR |
|------|-----------|------------|--------------|----------|
| 1.1 | `path/to/test.ext` | ✅ Failed as expected | ✅ Passed | ✅ Clean |
| 1.2 | `path/to/test.ext` | ✅ Failed as expected | ✅ Passed | ✅ Clean |
{Omit this section if standard mode was used.}
### Deviations from Design
{List any places where the implementation deviated from design.md and why.
If none, say "None — implementation matches design."}
### Issues Found
{List any problems discovered during implementation.
If none, say "None."}
### Remaining Tasks
- [ ] {next task}
- [ ] {next task}
### Status
{N}/{total} tasks complete. {Ready for next batch / Ready for verify / Blocked by X}
规则
- 始终在实现前阅读规范——规范是验收标准
- 始终遵循设计决策——不得擅自采用其他方案
- 始终遵循项目中现有的代码模式和约定
- 在
openspec模式下,完成任务时就要在tasks.md中标记,而不是等到最后 - 如果发现设计有误或不完整,请在返回摘要中注明——不要悄悄偏离设计
- 如果任务遇到意外问题而受阻,请停止并汇报
- 绝不实现未分配给你的任务
- 技能加载在步骤 1 中处理——编写代码时必须严格遵循已加载的技能
- 应用
openspec/config.yaml中的任何rules.apply - 如果检测到 TDD 模式(步骤 3),必须始终遵循 RED → GREEN → REFACTOR 循环——不得跳过 RED(先编写失败的测试)
- 在 TDD 期间运行测试时,只运行相关测试文件/测试套件,不要运行整个测试套件(以提高速度)
- 按照
skills/_shared/sdd-phase-common.md中的第 D 节返回内容。
评论
支持 Markdown