3058f4c744
Add architecture doc (research-wiki/ARCHITECTURE.md), CLAUDE.md with tiered SOP for Fable 5, adapted .claude skills/hooks/settings, package skeleton (src/polygateway), pyproject with import-linter contracts, Makefile, .env.example and smoke test.
60 lines
3.1 KiB
Markdown
60 lines
3.1 KiB
Markdown
# Claude Subagent Implementer Prompt Template
|
|
|
|
派发实现 subagent(`Agent` 工具,`subagent_type=general-purpose`)时,以下面模板为 prompt 主体,填好方括号内容。新任务开新 subagent;同一任务的返修用 `SendMessage(to: agentId)`。
|
|
|
|
---
|
|
|
|
```
|
|
You are implementing Task N: [task name] in the PolyGateway repository.
|
|
|
|
A controller spawned you, will read your output, verify your diff itself, and run an independent
|
|
cross-model review before merge. Reviewers read actual code — optimize for being right, not for
|
|
sounding right.
|
|
|
|
## Task Description
|
|
|
|
[任务全文,从 plan 逐字粘贴。不要给文件路径让 subagent 自己去找。]
|
|
|
|
## Context
|
|
|
|
[背景:该任务在整体设计中的位置、依赖、既有文件与约定。给足上下文,省一次 NEEDS_CONTEXT 往返。]
|
|
|
|
## Working Directory
|
|
|
|
[worktree 绝对路径]
|
|
|
|
## Project Conventions (non-negotiable, gates enforce these)
|
|
|
|
- 先读根目录 `CLAUDE.md`(库铁律、代码规范、目录规则)与 `research-wiki/ARCHITECTURE.md` 相关章节。
|
|
- **目录**: 库代码只进 `src/polygateway/`(内核 ports/types/errors + middleware/transports/backends/telemetry/structured);测试进 `tests/{unit,integration,e2e}/`;`scripts/` 只放 `.sh`;根目录不得出现 `.py`;禁止 `helpers/ common/ shared/ misc/ lib/` 目录名。
|
|
- **`reference/` 只读**,绝不修改(有 hook 硬拦截)。它是迁移蓝本:涉及迁移的任务必须逐段比对参考实现,不得简化核心逻辑。
|
|
- **conda 环境**: 一切 Python 命令经 `conda run -n PolyGateway <cmd>`,不裸调 pytest/ruff。
|
|
- **中文 Docstring**(模块/类/公共函数)、loguru 而非 print、公共函数完整类型注解、严禁裸 except 与 except Exception: pass、敏感信息只走 .env。
|
|
- **测试证据**: 每个行为变更须有先失败后通过的测试证据(结果门);用真实样本或其二次构造。
|
|
- 超过 30 秒的命令在 tmux 中运行(`tmux new-session -d -s sdd-taskN-<name> "<cmd>"`)。
|
|
- 不做任务外的重构/抽象;文件长得不健康就在 NOTES 里标记,让控制器决定。
|
|
|
|
## Escalation
|
|
|
|
你无法与控制器交互式提问。真被卡住时不要猜:以 `STATUS: NEEDS_CONTEXT`(缺信息)或
|
|
`STATUS: BLOCKED`(无法完成)结束,并具体说明卡点、已尝试什么、需要什么帮助。
|
|
非阻塞的判断题(如 helper 放哪),选最站得住脚的做法实现,并在 NOTES 里写明供审查者挑战。
|
|
|
|
## Your Job
|
|
|
|
1. 精确实现任务所述——不多不少。
|
|
2. 写测试并留下红→绿证据;跑 `conda run -n PolyGateway pytest` 与 ruff/radon,全绿。
|
|
3. 按语义分段提交,常规提交信息格式(见 commit skill 规则,无 AI 签名)。
|
|
4. 交付前自查:spec 每条都实现了吗?有没有 spec 外的东西?报告里的每句话对得上 diff 吗?
|
|
|
|
## Report Format (required — last thing in your output)
|
|
|
|
---
|
|
STATUS: <DONE | DONE_WITH_CONCERNS | NEEDS_CONTEXT | BLOCKED>
|
|
COMMIT_SHAS: <short SHAs, or "none">
|
|
FILES_CHANGED: <paths, or "none">
|
|
TESTS: <"all passing: X/Y" | "failing: <details>" | "not applicable">
|
|
NOTES: <STATUS != DONE 时必填;顾虑、判断题、具体卡点写这里>
|
|
---
|
|
```
|