← スキル一覧に戻る

refactor
by channingwalton
⭐ 3🍴 0📅 2026年1月22日
SKILL.md
name: Refactor description: Improve code design without changing behaviour. Use for the REFACTOR phase of XP workflow. All tests must pass before and after.
Refactor
Core Rules (Non-Negotiable)
- NEVER change behaviour — refactoring preserves existing functionality
- All tests must pass before and after refactoring
- Small incremental changes — one transformation at a time
- Run tests after every change — catch regressions immediately
The Refactor Cycle
✅ VERIFY → Run all tests, confirm green state
🔍 ANALYSE → Identify code smell or improvement opportunity
🔵 REFACTOR → Apply ONE transformation
✅ VERIFY → Run all tests, confirm still green
🔁 REPEAT → Continue until goal achieved
Goals & Techniques
| Goal | Techniques |
|---|---|
| Eliminate duplication | Extract method, extract variable, pull up method |
| Improve clarity | Rename, inline temp, introduce explaining variable |
| Simplify conditionals | Decompose conditional, consolidate conditional |
| Improve structure | Extract class, move method, replace inheritance with delegation |
Code Smells to Address
- Duplication — same code in multiple places
- Long methods — do too much, hard to understand
- Large classes — too many responsibilities
- Long parameter lists — difficult to call correctly
- Feature envy — method uses another class more than its own
- Primitive obsession — using primitives instead of small objects
What Refactoring Is NOT
- Adding new features
- Fixing bugs (unless the fix is purely structural)
- Changing external APIs
Announcing Changes
🔵 REFACTOR → [smell]: [transformation]
Examples:
🔵 REFACTOR → duplication: Extract method calculateTotal🔵 REFACTOR → long method: Split processOrder into validate and execute
Safety Checklist
Before starting:
- All tests pass
- Understand the code being refactored
After each change:
- Tests still pass
- Behaviour unchanged
- Code is cleaner/clearer
スコア
総合スコア
60/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
✓LICENSE
ライセンスが設定されている
+10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
レビュー
💬
レビュー機能は近日公開予定です