agent-sweep-orphans
Skill0 starsChanged 7 months agoMITView on GitHub
Triage orphan tasks in an autonomous coding agent — tasks marked "done" with commits or branches that never merged to main. Classifies each, shows the diff, and offers bulk merge / dead-letter / requeue dispositions.
- Sends data out
- Commits and pushes
1 other project uses a version of this.
Adopted by
Most recently taken up by
- HermeticOrmus/ormus-agent-opsword for word, first seen Apr 25, 2026
Other versions1 project uses a version of this.
Word for word · 1
- HermeticOrmus/ormus-agent-ops★ 0100% same
Edited · 0
None found.
Wrote their own version · 0
None found.
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository6 other files it gives its agents.
- agent-cleanSkill
- agent-evolveSkill
- agent-inspectSkill
- agent-opsSkill
- agent-statusSkill
- agent-triageSkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 3 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 18
After a few months: dozens of orphan branches, each with potentially valuable work.
- Distinctive: line 86
After the user has approved/declined each one, batch the actions:
- Distinctive: line 98
Only execute after explicit user confirmation.
- Very specific: line 154
If the agent has multiple parallel projects, run this skill per-project.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
/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:
# 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
donePhase 2: Classify each orphan
| Class | Test | Disposition |
| mergeable | git merge-tree main feature/X produces no conflicts AND tests pass | merge — fast-forward or squash-merge |
| conflicting | merge-tree produces conflicts | resolve-and-merge OR requeue to redo against current main |
| superseded | another task already implemented this functionality (search recent commits on main) | dead-letter — close the branch |
| stale | branch is >30 days old AND no longer relevant | dead-letter |
| wrong-target | branch was based on a different default branch (e.g. develop not main) | rebase-and-merge OR requeue |
| partial | branch has commits but task report shows incomplete work | requeue to finish the work |
Phase 3: Present per-orphan triage
For each orphan, show:
ORPHAN <task-id> <slug>
─────────────────────────
branch: feature/<task-id>
created: <date>
class: <mergeable / conflicting / superseded / stale / wrong-target / partial>
diff: +<lines>/-<lines> across <N> files
files: <top 5 changed files>
last commit: <hash> <date> <message>
DIFF SUMMARY
<brief description of what changed>
PROPOSED ACTION <merge / dead-letter / requeue / inspect>
[ apply | skip | inspect | requeue with notes ]Phase 4: Bulk disposition (after per-orphan review)
After the user has approved/declined each one, batch the actions:
BULK PLAN
merge: <N> branches (will fast-forward if possible, else open PRs)
dead-letter: <N> tasks (close branches, no merge)
requeue: <N> tasks (redo work against current main)
skip: <N> (leave for next sweep)
Confirm? [y/N]Only execute after explicit user confirmation.
Phase 5: Execute
For merges:
# Try fast-forward first; fall back to merge commit if non-FF
git checkout main
git pull origin main
git merge --ff-only feature/<task-id> || git merge feature/<task-id>
git push origin mainOr open PRs (if branch protection requires review):
gh pr create --base main --head feature/<task-id> --title "<task slug>" --body "..."For dead-letter:
git push origin --delete feature/<task-id>
curl -X POST -H "Authorization: Bearer $AGENT_API_TOKEN" \
"$AGENT_API_URL/api/tasks/<task-id>/dead-letter"For requeue:
curl -X POST -H "Authorization: Bearer $AGENT_API_TOKEN" \
-d '{"reset_branch": true}' \
"$AGENT_API_URL/api/tasks/<task-id>/requeue"
git push origin --delete feature/<task-id>Output
SWEEP COMPLETE — <project>
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Orphans found: <N>
Merged: <N> (✓ <N> fast-forward, ✓ <N> via PR)
Dead-lettered: <N>
Requeued: <N>
Skipped: <N>
Failed actions: <N> ← inspect these
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━Notes
- Never bulk-merge without per-orphan review. A task that "appears mergeable" by tree but breaks the build under integration is worse than no orphan at all.
- For
supersededorphans, the killer signal is whengit log --grep=<feature keyword>on main shows recent commits — someone else already did this work. - The
partialclass is the trickiest. The task says "done" but the branch is incomplete. Read the task's review verdict (/agent-inspect <task-id>) to see why review passed. - If the agent has multiple parallel projects, run this skill per-project. The cross-project version is
/agent-sweep-all(coming as a separate skill if your operator workflow needs it).
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

