agentleFS
AsiaOstrichAsiaOstrich/EngramGraph/.agents/skills/refactoring-assistant/SKILL.md

refactor

Skill4 starsChanged 29 days agoMITView on GitHub

[UDS] Guide refactoring decisions and strategy selection, including the refactor-versus-rewrite call. Use when: code has become hard to change, choosing between tactical and architectural refactoring, working safely inside legacy code. Not for: moving to a different framework or major version — use /migrate; clearing debug artifacts and dead code — use /sweep. Keywords: refactor, rewrite, strangler, legacy code, technical debt, code smell, 重構, 重寫, 技術債.

196 other projects use a version of this.

Adopted by

Most recently taken up by

Used with

Projects with it also use ascii-diagram, debug-fix and 10 more.

Other files people use alongside this one.

Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
  • SethGammonSkill

    ascii-diagram

    Generate perfectly aligned ASCII diagrams — architecture, flow, sequence, box-and-arrow. Uses a programmatic character-grid approach so alignment is guaranteed by math, not token prediction. Includes post-render verification.

    Also in 4 projects that use this

  • zebbernSkill

    debug-fix

    Find and fix a bug or issue — from any source (GitHub issue, error message, user report, or observed behavior)

    Also in 4 projects that use this

  • parcadeiSkill

    agent-context-isolation

    Agent Context Isolation

    Also in 3 projects that use this

  • parcadeiSkill

    agentica-infrastructure

    Reference guide for Agentica multi-agent infrastructure APIs

    Also in 3 projects that use this

  • +8 more from parcadei

The file

We split this skill into the rules it gives an agent

4 rules. 0 are common, 3 are distinctive, and 1 is very specific to this project.

  • 0

    Common

    Most of the 169 edited versions we read keep these.

  • 3

    Distinctive

    This author's own choices. Worth a look.

  • 1

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Decide: - Run decision tree (refactor vs.

    line 59
  2. Distinctive:

    Execute: - Follow step-by-step workflow with safety checks

    line 61
  3. Distinctive:

    Verify: - Run tests to confirm behavior is preserved

    line 62
  4. Very specific:

    After /refactor completes, the AI assistant should suggest:

    line 81

“Common” is measured: kept by at least 6 in 10 of the 169 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Refactoring Assistant | 重構助手

Guide refactoring decisions, recommend strategies, and provide step-by-step execution workflows.

引導重構決策、推薦策略,並提供逐步執行工作流程。

Usage | 使用方式

CommandPurpose用途
/refactorStart interactive refactoring guide啟動互動式重構引導
/refactor decideRun refactor vs. rewrite decision tree執行重構 vs 重寫決策樹
/refactor tacticalSuggest tactical (daily) strategies建議戰術性(日常)策略
/refactor strategicGuide strategic/architectural refactoring引導戰略性/架構重構
/refactor legacyLegacy code safety strategies遺留程式碼安全策略
/refactor debtTechnical debt assessment技術債評估

Strategy Quick Reference | 策略快速參考

Tactical Strategies (Daily) | 戰術性策略

StrategyWhen to Use使用時機
Preparatory RefactoringBefore adding a blocked feature新增被阻擋的功能之前
Boy Scout RuleDuring any maintenance work任何維護工作中
Red-Green-RefactorTDD development cycleTDD 開發循環

Strategic Strategies (Architectural) | 戰略性策略

StrategyWhen to Use使用時機
Strangler FigReplacing entire system gradually逐步替換整個系統
Anti-Corruption LayerIntegrating with legacy system與遺留系統整合
Branch by AbstractionShared code refactoring on trunk在主幹上重構共享程式碼

Safety Strategies (Legacy) | 安全防護策略

StrategyWhen to Use使用時機
Characterization TestsBefore any legacy refactoring任何遺留程式碼重構之前
Scratch RefactoringUnderstanding black-box code理解黑盒程式碼
Finding SeamsInjecting test doubles into legacy在遺留程式碼中注入測試替身

Workflow | 工作流程

  1. Assess - Identify code to refactor, evaluate test coverage
  2. Decide - Run decision tree (refactor vs. rewrite) if needed
  3. Select strategy - Choose appropriate strategy based on scope and risk
  4. Execute - Follow step-by-step workflow with safety checks
  5. Verify - Run tests to confirm behavior is preserved

Usage Examples | 使用範例

User: /refactor src/legacy-auth/
AI: Analyzing src/legacy-auth/...
    Test coverage: 23% — recommending safety-first approach.
    Suggested strategy: Characterization Tests + Preparatory Refactoring
User: /refactor decide
AI: Let me help you decide whether to refactor or rewrite.
    Question 1: Is the code currently working in production? [Y/N]

Next Steps Guidance | 下一步引導

After /refactor completes, the AI assistant should suggest:

重構完成。建議下一步 / Refactoring complete. Suggested next steps:

  • 執行 /checkin 通過品質關卡 ⭐ Recommended / 推薦 — Pass quality gates
  • 執行 /coverage 確認重構後覆蓋率不下降 — Verify coverage not decreased
  • 執行 /commit 提交重構變更 — Commit the refactoring changes

Reference | 參考

  • Detailed guide: guide.md
  • Core standard: refactoring-standards.md

AI Agent Behavior | AI 代理行為

完整的 AI 行為定義請參閱對應的命令文件:/refactor

For complete AI agent behavior definition, see the corresponding command file: /refactor

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.