agentleFS
Ormus-SolutionsOrmus-Solutions/ormus-agent-ops/skills/agent-sweep-orphans/SKILL.md

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

  • Other versions1 project uses a version of this.

    Word for word · 1

    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.

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
  1. Distinctive:

    After a few months: dozens of orphan branches, each with potentially valuable work.

    line 18
  2. Distinctive:

    After the user has approved/declined each one, batch the actions:

    line 86
  3. Distinctive:

    Only execute after explicit user confirmation.

    line 98
  4. Very specific:

    If the agent has multiple parallel projects, run this skill per-project.

    line 154

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

/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

VarPurpose
AGENT_API_URLBase URL of the agent's HTTP API
AGENT_API_TOKENBearer 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
done

Phase 2: Classify each orphan

ClassTestDisposition
mergeablegit merge-tree main feature/X produces no conflicts AND tests passmerge — fast-forward or squash-merge
conflictingmerge-tree produces conflictsresolve-and-merge OR requeue to redo against current main
supersededanother task already implemented this functionality (search recent commits on main)dead-letter — close the branch
stalebranch is >30 days old AND no longer relevantdead-letter
wrong-targetbranch was based on a different default branch (e.g. develop not main)rebase-and-merge OR requeue
partialbranch has commits but task report shows incomplete workrequeue 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 main

Or 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 superseded orphans, the killer signal is when git log --grep=<feature keyword> on main shows recent commits — someone else already did this work.
  • The partial class 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).

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.