Autonomous development loop with research and implementation modes
A self-sustaining development loop with two modes: Researcher and Implementor.
Full permissions required. The loop runs autonomously and needs unrestricted access.
claude --dangerously-skip-permissions
The script automatically uses --yolo mode (no sandbox, no prompts).
When this skill is invoked, ask the user FOUR questions using AskUserQuestion, then one text prompt:
Research - Explore, investigate, and plan. Creates specs for implementation.Implement - Execute on specs. Write code, tests, and documentation.Push - Commit and push to current branch (default)Commit only - Commit locally, no pushOpen PR - Open PR, wait for CI (no merge)PR and merge - Open PR, wait for CI, then auto-mergeFresh context - Clear context between iterations (default, recommended)Keep context - Maintain conversation history across iterationsNone - No specific directions, work autonomouslyFocus on specs - Review and improve existing implementation specsExplore dependencies - Research external libraries and frameworksFix issues first - Prioritize fixing build errors and warningsSkip tests - Focus on implementation, skip test writing for nowIf user selects "Other", they can provide custom directions like:
The agent interprets directions intelligently (creating dots, modifying tasks, updating docs, changing priorities, etc.).
After the AskUserQuestion completes, ask:
"How many iterations? Enter a number, 'inf' for infinite, or 'comp' for until complete:"
Parse the response:
Key distinction:
After collecting answers:
./scripts/setup-loop.sh <mode> --iterations <N> --git-workflow <workflow> [--fresh-context] [--directions "..."]
<mode>-loop.md (mode-specific sections)loop-shared.md (common sections)Fresh context mode (default): You are the orchestrator. Run this loop in the main conversation:
iteration = 0
PROMPT = contents of <mode>-loop.md + "\n\n" + contents of loop-shared.md
DIRECTIONS = user's directions (if provided)
# Exponential backoff for infinite mode
MIN_DELAY = 5 # seconds
current_delay = MIN_DELAY
# If directions were provided, append them to the prompt
if DIRECTIONS:
PROMPT = PROMPT + "\n\n## User Directions\n\n" + DIRECTIONS
LOOP:
iteration += 1
print "=== Iteration {iteration} ==="
result = Task(prompt=PROMPT, subagent_type="general-purpose")
# Check termination conditions
if iterations == 0: # "until complete" mode
if result contains "RANDROID_LOOP_COMPLETE":
print "Loop complete (promise found after {iteration} iterations)"
EXIT LOOP
elif iterations > 0: # exact N iterations mode
if iteration >= iterations:
print "Completed {iteration} iterations"
EXIT LOOP
# iterations == -1 means infinite, continues below
# Exponential backoff for infinite mode when no work done
if iterations == -1: # infinite mode
if result contains "RANDROID_LOOP_COMPLETE":
print "No work this iteration, backing off for {current_delay}s..."
sleep(current_delay)
current_delay = current_delay * 2 # No max cap
else:
# Meaningful work done, reset backoff
current_delay = MIN_DELAY
GOTO LOOP
CRITICAL: After each Task returns, YOU (the orchestrator) must:
Keep context mode: Run the loop directly in the current conversation. The stop hook will intercept exit and continue looping with accumulated context.
/randroid
Prompts for mode, iterations, and optional directions.
/randroid research - Research mode, prompts for iterations/randroid implement - Implement mode, prompts for iterations/randroid research --loop - Research mode, infinite (ignores completion)/randroid research --until-complete - Research mode, stops on completion/randroid implement --iterations 5 - Implement mode, exactly 5 iterations/randroid implement --open-pr - Open PR workflow/randroid implement --pr-and-merge - PR with auto-merge workflow/randroid implement --commit-only - Local commits only/randroid implement --keep-context - Keep conversation context (no fresh start)/randroid implement --iterations 5 --open-pr - Combine optionsYou can provide guidance for the agent. When prompted for directions:
Directions can include:
# From terminal (outside Codex)
./skills/randroid-loop/scripts/randroid-loop.sh
# Interactive prompts for mode, iterations, and git workflow
# Note: Wrapper always uses fresh context (each iteration is a new codex exec)
# Direct invocation:
./skills/randroid-loop/scripts/randroid-loop.sh research -1 # infinite
./skills/randroid-loop/scripts/randroid-loop.sh research 0 # until complete
./skills/randroid-loop/scripts/randroid-loop.sh implement 5 # exactly 5 iterations
./skills/randroid-loop/scripts/randroid-loop.sh implement 5 pr # 5 iterations, open PR
./skills/randroid-loop/scripts/randroid-loop.sh implement 0 pr-merge # until complete, PR + merge
The researcher explores, investigates, and plans. It:
research: prefixed dots to track its own explorationimplement: prefixed dots as deliverables for the implementorThe implementor executes. It:
implement: dotsimplement: dots if scope expandsresearch: dots if blocked by unknowns (for next research cycle)Each loop iteration starts with fresh conversational context. Only the filesystem persists:
This prevents context bloat and allows the agent to approach each iteration with clarity.
.dots/ task stateOutput <promise>RANDROID_LOOP_COMPLETE</promise> when:
The loop also stops when --iterations N limit is reached.
skills/randroid-loop/
├── SKILL.md # This file
├── research-loop.md # Research mode prompt
├── implement-loop.md # Implementor mode prompt
├── loop-shared.md # Shared sections (git, dots, termination)
├── LOOPING_DESIGN.md # Technical design doc
├── hooks/
│ └── stop-hook.sh # Claude Code stop hook
├── scripts/
│ ├── setup-loop.sh # Initialize loop state
│ └── randroid-loop.sh # Codex external wrapper
└── state/
└── .gitignore # Excludes local state files