Loading...
Loading...
Compare original and translation side by side
Agentsubagent_type="Explore"| Analysis Target | What to Document | Priority |
|---|---|---|
| Entry points | All ways the system can be invoked (HTTP, CLI, events, cron) | P0 |
| Code paths | Every branch, loop, conditional, early return | P0 |
| Data flows | Input → transformation → output for every pipeline | P0 |
| State mutations | Every place state is read, written, or deleted | P0 |
| Error handling | Try/catch blocks, error codes, fallback behaviors | P0 |
| Side effects | External calls, file I/O, database writes, event emissions | P1 |
| Configuration | Environment variables, config files, feature flags | P1 |
| Dependencies | External services, libraries, APIs consumed | P1 |
| Concurrency | Async operations, race conditions, locking mechanisms | P2 |
| Implicit behavior | Convention-based routing, middleware chains, decorators | P2 |
Agentsubagent_type="Explore"| 分析目标 | 需要记录的内容 | 优先级 |
|---|---|---|
| 入口点 | 系统可被调用的所有方式(HTTP、CLI、事件、定时任务) | P0 |
| 代码路径 | 每一个分支、循环、条件判断、提前返回 | P0 |
| 数据流 | 每条管线的输入→转换→输出流程 | P0 |
| 状态变更 | 所有状态被读取、写入、删除的位置 | P0 |
| 错误处理 | Try/catch块、错误码、降级行为 | P0 |
| 副作用 | 外部调用、文件I/O、数据库写入、事件触发 | P1 |
| 配置 | 环境变量、配置文件、功能开关 | P1 |
| 依赖 | 外部服务、类库、调用的API | P1 |
| 并发 | 异步操作、竞态条件、锁机制 | P2 |
| 隐式行为 | 基于约定的路由、中间件链、装饰器 | P2 |
| Codebase Size | Strategy | Subagent Count |
|---|---|---|
| Small (<50 files) | Single-pass full scan | 5-10 |
| Medium (50-500 files) | Module-by-module scan | 50-100 |
| Large (500+ files) | Entry-point-first, then depth scan | 200-500 |
| 代码库规模 | 策略 | 子Agent数量 |
|---|---|---|
| 小型(<50个文件) | 单轮全量扫描 | 5-10 |
| 中型(50-500个文件) | 逐模块扫描 | 50-100 |
| 大型(500+个文件) | 先按入口点分析,再深度扫描 | 200-500 |
spec-writingspec-writing| Rule | Explanation |
|---|---|
| Strip ALL implementation details | No function names, variable names, technology references |
| Describe WHAT, never HOW | Observable behavior only |
| Document actual behavior (bugs included) | Bugs become "current behavior" in specs |
| Use Given/When/Then format | For all acceptance criteria |
| Include data contracts | Input shapes, output shapes, invariants |
| Separate known issues | Bugs go in KNOWN_ISSUES.md, not inline |
| 规则 | 说明 |
|---|---|
| 移除所有实现细节 | 不包含函数名、变量名、技术栈相关引用 |
| 只描述“是什么”,绝不描述“怎么做” | 仅记录可观测的行为 |
| 记录实际行为(包括bug) | bug在规范中被标记为“当前行为” |
| 使用Given/When/Then格式 | 所有验收标准都采用该格式 |
| 包含数据契约 | 输入结构、输出结构、不变量 |
| 已知问题单独归档 | bug放在KNOWN_ISSUES.md中,不写在规范正文里 |
| Code Artifact | What You See | What You Write in Spec |
|---|---|---|
| Token validation with JWT | "Credentials are validated against the authentication system" |
| Redis cache lookup | "Previously computed results are retrieved from cache" |
| Role check | "Privileged operations require administrator access" |
| Rate limiting response | "Excessive requests receive a rate limit error" |
| Password hashing | "Passwords are stored in a non-reversible format" |
| 代码片段 | 实际含义 | 你需要写在规范里的内容 |
|---|---|---|
| 使用JWT做token校验 | “凭据会通过认证系统进行校验” |
| Redis缓存查询 | “从缓存中获取之前计算好的结果” |
| 角色校验 | “特权操作需要管理员权限” |
| 限流响应 | “请求过多时会返回限流错误” |
| 密码哈希 | “密码以不可逆格式存储” |
specs/
├── 01-[first-capability].md
├── 02-[second-capability].md
├── ...
├── NN-[last-capability].md
└── KNOWN_ISSUES.mdspecs/
├── 01-[first-capability].md
├── 02-[second-capability].md
├── ...
├── NN-[last-capability].md
└── KNOWN_ISSUES.mdundefinedundefinedundefinedundefined| Severity | Criteria | Action |
|---|---|---|
| Critical | Data loss, security vulnerability, system crash | Fix before any new features |
| High | Incorrect results, broken workflow | Fix in next release |
| Medium | Poor UX, performance issue | Plan for future fix |
| Low | Cosmetic, minor inconsistency | Fix opportunistically |
| 严重程度 | 判定标准 | 处理方式 |
|---|---|---|
| Critical(致命) | 数据丢失、安全漏洞、系统崩溃 | 新增任何功能前必须修复 |
| High(高) | 结果错误、工作流中断 | 下一个版本修复 |
| Medium(中) | 用户体验差、性能问题 | 规划未来修复 |
| Low(低) | 样式问题、微小不一致 | 有空再修复 |
| # | Check | Question | Status |
|---|---|---|---|
| 1 | Entry points | Are ALL entry points documented? | [ ] |
| 2 | Code paths | Are ALL branches and conditionals traced? | [ ] |
| 3 | Data flows | Are ALL input→output pipelines described? | [ ] |
| 4 | State mutations | Are ALL state changes captured? | [ ] |
| 5 | Error handling | Are ALL error paths documented? | [ ] |
| 6 | Side effects | Are ALL external interactions noted? | [ ] |
| 7 | Edge cases | Are boundary conditions described? | [ ] |
| 8 | Concurrency | Are async behaviors documented? | [ ] |
| 9 | Configuration | Are ALL config options listed? | [ ] |
| 10 | Dependencies | Are ALL external dependencies identified? | [ ] |
| 11 | Implementation-free | Zero code, tech names, or architecture in specs? | [ ] |
| 12 | Given/When/Then | All acceptance criteria in correct format? | [ ] |
| 序号 | 检查项 | 检查问题 | 状态 |
|---|---|---|---|
| 1 | 入口点 | 所有入口点都被记录了吗? | [ ] |
| 2 | 代码路径 | 所有分支和条件判断都被追溯了吗? | [ ] |
| 3 | 数据流 | 所有输入→输出管线都被描述了吗? | [ ] |
| 4 | 状态变更 | 所有状态变化都被捕获了吗? | [ ] |
| 5 | 错误处理 | 所有错误路径都被记录了吗? | [ ] |
| 6 | 副作用 | 所有外部交互都被标注了吗? | [ ] |
| 7 | 边界情况 | 边界条件都被描述了吗? | [ ] |
| 8 | 并发 | 异步行为都被记录了吗? | [ ] |
| 9 | 配置 | 所有配置项都被列出了吗? | [ ] |
| 10 | 依赖 | 所有外部依赖都被识别了吗? | [ ] |
| 11 | 无实现细节 | 规范中没有代码、技术名称或架构相关内容吗? | [ ] |
| 12 | Given/When/Then | 所有验收标准都使用了正确格式吗? | [ ] |
function checkAuth(req, res, next) {
const token = req.headers.authorization?.split(' ')[1];
if (!token) return res.status(401).json({ error: 'No token' });
try {
const decoded = jwt.verify(token, process.env.JWT_SECRET);
req.user = decoded;
next();
} catch (e) {
return res.status(403).json({ error: 'Invalid token' });
}
}function checkAuth(req, res, next) {
const token = req.headers.authorization?.split(' ')[1];
if (!token) return res.status(401).json({ error: 'No token' });
try {
const decoded = jwt.verify(token, process.env.JWT_SECRET);
req.user = decoded;
next();
} catch (e) {
return res.status(403).json({ error: 'Invalid token' });
}
}undefinedundefined
Notice: No mention of JWT, middleware, Express, environment variables, or any implementation detail.
注意:规范中没有提到JWT、中间件、Express、环境变量或任何实现细节。| Mistake | Why It Is Wrong | What To Do Instead |
|---|---|---|
| Skipping "boring" code paths | Undocumented behavior causes bugs during refactoring | Trace EVERY path, even error handlers |
| Leaking implementation details into specs | Defeats the purpose of behavioral specs | Strip all tech names, function names, code |
| Marking bugs as "correct behavior" | Loses the information that it is a bug | Document in KNOWN_ISSUES.md with severity |
| Skipping async/concurrency analysis | Race conditions are the hardest bugs to find | Document all async behavior |
| Analyzing only happy paths | Most bugs live in error paths | Document ALL error handling paths |
| Guessing behavior instead of tracing code | Spec becomes fiction | Read every line — no assumptions |
| Generating specs without user review | Misunderstandings propagate | Present for review after each phase |
| 错误 | 错误原因 | 正确做法 |
|---|---|---|
| 跳过“无聊”的代码路径 | 未记录的行为会在重构时导致bug | 追溯每一条路径,哪怕是错误处理逻辑 |
| 规范中泄露实现细节 | 违背了行为规范的设计目的 | 移除所有技术名称、函数名、代码 |
| 将bug标记为“正确行为” | 丢失了bug相关信息 | 在KNOWN_ISSUES.md中按严重程度记录 |
| 跳过异步/并发分析 | 竞态条件是最难发现的bug | 记录所有异步行为 |
| 只分析正常路径 | 大多数bug都存在于错误路径中 | 记录所有错误处理路径 |
| 猜测行为而不是追溯代码 | 规范会失去参考价值 | 逐行阅读代码——不做任何假设 |
| 未经用户审核就生成规范 | 误解会被传递放大 | 每个阶段完成后都提交给用户审核 |
| Skill | Relationship |
|---|---|
| Output follows spec-writing format; use for audit after generation |
| Specs feed into planning mode for gap analysis |
| Tests derived from reverse-engineered acceptance criteria |
| Populate memory files with discovered project context |
| After specs exist, plan improvements or new features |
| Known issues inform debugging priorities |
| 技能 | 关系 |
|---|---|
| 输出遵循spec-writing格式;生成后可用于审计 |
| 规范会输入到规划模式用于缺口分析 |
| 测试用例可从逆向得到的验收标准派生 |
| 将发现的项目上下文存入内存文件 |
| 规范生成后,可规划改进或新功能 |
| 已知问题可用于确定调试优先级 |
| Step | Skill | Purpose |
|---|---|---|
| 1 | | Generate behavioral specs from code |
| 2 | | Verify quality and completeness |
| 3 | | Identify gaps, plan improvements |
| 4 | | Implement features or fixes with specs as guide |
| 步骤 | 技能 | 目的 |
|---|---|---|
| 1 | | 从代码生成行为规范 |
| 2 | | 校验质量和完整性 |
| 3 | | 识别缺口,规划改进 |
| 4 | | 以规范为指导实现功能或修复 |