Get the FREE Ultimate OpenClaw Setup Guide →

auto-loop

npx machina-cli add skill claude-world/director-mode-lite/auto-loop --openclaw
Files (1)
SKILL.md
7.6 KB

Auto-Loop

Execute a TDD-based autonomous development loop with full observability.


Usage

# Start new task
/auto-loop "Implement user login"

# With acceptance criteria
/auto-loop "Implement authentication

Acceptance Criteria:
- [ ] Login form (email + password)
- [ ] JWT token generation
- [ ] Error handling
"

# Resume interrupted session
/auto-loop --resume

# Force restart (clear old state)
/auto-loop --force "New task"

# Check status
/auto-loop --status

# With iteration limit
/auto-loop "Task" --max-iterations 15

How It Works

┌───────────────────────────────────────────────────────────────┐
│                      TDD Iteration                            │
├───────────┬───────────────────────────────────────────────────┤
│  RED      │ Write failing test for next AC                    │
│           │ → Auto-logged: file_created, test_fail            │
├───────────┼───────────────────────────────────────────────────┤
│  GREEN    │ Write implementation to make test pass            │
│           │ → Auto-logged: file_created/modified, test_pass   │
├───────────┼───────────────────────────────────────────────────┤
│  REFACTOR │ Improve code quality (no behavior change)         │
│           │ → Use code-reviewer agent for suggestions         │
├───────────┼───────────────────────────────────────────────────┤
│  VALIDATE │ Run full test suite + linter                      │
│           │ → Auto-logged: test_pass/fail                     │
├───────────┼───────────────────────────────────────────────────┤
│  COMMIT   │ Commit changes with descriptive message           │
│           │ → Auto-logged: commit                             │
├───────────┼───────────────────────────────────────────────────┤
│  DECIDE   │ Check AC completion → continue or complete        │
└───────────┴───────────────────────────────────────────────────┘

Execution

When user runs /auto-loop "<request>":

1. State Detection (Conflict Prevention)

STATE_DIR=".auto-loop"
CHECKPOINT="$STATE_DIR/checkpoint.json"

# Check for existing in-progress session
if [ -f "$CHECKPOINT" ]; then
    status=$(jq -r '.status // "unknown"' "$CHECKPOINT" 2>/dev/null || echo "unknown")
    iteration=$(jq -r '.current_iteration // 0' "$CHECKPOINT" 2>/dev/null || echo "0")

    if [ "$status" == "in_progress" ]; then
        echo "⚠️  Found interrupted session at iteration #$iteration"
        echo "Options:"
        echo "  /auto-loop --resume        → Continue"
        echo "  /auto-loop --force \"...\"  → Start fresh"
        exit 1
    fi
fi

Behavior Matrix:

Existing StateCommandAction
None/auto-loop "task"Start new
completed/auto-loop "task"Archive & start new
in_progress/auto-loop "task"Block - prompt user
in_progress/auto-loop --resumeContinue
in_progress/auto-loop --force "task"Archive & start new

2. Initialize

# Archive old changelog if > 100 lines
CHANGELOG_DIR=".director-mode"
CHANGELOG="$CHANGELOG_DIR/changelog.jsonl"

if [ -f "$CHANGELOG" ] && [ $(wc -l < "$CHANGELOG") -gt 100 ]; then
    mv "$CHANGELOG" "$CHANGELOG_DIR/changelog.$(date +%Y%m%d_%H%M%S).jsonl"
fi

# Create state directories
mkdir -p "$STATE_DIR" "$CHANGELOG_DIR"

# Initialize checkpoint
cat > "$CHECKPOINT" << EOF
{
  "request": "$ARGUMENTS",
  "current_iteration": 0,
  "max_iterations": 20,
  "status": "in_progress",
  "started_at": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
  "acceptance_criteria": [],
  "last_test_result": null,
  "files_changed": []
}
EOF

3. Parse Acceptance Criteria

Input:
  "Implement authentication

  Acceptance Criteria:
  - [ ] Login form
  - [ ] JWT token
  "

Parsed:
{
  "acceptance_criteria": [
    { "id": 1, "description": "Login form", "done": false },
    { "id": 2, "description": "JWT token", "done": false }
  ]
}

4. DECIDE - Completion Check

┌─────────────────────────────────────────────────────────────┐
│  DECIDE - Iteration #3                                      │
├─────────────────────────────────────────────────────────────┤
│  [x] 1. Login form            ← test passing               │
│  [x] 2. JWT token             ← test passing               │
│  [ ] 3. Error handling        ← NO TEST YET                │
├─────────────────────────────────────────────────────────────┤
│  Decision: 2/3 complete → CONTINUE                          │
└─────────────────────────────────────────────────────────────┘

Complete when:

  • All AC marked done: true
  • All tests passing

Stop when:

  • max_iterations reached
  • .auto-loop/stop file exists

Flags

FlagDescription
--resumeContinue interrupted session
--forceClear old state, start fresh
--statusShow current session status
--max-iterations NSet iteration limit (default: 20)

Observability

All events are automatically logged via PostToolUse hooks:

EventTriggerHook
file_createdWrite toollog-file-change.sh
file_modifiedEdit toollog-file-change.sh
test_pass/failBash (test)log-bash-event.sh
commitBash (git commit)log-bash-event.sh

Query with /changelog:

/changelog              # Recent events
/changelog --summary    # Statistics
/changelog --type test  # Filter by type

Stop / Resume

# Interrupt (stop after current iteration)
touch .auto-loop/stop

# Check status
/auto-loop --status

# Resume
/auto-loop --resume

# Force restart
/auto-loop --force "New task"

Related

Source

git clone https://github.com/claude-world/director-mode-lite/blob/main/skills/auto-loop/SKILL.mdView on GitHub

Overview

Auto-loop runs a TDD-based autonomous development cycle end-to-end. It maintains a checkpointed state to survive interruptions and supports quick resumption. It also emits an observability changelog that records test outcomes, file changes, and commits for each iteration.

How This Skill Works

It follows the RED/GREEN/REFACTOR/VALIDATE/COMMIT cycle with auto-logged events at each step. On start, it creates a state directory and a JSON checkpoint, then checks for existing in-progress sessions to prevent conflicts. You can resume or force-start a new task using --resume or --force to control flow.

When to Use It

  • You want a hands-off, TDD-driven workflow for a feature with clear acceptance criteria
  • You need automatic checkpointing to recover from interruptions without losing progress
  • You require an auditable, per-iteration observability changelog for compliance or QA
  • You want to cap work with a max-iterations limit to prevent scope creep
  • You need to archive old task state and start fresh while preserving history

Quick Start

  1. Step 1: /auto-loop "Implement user login"
  2. Step 2: If interrupted, run /auto-loop --resume or /auto-loop --force "New task" as needed
  3. Step 3: After completion, run /auto-loop --status and review the observability changelog

Best Practices

  • Define clear, testable acceptance criteria before starting a task
  • Keep acceptance criteria in sync with the automated test results and changelog
  • Review the observability changelog after each iteration to spot regressions
  • Use --resume and --force deliberately to manage interrupted sessions
  • Set a realistic max-iterations to bound scope and encourage finishing tasks

Example Use Cases

  • Implement user login with email/password; generate JWT; handle errors
  • Add an authentication flow with acceptance criteria coverage and tests
  • Create password reset flow with token verification and UI tests
  • Refactor authentication modules using code-reviewer suggestions
  • Deliver end-to-end login plus session management with full test pass

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers