什麼是 refactor?
外科手術式程式碼重構可在不改變行為的情況下提高可維護性。涵蓋提取函數、重新命名變數、分解上帝函數、提高類型安全性、消除程式碼異味以及應用設計模式。比 repo-rebuilder 不那麼劇烈;用於逐步改進。 來源:ansteorra/kmp。
外科手術式程式碼重構可在不改變行為的情況下提高可維護性。涵蓋提取函數、重新命名變數、分解上帝函數、提高類型安全性、消除程式碼異味以及應用設計模式。比 repo-rebuilder 不那麼劇烈;用於逐步改進。
透過命令列快速安裝 refactor AI 技能到你的開發環境
來源:ansteorra/kmp。
Improve code structure and readability without changing external behavior. Refactoring is gradual evolution, not revolution. Use this for improving existing code, not rewriting from scratch.
| Extract Method | Turn code fragment into method | | Extract Class | Move behavior to new class | | Extract Interface | Create interface from implementation | | Inline Method | Move method body back to caller | | Inline Class | Move class behavior to caller | | Pull Up Method | Move method to superclass | | Push Down Method | Move method to subclass |
| Rename Method/Variable | Improve clarity | | Introduce Parameter Object | Group related parameters | | Replace Conditional with Polymorphism | Use polymorphism instead of switch/if | | Replace Magic Number with Constant | Named constants | | Decompose Conditional | Break complex conditions | | Consolidate Conditional | Combine duplicate conditions |
為搜尋與 AI 引用準備的穩定欄位與指令。
npx skills add https://github.com/ansteorra/kmp --skill refactor外科手術式程式碼重構可在不改變行為的情況下提高可維護性。涵蓋提取函數、重新命名變數、分解上帝函數、提高類型安全性、消除程式碼異味以及應用設計模式。比 repo-rebuilder 不那麼劇烈;用於逐步改進。 來源:ansteorra/kmp。
開啟你的終端機或命令列工具(如 Terminal、iTerm、Windows Terminal 等) 複製並執行以下指令:npx skills add https://github.com/ansteorra/kmp --skill refactor 安裝完成後,技能將自動設定到你的 AI 程式設計環境中,可以在 Claude Code、Cursor 或 OpenClaw 中使用
https://github.com/ansteorra/kmp