refactor-engineer
Skill1 starsChanged 3 months agoMITView on GitHub
Detect code smells (God class, long functions, duplication, circular dependencies, bad abstractions) with real static analysis, refactor safely with regression tests as guardrails, and verify no behavior change. Use when improving code structure, reducing technical debt, or preparing legacy code for extension.
2 other projects use a version of this.
Adopted by
Most recently taken up by
- Kshitijpalsinghtomar/depth-skillstheir own version, first seen Oct 1, 2026
- neeraj181-dot/ClaudeSkillstheir own version, first seen Aug 25, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- Kshitijpalsinghtomar/depth-skills★ 5same name
- neeraj181-dot/ClaudeSkills★ 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 repository9 other files it gives its agents.
- codebase-architectSkill
- deep-debuggerSkill
- dependency-doctorSkill
- documentation-engineerSkill
- performance-engineerSkill
- release-engineerSkill
- repo-resurrectionSkill
- security-auditorSkill
- test-engineerSkill
The file
Files
Refactor Engineer
Refactor an toàn = phát hiện thật + regression guard + verify behavior không đổi. Không refactor vì thích — refactor vì có smell cụ thể và risk được kiểm soát.
Quy trình (6 bước)
- Phát hiện smells (script thật): chạy
scripts/detect_smells.py <repo>— tìm God class (>500 dòng, >15 method), long function (>50 dòng, >4 nested), duplication (clone detection qua normalized hashing), circular dependency (import graph), bad abstraction (deep inheritance, shotgun surgery indicators). - Chọn mục tiêu: 1 smell, ưu tiên theo: frequency × sửa dễ × impact. Không refactor toàn repo cùng lúc.
- Establish guardrails: chạy regression test suite hiện có (hoặc viết characterization test nếu chưa có) — green trước khi chạm code.
- Refactor từng bước nhỏ: mỗi bước giữ behavior, chạy regression sau mỗi bước. Commit riêng từng bước.
- Verify: regression suite green + diff behavior kiểm tra (output các entry point không đổi) + re-run smell detector xác nhận smell giảm.
- Report: bảng smell trước/sau, danh sách commits, risk còn lại.
Nguyên tắc
- Behavior preservation là bất biến — test fail = revert.
- Một smell một lần refactor.
- Không đổi API public nếu không cần; nếu đổi, cập nhật callers cùng lúc + doc.
- Refactor nhỏ > refactor lớn.
Scripts
scripts/detect_smells.py <repo> [--thresholds FILE]— output JSON smells với severity.scripts/import_graph.py <repo>— vẽ dependency graph, phát hiện cycle.
References
- SMELL-CATALOG.md — định nghĩa + ngưỡng từng smell
- SAFETY-CHECKLIST.md
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
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.

