Runs /autocoder:fix in an infinite loop, continuously fixing GitHub issues until none remain. Supports optional skill enhancements for pstack, Compound Engineering, and personal toolkit skills.
Wrapper around /autocoder:fix that runs it in a loop forever.
Uses the /loop command (CronCreate-based) if available in this Claude Code version; falls back to the stop hook mechanism for older versions.
Silent-worker rule (MANDATORY): Do NOT use
SendMessageat any point during this loop — not to announce startup, not to report idle/available status, not to confirm issue completion. The ONLY time to useSendMessageis when you hit a genuine blocker that the manager must resolve before you can continue. All other communication is via GitHub issues and PRs. Sending idle or status pings wastes tokens and triggers a security banner in the manager's session.
If a named skill appears in your available skills list (delivered in the session-start system-reminder), invoke it via the Skill tool at the indicated step. Otherwise, follow the inline protocol below — it remains the source of truth and is unchanged by this section.
Platform note: in Gemini CLI / Antigravity, skills activate via activate_skill instead of the Skill tool; in Codex they activate as $<skill>; in Factory Droid they load from the skills tree. The mapping is otherwise identical on all four platforms.
Skill-name matching. Match each table entry as an exact string. Mapping tables use fully-qualified names (<plugin>:<skill>) for plugin-installed skills and bare names for personal toolkit skills. Compound Engineering skills are the exception: match them in either form — fully-qualified compound-engineering:ce-<name> (how Claude Code lists them) or bare ce-<name> (how Codex, Factory Droid, and Antigravity list them). pstack skills match as fully-qualified pstack:<name> (how Claude Code and Codex list them). A bare <name> counts as pstack only when bare poteto-mode is also in your available-skills list, which marks a skills-only pstack install; otherwise a bare tdd or how is a personal toolkit skill and gets no pstack precedence.
Notation. A → B → C means sequence (invoke in order). A + B + C means independent facets (all apply, order irrelevant). A (primary) means A is the orchestration spine. A leading → on a row indicates "next in sequence if applicable."
pstack precedence. pstack (https://github.com/michael-denyer/pstack-claude) outranks Compound Engineering, superpowers:*, and personal toolkit skills for the role below. If the listed pstack:* skill appears in your available-skills list, invoke it in place of every skill in the "In place of" column, including a Compound Engineering skill that would otherwise substitute for it. Roles pstack does not cover fall through to the Compound Engineering table. In an unattended run, take pstack:interrogate's intent statement from the issue or plan instead of asking the user.
| Role | Use when installed | In place of |
|---|---|---|
| reviewing written code | pstack:interrogate | ce-code-review, superpowers:requesting-code-review |
Mapping tables also name pstack skills directly where no other plugin covers the step: pstack:tdd (bug regression test), pstack:how (understand unfamiliar code), pstack:deslop (clean the diff), pstack:blast-radius (what a change breaks beyond its diff), and pstack:unslop / pstack:technical-writing (prose this command authors). Run pstack:blast-radius without its arena escalation, and write its proof scripts outside the working tree so they are never committed.
pstack orchestrators are not invoked. This command's inline protocol is the spine. Do not enter pstack:poteto-mode, pstack:figure-it-out, pstack:swarm, pstack:arena, pstack:architect, pstack:babysit, or pstack:make-pr-easy-to-review, including when another pstack skill's steps tell you to run one. Each owns its own playbook, dispatch, implementation, or PR tail and would bypass worktree naming, the issue-claim sequence, and the configured Merge Mode. pstack's SessionStart hook injects "Invoke the pstack:poteto-mode skill ... when a task touches more than one file" at startup and after every compaction. Ignore that instruction while this command runs, every time it reappears. The hook defers only to CLAUDE.md, AGENTS.md, and direct requests, so for unattended workers also set session hook: off in pstack-models.md (see docs/PSTACK.md).
Compound Engineering precedence. If a skill from the compound-engineering plugin covers a role in the table below and appears in your available-skills list, invoke it in place of the skill named in the mapping tables for that role. Compound Engineering outranks both superpowers:* and personal toolkit skills (pstack outranks it, per the table above), and this rule overrides any "(preferred)" annotation a mapping table places on a substituted skill. Roles with no entry below are unaffected.
| Role | Use when installed | In place of |
|---|---|---|
| design exploration / requirements | ce-brainstorm | thorough-brainstorming, superpowers:brainstorming |
| implementation planning | ce-plan | thorough-writing-plans, superpowers:writing-plans |
| executing a plan | ce-work, invoked as mode:return-to-caller <plan path> | superpowers:executing-plans |
| debugging a defect | ce-debug | superpowers:systematic-debugging |
| reviewing a spec, plan, or report document | ce-doc-review | critical-design-review, critical-implementation-review, update-design-doc, update-implementation-plan |
| reviewing written code | ce-code-review | superpowers:requesting-code-review |
| acting on review feedback on an existing PR | ce-resolve-pr-feedback | superpowers:receiving-code-review |
| session handoff | ce-handoff | create-handoff, resume-handoff |
Three deliberate exclusions:
superpowers:using-git-worktrees and superpowers:finishing-a-development-branch remain in force — do not substitute ce-worktree, ce-commit-push-pr, ce-commit, or lfg for them — because the inline protocol owns worktree naming, the issue-claim sequence, and the configured Merge Mode. ce-work is substituted for plan execution only, which is why the table requires mode:return-to-caller: bare ce-work owns its own shipping tail and would bypass all three.completion-review is never substituted. It is a plan-vs-delivery audit, not a diff review, and it runs on Document deliverables (/retro, /fix's Document row) where a code reviewer has nothing to read. Run it as the mapping tables specify, alongside the code reviewer (pstack:interrogate or ce-code-review) rather than replaced by it.pstack:interrogate or ce-code-review) and no PR exists yet, act on them via the inline protocol or superpowers:receiving-code-review; ce-resolve-pr-feedback requires GitHub PR threads.Failure semantics. Not-installed: silent fallback. Mid-run failure or interruption of an installed skill: surface the failure message, fall back to the inline protocol for the rest of that step, no retry. Self-skip (e.g., <SUBAGENT-STOP>): silent fallback, not treated as failure. If at least one superpowers:* skill named in this command's mapping table is missing from your available-skills list and no installed pstack or Compound Engineering skill covers its role, emit one consolidated recommendation line at command entry: Tip: this command works best with the superpowers plugin (https://github.com/obra/superpowers) — install via /plugin install superpowers@claude-plugins-official. Never emit such notices for pstack, Compound Engineering, or personal toolkit skills.
Skills are advisory, not gating. A command's completion criteria are defined by its inline protocol. Optional skill outcomes are surfaced and considered, but do not override inline success criteria. "Always applied" in a mapping table means the skill is invoked when installed; outcomes remain advisory. When a command claims success while an advisory skill earlier in the run surfaced a failure, the success summary acknowledges the advisory finding.
Version trust. Skills are matched by name; the integration does not pin or verify versions. If a tracked skill's contract changes in a way that breaks the chain, the integration is stale and must be updated.
/fix-loop is a dispatcher coordinating parallel workers. The dispatcher and workers have distinct skill mappings.
Dispatcher level (runs in the host workspace, not a worktree).
| Step | Skill mapping |
|---|---|
| Plan and dispatch parallel workers | superpowers:subagent-driven-development + superpowers:dispatching-parallel-agents |
| Provision isolated worktrees for workers | superpowers:using-git-worktrees (for workers only; dispatcher runs in host workspace) |
Per-worker level (each worker in its own worktree; workers receive the dispatcher's manifest and apply the full /fix mapping above to their assigned issue, including the same composition rule and ordering-across-steps rule), plus:
| Step | Skill mapping |
|---|---|
| Each worker finishes its branch (PR / merge) | superpowers:finishing-a-development-branch |
Worker dispatch. Prepend the optional-skills-manifest v3 block (from plugins/shared/optional-skills-prelude.md / .agent/shared/optional-skills-prelude.md) as the first paragraph of each worker's prompt. Generate the bullet list as the intersection of your available skills × the per-worker skill set: superpowers:systematic-debugging, superpowers:test-driven-development, superpowers:using-git-worktrees, superpowers:verification-before-completion, superpowers:requesting-code-review, superpowers:receiving-code-review, superpowers:finishing-a-development-branch, thorough-brainstorming, thorough-writing-plans, superpowers:brainstorming, superpowers:writing-plans, autocoder:improve-test-coverage, critical-design-review, critical-implementation-review, completion-review, and the Compound Engineering skills compound-engineering:ce-brainstorm, compound-engineering:ce-plan, compound-engineering:ce-work, compound-engineering:ce-debug, compound-engineering:ce-code-review, compound-engineering:ce-doc-review, compound-engineering:ce-resolve-pr-feedback (or the bare ce-* form on platforms that list them that way) (preferred over the superpowers/toolkit skills covering the same roles), and the pstack skills pstack:interrogate, pstack:tdd, pstack:how, pstack:deslop, pstack:blast-radius, pstack:unslop (bare form only alongside bare poteto-mode) (pstack:interrogate preferred over Compound Engineering and superpowers for code review).
# Start infinite loop
/fix-loop
# Limit to 100 iterations (stop hook mode only)
/fix-loop 100
# Custom idle sleep time (default: 4 minutes — stays inside the 5-min prompt cache TTL)
/fix-loop --sleep 30
# Phase 3 opt-in: route loop through /autocoder:dispatch (Haiku gate,
# Sonnet/Opus worker via Task model= handoff). Default unset → uses
# /autocoder:gate (same-model, Phase 2). Acceptance criteria in spec §13.4.
LOOP_MODEL_SPLIT=1 /fix-loop
# Multi-agent coordination with deployment
/fix-loop --branch main --deploy "deploy.sh staging ."
# Or set via environment
export CLAUDE_CODE_INTEGRATION_BRANCH="main"
export CLAUDE_CODE_DEPLOY_COMMAND="deploy.sh staging ."
/fix-loop
Mode 1: /loop command (preferred, when CronCreate tool is available)
loop skill to schedule /autocoder:fix every IDLE_SLEEP_MINUTES minutesMode 1b: Grok scheduler (when scheduler_create is available and CronCreate is not)
Grok's /loop is the scheduler_create tool. Each fire is a detached background subagent, which is what keeps the loop alive. A Stop hook is not a loop on Grok: it can continue the same turn at most 8 times, then the turn is forced to end.
Mode 2: Stop hook (fallback for older Claude Code versions, not for Grok)
.claude/settings.json (if not present).claude/fix-loop.local.md/autocoder:fix/autocoder:fix back as inputWhen CLAUDE_CODE_TASK_LIST_ID is set, /fix-loop automatically coordinates with other agents:
Setup:
# 1. Configure deployment in your CLAUDE.md:
cat >> CLAUDE.md << 'EOF'
## Deployment
Integration branch: main
Deploy to staging: deploy.sh staging .
EOF
# 2. Set shared task list ID in all worktrees
export CLAUDE_CODE_TASK_LIST_ID="project-$(date +%Y%m%d)"
# 3. Run /fix-loop in each worktree (same command everywhere)
# Main worktree
cd /path/to/project
/fix-loop # → Auto-detects: "I'm coordinator, will deploy when ready"
# Feature worktree 1
cd /path/to/project-wt-auth
/fix-loop # → Auto-detects: "I'm worker, will complete tasks"
# Feature worktree 2
cd /path/to/project-wt-api
/fix-loop # → Auto-detects: "I'm worker, will complete tasks"
Configuration Options:
The integration branch and deploy command can be specified:
In CLAUDE.md (recommended):
## Deployment
Integration branch: main
Deploy to staging: deploy.sh staging .
Via environment:
export CLAUDE_CODE_INTEGRATION_BRANCH="main"
export CLAUDE_CODE_DEPLOY_COMMAND="deploy.sh staging ."
Via command line:
/fix-loop --branch main --deploy "deploy.sh staging ."
Auto-detection: Defaults to main branch and looks for:
scripts/deploy-staging.shdeploy.sh stagingAutomatic Deployment Trigger:
When ALL these conditions are met:
Then: Main worktree automatically:
Benefits:
/fix-loop command everywhere/loop mode:
Stop hook mode:
STOP_FIX_GITHUB_LOOP - Explicit stop signalrm .claude/fix-loop.local.md# Parse arguments
MAX_ITERATIONS="${1:-0}" # 0 = unlimited
# Default 4 min keeps consecutive ticks inside the 5-min prompt cache TTL —
# see docs/specs/2026-05-21-fix-loop-token-efficiency-design.md §6 for the analysis.
IDLE_SLEEP_MINUTES="4"
INTEGRATION_BRANCH="${CLAUDE_CODE_INTEGRATION_BRANCH:-}"
DEPLOY_COMMAND="${CLAUDE_CODE_DEPLOY_COMMAND:-}"
args=("$@")
for ((i=0; i<${#args[@]}; i++)); do
case ${args[i]} in
--sleep)
IDLE_SLEEP_MINUTES="${args[i+1]}"
((i++))
;;
--branch)
INTEGRATION_BRANCH="${args[i+1]}"
((i++))
;;
--deploy)
DEPLOY_COMMAND="${args[i+1]}"
((i++))
;;
[0-9]*)
MAX_ITERATIONS="${args[i]}"
;;
esac
done
# If not set, try to extract from CLAUDE.md
if [[ -z "$INTEGRATION_BRANCH" ]]; then
for claude_file in CLAUDE.md claude.md README.md; do
if [[ -f "$claude_file" ]]; then
INTEGRATION_BRANCH=$(grep -i "integration.*branch\|main.*branch\|merge.*into" "$claude_file" | \
grep -Eo '\b(main|master|develop|integration)\b' | head -1)
[[ -n "$INTEGRATION_BRANCH" ]] && break
fi
done
fi
# Default to main if still not found
INTEGRATION_BRANCH="${INTEGRATION_BRANCH:-main}"
# If not set, try to extract deploy command from CLAUDE.md
if [[ -z "$DEPLOY_COMMAND" ]]; then
for claude_file in CLAUDE.md claude.md README.md; do
if [[ -f "$claude_file" ]]; then
DEPLOY_COMMAND=$(grep -i "deploy.*staging\|staging.*deploy" "$claude_file" | \
grep -Eo '(\.?/)?[a-zA-Z0-9_/-]+\.sh\s+[a-zA-Z0-9_. /-]*' | head -1)
[[ -n "$DEPLOY_COMMAND" ]] && break
fi
done
fi
export CLAUDE_CODE_INTEGRATION_BRANCH="$INTEGRATION_BRANCH"
export CLAUDE_CODE_DEPLOY_COMMAND="$DEPLOY_COMMAND"
# Phase 3 opt-in: LOOP_MODEL_SPLIT=1 routes to /autocoder:dispatch
# (Haiku gate + Sonnet/Opus worker via Task model=). Default → /autocoder:gate.
# See docs/specs/2026-05-21-fix-loop-token-efficiency-design.md §5.3, §10 Phase 3.
if [[ "${LOOP_MODEL_SPLIT:-0}" = "1" ]]; then
LOOP_TARGET="/autocoder:dispatch"
else
LOOP_TARGET="/autocoder:gate"
fi
mkdir -p .claude
# Record this worker in the swarm manifest (#217, part of #178), so a worker started by hand (plain agent + this command) still appears
# in .autocoder/swarm/<session>.json instead of "workers": [].
# Outside a swarm (no manifest) swarm-register.sh prints a note and exits 0.
# Never fatal: a failed registration must not stop the loop.
REGISTER_SH=$(
for d in "$(pwd)/.agent/scripts" \
"$(pwd)/plugins/autocoder/scripts" \
"$(pwd)/.claude-plugin/plugins/autocoder/scripts"; do
if [ -f "$d/swarm-register.sh" ]; then echo "$d/swarm-register.sh"; exit 0; fi
done
found=$(
find "$HOME/.claude/plugins/cache" -type f -name swarm-register.sh -path "*/autocoder/*" -not -path "*/skills/*" 2>/dev/null \
| awk -F/ '{print $(NF-2) "\t" $0}' | sort -V -t$'\t' -k1,1 | tail -1 | cut -f2-
)
if [ -n "$found" ]; then echo "$found"; exit 0; fi
# Grok installs to ~/.grok/installed-plugins/<name>-<hash>/. The hash is in
# the directory name, so the Claude cache glob */autocoder/* does not match.
find "$HOME/.grok/installed-plugins" -type f -name swarm-register.sh -path "*/autocoder-*/*" -not -path "*/skills/*" 2>/dev/null \
| awk -F/ '{print $(NF-2) "\t" $0}' | sort -V -t$'\t' -k1,1 | tail -1 | cut -f2-
)
if [ -n "$REGISTER_SH" ]; then
bash "$REGISTER_SH" || echo "⚠️ swarm-register.sh failed; continuing without updating the manifest" >&2
fi
Check whether the CronCreate tool is available (it appears in the available deferred tools list when Claude Code supports the /loop command).
If CronCreate IS available → Use /loop mode (preferred):
# Remove the stop hook if it was previously installed, since /loop replaces it
if [ -f ".claude/settings.json" ] && grep -q "autocoder/hooks/stop-hook.sh" .claude/settings.json 2>/dev/null; then
echo "🔄 Removing stop hook (replaced by /loop command)..."
python3 << 'PYTHON_SCRIPT'
import json
with open(".claude/settings.json", 'r') as f:
settings = json.load(f)
if "hooks" in settings and "Stop" in settings["hooks"]:
settings["hooks"]["Stop"] = [h for h in settings["hooks"]["Stop"] if "stop-hook" not in str(h)]
if not settings["hooks"]["Stop"]:
del settings["hooks"]["Stop"]
if not settings["hooks"]:
del settings["hooks"]
with open(".claude/settings.json", 'w') as f:
json.dump(settings, f, indent=2)
PYTHON_SCRIPT
echo "✅ Stop hook removed"
fi
echo ""
echo "🔄 Starting fix loop using /loop command"
echo " Interval: ${IDLE_SLEEP_MINUTES}m"
if [[ -n "$CLAUDE_CODE_TASK_LIST_ID" ]]; then
echo " Coordination: Enabled (task list: ${CLAUDE_CODE_TASK_LIST_ID:0:20}...)"
echo " Integration branch: $INTEGRATION_BRANCH"
[[ -n "$DEPLOY_COMMAND" ]] && echo " Deploy command: $DEPLOY_COMMAND"
fi
echo ""
echo "To stop: use CronDelete to remove the scheduled job, or Ctrl+C"
echo ""
Then invoke the loop skill:
Use the Skill tool to invoke: loop
With args: ${IDLE_SLEEP_MINUTES}m ${LOOP_TARGET}
This schedules ${LOOP_TARGET} (the slim pre-LLM gate, per spec §5.4; /autocoder:dispatch when LOOP_MODEL_SPLIT=1) to run every IDLE_SLEEP_MINUTES minutes using the native CronCreate mechanism. The gate dispatches to /autocoder:fix only when there is actual work to do; idle ticks exit cheaply. No stop hook or settings.json modification needed.
If scheduler_create is available and CronCreate is not (Grok) → schedule with the Grok scheduler:
Do not install a Stop hook and do not create .claude/fix-loop.local.md. A Stop hook on Grok continues the same turn at most 8 times, and an idle sleep inside the hook is killed at the hook timeout (default 600 seconds). The schedule is the loop.
Call scheduler_create with:
| Parameter | Value |
|---|---|
interval | ${IDLE_SLEEP_MINUTES}m. If that would be under 60 seconds, use 1m. |
prompt | ${LOOP_TARGET} exactly (/autocoder:gate, or /autocoder:dispatch when LOOP_MODEL_SPLIT=1). The subagent runs that command. |
fire_immediately | true |
recurring | true |
durable | true, so it keeps firing after this session closes |
When the tool returns an id, record it and drop any previous fix-loop id:
mkdir -p .grok
python3 - "$JOB_ID" "$LOOP_TARGET" "${IDLE_SLEEP_MINUTES}m" << 'PY'
import json, os, sys
path = ".grok/autocoder-loops.json"
data = json.load(open(path)) if os.path.exists(path) else {"jobs": []}
data["jobs"] = [j for j in data.get("jobs", []) if j.get("kind") != "fix-loop"]
data["jobs"].append({"kind": "fix-loop", "id": sys.argv[1], "prompt": sys.argv[2], "interval": sys.argv[3]})
json.dump(data, open(path, "w"), indent=2)
print("recorded", sys.argv[1])
PY
echo "🔄 Fix loop scheduled on Grok"
echo " Recurring Grok tasks expire after 7 days. Run /fix-loop again to renew."
echo " To stop: /stop-loop"
Substitute the id scheduler_create returned for $JOB_ID before running that script. One fix-loop schedule at a time: if scheduler_list already has a job whose prompt is this same target, scheduler_delete it before creating another.
If neither CronCreate nor scheduler_create is available → Use stop hook mode (fallback):
# ============================================================
# Install stop hook if not configured
# ============================================================
if [ -f ".claude/settings.json" ] && grep -q "autocoder/hooks/stop-hook.sh" .claude/settings.json 2>/dev/null; then
echo "✅ Stop hook already configured"
else
echo "📝 Installing stop hook..."
if [ -f ".claude/settings.json" ]; then
python3 << 'PYTHON_SCRIPT'
import json
with open(".claude/settings.json", 'r') as f:
settings = json.load(f)
stop_hook = {"matcher": "", "hooks": [{"type": "command", "command": "bash ~/.claude/plugins/autocoder/hooks/stop-hook.sh"}]}
if "hooks" not in settings:
settings["hooks"] = {}
if "Stop" not in settings["hooks"]:
settings["hooks"]["Stop"] = []
CURRENT_PATH = "autocoder/hooks/stop-hook.sh"
# Remove stale/legacy stop hooks (e.g. stop-hook-wrapper.sh) that aren't the current autocoder hook
settings["hooks"]["Stop"] = [h for h in settings["hooks"]["Stop"] if "stop-hook" not in str(h) or CURRENT_PATH in str(h)]
if not any(CURRENT_PATH in str(h) for h in settings["hooks"]["Stop"]):
settings["hooks"]["Stop"].append(stop_hook)
with open(".claude/settings.json", 'w') as f:
json.dump(settings, f, indent=2)
PYTHON_SCRIPT
else
cat > .claude/settings.json << 'EOF'
{
"hooks": {
"Stop": [
{
"matcher": "",
"hooks": [
{
"type": "command",
"command": "bash ~/.claude/plugins/autocoder/hooks/stop-hook.sh"
}
]
}
]
}
}
EOF
fi
echo "✅ Stop hook installed"
fi
# Create loop state file
cat > .claude/fix-loop.local.md << EOF
---
iteration: 0
max_iterations: $MAX_ITERATIONS
idle_sleep_minutes: $IDLE_SLEEP_MINUTES
integration_branch: $INTEGRATION_BRANCH
deploy_command: $DEPLOY_COMMAND
started: $(date -Iseconds)
---
${LOOP_TARGET}
EOF
echo ""
echo "🔄 Loop initialized (stop hook mode)"
echo " Max iterations: $([ "$MAX_ITERATIONS" = "0" ] && echo "unlimited" || echo "$MAX_ITERATIONS")"
echo " Idle sleep: $IDLE_SLEEP_MINUTES minutes"
if [[ -n "$CLAUDE_CODE_TASK_LIST_ID" ]]; then
echo " Coordination: Enabled (task list: ${CLAUDE_CODE_TASK_LIST_ID:0:20}...)"
echo " Integration branch: $INTEGRATION_BRANCH"
[[ -n "$DEPLOY_COMMAND" ]] && echo " Deploy command: $DEPLOY_COMMAND"
fi
echo ""
Then execute /gate using the Skill tool:
Use the Skill tool to invoke: autocoder:${LOOP_TARGET#/autocoder:}
The stop hook will automatically re-invoke ${LOOP_TARGET} when Claude exits, creating an infinite loop. The gate dispatches to /autocoder:fix only when there is work to do (spec §5.4).
What the command file sets; muted values are Claude Code's defaults
7-day visitors to each command page
33 commands in this plugin
/analyze-tracesAnalyze TracesName the agent failures that repeat (#395). This builds one trace per issue attempt from the/approve-proposalApprove ProposalsApprove one or more AI-generated proposals for implementation by removing the `proposal` label./author-evalsAuthor EvalsTurn the failures that repeat into evaluation cases a machine can run and grade (#395). This/autocoder:fix-loopfrom autocoder
Claude never picks this command on its own
Its frontmatter has no description. Without a description, Claude Code leaves it out of the list Claude chooses from. Typing /autocoder:fix-loop still runs it.
npx claudepluginhub laird/agents --plugin autocoder