用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/Arete-Consortium/ai-skills --skill refactor命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
Intelligent CI failure diagnosis and guided remediation for GitHub Actions, GitLab CI, and local builds
Pre-execution mapping of codebases, document collections, or problem spaces. Runs BEFORE any Gorgon workflow to give all agents shared situational awareness
Investigative methodology for analyzing document collections — provenance analysis, anomaly detection, redaction detection, and cross-document validation
| 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