agentleFS
LaansDoleLaansDole/my-hermes-skills/skills/productivity/auditing-worktrees/SKILL.md

auditing-worktrees

Skill3 starsChanged 10 days agoMITView on GitHub

Use when asked for the status of worktrees, which worktree branches are ready to review, pushed, merged or shipped, which worktrees are stale, idle or purgeable, or for a periodic worktree audit across one or several repos

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 0 are distinctive, and 1 is very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈0

    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. Very specific:

    No repos → cwd if it is a git repo, else every git repo directly under cwd (e.g.

    line 22

≈ “Common” is an estimate: at least 1 in 5 of the 364,980 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

Auditing Worktrees

Overview

Read-only report that sorts every linked worktree into Ready to review, Shipped, Local only (recently active) and Purgeable (idle). The script does the classification. You don't redo it by hand. The only state it changes is git fetch --prune, which updates remote-tracking refs. That is expected, so leave the fetch on unless the user forbids network or ref updates (--no-fetch).

Usage

~/.agents/skills/auditing-worktrees/audit.py [repo...] [--days 7] [--stale-days 21] [--no-fetch]

No repos → cwd if it is a git repo, else every git repo directly under cwd (e.g. ~/Projects/acme → api, web, e2e, portal). User says "last N days" → --days N. "idle N weeks" → --stale-days 7N.

Buckets

BucketRule
ShippedMerged PR (gh) or ancestor of origin/dev/origin/main or every patch already upstream (cherry-pick/rebase) or squash-equivalent upstream
Ready to reviewNot shipped, branch exists on origin
Local onlyNot shipped, never pushed (incl. detached HEAD, branches with no commits)
PurgeableLast active ≥ --stale-days, any of the above. "Safe to remove" = no uncommitted files

Ready/Shipped/Local only list worktrees active within --days. Worktrees idle between the two thresholds are counted in the TL;DR but not listed.

Last active = newest of worktree creation, that worktree's HEAD reflog, and mtimes of uncommitted files.

Report Shape

Pass the script's output through, in this order:

  1. The script's TL;DR line, rewritten as 2–3 plain-English sentences.
  2. One next step, the most urgent item from the Attention list (unpushed commits > closed-unmerged PR > shipped-but-dirty > no PR).
  3. The tables and the Attention list, unchanged.

Purging

The audit only reports; it removes nothing. Remove worktrees only after the user asks:

  • Shipped rows → git -C <repo> worktree remove <path>; copy out any untracked files you want to keep first.
  • Idle, unshipped rows that are safe to remove → git -C <repo> worktree remove <path>. The branch ref survives, so no commits are lost.
  • Rows with uncommitted files → show the user what is dirty (git -C <path> status). Never use --force.

Footguns (why the script exists)

Wrong shortcutWhy it's wrong
Index or directory mtime as "last active"git status rewrites the index, so any audit makes every worktree look active today
Ancestor of dev ⇒ shippedA branch created off dev with no commits is an ancestor. Check that it has work first
Only merge-base --is-ancestorMisses cherry-picked and squash-merged branches
Deleted upstream ⇒ not ready/shippedMerged PRs often delete the branch. PR state and patch-ids still prove it shipped
git cherry alone for squashA squash is one combined patch-id, so per-commit cherry shows +. The script compares a squashed virtual commit

Without gh, PR columns show —, and Shipped falls back to git evidence only.

Verifying Changes

audit.py --self-test

Builds a fixture covering merged, squash-merged, cherry-picked, pushed-unmerged, never-pushed, empty-branch and 30-day-stale worktrees (the stale one gets an index rewrite), then checks the buckets and the report.

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.