← 返回 Skills 市场
Code Optimizer
作者
Clement Gu
· GitHub ↗
· v1.0.0
· MIT-0
72
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install code-optimizer
功能描述
代码质量自动评估与优化系统 — 基于ML的代码评分、策略选择、自动优化
使用说明 (SKILL.md)
🔧 Code Optimizer — 代码质量自动评估与优化
概述
基于机器学习的代码质量自动评估和优化系统。从 15 个标准测试案例、35 个特征维度出发,通过平衡随机森林模型自动评估代码质量并选择最优生成策略。
核心能力
| 功能 | 描述 |
|---|---|
| 📊 代码质量评估 | 35维度特征分析,ML评分模型,综合质量报告 |
| 🎯 智能策略选择 | 平衡随机森林 + 规则引擎混合架构,自动选择最优代码生成策略 |
| 🔄 自动反馈闭环 | 评估结果自动记录,持续优化ML模型 |
| 📋 标准化测试 | 15个标准测试案例覆盖算法、调试、重构、数据结构 |
性能指标
| 指标 | 结果 |
|---|---|
| 评分差异 | 0.36 分 (↓96% 相比基线) |
| 不平衡比 | 6:1 (从 36:1 改善) |
| 宏 F1 | 0.410 (↑40%) |
| 处理速度 | 0.006 秒/案例 |
| ML 使用率 | 100% (阈值优化后) |
安装
前提条件
- Python 3.9+
- scikit-learn 1.0+
- numpy, pandas
通过 ClawHub 安装
clawhub install code-optimizer
手动安装
# 克隆或复制到 skills 目录
cd ~/.openclaw/workspace
pip install scikit-learn numpy pandas
# 安装技能
clawhub install code-optimizer
使用方法
评估代码质量
# 评估单个文件
code-eval evaluate --code-file my_code.py --task "实现功能"
# 评估代码字符串
code-eval evaluate --code "def hello(): pass" --task "Hello World"
# 批量评估
code-eval batch --dir ./code_samples
运行标准测试
# 运行所有 15 个标准测试
code-eval test-suite
# 运行指定测试
code-eval test --case CASE_001
选择生成策略
# 自动选择最优策略
code-eval select-strategy --code-file my_code.py
# 输出: balanced | emphasize_correctness | extreme_correctness
生成报告
# 生成 HTML 报告
code-eval report --format html --output report.html
配置
主配置
# config.yaml
evaluator:
model_path: models/balanced_forest.pkl
threshold: 0.5
feature_count: 35
strategies:
- balanced
- emphasize_correctness
- extreme_correctness
integration:
auto_evaluate: true
log_results: true
feedback_loop: true
与 Hermes 集成
当与 Hermes 记忆系统配合使用时:
- 自动评估每个代码生成任务
- 评估结果存入记忆系统
- ML 数据集持续扩充
- 策略选择融入任务规划
版本历史
| 版本 | 日期 | 说明 |
|---|---|---|
| 1.0.0 | 2026-04-23 | 初始版本:代码评估 + 策略选择 + ML模型 |
许可
MIT License
安全使用建议
Do not run deploy.sh or perform the advertised 'clawhub install' until you inspect the deploy.sh and the missing evaluator code. Specific checks: 1) The script expects optimizer source at /Users/apple/.openclaw/workspace/claude_optimization — verify those files exist and inspect their contents (auto_evaluator.py, evaluator/, model json). 2) Review and back up your Hermes config (~/.openclaw/workspace/hermes/config/hermes.yaml) before deployment; the script will enable auto_evaluate and feedback_loop. 3) Check the CLI being created (HERMES_DIR/bin/code-eval) to confirm it only runs local code and does not transmit data externally. 4) Consider running the deployment in a sandbox or test account first; if you proceed, remove or change the automatic config changes (set auto_evaluate:false) if you do not want evaluations run automatically. 5) If the skill was advertised as a self-contained ClawHub install, ask the publisher why core evaluator code and model files are not bundled and why a hardcoded user path is used. These inconsistencies elevate risk even though no network exfiltration or credential requests are present.
功能分析
Type: OpenClaw Skill
Name: code-optimizer
Version: 1.0.0
The skill bundle's deployment script (scripts/deploy.sh) contains a hardcoded absolute path (/Users/apple/.openclaw/workspace/claude_optimization) as the source for its core logic, which is highly irregular for a portable skill and suggests it was not properly sanitized or is environment-specific. The script also performs intrusive system modifications, including creating symbolic links in the user's $HOME/bin directory and programmatically modifying external configuration files (hermes.yaml). While these actions are framed as integration steps for the 'Code Optimizer' tool, the reliance on external hardcoded paths and broad filesystem modifications without clear justification within the bundle itself are significant red flags.
能力评估
Purpose & Capability
The skill claims an ML-based code-evaluator and Hermes integration; the deploy.sh script and SKILL.md behaviors (creating a CLI, writing models into Hermes optimizer dir, updating Hermes config) are consistent with that purpose. However, the package does not include the actual evaluator modules or model files — the deploy script expects them at a hardcoded external path (OPTIMIZER_SRC set to /Users/apple/.openclaw/workspace/claude_optimization). That mismatch (claiming a functioning optimizer while not bundling its code/models) is unexpected.
Instruction Scope
The runtime instructions (deploy.sh) perform several system actions beyond a simple install: they install Python packages if missing, copy directories and model/json files from a hardcoded absolute path, create directories under the user's OpenClaw/Hermes workspace, write a CLI script into Hermes/bin, and update Hermes' config file to enable auto_evaluate and feedback_loop. The script will read from arbitrary file paths supplied or implied (e.g., copying from OPTIMIZER_SRC) and writes into $HOME and Hermes config — actions that are broader than the SKILL.md's high-level install steps and could have unexpected side effects for users who do not have the expected source tree.
Install Mechanism
There is no formal install spec — this is instruction-only — but the included deploy.sh installs Python packages (pip3 install ...), creates symlinks in $HOME/bin, and extracts/copies files from an external, hardcoded path. The use of a user-specific absolute path (/Users/apple/...) and reliance on external local files (not downloaded from a vetted release host or bundled) is risky and incoherent with a package that advertises simple 'clawhub install' capability.
Credentials
The skill does not request environment variables or credentials, which is appropriate. However, it modifies Hermes configuration (setting code_optimizer.enabled/auto_evaluate/feedback_loop to true) automatically during deployment. Changing an integration's auto-run behavior without explicit, documented user consent is a disproportionate level of persistence/control relative to a code-evaluator utility.
Persistence & Privilege
The deploy script makes persistent changes: it installs a CLI into Hermes/bin and $HOME/bin, copies model and evaluator files into Hermes directories, and updates Hermes config to enable automatic evaluation/feedback. While not marked always:true, these actions grant the skill ongoing presence and can change runtime behavior (auto-evaluate code tasks). That automatic enabling of auto-evaluate is a notable privilege and should be opt-in rather than automatic.
如何使用
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install code-optimizer - 安装完成后,直接呼叫该 Skill 的名称或使用
/code-optimizer触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
初始发布:代码质量自动评估与优化系统,15个标准测试案例,35维特征分析,ML+规则混合架构
元数据
常见问题
Code Optimizer 是什么?
代码质量自动评估与优化系统 — 基于ML的代码评分、策略选择、自动优化. 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 72 次。
如何安装 Code Optimizer?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install code-optimizer」即可一键安装,无需额外配置。
Code Optimizer 是免费的吗?
是的,Code Optimizer 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
Code Optimizer 支持哪些平台?
Code Optimizer 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Code Optimizer?
由 Clement Gu(@clementgu)开发并维护,当前版本 v1.0.0。
推荐 Skills