Install
npx skillscat add maxoreric/sop-engine/loop-skill Install via the SkillsCat registry.
About this skill
We need to produce a 2-3 sentence plain-text summary, objective, factual, no marketing language, no superlatives, no calls to action. Must be natural prose, no bullet points, no headings, no markdown. At most 60 words. Must be only the summary text, no quotes. So produce something like: "The loop-skill repeatedly executes a specified task until a defined condition is met, such as a file appearing or a score threshold reached.
SKILL.md
循环执行
重复执行某个操作,直到满足完成条件。
机制
基于 Claude Code 的 Stop hook 实现:
- 执行任务
- Claude 尝试停止
- Stop hook 检查完成条件
- 未完成 → exit code 2 → 继续执行
- 已完成 → exit code 0 → 允许停止
参数
- 任务描述:要重复执行的任务
- 完成条件:什么情况算完成
- 最大次数:防止无限循环
使用方式
在对话中说明:
请循环执行 [任务描述],直到 [完成条件],最多 [N] 次或使用 slash command:
/loop "任务描述" --until "完成条件" --max 10完成条件类型
1. 文件存在
直到 output.md 存在2. 内容匹配
直到输出包含 "DONE"3. 评价通过
直到评价分数 >= 74. 人工确认
直到用户确认满意状态追踪
在 .meta/loop-status.json 中记录:
{
"task": "任务描述",
"completion_condition": "完成条件",
"max_iterations": 10,
"current_iteration": 3,
"status": "running",
"history": [
{"iteration": 1, "result": "..."},
{"iteration": 2, "result": "..."}
]
}原则
- 必须设置最大次数,防止无限循环
- 每次迭代要有进展,不要原地踏步
- 卡住时要能跳出并报告
- 记录每次迭代的结果