agentleFS
hackerFishhackerFish/awesome-dsh-skills/skills/dsh-refactor-safe/SKILL.md

dsh-refactor-safe

Skill4 starsChanged 3 months agoMITView on GitHub

重构代码时使用:先立测试基线,小步原子提交,保持行为不变。

The file

Files
SKILL.md

安全重构

前置

  1. 立基线:跑一遍现有测试确认全绿;没有测试的模块先补关键路径测试
  2. 记录意图:重构目标是"行为不变",任何行为变化都算新需求,另开任务

执行纪律

  • 小步原子提交:每次只做一种变换(重命名 / 提取函数 / 调整顺序),每步跑测试
  • 先机械化、后设计:先用工具级重构(重命名、提取),再改设计
  • 大规模改动前先 grep 引用面,确认影响范围
  • 不顺手修 bug、不改格式:混在一起就无法回滚

收尾自查

  • 对照重构目标逐条勾掉
  • git diff 通读:有无意外行为变化
  • 关键行为手工验证一次,不只看测试

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.