← Back to Skills Marketplace
Code Optimizer
by
Clement Gu
· GitHub ↗
· v1.0.0
· MIT-0
72
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install code-optimizer
Description
代码质量自动评估与优化系统 — 基于ML的代码评分、策略选择、自动优化
README (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
Usage Guidance
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.
Capability Analysis
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.
Capability Assessment
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.
How to Use
- Make sure OpenClaw is installed (local or Docker)
- Run the install command in chat:
/install code-optimizer - After installation, invoke the skill by name or use
/code-optimizer - Provide required inputs per the skill's parameter spec and get structured output
Version History
v1.0.0
初始发布:代码质量自动评估与优化系统,15个标准测试案例,35维特征分析,ML+规则混合架构
Metadata
Frequently Asked Questions
What is Code Optimizer?
代码质量自动评估与优化系统 — 基于ML的代码评分、策略选择、自动优化. It is an AI Agent Skill for Claude Code / OpenClaw, with 72 downloads so far.
How do I install Code Optimizer?
Run "/install code-optimizer" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.
Is Code Optimizer free?
Yes, Code Optimizer is completely free, licensed under MIT-0. You can download, install and use it at no cost.
Which platforms does Code Optimizer support?
Code Optimizer is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).
Who created Code Optimizer?
It is built and maintained by Clement Gu (@clementgu); the current version is v1.0.0.
More Skills