Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
200 changes: 121 additions & 79 deletions skills/subagent-driven-development/SKILL.md

Large diffs are not rendered by default.

26 changes: 0 additions & 26 deletions skills/subagent-driven-development/code-quality-reviewer-prompt.md

This file was deleted.

56 changes: 41 additions & 15 deletions skills/subagent-driven-development/implementer-prompt.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
分派实现子智能体时使用此模板。

```
Task tool (general-purpose):
Subagent (general-purpose):
description: "实现任务 N:[任务名称]"
model: [模型 —— 必填:按 SKILL.md 的"模型选择"来选;省略模型会默默
继承会话里最贵的那个]
prompt: |
你正在实现任务 N:[任务名称]

## 任务描述

[计划中任务的完整文本 - 粘贴到这里,不要让子智能体去读文件]
先读你的任务简报:[BRIEF_FILE]
它包含计划中该任务的完整文本。

## 上下文

Expand Down Expand Up @@ -41,33 +44,36 @@ Task tool (general-purpose):
**工作过程中:** 如果遇到意料之外或不清楚的情况,**提问**。
随时可以暂停并澄清。不要猜测或做假设。

迭代过程中,只跑你正在改动的那部分的聚焦测试;在提交前跑一次
完整测试套件,而不是每次编辑后都跑。

## 代码组织

你在能一次性放入上下文的代码上推理效果最好,文件聚焦时编辑也更可靠
你在能一次性放入上下文的代码上推理效果最好,文件聚焦时你的编辑也更可靠
请牢记:
- 遵循计划中定义的文件结构
- 每个文件应有单一明确的职责和定义清晰的接口
- 如果你正在创建的文件超出了计划预期的规模,停下来并以
- 如果你正在创建的文件超出了计划的意图规模,停下来并以
DONE_WITH_CONCERNS 状态报告——不要在没有计划指导的情况下自行拆分文件
- 如果你正在修改的现有文件已经很大或很混乱,小心操作
- 如果你正在修改的现有文件已经很大或很混乱,小心操作
并在报告中将其标注为疑虑
- 在已有代码库中,遵循已建立的模式。像一个好的开发者那样
改善你接触的代码,但不要重构你任务范围之外的东西。
改善你接触到的代码,但不要重构你任务范围之外的东西。

## 当你力不从心时

"这对我来说太难了"完全没问题。劣质的工作比不做更糟。
随时可以停下来说"这对我来说太难了"。劣质的工作比不做更糟。
上报不会受到惩罚。

**遇到以下情况时停下来上报:**
- 任务需要在多个有效方案之间做架构决策
- 你需要理解提供内容之外的代码但找不到答案
- 你需要理解提供内容之外的代码但找不到清晰答案
- 你对自己的方案是否正确感到不确定
- 任务涉及计划未预期的现有代码重构
- 你一直在逐个读文件试图理解系统但没有进展

**如何上报:** 以 BLOCKED 或 NEEDS_CONTEXT 状态汇报。具体描述
你卡在哪里、尝试了什么、需要什么帮助
你卡在哪里、尝试了什么、需要什么样的帮助
控制者可以提供更多上下文、用更强的模型重新分派,
或将任务拆分为更小的部分。

Expand All @@ -94,20 +100,40 @@ Task tool (general-purpose):
- 测试是否真正验证了行为(而非只是 mock 行为)?
- 如果要求了 TDD,我是否遵循了?
- 测试是否全面?
- 测试输出是否干净(没有零散的告警或噪声)?

如果在自审中发现问题,在汇报前就修复。

## 汇报格式
## 审查发现之后

完成后汇报:
- **状态:** DONE | DONE_WITH_CONCERNS | BLOCKED | NEEDS_CONTEXT
- 你实现了什么(或尝试了什么,如果被阻塞)
如果审查者发现了问题、你也修复了,就重跑覆盖被改动代码的测试,
并把结果追加到你的报告文件里。审查者不会替你重跑测试——
你的报告就是测试证据。

## 报告格式

把你的完整报告写到 [REPORT_FILE]:
- 你实现了什么(如果被阻塞,则是你尝试了什么)
- 你测试了什么以及测试结果
- **TDD 证据**(如果本任务要求了 TDD):
- RED:跑的命令、实现前相关的失败输出、以及为什么这个失败是预期的
- GREEN:跑的命令、以及实现后相关的通过输出
- 修改了哪些文件
- 自审发现(如果有)
- 任何问题或疑虑

然后只汇报以下内容(不超过 15 行——细节都在报告文件里):
- **状态:** DONE | DONE_WITH_CONCERNS | BLOCKED | NEEDS_CONTEXT
- 创建的提交(短 SHA + 标题)
- 一行测试小结(例如"14/14 通过,输出干净")
- 你的疑虑,如果有
- 报告文件路径

如果是 BLOCKED 或 NEEDS_CONTEXT,把具体细节放进最终消息本身——
控制者会直接据此行动。

如果你完成了工作但对正确性有疑虑,使用 DONE_WITH_CONCERNS。
如果你无法完成任务,使用 BLOCKED。如果你需要
未提供的信息,使用 NEEDS_CONTEXT。绝不默默产出你不确定的工作。
如果你无法完成任务,使用 BLOCKED。如果你需要未提供的信息,
使用 NEEDS_CONTEXT。绝不默默产出你不确定的工作。
```
</content>
44 changes: 44 additions & 0 deletions skills/subagent-driven-development/scripts/review-package
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash
# Generate a review package: commit list, stat summary, and the net
# diff with extended context, written to a file the reviewer reads in one
# call. Using the recorded per-task BASE (not HEAD~1) keeps multi-commit
# tasks intact.
#
# Usage: review-package BASE HEAD [OUTFILE]
# Default OUTFILE: <repo-root>/.superpowers/sdd/review-<base7>..<head7>.diff
# (named per range, so a re-review after fixes gets a distinct fresh file).
set -euo pipefail

