de-sloppify
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese/de-sloppify — 7-Step Cleanup Pipeline
/de-sloppify — 七步代码清理流水线
What
概述
Runs an ordered, verified cleanup pipeline over a .NET codebase. Order matters:
formatting first (it touches every file — get the churn out of the way before
anything else), dead code late (earlier steps reveal it). Random cleanup misses
things and creates merge conflicts; the pipeline doesn't.
Three rules make it safe:
- Verify after each step — +
dotnet buildbetween steps. A cleanup that breaks something is worse than the mess it was fixing.dotnet test - Commit per step — each step is its own commit, so a bad Step 4 reverts without losing Steps 1-3.
- Safe removals only — before deleting "dead" code, check for reflection, DI-convention, and serialization usage that Roslyn cannot see.
Per-step commands, safety checklists, and code examples live in
— read it before executing.
references/cleanup-steps.md为.NET代码库运行一个有序、经过验证的清理流水线。步骤顺序至关重要:先执行格式化(它会修改每个文件——先搞定格式变动,再处理其他操作),最后处理死代码(前面的步骤会暴露死代码)。随机清理会遗漏内容并造成合并冲突,而本流水线不会出现这些问题。
确保安全的三条规则:
- 每步后验证——步骤间执行+
dotnet build。会破坏功能的清理比原本的混乱更糟糕。dotnet test - 分步提交——每个步骤单独提交,因此如果第4步出现问题,只需回滚第4步,不会丢失第1-3步的成果。
- 仅安全移除——删除“死”代码前,检查Roslyn无法识别的反射、DI约定和序列化用法。
各步骤的命令、安全检查清单和代码示例位于中——执行前请阅读该文档。
references/cleanup-steps.mdWhen
适用场景
- "Clean up", "tidy up", "de-sloppify", "housekeeping", "tech debt"
- After a large feature merge or dependency upgrade (new warnings accumulate)
- Pre-release hardening, or a scheduled quarterly cleanup sprint
- Before performance work (dead code out, classes sealed for devirtualization)
- Never mixed with feature work — cleanup commits stay pure
- 当需要“清理”、“整理”、“规整代码”、“代码维护”、“技术债务”处理时
- 大型功能合并或依赖项升级后(会积累新的警告)
- 预发布加固,或定期的季度清理迭代
- 性能优化工作前(移除死代码,密封类以实现去虚拟化)
- 切勿与功能开发混合——清理提交需保持纯粹
How
操作指南
Step 0: Pick the Steps
步骤0:选择要执行的步骤
| Scenario | Steps to run |
|---|---|
| Full cleanup pass / pre-release / quarterly | All 7 |
| Quick tidy before PR | 1, 2, 6 |
| After large feature merge | 1, 2, 3, 4 |
| After dependency upgrade | 2, 3 |
| Before performance work | 4, 6 |
| CI warning threshold exceeded | 3 only |
| Tech debt sprint | 4, 5 |
| 场景 | 需执行的步骤 |
|---|---|
| 完整清理/预发布/季度清理 | 全部7步 |
| 提交PR前快速整理 | 1、2、6 |
| 大型功能合并后 | 1、2、3、4 |
| 依赖项升级后 | 2、3 |
| 性能优化工作前 | 4、6 |
| CI警告阈值超标 | 仅3 |
| 技术债务迭代 | 4、5 |
Steps 1-7 (execute in order, details in references/cleanup-steps.md)
步骤1-7(按顺序执行,详细内容见references/cleanup-steps.md)
| # | Step | Tool | Commit message |
|---|---|---|---|
| 1 | Format all code | | |
| 2 | Remove unused usings | | |
| 3 | Fix analyzer warnings | MCP | |
| 4 | Remove dead code | MCP | |
| 5 | Resolve TODOs | grep TODO/HACK/FIXME → fix, file issue, or delete | |
| 6 | Seal non-inherited classes | MCP | |
| 7 | Propagate CancellationToken | MCP | |
After every step: + , then commit. If a step breaks
the build or tests, fix or revert that step before continuing — never carry a
red state into the next step. Delegate structural steps (4, 6, 7) to the
agent.
dotnet builddotnet testrefactor-cleaner| 序号 | 步骤 | 工具 | 提交信息 |
|---|---|---|---|
| 1 | 格式化所有代码 | | |
| 2 | 移除未使用的using语句 | | |
| 3 | 修复分析器警告 | MCP | |
| 4 | 移除死代码 | MCP | |
| 5 | 处理TODO注释 | grep TODO/HACK/FIXME → 修复、创建问题或删除 | |
| 6 | 密封非继承类 | MCP | |
| 7 | 传递CancellationToken | MCP | |
每一步完成后:执行 + ,然后提交。如果某一步破坏了构建或测试,修复或回滚该步骤后再继续——切勿带着失败状态进入下一步。将结构性步骤(4、6、7)委托给 agent处理。
dotnet builddotnet testrefactor-cleanerFinal Report
最终报告
markdown
undefinedmarkdown
undefinedDe-Sloppify Report
De-Sloppify 清理报告
| Step | Changes | Files Affected |
|---|---|---|
| 1. Format | Applied consistent formatting | 23 files |
| 2. Usings | Removed 47 unused usings | 18 files |
| 3. Analyzers | Fixed 12 warnings (8 nullability, 3 unused vars, 1 obsolete) | 9 files |
| 4. Dead Code | Removed 3 unused types, 5 unused methods | 6 files |
| 5. TODOs | Fixed 2, created issues for 3, removed 1 stale | 5 files |
| 6. Sealed | Sealed 14 classes | 14 files |
| 7. CancellationToken | Added propagation to 8 async chains | 11 files |
Total: 7 commits, 86 files improved
undefined| 步骤 | 变更内容 | 影响文件数 |
|---|---|---|
| 1. 格式化 | 应用统一格式 | 23个文件 |
| 2. 移除using | 移除47个未使用的using语句 | 18个文件 |
| 3. 修复分析器警告 | 修复12个警告(8个可空性问题、3个未使用变量、1个过时API) | 9个文件 |
| 4. 移除死代码 | 移除3个未使用类型、5个未使用方法 | 6个文件 |
| 5. 处理TODO | 修复2个、为3个创建问题、删除1个过期TODO | 5个文件 |
| 6. 密封类 | 密封14个类 | 14个文件 |
| 7. CancellationToken传递 | 为8条异步调用链添加传递逻辑 | 11个文件 |
总计:7次提交,86个文件得到优化
undefinedExample
示例
User: /de-sloppify — full pass before the release
Claude: Running the 7-step pipeline...
Step 1: dotnet format — 23 files reformatted. Build + tests green. Committed.
Step 2: IDE0005 — 47 unused usings removed across 18 files. Green. Committed.
Step 3: 12 warnings triaged: 8 nullability fixed with null checks,
3 unused vars removed, 1 CS0618 migrated off the obsolete API. Committed.
Step 4: find_dead_code → 9 candidates. Safety check: PaymentProcessor is
registered via DI convention — kept. Removed 3 types, 5 methods. Committed.
Step 5: 6 TODOs → 2 fixed, 3 became issues (#141-#143), 1 stale removed. Committed.
Step 6: 14 classes sealed (2 skipped: xUnit fixture base, virtual members). Committed.
Step 7: 8 async chains now propagate ct end-to-end. Committed.
7 commits, 86 files improved. Full report above.用户:/de-sloppify — 发布前完整清理
Claude:正在运行七步流水线...
步骤1:dotnet format — 23个文件已格式化。构建 + 测试通过。已提交。
步骤2:IDE0005 — 18个文件中移除了47个未使用的using语句。测试通过。已提交。
步骤3:12个警告已分类处理:8个可空性问题已通过空检查修复,3个未使用变量已移除,1个CS0618已迁移出过时API。已提交。
步骤4:find_dead_code → 9个候选对象。安全检查:PaymentProcessor通过DI convention注册——保留。移除了3个类型、5个方法。已提交。
步骤5:6个TODO → 2个已修复,3个转为问题(#141-#143),1个过期TODO已删除。已提交。
步骤6:14个类已密封(2个跳过:xUnit fixture基类、包含虚成员的类)。已提交。
步骤7:8条异步调用链现在已端到端传递ct。已提交。
共7次提交,86个文件得到优化。完整报告如上。Related
相关内容
- — per-step commands, safety checks, examples
references/cleanup-steps.md - — run the full verification pipeline after cleanup
/verify - — re-grade the project to quantify the improvement
/health-check - — cleanup handles style; review handles logic and design
/code-review
- — 各步骤的命令、安全检查、示例
references/cleanup-steps.md - — 清理后运行完整验证流水线
/verify - — 重新评估项目以量化改进效果
/health-check - — 清理处理风格问题;评审处理逻辑和设计问题
/code-review