AgentSkillsCN

loop

采用 Ralph Loop 模式执行任务:执行 → 验证 → 迭代,直至 VERIFIED_DONE。每种模型均设有迭代次数上限(Claude:25 次;MiniMax:50 次;MiniMax-lightning:100 次)。当您需要:(1) 迭代式修复;(2) 持续运行直至质量达标;(3) 自动化完成任务时,可调用此技能。常用触发词包括:/loop、“循环至完成”、“迭代”、“持续尝试”、“修复直至通过”。

SKILL.md
--- frontmatter
# VERSION: 2.43.0
name: loop
description: "Execute task with Ralph Loop pattern: Execute -> Validate -> Iterate until VERIFIED_DONE. Enforces iteration limits per model (Claude: 25, MiniMax: 50, MiniMax-lightning: 100). Use when: (1) iterative fixes needed, (2) running until quality passes, (3) automated task completion. Triggers: /loop, 'loop until done', 'iterate', 'keep trying', 'fix until passing'."
user-invocable: true

Loop - Ralph Loop Pattern

Execute -> Validate -> Iterate until VERIFIED_DONE.

Quick Start

bash
/loop "fix all type errors"
/loop "implement tests until 80% coverage"
ralph loop "fix lint errors"

Pattern

code
     EXECUTE
        |
        v
    +---------+
    | VALIDATE |
    +---------+
        |
   Quality    YES    +---------------+
   Passed? --------> | VERIFIED_DONE |
        |            +---------------+
        | NO
        v
    +---------+
    | ITERATE | (max iterations)
    +---------+
        |
        +-------> Back to EXECUTE

Iteration Limits

ModelMax IterationsUse Case
Claude (Sonnet/Opus)25Complex reasoning
MiniMax M2.150Standard tasks
MiniMax-lightning100Extended loops

Workflow

1. Execute Task

yaml
# Attempt implementation
Edit/Write/Bash as needed

2. Validate

yaml
# Run quality gates
ralph gates

3. Check & Iterate

yaml
# If validation fails and under limit
iteration += 1
if iteration <= MAX:
    continue  # Back to Execute
else:
    report "Max iterations reached"

Loop Types

Fix Loop

bash
/loop "fix all type errors"

Repeatedly fix errors until build passes.

Coverage Loop

bash
/loop "increase test coverage to 80%"

Add tests until coverage target met.

Lint Loop

bash
/loop "fix all lint warnings"

Fix lint issues until clean.

Build Loop

bash
/loop "fix build errors"

Fix compilation errors until success.

Exit Conditions

Success (VERIFIED_DONE)

  • Quality gates pass
  • Tests pass
  • No remaining errors

Failure (MAX_ITERATIONS)

  • Iteration limit reached
  • Report remaining issues
  • Ask user for guidance

Manual Exit

  • User interrupts
  • Critical error detected
  • Deadlock detected

Integration

  • Core pattern for all Ralph tasks
  • Used by /orchestrator in Step 5
  • Hooks enforce limits automatically

Anti-Patterns

  • Never exceed iteration limits
  • Never loop without validation step
  • Never ignore failing tests
  • Never loop on same error repeatedly (detect deadlock)