Install
openclaw skills install code-simplifier当用户要求简化代码、重构代码、优化代码、改进代码质量时使用此技能。提供代码简化原则和最佳实践指导,确保代码符合质量标准。
openclaw skills install code-simplifier提供代码简化、重构和优化的原则指导。
except:raise ... from e)# ✅ 类型注解
def process(user_id: int, data: dict) -> dict | None:
...
# ✅ list/dict comprehension(避免嵌套)
result = [x for x in items if x.condition]
# ✅ 命名
snake_case(变量/函数), PascalCase(类), UPPER_SNAKE_CASE(常量)
# ❌ 避免
# - 嵌套 comprehension
# - 过度使用 lambda
# - 裸 except:
// ✅ const/let,无 var
// ✅ 箭头函数
const process = (data) => data.filter(x => x.valid);
// ✅ 解构
const { name, email } = user;
// ✅ 命名
camelCase(变量/函数), PascalCase(类/接口), UPPER_SNAKE_CASE(常量)
python scripts/code_simplifier.py <file.py> --analyze # 分析复杂度
python scripts/code_simplifier.py <file.py> --suggest # 生成重构建议
python scripts/code_simplifier.py <file.py> --simplify # 自动简化代码
python scripts/code_simplifier.py <file.py> --output=out.py # 指定输出文件
输出格式支持 text(默认)和 json。
textContent 赋值,禁止 innerHTML;必须用 escapeHTML() 转义 < > & ' "touch-action: manipulation,点击目标 ≥44px修复阶段加载
web-fixing技能诊断;编码阶段遵守以上 5 条即可预防大部分问题。