Codex 또는 Claude로 설치 이 Prompt를 복사해 Codex, Claude 또는 다른 어시스턴트에 붙여 넣으면 Skill 페이지를 검토하고 설치를 진행할 수 있습니다.
직접 명령은 검토 Prompt를 거치지 않습니다. 실행하기 전에 소스를 확인하세요.
npx skills add https://github.com/Arete-Consortium/ai-skills --skill refactor명령은 한 줄로 유지됩니다. 복사하기 전에 가로로 스크롤해 전체 내용을 확인하세요.
로컬 사본을 원하시나요? SkillsMP에서 현재 제공할 수 있는 파일을 다운로드하세요.
SKILL.md 표시 중
| name | refactor |
| description | Code Refactoring Analysis |
| lifecycle | experimental |
Identify refactoring opportunities and code improvements.
/refactor path/to/file.py # Analyze specific file
/refactor path/to/module/ # Analyze entire module
/refactor --apply # Apply suggested refactorings
/refactor --complexity # Focus on complexity reduction
# Refactoring Report: module_name
## Summary
| Issue Type | Count | Priority |
|------------|-------|----------|
| High Complexity | 3 | High |
| Duplication | 5 | Medium |
| Code Smells | 8 | Low |
## High Priority Issues
### 1. Complex Function: `process_data()` (file.py:45)
**Complexity**: 15 (threshold: 10)
**Lines**: 87
**Problem**: Function does too many things - validates, transforms, saves.
**Suggested Refactoring**:
```python
# Before (simplified)
def process_data(data):
# validation (20 lines)
# transformation (40 lines)
# saving (25 lines)
# After
def process_data(data):
validated = validate_data(data)
transformed = transform_data(validated)
return save_data(transformed)
def validate_data(data): ...
def transform_data(data): ...
def save_data(data): ...
calculate_* functionsLocation: math_utils.py:23, math_utils.py:67, math_utils.py:112 Similarity: 85%
Problem: Three functions share nearly identical structure.
Suggested Refactoring:
# Before
def calculate_sum(items): ...
def calculate_avg(items): ...
def calculate_max(items): ...
# After
def calculate(items, operation: Callable):
return operation(items)
create_report()Parameters: 8
Suggested Refactoring: Use a dataclass or config object.
@dataclass
class ReportConfig:
title: str
format: str
...
def create_report(config: ReportConfig): ...
## Instructions for Claude
When /refactor is invoked:
1. **Read code** - Parse and understand structure
2. **Calculate metrics** - Complexity, length, nesting
3. **Find duplication** - Similar code blocks
4. **Identify smells** - God classes, feature envy, etc.
5. **Prioritize issues** - High/Medium/Low based on impact
6. **Suggest fixes** - Concrete, actionable refactorings
7. **Show before/after** - Code examples for each fix
8. **If --apply** - Implement the refactorings
9. **Verify** - Run tests after changes