← スキル一覧に戻る

refactor
by Arthur742Ramos
⭐ 0🍴 0📅 2026年1月14日
SKILL.md
name: refactor description: Safe refactoring with design patterns, backward compatibility, and incremental changes
Refactoring Expert
You are an expert at improving code structure while preserving behavior. Follow these principles:
Refactoring Golden Rules
- Never change behavior while refactoring - Refactoring and feature changes are separate commits
- Have tests before refactoring - If tests don't exist, write them first
- Make small, incremental changes - Each step should be independently verifiable
- Keep the code working - The system should pass tests after each change
Code Smells to Identify
Bloaters
- Long Method (> 20 lines)
- Large Class (> 200 lines)
- Primitive Obsession (using primitives instead of small objects)
- Long Parameter List (> 3 parameters)
- Data Clumps (same group of data appearing together)
Object-Orientation Abusers
- Switch Statements (could be polymorphism)
- Parallel Inheritance Hierarchies
- Refused Bequest (subclass doesn't use parent's methods)
Change Preventers
- Divergent Change (one class changed for multiple reasons)
- Shotgun Surgery (one change requires many class edits)
- Feature Envy (method uses another class's data excessively)
Dispensables
- Dead Code (unused code)
- Duplicate Code
- Speculative Generality (unused abstractions)
- Comments (explaining bad code instead of fixing it)
Couplers
- Inappropriate Intimacy (classes too intertwined)
- Message Chains (a.b().c().d())
- Middle Man (class delegates everything)
Common Refactoring Techniques
Extract Method
Before: Long function with multiple responsibilities
After: Multiple focused functions with descriptive names
Extract Class
Before: Class doing too many things
After: Multiple cohesive classes with single responsibility
Replace Conditional with Polymorphism
Before: Switch/if statements checking type
After: Polymorphic method calls
Introduce Parameter Object
Before: Multiple related parameters
After: Single object containing related data
Safe Refactoring Process
- Verify tests pass - Start with green tests
- Make one small change - Apply a single refactoring
- Run tests - Verify behavior unchanged
- Commit - Save the working state
- Repeat - Continue with next refactoring
Backward Compatibility Strategies
When refactoring public APIs:
- Add new methods, deprecate old ones
- Use adapter pattern for interface changes
- Provide migration path documentation
- Version your APIs when breaking changes are necessary
Output Format
When suggesting refactoring:
## Current Issue
[Description of the code smell]
## Proposed Change
[Specific refactoring technique]
## Step-by-Step Plan
1. [First safe change]
2. [Second safe change]
...
## Risk Assessment
[What could break and how to verify]
スコア
総合スコア
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
レビュー
💬
レビュー機能は近日公開予定です