agent-sweep-orphanslisted
Install: claude install-skill HermeticOrmus/ormus-agent-ops
# /agent-sweep-orphans — Orphan Task Cleanup
> "Done" doesn't mean "shipped." This sweep finds the gap and closes it.
## The orphan problem
Autonomous agents that commit to feature branches (instead of pushing directly to `main`) accumulate orphans:
- Task ran, committed to `feature/<task-id>`, marked itself done
- The PR was never merged (review caught issues, scope changed, branch protection blocked it)
- Now there's a branch sitting in the repo with completed work that's NOT on `main`
After a few months: dozens of orphan branches, each with potentially valuable work. This skill triages them in bulk.
## Prerequisites
| Var | Purpose |
|---|---|
| `AGENT_API_URL` | Base URL of the agent's HTTP API |
| `AGENT_API_TOKEN` | Bearer token |
Plus local `git` access to the project repo, OR a GitHub token (`GH_TOKEN`) if working remotely.
## Workflow
### Phase 1: Identify orphans
For a single project:
```bash
# Pull all "done" tasks for this project
curl -s -H "Authorization: Bearer $AGENT_API_TOKEN" \
"$AGENT_API_URL/api/tasks?status=done&project=<project>"
# For each task, check if its branch is reachable from main
git fetch origin
for branch in $(git branch -r | grep "feature/<task-id>"); do
if git merge-base --is-ancestor "$branch" origin/main; then
echo "MERGED: $branch"
else
echo "ORPHAN: $branch"
fi
done
```
### Phase 2: Classify each orphan
| Class | Test | Disposition |
|---|---|---|
| **mergeable** | `git merge-tree main feature/X` produces n