Skills

Skill Iterative Loop

Run tasks in a loop until goals are met, use for iterative refinement, polling, or...

Install

npx skills add nyldn/claude-octopus --skill skill-iterative-loop -g -a claude-code -y
Repository
nyldn/claude-octopus4.4k
Category
Engineering
Updated
3d ago
License
MIT
Context cost
Mediumabout 3,000 tokens
Runs scripts
No, instructions only

What it does

Run tasks in a loop until goals are met, use for iterative refinement, polling, or convergence

Iterative Loop Execution

Overview

Systematic iterative execution with clear goals, exit conditions, and progress tracking.

Core principle: Define goal → Set max iterations → Execute → Evaluate → Loop or complete.


When to Use

Use this skill when user wants to:

  • Execute a task multiple times with refinements
  • Loop until a condition is met
  • Iteratively improve something (code, tests, performance)
  • Retry operations with modifications
  • Progressive enhancement in rounds

Do NOT use for:

  • Single execution ("run tests once")
  • Manual step-by-step work
  • Infinite loops without bounds
  • Simple retry logic (use skill-debug)

The Process

Phase 1: Loop Setup

Step 1: Understand the Intent

**Loop Intent:**

Goal: [what should be achieved]
Success criteria: [how do we know we're done]
Max iterations: [safety limit]
Per-iteration tasks: [what to do each loop]

Step 2: Clarify Parameters

Use AskUserQuestion if unclear:

  • Max iterations: How many times maximum?
  • Success condition: What indicates we can stop early?
  • Per-iteration actions: What exactly to do each round?
  • Failure handling: What if it never succeeds?

Step 3: Safety Checks

**Safety Validation:**

- [ ] Max iterations defined (no infinite loops)
- [ ] Success condition is measurable
- [ ] Each iteration makes progress
- [ ] Failure exit strategy exists
- [ ] User aware of potential duration

Never proceed without max iterations defined.


Phase 2: Loop Execution

Step 1: Initialize Loop

**Starting Iterative Loop**

Goal: [description]
Max iterations: [N]
Success criteria: [condition]

---

### Iteration 1 / [N]

Step 2: Execute Iteration

For each iteration:

**Iteration [current] / [max]**

**Actions:**
1. [Action 1]
   → [result/output]
2. [Action 2]
   → [result/output]
3. [Action 3]
   → [result/output]
Read the whole SKILL.md on GitHub

More in Engineering