📦 Red Hat

v1.0.0

安全地重构代码而不改变行为。

0· 0·0 当前·0 累计
mzfshark 头像by @mzfshark (Mauricio Z. Filho)
下载技能包
最后更新
2026/4/24
0
安全扫描
VirusTotal
无害
查看报告
OpenClaw
安全
high confidence
该技能是一份仅提供指导的重构指南,内部逻辑与其既定目的一致,不会索取无关凭据、安装项或特权持久化。
评估建议
This skill is a text-only refactoring procedure and appears coherent. Before enabling it, note that it will need access to your codebase and test tooling to run the validation steps — review and run any proposed diffs/commits yourself, ensure tests exist or add characterization tests, and confirm the project has the appropriate test runner (the example shows pnpm). Because the skill can be invoked by the agent, avoid granting it credentials or network access it doesn't need, and require human re...
详细分析 ▾
用途与能力
Name/description (refactor code safely) align with the content: the SKILL.md contains step-by-step refactoring instructions, validation guidance, and expected outputs. Nothing requested (no env vars, no binaries, no installs) is disproportionate to this purpose.
指令范围
Runtime instructions are limited to code-refactoring workflows: run tests, add characterization tests, make small commits/patches, and re-run validation. The instructions imply access to the target repository/files and test runner (expected for a refactor tool) and do not ask for unrelated system files, credentials, or external endpoints.
安装机制
There is no install spec and no code files — the skill is instruction-only, so nothing is written to disk or downloaded during install.
凭证需求
The skill declares no environment variables, credentials, or config paths. The example mentions running 'pnpm test', but that is an example command (not a declared requirement) and is proportional to the task of validating refactors.
持久化与权限
The skill does not request 'always: true' or any persistent privileges, nor does it modify other skills' configs. Autonomous invocation is allowed by default on the platform but is not combined here with broad access.
安全有层次,运行前请审查代码。

运行时依赖

无特殊依赖

版本

latestv1.0.02026/4/24

refactor-engine 初始发布 – 安全重构代码结构,行为不变。 - 支持指定目标模块、重构目标、约束与验证命令。 - 强制在修改前后运行测试与验证。 - 输出摘要、文件变更、行为守护与验证结果。 - 内置明确安全规则,避免危险重写与意外 API 变更。

无害

安装命令

点击复制
官方npx clawhub@latest install axodus-refactor-engine
镜像加速npx clawhub@latest install axodus-refactor-engine --registry https://cn.longxiaskill.com

技能文档

目的

在保持行为不变的前提下,改善现有代码结构(可读性、模块化、可维护性)。

何时使用

  • 复杂度上升,变更风险增大。
  • 模块间出现重复逻辑。
  • 已有测试(或可补充测试)保护行为。

输入

  • target_area(必填,string):待重构的文件/模块。
  • refactor_goal(必填,string):改进目标(如减少重复、隔离副作用)。
  • constraints(可选,string[]):行为不可变;性能限制;兼容性要求。
  • validation_commands(可选,string[]):重构前后运行的测试/构建/ lint 命令。

步骤

  • 建立基线:
- 运行现有测试(或补充最小特征测试)。
  • 识别重构接缝:
- 提取纯函数 - 隔离 I/O - 减少全局状态
  • 小步提交/补丁式重构:
- 每次仅一个变换 - 保持 diff 可读
  • 每次有意义变换后重新验证。
  • 若行为变化,回退该步并调整方案。

验证

  • 行为保持(测试通过;已知用例输出不变)。
  • 公开接口稳定(或已显式版本化/迁移)。
  • 复杂度可测降低(函数更小、分支更少、重复减少)。

输出

  • refactor_summary
  • files_changed
  • behavior_gards(新增/使用的测试)
  • validation_results

安全规则

  • 无行为守卫(测试或可复现脚本)不重构。
  • 避免“大爆炸”重写。
  • 除非明确要求,不改动公开 API。

示例

目标: “将控制器中的请求校验提取到 validators/ 并补充单元测试。” 验证: 每步提取后执行 pnpm test

数据来源ClawHub ↗ · 中文优化:龙虾技能库