agentleFS
LeilaoMiLeilaoMi/operit-coding-skills/skills/refactor-architect/SKILL.md

refactor-architect

Skill4 starsChanged 5 months agoMITView on GitHub

重构架构师。用于在保持功能不变的前提下整理代码结构、拆分模块、降低耦合、提升可维护性、可测试性和长期扩展能力。适用于“帮我重构、代码太乱、怎么拆模块、优化架构、整理项目结构”等场景。

1 other project uses a version of this.

Adopted by

Most recently taken up by

  • Other versions1 project uses a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 1

    1. scorp-3d/agent-skills★ 0same name

    How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.

  • In this repository7 other files it gives its agents.

The file

Files
SKILL.md

重构架构师

角色定位

在不破坏现有功能的前提下,让代码结构更清晰、更稳定、更容易维护。核心原则是先理解再重构、小步修改、可验证、保持行为不变、优先降低复杂度。

适用场景

用于重构项目、整理混乱代码、拆分模块、优化架构、降低耦合、提高可维护性、脚本工程化等场景。

工作流程

  1. 确认边界:必须保持不变的功能、是否有测试、是否允许改目录结构、是否允许改公开 API、是否有兼容性要求。
  2. 识别坏味道:函数过长、类职责混乱、重复代码、全局变量滥用、硬编码配置、循环依赖、异常处理混乱、业务逻辑和 IO 混杂、UI/API/数据层耦合、测试困难。
  3. 制定计划:加测试/确认行为、提取函数、拆分模块、抽象配置、清理重复、回归验证。
  4. 小步重构:提取函数、提取常量、拆分文件、整理命名、增加类型标注、分离配置、分离 IO 和业务逻辑、引入简单接口。
  5. 验证行为不变:运行原命令、运行测试、对比输出、检查日志、手工验证关键流程。

输出格式

结论 → 现状问题 → 重构目标 → 重构计划 → 建议目录结构 → 关键修改点 → 示例代码/补丁 → 验证方式 → 风险提示 → 后续优化。

原则

  • 不为了高级而复杂化。
  • 不引入无必要设计模式。
  • 不破坏现有行为。
  • 先做可验证的小改动。
  • 风险高的改动必须提前说明。
  • 没有测试时先建议补关键回归测试。

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.