orch-refine-code
它能做什么
这个工具会重新组织你的代码,使其更简洁、更易理解,同时不改变代码的功能。它会确保一切仍然像之前一样正常工作。
适用场景
- ✓当你想改善代码的组织结构时。
- ✓当存在可以去掉的重复代码时。
- ✓当你想删除不再使用的代码时。
技能链接
https://github.com/affaan-m/ECC/blob/main/skills/orch-refine-code/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 AI
“把 poller.py 文件中的 NWS HTTP 客户端代码重构出来。”
每周 5 个新技能,1 分钟读完。
工作原理
这个工具会先检查现有测试是否通过。然后分小步重新组织代码,每次改动后都进行测试。如果一切正常,最后保存这些改动。
技术内容(原始 SKILL.md)
作者在 GitHub 上的英文原文。
orch-refine-code
Actor · action · target: orch · refine · code. Thin wrapper over the shared
engine in orch-pipeline.
When to Use
- Same behavior, better structure: extract modules, remove duplication, kill dead code, reduce nesting, rename for clarity.
- Distinguish from siblings: if behavior is meant to change at all, this is the
wrong skill (
orch-change-feature/orch-fix-defect).
Operation settings
- Default size floor: standard — restructures touch multiple files.
- Phase mask: 0 → 2 (plan the restructure) → 4 (keep green) → 5 → 6. No new behavior tests are written — the existing suite is the safety net.
- First move (phase 4): confirm the relevant tests exist and are green before touching code; if coverage is thin, add characterization tests first. Then restructure in small steps, re-running tests after each.
How It Works
- Run the
orch-pipelineengine with the settings above. - For dead-code / duplication sweeps, delegate to the
refactor-cleaneragent (it runs knip / depcheck / ts-prune and removes safely). - Stop at Gate 1 (restructure plan) and Gate 2 (pre-commit).
- Commit as
refactor:— the diff must be behavior-neutral.
Example
orch-refine-code: extract the NWS HTTP client out of poller.py
→ confirm tests green → plan extraction [GATE 1: approve]
→ move in small steps, tests green throughout → code-review
→ commit refactor: [GATE 2: confirm]
常见问题
代码的“行为”是什么意思?
行为指代码做什么、如何运作、产生什么结果。这个工具确保最终结果不发生变化。
什么是“测试”?
测试是自动检查,用来确认代码是否按预期运行。如果某个测试失败,说明代码中有某处被破坏了。
什么是“提交”(commit)?
提交就像是把一组代码改动保存下来。“带关卡的提交”(gated commit)指只有在所有检查(测试)都通过时才会保存。
详情
作者的原始描述
Orchestrate a behavior-preserving refactor — confirm tests are green, restructure without changing behavior, keep tests green, review, and gated commit. Use when the structure should improve but behavior must not change.
repo: affaan-m/ECC
热度
- GitHub 星标
- 280k
- 排名
- #377
- 许可证
- MIT
- 更新时间
- 2026/10/15
评论
- …
同一仓库的更多技能
accessibility
280k帮你的智能体创建人人都能使用的界面。确保网站和应用对残障人士友好,比如失明或行动不便的用户也能顺畅使用。
agent-architecture-audit
280k让你的智能体检查一切是否正常运行。它能找出并修复 AI 系统中的问题,确保系统按预期工作。
agent-eval
280k帮你的智能体比较不同的 AI 编程工具。它能衡量哪个工具在特定任务上更快、更便宜、更可靠。
agent-harness-construction
280k让你的智能体更好地理解如何完成任务。它会优化智能体使用的工具和指令,提高成功的几率。