loose-ends

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Loose 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
    any
    types added
  • 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
</checklist>
  • 错误已处理或显式向上抛出
  • 用户可见的错误配有清晰提示信息
  • 无静默失败情况
</checklist>

Automated Sweep

自动化排查

Run the sweep script to find common cruft:
bash
python scripts/sweep.py
Scans for:
  • console.log
    ,
    print()
    ,
    debugger
    statements
  • TODO
    ,
    FIXME
    ,
    XXX
    ,
    HACK
    comments
  • dd()
    ,
    var_dump()
    ,
    binding.pry
    (PHP/Ruby)
运行清理脚本以查找常见冗余内容:
bash
python scripts/sweep.py
可扫描以下内容:
  • console.log
    ,
    print()
    ,
    debugger
    语句
  • TODO
    ,
    FIXME
    ,
    XXX
    ,
    HACK
    注释
  • dd()
    ,
    var_dump()
    ,
    binding.pry
    (PHP/Ruby)

Quick Scan Commands

快速扫描命令

bash
undefined
bash
undefined

Find 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"
undefined
git diff | grep ": any"
undefined

Prioritize by Impact

按影响程度优先处理

Not all loose ends are equal:
PriorityTypeAction
Fix nowBroken imports, missing exportsBlocks functionality
Fix nowconsole.log in production codeLeaks info
Should fixUnused imports/variablesCode smell
Should fixMissing tests for new logicTechnical debt
Note for laterOld TODOs in touched filesExisting debt
IgnoreStyle inconsistenciesNot your scope
并非所有遗留问题的影响都相同:
优先级类型操作
立即修复失效的导入、缺失的导出会阻塞功能运行
立即修复生产代码中的console.log会泄露信息
应当修复未使用的导入/变量代码异味
应当修复新增逻辑缺失测试技术债务
后续记录已修改文件中的旧TODO已有技术债务
忽略样式不一致不在你的职责范围内

Output Format

输出格式

markdown
undefined
markdown
undefined

Loose Ends Check

遗留问题检查

Files changed: [count]
Fixed:
  • Removed unused import in
    file.ts
  • Removed console.log in
    handler.ts
Noted:
  • utils.ts:45
    has existing TODO (not from this change)
Clean: No loose ends found / All addressed
undefined
已修改文件数: [count]
已修复:
  • 移除
    file.ts
    中未使用的导入
  • 移除
    handler.ts
    中的console.log
已记录:
  • utils.ts:45
    存在旧TODO(非本次变更产生)
状态: 未发现遗留问题 / 所有问题均已处理
undefined

NEVER

禁止操作

  • 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
undefined

Loose Ends Check

遗留问题检查

Files changed: 4
Scanning...
api/users.ts
:
  • Line 3: unused import
    lodash
    → Removed
  • 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