if [ $# -lt 2 ] || [ $# -gt 3 ]; then
echo "usage: review-package BASE HEAD [OUTFILE]" >&2
exit 2
fi

base=$1
head=$2

git rev-parse --verify --quiet "$base" >/dev/null || { echo "bad BASE: $base" >&2; exit 2; }
git rev-parse --verify --quiet "$head" >/dev/null || { echo "bad HEAD: $head" >&2; exit 2; }

if [ $# -eq 3 ]; then
out=$3
else
dir=$("$(cd "$(dirname "$0")" && pwd)/sdd-workspace")
out="$dir/review-$(git rev-parse --short "$base")..$(git rev-parse --short "$head").diff"
fi

{
echo "# Review package: ${base}..${head}"
echo
echo "## Commits"
git log --oneline "${base}..${head}"
echo
echo "## Files changed"
git diff --stat "${base}..${head}"
echo
echo "## Diff"
git diff -U10 "${base}..${head}"
} > "$out"

commits=$(git rev-list --count "${base}..${head}")
echo "wrote ${out}: ${commits} commit(s), $(wc -c < "$out" | tr -d ' ') bytes"
22 changes: 22 additions & 0 deletions skills/subagent-driven-development/scripts/sdd-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# Resolve and ensure the working-tree directory SDD uses for its short-lived
# artifacts: task briefs, implementer reports, review packages, and the
# progress ledger. Print the directory's absolute path.
#
# The workspace lives in the working tree (not under .git/) because Claude Code
# treats .git/ as a protected path and denies agent writes there — which blocks
# an implementer subagent from writing its report file. A self-ignoring
# .gitignore keeps the workspace out of `git status` and out of accidental
# commits without modifying any tracked file.
#
# Single source of truth for the workspace location, so task-brief and
# review-package cannot drift to different directories.
#
# Usage: sdd-workspace
set -euo pipefail

root=$(git rev-parse --show-toplevel)
dir="$root/.superpowers/sdd"
mkdir -p "$dir"
printf '*\n' > "$dir/.gitignore"
cd "$dir" && pwd
44 changes: 44 additions & 0 deletions skills/subagent-driven-development/scripts/task-brief
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash
# Extract one task's full text from an implementation plan into a file the
# implementer reads in one call, so the task text never has to be pasted
# through the controller's context.
#
# Usage: task-brief PLAN_FILE TASK_NUMBER [OUTFILE]
# Default OUTFILE: <repo-root>/.superpowers/sdd/task-<N>-brief.md
# (per worktree; concurrent runs in the same working tree share it).
#
# 中文 fork 适配:上游只识别英文任务标题 "## Task N",而 superpowers-zh
# 的 writing-plans 产出的是 "### 任务 N:..."。下方 awk 同时匹配
# "Task" 与 "任务",两种计划都能抽取。
set -euo pipefail

if [ $# -lt 2 ] || [ $# -gt 3 ]; then
echo "usage: task-brief PLAN_FILE TASK_NUMBER [OUTFILE]" >&2
exit 2
fi

plan=$1
n=$2
[ -f "$plan" ] || { echo "no such plan file: $plan" >&2; exit 2; }

if [ $# -eq 3 ]; then
out=$3
else
dir=$("$(cd "$(dirname "$0")" && pwd)/sdd-workspace")
out="$dir/task-${n}-brief.md"
fi

awk -v n="$n" '
/^```/ { infence = !infence }
!infence && /^#+[ \t]+(Task|任务)[ \t]*[0-9]+/ {
intask = ($0 ~ ("^#+[ \t]+(Task|任务)[ \t]*" n "([^0-9]|$)"))
}
intask { print }
' "$plan" > "$out"

if [ ! -s "$out" ]; then
echo "task ${n} not found in ${plan} (no heading matching 'Task ${n}' / '任务 ${n}')" >&2
exit 3
fi

echo "wrote ${out}: $(wc -l < "$out" | tr -d ' ') lines"
61 changes: 0 additions & 61 deletions skills/subagent-driven-development/spec-reviewer-prompt.md

This file was deleted.

Loading
Loading