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
In this repository20 other files it gives its agents.
- AGENTS.mdAGENTS.md
- covidence-full-text-reviewSkill
- covidence-full-text-retrievalSkill
- covidence-screeningSkill
- impeccableSkill
- ilearning-autoadvanceSkill
- oh-my-piSkill
- camofox-browserSkill
- demo-runbookSkill
- hermes-deepseek-cacheSkill
- i-have-adhdSkill
- memory-uiSkill
- multi-repo-pr-review-merge-roundSkill
- oh-my-ghosttySkill
- tldrSkill
- writing-reportsSkill
- sci-hub-accessSkill
- slack-mention-watchSkill
- slack-scanSkill
- superpowers-using-superpowersSkill
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
- Very specific: line 22
No repos → cwd if it is a git repo, else every git repo directly under cwd (e.g.
≈ “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.
Files
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
| Bucket | Rule |
| Shipped | Merged PR (gh) or ancestor of origin/dev/origin/main or every patch already upstream (cherry-pick/rebase) or squash-equivalent upstream |
| Ready to review | Not shipped, branch exists on origin |
| Local only | Not shipped, never pushed (incl. detached HEAD, branches with no commits) |
| Purgeable | Last 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:
- The script's TL;DR line, rewritten as 2–3 plain-English sentences.
- One next step, the most urgent item from the Attention list (unpushed commits > closed-unmerged PR > shipped-but-dirty > no PR).
- 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 shortcut | Why 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 ⇒ shipped | A branch created off dev with no commits is an ancestor. Check that it has work first |
Only merge-base --is-ancestor | Misses cherry-picked and squash-merged branches |
| Deleted upstream ⇒ not ready/shipped | Merged PRs often delete the branch. PR state and patch-ids still prove it shipped |
git cherry alone for squash | A 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-testBuilds 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.
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.

