Pattern for running Claude Code as an autonomous research agent with restart-with-state loops. Use when: (1) long-running research or enumeration that exceeds context limits, (2) need autonomous operation for hours/days, (3) systematic task-based work that should survive crashes and quota limits. Covers: loop script, state tracking, cron auto-restart, heartbeat monitoring, backup, inflight task addition, graceful quota handling.
How this skill is triggered — by the user, by Claude, or both
Slash command
/autonomous-research-loop:autonomous-research-loopThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Long-running research or enumeration tasks exceed Claude Code's context window. Single
Long-running research or enumeration tasks exceed Claude Code's context window. Single sessions degrade over time with autocompact. You need autonomous operation for 12-24+ hours.
Instead of one long session, use a loop that:
RESEARCH_STATE.md)State file — Markdown checklist that agents read/write:
- [ ] pending, - [~] in progress, - [x] doneLoop script — Bash wrapper that:
claude --print --dangerously-skip-permissionscaffeinate to prevent sleepCron auto-restart — Every 5 min, check if loop is running:
Backup — Cron rsync to external drive every 15 min
Inflight task addition — Edit state file while loop is running. Next iteration picks up new tasks automatically.
tmux new-session -d -s research './scripts/research-loop.sh 0 60'
tmux attach -t research # optional: watch it work
# Detach: Ctrl-b d
tmux kill-session -t research
./scripts/disable-crons.sh
cat .research-heartbeattail agent-monitor.loggit log --onelinecat PROGRESS.mdtmux has-session -t research returns 0ps aux | grep "claude --print" shows active process.research-heartbeat updates every iterationgit log shows commits from the agent--max-budget-usd does NOT apply to Claude Max subscription accountsCreates, edits, and optimizes skills for Claude Code, including drafting, evaluating with test prompts, iterating on performance, and improving skill descriptions for better triggering accuracy.
npx claudepluginhub dmaynor/dmaynor-skills-marketplace --plugin autonomous-research-loop