reclaim
Reclaim a stuck loop from a dead or unresponsive owner. Check reclaim candidacy, prompt confirmation, atomically take ownership.
What this skill does
# autoloop: Reclaim
Forcibly reclaim ownership of a loop that appears stuck (dead owner or stale heartbeat). This skill performs an atomic takeover, increments the generation counter, and logs the event in the revision-log.
> **Self-Evolving Skill**: This skill improves through use. If instructions are wrong, parameters drifted, or a workaround was needed — fix this file immediately, don't defer. Only update for real, reproducible issues.
## Arguments
- Positional (optional): a loop identifier. Three forms accepted, all routed through `resolve_loop_identifier`:
- `<loop_id>` — bare 12 hex chars, e.g. `3555bbe1f0fb`
- `AL-<slug>--<hash>` — display-name with disambiguator, e.g. `AL-odb-research--a1b2c3` (matches the on-disk `.autoloop/<slug>--<hash>/` directory)
- `AL-<slug>` — display-name without disambiguator, e.g. `AL-flaky-ci-watcher`. Errors with a candidate list if multiple campaigns share the slug.
## Step 1: Identify the loop
```bash
INPUT="${1:-}"
if [ -z "$INPUT" ]; then
echo "ERROR: identifier required. Try one of:"
echo " /autoloop:reclaim <loop_id> (e.g. 3555bbe1f0fb)"
echo " /autoloop:reclaim AL-<slug> (e.g. AL-odb-research)"
echo " /autoloop:reclaim AL-<slug>--<hash> (e.g. AL-odb-research--a1b2c3)"
echo " Run /autoloop:muster to list active campaigns by name."
exit 1
fi
# Source the resolver and translate any input form to the canonical loop_id.
PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-$HOME/.claude/plugins/marketplaces/cc-skills/plugins/autoloop}"
source "$PLUGIN_ROOT/scripts/registry-lib.sh" || {
echo "ERROR: Failed to source registry-lib.sh" >&2
exit 1
}
if ! LOOP_ID=$(resolve_loop_identifier "$INPUT"); then
# resolve_loop_identifier already printed the error context to stderr (no
# match / ambiguous slug / refused regex). Exit code 2 = ambiguity, in
# which case the candidate list was printed and the user picks one.
# Wave 5 A6: when no match was found, surface the closest registered
# loops so the user has a concrete candidate to retry with instead of
# a bare "not in registry" error.
SUGGESTIONS=$(suggest_closest_loops "$INPUT" 2>/dev/null)
if [ -n "$SUGGESTIONS" ]; then
echo "" >&2
echo "Did you mean one of these?" >&2
echo "$SUGGESTIONS" >&2
echo "" >&2
echo "Run /autoloop:muster to see the full registered fleet." >&2
fi
exit 1
fi
```
## Step 2: Source ownership library and check reclaim candidacy
```bash
PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-$HOME/.claude/plugins/marketplaces/cc-skills/plugins/autoloop}"
source "$PLUGIN_ROOT/scripts/ownership-lib.sh" || {
echo "ERROR: Failed to source ownership-lib.sh" >&2
exit 1
}
```
Check if the loop is a reclaim candidate:
```bash
CANDIDATE=$(is_reclaim_candidate "$LOOP_ID")
if [ "$CANDIDATE" = "no" ]; then
echo "ERROR: Loop $LOOP_ID does not exist in the registry."
exit 1
elif [ "$CANDIDATE" = "owner_alive" ]; then
echo "ERROR: Loop $LOOP_ID has a live owner and fresh heartbeat. Reclaim not needed."
echo " Use /autoloop:stop to cleanly terminate an active loop."
exit 1
fi
```
If `$CANDIDATE = "yes"`, proceed to Step 3.
## Step 3: Show owner info and prompt confirmation
Read the registry entry to display owner information:
```bash
ENTRY=$(jq --arg id "$LOOP_ID" '.loops[] | select(.loop_id == $id)' "$HOME/.claude/loops/registry.json" 2>/dev/null)
if [ -z "$ENTRY" ] || [ "$ENTRY" = "{}" ]; then
echo "ERROR: Registry entry not found for loop $LOOP_ID"
exit 1
fi
# Source state-lib for the human-readable display name.
source "$PLUGIN_ROOT/scripts/state-lib.sh" 2>/dev/null || true
DISPLAY_NAME=$(format_loop_display_name "$LOOP_ID" 2>/dev/null || echo "AL-loop-${LOOP_ID:0:6}")
OWNER_PID=$(echo "$ENTRY" | jq -r '.owner_pid // "unknown"')
OWNER_SESSION=$(echo "$ENTRY" | jq -r '.owner_session_id // "unknown"')
GENERATION=$(echo "$ENTRY" | jq -r '.generation // 0')
CONTRACT_PATH=$(echo "$ENTRY" | jq -r '.contract_path // "unknown"')
STALENESS=$(staleness_seconds "$LOOP_ID")
```
Format confirmation message:
```
Loop: $DISPLAY_NAME ($LOOP_ID)
Current owner PID: $OWNER_PID
Current owner session: $OWNER_SESSION (last seen $STALENESS seconds ago)
Current generation: $GENERATION
Contract path: $CONTRACT_PATH
WARNING: Reclaiming will:
1. Increment generation counter to $(($GENERATION + 1))
2. Transfer ownership to this session
3. Log a takeover event in the revision-log
4. The original owner may conflict if it resumes
Proceed with reclaim?
```
Use `AskUserQuestion` with "Yes, reclaim" / "Cancel" options.
If user selects "Cancel", exit with status 0 (not an error).
## Step 4: Atomically reclaim the loop
Once confirmed:
```bash
PLUGIN_ROOT="${CLAUDE_PLUGIN_ROOT:-$HOME/.claude/plugins/marketplaces/cc-skills/plugins/autoloop}"
source "$PLUGIN_ROOT/scripts/ownership-lib.sh" || exit 1
if reclaim_loop "$LOOP_ID" --reason "user_request"; then
NEW_GEN=$(jq -r --arg id "$LOOP_ID" '.loops[] | select(.loop_id == $id) | .generation' "$HOME/.claude/loops/registry.json" 2>/dev/null)
echo "✓ Reclaimed $DISPLAY_NAME ($LOOP_ID)"
echo " New generation: $NEW_GEN"
exit 0
else
echo "ERROR: Failed to reclaim $DISPLAY_NAME ($LOOP_ID) — it may have been reclaimed or deleted concurrently"
exit 1
fi
```
## Step 5: Print next steps
After successful reclaim:
```
Ready to resume the loop. Next steps:
1. Review the contract at: $CONTRACT_PATH
2. Verify its state (iteration, Current State section, etc.)
3. Run /autoloop:start $CONTRACT_PATH to resume
Or, to clean up:
4. Run /autoloop:stop $CONTRACT_PATH if the loop is no longer needed
```
## Anti-patterns
- Do NOT reclaim an active loop without confirmation — this will conflict with the running owner
- Do NOT change the contract file before the new owner reads it — generation mismatch will cause confusion
- Do NOT use reclaim as a workaround for slow loops — use `/autoloop:stop` and `/autoloop:start` instead
## Troubleshooting
| Symptom | Fix |
| -------------------------------------- | -------------------------------------------------------------------- |
| "does not exist in the registry" | Loop was never registered; use `/autoloop:start` instead |
| "has a live owner and fresh heartbeat" | Don't forcibly reclaim; use `/autoloop:stop` to shut it down cleanly |
| "Failed to reclaim loop" | Registry file was deleted or unreadable; reinstall the plugin |
## Post-Execution Reflection
0. **Locate yourself.** — Confirm this SKILL.md is the canonical file before any edit.
1. **What failed?** — Fix the instruction that caused it.
2. **What drifted?** — Update confirmation message template if needed.
3. **Log it.** — Evolution-log entry.
Related in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.