Install
openclaw skills install yuyonghao-code-refactorAnalyze code quality issues, detect code smells, and automatically apply refactoring suggestions with preview, apply, and rollback support.
openclaw skills install yuyonghao-code-refactor智能代码重构助手,用于分析代码质量问题并自动应用重构建议。
const { CodeRefactor } = require('./src/index');
const refactor = new CodeRefactor();
// 分析代码
const analysis = refactor.analyze('path/to/file.js');
// 查看问题
console.log(analysis.issues);
// 自动重构
const result = refactor.refactor('path/to/file.js', {
dryRun: true // 预览模式
});
// 应用变更
if (result.canApply) {
refactor.applyChanges(result.changes);
}
# 分析代码
node src/index.js analyze file.js
# 重构代码(dry-run)
node src/index.js refactor file.js --dry-run
# 应用重构
node src/index.js refactor file.js --apply
{
maxFunctionLength: 50, // 函数最大行数
maxParameters: 4, // 参数最大数量
maxNestingDepth: 3, // 最大嵌套深度
minDuplicateLines: 5, // 最小重复行数
complexityThreshold: 10 // 复杂度阈值
}
npm test