Autonomously execute all tasks in a GitHub epic
Executes all tasks in a GitHub epic autonomously with overnight unattended runs.
/plugin marketplace add stickystyle/regent/plugin install regent@regent-pluginscommands/Autonomous serial execution of all tasks in a GitHub epic. Designed for overnight unattended runs with --dangerously-skip-permissions.
/regent-execute-epic {epic-number}
/regent-execute-epic {epic-url}
/regent-execute-epic {epic-number} --dry-run
plugin/scripts/init-execute-epic.sh {epic-number-or-url} [--dry-run]
This script handles:
regent:epic labelIf --dry-run flag was passed: Display the dry run output and stop. Do not proceed to Phase 1.
Executing Epic #{EPIC_NUM}: {EPIC_TITLE}
Spec: {SPEC_NAME}
Branch: {BRANCH} ({BRANCH_ACTION})
{if STASHED: "Stashed local changes"}
Issues: {OPEN_ISSUES} open / {TOTAL_ISSUES} total
{if RESUME_FROM: "Resuming from: #{RESUME_FROM}"}
Read the progress file if it exists ({SPEC_DIR}/epic-progress.json).
in_progress{
"epic_number": {EPIC_NUM},
"started_at": "{ISO_TIMESTAMP}",
"last_updated": "{ISO_TIMESTAMP}",
"issues": {},
"current_issue": null,
"branch": "{BRANCH}"
}
CRITICAL ARCHITECTURE: Each issue is executed by a separate Claude instance spawned via claude -p. This prevents context window overflow during long-running epic execution.
The orchestrator Claude (running this command) only:
For each OPEN issue in the ordered list from {ISSUES_FILE}:
in_progress╔════════════════════════════════════════════════════════════╗
║ Issue #{N}: {title} ║
║ Progress: {completed}/{total} issues ║
╚════════════════════════════════════════════════════════════╝
Spawning worker Claude for issue #{N}...
Execute the issue using a fresh Claude instance:
claude -p "/regent-execute-issue {issue_number} --auto-confirm" \
--plugin-dir . \
--settings ".regent/worker-settings.json" \
--dangerously-skip-permissions \
--max-turns 50 \
--output-format json \
--no-session-persistence \
2>&1 | tee "{SPEC_DIR}/worker-{issue_number}.log"
Flags explained:
-p - Print mode (non-interactive)--plugin-dir . - Load the regent plugin from current directory--settings - Load worker-specific sandbox/permission settings (avoids modifying user's settings)--dangerously-skip-permissions - No permission prompts--max-turns 50 - Limit per-issue work (prevents runaway)--output-format json - Structured output for parsing--no-session-persistence - Workers are single-use, skip session file I/O--auto-confirm - Flag to execute-issue to skip Phase 6.5 human confirmationRun in background and poll for completion:
run_in_background: true - this returns a task_id immediatelyTaskOutput(task_id, block=true, timeout=600000) in a loop until status is "completed"Parse the worker's exit status and output from TaskOutput:
WORKER_EXIT=$?
if [ $WORKER_EXIT -ne 0 ]; then
# Worker failed
Update progress: status: "failed", exit_code: $WORKER_EXIT
Report error from worker log
STOP - Do not continue to next issue
fi
Double-check the issue state (worker should have closed it):
ISSUE_STATE=$(gh issue view {issue_number} --json state --jq '.state')
if [ "$ISSUE_STATE" != "CLOSED" ]; then
# Worker completed but didn't close issue - something went wrong
Update progress: status: "incomplete"
Report warning
STOP - Manual investigation needed
fi
Update progress file:
{
"issues": {
"{issue_number}": {
"status": "completed",
"completed_at": "{ISO_TIMESTAMP}"
}
},
"current_issue": {next_issue_number_or_null}
}
Report:
✓ Issue #{N} completed by worker
Progress: {completed}/{total} issues
Continue to next issue in loop
The /regent-execute-issue command needs a --auto-confirm flag that:
This flag should be documented in execute-issue.md but implementation is:
--auto-confirm is in argumentsAfter all issues are processed (or if all were already closed):
╔════════════════════════════════════════════════════════════╗
║ Epic #{EPIC_NUM} Complete! ║
╚════════════════════════════════════════════════════════════╝
Summary:
- {completed}/{total} issues completed this run
- {total_commits} commits on {BRANCH}
- Started: {started_at}
- Finished: {now}
Check if PR already exists:
EXISTING_PR=$(gh pr list --head "{BRANCH}" --json number --jq '.[0].number // empty')
If no existing PR, create one:
gh pr create --base {DEFAULT_BRANCH} --head {BRANCH} \
--title "Epic #{EPIC_NUM}: {EPIC_TITLE}" \
--body "$(cat <<'EOF'
## Summary
Autonomous implementation of all tasks from Epic #{EPIC_NUM}.
### Completed Issues
{list of closed issues with commit links}
### Commits
{list of commits on this branch}
---
🤖 Generated with [Claude Code](https://claude.com/claude-code) via `/regent:execute-epic`
EOF
)"
Pull Request: #{PR_NUMBER}
URL: {PR_URL}
Epic #{EPIC_NUM} autonomous execution complete.
The progress file can be left for reference or deleted:
Execution stopped at Issue #{N} (phase: {phase})
Error: {error_message}
To resume after fixing:
/regent-execute-epic {EPIC_NUM}
The command will automatically resume from Issue #{N}.
| Failure | Phase State | Resume Behavior |
|---|---|---|
| Init script error | No file | Fresh start |
| Exploration timeout | exploring | Re-explore |
| Implementation stuck | implementing | Re-explore + implement |
| Code review fail (3x) | review_failed | Manual fix, then resume |
| Tests fail | verification_failed | Manual fix, then resume |
| Git conflict | committing | Resolve conflict, then resume |
| PR creation fail | All completed | Manual gh pr create |
For fully autonomous execution:
gh auth loginclaude -p "/regent-execute-epic 42" \
--dangerously-skip-permissions \
--max-turns 100
Unlike /regent-execute-issue, this command does NOT stop to ask questions. If something is ambiguous: