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:
  1. Verify after each step
    dotnet build
    +
    dotnet test
    between steps. A cleanup that breaks something is worse than the mess it was fixing.
  2. Commit per step — each step is its own commit, so a bad Step 4 reverts without losing Steps 1-3.
  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
references/cleanup-steps.md
— read it before executing.
为.NET代码库运行一个有序、经过验证的清理流水线。步骤顺序至关重要:先执行格式化(它会修改每个文件——先搞定格式变动,再处理其他操作),最后处理死代码(前面的步骤会暴露死代码)。随机清理会遗漏内容并造成合并冲突,而本流水线不会出现这些问题。
确保安全的三条规则:
  1. 每步后验证——步骤间执行
    dotnet build
    +
    dotnet test
    。会破坏功能的清理比原本的混乱更糟糕。
  2. 分步提交——每个步骤单独提交,因此如果第4步出现问题,只需回滚第4步,不会丢失第1-3步的成果。
  3. 仅安全移除——删除“死”代码前,检查Roslyn无法识别的反射、DI约定和序列化用法。
各步骤的命令、安全检查清单和代码示例位于
references/cleanup-steps.md
中——执行前请阅读该文档。

When

适用场景

  • "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:选择要执行的步骤

ScenarioSteps to run
Full cleanup pass / pre-release / quarterlyAll 7
Quick tidy before PR1, 2, 6
After large feature merge1, 2, 3, 4
After dependency upgrade2, 3
Before performance work4, 6
CI warning threshold exceeded3 only
Tech debt sprint4, 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)

#StepToolCommit message
1Format all code
dotnet format
chore: apply dotnet format
2Remove unused usings
dotnet format analyzers --diagnostics IDE0005
chore: remove unused using statements
3Fix analyzer warningsMCP
get_diagnostics
→ triage by category
chore: fix analyzer warnings
4Remove dead codeMCP
find_dead_code
+ safety check (reflection/DI/serialization grep)
chore: remove dead code
5Resolve TODOsgrep TODO/HACK/FIXME → fix, file issue, or delete
chore: resolve TODO comments
6Seal non-inherited classesMCP
get_type_hierarchy
per candidate + test-project grep
chore: seal non-inherited classes
7Propagate CancellationTokenMCP
detect_antipatterns
→ trace async chains
chore: propagate CancellationToken through async chains
After every step:
dotnet build
+
dotnet test
, 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
refactor-cleaner
agent.
序号步骤工具提交信息
1格式化所有代码
dotnet format
chore: apply dotnet format
2移除未使用的using语句
dotnet format analyzers --diagnostics IDE0005
chore: remove unused using statements
3修复分析器警告MCP
get_diagnostics
→ 按类别分类处理
chore: fix analyzer warnings
4移除死代码MCP
find_dead_code
+ 安全检查(反射/DI/序列化 grep)
chore: remove dead code
5处理TODO注释grep TODO/HACK/FIXME → 修复、创建问题或删除
chore: resolve TODO comments
6密封非继承类MCP
get_type_hierarchy
逐个检查候选类 + 测试项目grep
chore: seal non-inherited classes
7传递CancellationTokenMCP
detect_antipatterns
→ 追踪异步调用链
chore: propagate CancellationToken through async chains
每一步完成后:执行
dotnet build
+
dotnet test
,然后提交。如果某一步破坏了构建或测试,修复或回滚该步骤后再继续——切勿带着失败状态进入下一步。将结构性步骤(4、6、7)委托给
refactor-cleaner
agent处理。

Final Report

最终报告

markdown
undefined
markdown
undefined

De-Sloppify Report

De-Sloppify 清理报告

StepChangesFiles Affected
1. FormatApplied consistent formatting23 files
2. UsingsRemoved 47 unused usings18 files
3. AnalyzersFixed 12 warnings (8 nullability, 3 unused vars, 1 obsolete)9 files
4. Dead CodeRemoved 3 unused types, 5 unused methods6 files
5. TODOsFixed 2, created issues for 3, removed 1 stale5 files
6. SealedSealed 14 classes14 files
7. CancellationTokenAdded propagation to 8 async chains11 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个过期TODO5个文件
6. 密封类密封14个类14个文件
7. CancellationToken传递为8条异步调用链添加传递逻辑11个文件
总计:7次提交,86个文件得到优化
undefined

Example

示例

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

相关内容

  • references/cleanup-steps.md
    — per-step commands, safety checks, examples
  • /verify
    — run the full verification pipeline after cleanup
  • /health-check
    — re-grade the project to quantify the improvement
  • /code-review
    — cleanup handles style; review handles logic and design
  • references/cleanup-steps.md
    — 各步骤的命令、安全检查、示例
  • /verify
    — 清理后运行完整验证流水线
  • /health-check
    — 重新评估项目以量化改进效果
  • /code-review
    — 清理处理风格问题;评审处理逻辑和设计问题