用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/firstbatchxyz/kai --skill optimization-workflow命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
正在显示 SKILL.md
基于 SOC 职业分类
| name | optimization-workflow |
| description | Full code optimization workflow - from analyzing code to running optimization and reviewing results |
| version | 2.0.0 |
| author | kai-agent |
| metadata | {"kai":{"tags":["kai","optimization","code-quality","performance"]}} |
End-to-end workflow for running AI-powered code optimization through Kai.
Ask the user or infer from context:
browse_repository_files(workspaceId, repoId) → understand structure
read_repository_files(workspaceId, repoId, paths) → read target code
Identify optimization candidates:
Before starting, verify no optimization is already running on the same file:
list_code_optimizations(workspaceId, repoId)
If there's an active run on the same scope, do NOT start another one. Instead:
get_code_optimization_progressabort_code_optimization — the evaluator is brokenCreate a lifecycle action and wait for the user to approve before proceeding:
lifecycle_actions_create(workspaceId, type="evolution", title="Optimize [target]", description="...", priority="high", repoId=repoId)
Wait for the user to execute the action (status changes to in_progress).
Write a Python evaluator yourself — never use create_ai_evaluator. You understand the code and the goal better than an auto-generator.
Self-test before uploading (critical — do not skip):
# Save evaluator to temp file and run it against the target
# In terminal:
python3 -c "
from evaluator import evaluate
result = evaluate('/path/to/target_program.py')
print(result)
assert isinstance(result, dict), 'Must return dict'
assert 'combined_score' in result, 'Must have combined_score'
assert result['combined_score'] > 0, 'Score must be > 0 for the initial program'
print('PASS')
"
If the self-test fails, fix the evaluator before uploading. A broken evaluator wastes hundreds of LLM calls.
The evaluator must define evaluate(program_path) — it receives a file path string, not a module. Must return a dict like {"correctness": 1.0, "performance": score}. Load the evaluator-creation skill for detailed patterns and examples.
create_evaluator_from_code(workspaceId, repoId, code=evaluator_code, name="My Evaluator")
→ returns { evaluatorId }
If the evaluator needs GPU: the default path is Modal via the workspace proxy (zero user setup when MODAL_SERVER_URL is set). Load the kai-evolve/evaluator-creation skill and follow Option A in the GPU Evaluator Pattern. Only fall back to user-hosted GPU infrastructure (Option C) or CPU approximation (Option D) when Modal isn't connected and can't be.
config = {
"llm": {
"models": [{"name": "openai/gpt-4o", "weight": 1.0}],
},
"prompt": {
"systemMessage": "Optimize <target> for <metric>. Keep public API unchanged.",
},
}
scopes = [
{"path": "src/foo.py", "fromLine": 42, "toLine": 87},
]
start_code_optimization(workspaceId, repoId, config, scopes, evaluatorId)
# → returns optimizationId
Field-name pitfalls (use these, not the alternatives on the right):
scopes[].path / fromLine / toLine — not filePath / startLine / endLineconfig.llm.models (array of {name, weight}) — not config.llm.model (string)config.prompt.systemMessage — not config.prompt.goalOptimizations take time (minutes to hours depending on complexity). Set up a cron job to poll progress every 10-15 minutes:
get_code_optimization_progress(optimizationId) → overall status
get_optimization_iterations(optimizationId) → iteration history with fitness scores
Report to team at milestones:
get_optimized_programs(optimizationId) → best solutions found
For each solution:
Use research tools to:
Present to the team: