loose-ends
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLoose Ends
遗留问题清理
<purpose>
Implementation feels done, but loose ends remain. The import you added but didn't
use. The TODO you wrote and forgot. The test you meant to add. The console.log
you left in. This skill forces a sweep before declaring victory.
</purpose>
<purpose>
功能开发看似完成,但仍存在各类遗留问题:你添加后未使用的导入、写下后遗忘的TODO、本该添加的测试、遗留的console.log。这个技能会强制你在宣布完成前进行一次全面排查。
</purpose>
When To Activate
启用时机
<triggers>
- About to say "done" or "complete"
- Finishing a feature implementation
- After fixing a bug
- Before committing changes
- After any multi-file change
- User asks "is it ready?"
</triggers>
<triggers>
- 即将说出“完成”时
- 完成功能开发后
- 修复bug后
- 提交代码变更前
- 完成多文件修改后
- 用户询问“是否准备就绪?”时
</triggers>
Instructions
操作指南
The Loose Ends Checklist
遗留问题检查清单
Before declaring complete, run through:
<checklist>在宣布完成前,逐一检查以下内容:
<checklist>Loose Ends Sweep
遗留问题全面排查
Code Hygiene
代码整洁度
- No unused imports
- No unused variables
- No commented-out code (unless intentional)
- No console.log/print statements left in
- No debugger statements
- 无未使用的导入语句
- 无未使用的变量
- 无注释掉的代码(除非是有意保留)
- 无遗留的console.log/print语句
- 无debugger语句
TODOs and FIXMEs
TODO与FIXME注释
- No new TODOs created and forgotten
- Any existing TODOs in touched files addressed or noted
- 无创建后遗忘的新TODO
- 已修改文件中的现有TODO均已处理或记录
Tests
测试
- New code has tests (or explicit reason why not)
- Existing tests still pass
- Edge cases considered
- 新增代码配有测试(或有明确理由无需测试)
- 现有测试仍能通过
- 已考虑边缘情况
Types (if applicable)
类型检查(如适用)
- No types added
any - No type assertions without reason
- Interfaces/types defined for new structures
- 未新增类型
any - 无无理由的类型断言
- 为新结构定义了接口/类型
References
引用检查
- Old references updated if things were renamed
- No broken imports
- No stale comments referring to old code
- 若有重命名,旧引用已更新
- 无失效的导入语句
- 无提及旧代码的过时注释
Error Handling
错误处理
- Errors handled or explicitly bubbled up
- User-facing errors have good messages
- No silent failures
- 错误已处理或显式向上抛出
- 用户可见的错误配有清晰提示信息
- 无静默失败情况
Automated Sweep
自动化排查
Run the sweep script to find common cruft:
bash
python scripts/sweep.pyScans for:
- ,
console.log,print()statementsdebugger - ,
TODO,FIXME,XXXcommentsHACK - ,
dd(),var_dump()(PHP/Ruby)binding.pry
运行清理脚本以查找常见冗余内容:
bash
python scripts/sweep.py可扫描以下内容:
- ,
console.log,print()语句debugger - ,
TODO,FIXME,XXX注释HACK - ,
dd(),var_dump()(PHP/Ruby)binding.pry
Quick Scan Commands
快速扫描命令
bash
undefinedbash
undefinedFind TODOs in changed files
在已修改文件中查找TODO
git diff --name-only | xargs grep -n "TODO|FIXME"
git diff --name-only | xargs grep -n "TODO|FIXME"
Find console.log in changed files
在已修改文件中查找console.log
git diff --name-only | xargs grep -n "console.log"
git diff --name-only | xargs grep -n "console.log"
Find unused imports (TypeScript)
查找未使用的导入(TypeScript)
npx tsc --noEmit 2>&1 | grep "declared but"
npx tsc --noEmit 2>&1 | grep "declared but"
Find any types added
查找新增的any类型
git diff | grep ": any"
undefinedgit diff | grep ": any"
undefinedPrioritize by Impact
按影响程度优先处理
Not all loose ends are equal:
| Priority | Type | Action |
|---|---|---|
| Fix now | Broken imports, missing exports | Blocks functionality |
| Fix now | console.log in production code | Leaks info |
| Should fix | Unused imports/variables | Code smell |
| Should fix | Missing tests for new logic | Technical debt |
| Note for later | Old TODOs in touched files | Existing debt |
| Ignore | Style inconsistencies | Not your scope |
并非所有遗留问题的影响都相同:
| 优先级 | 类型 | 操作 |
|---|---|---|
| 立即修复 | 失效的导入、缺失的导出 | 会阻塞功能运行 |
| 立即修复 | 生产代码中的console.log | 会泄露信息 |
| 应当修复 | 未使用的导入/变量 | 代码异味 |
| 应当修复 | 新增逻辑缺失测试 | 技术债务 |
| 后续记录 | 已修改文件中的旧TODO | 已有技术债务 |
| 忽略 | 样式不一致 | 不在你的职责范围内 |
Output Format
输出格式
markdown
undefinedmarkdown
undefinedLoose Ends Check
遗留问题检查
Files changed: [count]
Fixed:
- Removed unused import in
file.ts - Removed console.log in
handler.ts
Noted:
- has existing TODO (not from this change)
utils.ts:45
Clean: No loose ends found / All addressed
undefined已修改文件数: [count]
已修复:
- 移除中未使用的导入
file.ts - 移除中的console.log
handler.ts
已记录:
- 存在旧TODO(非本次变更产生)
utils.ts:45
状态: 未发现遗留问题 / 所有问题均已处理
undefinedNEVER
禁止操作
- Declare "done" without scanning for loose ends
- Leave console.log in production code
- Create TODOs and forget about them
- Leave unused imports from experimentation
- Skip the checklist because "it's a small change"
- 未扫描遗留问题就宣布“完成”
- 在生产代码中遗留console.log
- 创建TODO后遗忘
- 保留实验性的未使用导入
- 以“只是小改动”为由跳过检查清单
ALWAYS
必须执行
- Scan changed files before committing
- Remove debugging artifacts
- Address or document any TODOs you create
- Verify imports are used
- Check that tests pass after changes
- 提交前扫描已修改文件
- 删除调试痕迹
- 处理或记录你创建的所有TODO
- 验证导入语句均已使用
- 修改后确认测试仍能通过
Example
示例
After implementing a new API endpoint:
markdown
undefined完成新API端点开发后:
markdown
undefinedLoose Ends Check
遗留问题检查
Files changed: 4
Scanning...
api/users.ts- Line 3: unused import → Removed
lodash - Line 45: console.log for debugging → Removed
types/user.ts- Clean
tests/users.test.ts- New endpoint has test → Good
- Edge case (empty input) not tested → Added
services/user.ts- Line 23: TODO I wrote: "validate email format" → Addressed now
Result: 4 loose ends found and fixed. Ready to commit.
undefined已修改文件数:4
扫描结果...
api/users.ts- 第3行:未使用的导入→ 已移除
lodash - 第45行:调试用console.log → 已移除
types/user.ts- 无问题
tests/users.test.ts- 新端点已有测试 → 符合要求
- 边缘情况(空输入)未测试 → 已补充
services/user.ts- 第23行:我创建的TODO:“验证邮箱格式” → 已处理
结果: 发现4个遗留问题并已修复,可提交。
undefined