用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/pluginagentmarketplace/custom-plugin-software-design --skill refactoring命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | refactoring |
| description | Detect code smells and apply safe refactoring techniques |
| sasmp_version | 1.3.0 |
| bonded_agent | 04-refactoring |
| bond_type | PRIMARY_BOND |
| version | 2.0.0 |
| updated | 2025-12-30 |
Atomic skill for code smell detection and safe refactoring
skill_id: refactoring
responsibility: Single - Code smell detection and refactoring guidance
atomic: true
idempotent: true
interface SkillParams {
// Required
action: 'detect' | 'plan' | 'apply' | 'validate';
code: string;
language: string;
// Optional
smell_categories?: SmellCategory[];
risk_tolerance?: 'low' | 'medium' | 'high';
test_coverage?: 'none' | 'partial' | 'full';
}
type SmellCategory = 'bloaters' | 'oo_abusers' | 'change_preventers' | 'dispensables' | 'couplers';
interface SkillResult {
smells?: CodeSmell[];
plan?: RefactoringPlan;
refactored_code?: string;
validation?: ValidationResult;
}
input_validation:
action:
required: true
enum: [detect, plan, apply, validate]
code:
required: true
min_length: 10
max_length: 100000
language:
required: true
allowed: [typescript, javascript, python, java, csharp, go]
retry_config:
max_attempts: 3
backoff:
type: exponential
initial_delay_ms: 1000
max_delay_ms: 10000
multiplier: 2
retryable_errors:
- TIMEOUT
- RATE_LIMIT
non_retryable_errors:
- INVALID_CODE
- UNSAFE_REFACTORING
long_method:
threshold: 20 lines
severity_scale:
20-30: low
30-50: medium
50+: high
refactorings:
- Extract Method
- Replace Temp with Query
large_class:
threshold: 200 lines
refactorings:
- Extract Class
- Extract Subclass
long_parameter_list:
threshold: 3 params
refactorings:
- Introduce Parameter Object
- Preserve Whole Object
feature_envy:
description: "Method uses another class's data more than its own"
refactorings:
- Move Method
- Extract Method
message_chains:
pattern: "a.b().c().d().e()"
threshold: 3 calls
refactorings:
- Hide Delegate
extract_method:
safety: high
steps:
1. Create new method with descriptive name
2. Copy extracted code
3. Replace original with call
4. Run tests
move_method:
safety: medium
steps:
1. Copy method to target
2. Adjust references
3. Update callers
4. Remove original
5. Run tests
// Input
{
action: "detect",
code: `
class OrderProcessor {
process(order, user, config, logger, db, cache, validator) {
// 150 lines of code
}
}
`,
language: "typescript"
}
// Output
{
smells: [
{
name: "Long Parameter List",
category: "bloaters",
severity: "high",
location: "OrderProcessor.process"
},
{
name: "Long Method",
category: "bloaters",
severity: "high"
}
]
}
describe('RefactoringSkill', () => {
describe('detect', () => {
it('should detect Long Method smell', async () => {
const code = generateLongMethod(60);
const result = await skill.execute({
action: 'detect',
code,
language: 'typescript'
});
expect(result.smells).toContainEqual(
expect.objectContaining({ name: 'Long Method' })
);
});
});
});
errors:
INVALID_CODE:
code: 400
message: "Code cannot be parsed"
recovery: "Fix syntax errors"
UNSAFE_REFACTORING:
code: 400
message: "Refactoring too risky without tests"
recovery: "Add tests or increase risk_tolerance"
requires:
- ast_parser
- smell_detector
emits:
- smells_detected
- refactoring_planned
- refactoring_applied
consumed_by:
- 04-refactoring (bonded agent)
- 01-design-principles (for principle violations)