worktree-cleanup SKILL.md skillA
worktree-cleanup from wpfleger96/ai-agent-rules is an agent skill: a SKILL.md folder an AI agent loads when a task calls for it.
mdr add wpfleger96/ai-agent-rules/worktree-cleanup@v1.1.0Pins v1.1.0 in mdr.lock. Pin the fingerprint instead.
- Audit grade
- A, 17 of 17 checks passed
- Kind
- SKILL.md skill
- Repository
- wpfleger96/ai-agent-rules
- Path
src/ai_rules/config/skills/worktree-cleanup/SKILL.md- Versions recorded
- 5
- Latest version
- v1.1.0, committed Jul 4, 2026
- First version recorded
- Jun 9, 2026
- Size
- 15,028 bytes
- Repository stars
- 10
- License
- MIT
Clean up stale git worktrees to reclaim disk space. Detects merged branches, deleted remotes, and abandoned worktrees. Rust-aware (reports target/ sizes separately). Use for worktree cleanup or disk reclamation.
Collected from public GitHub. Every version is saved exactly as it was and never changes. Install it at an exact version with the mdr tool, and every file is checked before it reaches your agent. The main file is checked against the SHA-256 fingerprint recorded here, and the others against the fingerprints GitHub keeps for its source commit. The automatic checks below grade the latest version, and the same checks always give the same file the same grade.
What the file says
## Context
- Arguments: `${ARGS}`
- Main repo root: !`sh -c 'COMMON=$(git rev-parse --path-format=absolute --git-common-dir 2>/dev/null) && dirname "$COMMON" || echo "NOT_IN_GIT_REPO"'`
- Default branch: !`sh -c 'ref=$(git symbolic-ref refs/remotes/origin/HEAD 2>/dev/null | sed "s@^refs/remotes/origin/@@"); echo "${ref:-main}"'`
- Worktree count: !`git worktree list 2>/dev/null | wc -l | xargs`
- Platform: !`uname -s`
**Shell variables** do not persist across Bash tool calls. Re-derive from Context when needed.
# Worktree Cleanup
You analyze git worktrees in the current repo, classify them by safety tier, report disk usage, and interactively clean up stale worktrees. Especially useful for large Rust repos where each worktree has its own `target/` directory (often 1-15 GB).
## Argument Parsing
| Args | Behavior |
|------|----------|
| Empty | Analyze worktrees in the current repo |
| `--dry-run` | Report only, no removals |
If "Main repo root" is "NOT_IN_GIT_REPO" — stop and inform the user.
## Phase 0: Pre-flight
1. Validate the repo context from "Main repo root"
2. Parse `${ARGS}` for `--dry-run` flag
3. Fetch and prune remote tracking refs:
```bash
…Read the whole file at its exact version.
How to install
mdr add wpfleger96/ai-agent-rules/worktree-cleanup@sha256:d12c1ae3c7f636ecThe line at the top of this page pins the label v1.1.0, which is what most people want. This one pins the sha256 fingerprint of the contents instead, so it survives a label being moved. Either way the exact version is written to mdr.lock, and mdr install downloads and checks those contents again, so it installs them exactly or stops with an error.
[](https://markdownregistry.com/a/art_zsrrzb3scir4bw2g)
3 badge image fetches in 30 days. What the badge shows.
Versions
The registry has recorded 5 versions of this file, between Jun 9, 2026 and Jul 4, 2026, about one every 6 days.
| version | committed | commit | size | audit | |
|---|---|---|---|---|---|
| v1.1.0 latest | 2026-07-04 | cac8f2d | 15,028 B | A | view · diff |
| v1.1.0 | 2026-06-30 | d937493 | 14,929 B | A | view · diff |
| v1.0.1 | 2026-06-27 | 4f79b6e | 12,068 B | A | view · diff |
| v1.0.1 | 2026-06-13 | 149c6f4 | 12,135 B | A | view · diff |
| v1.0.0 | 2026-06-09 | c0ea4df | 12,134 B | A | view |
Audit of the latest version
- pass: Frontmatter block present
- pass: Frontmatter declares a name
- pass: Frontmatter declares a description
- pass: Size between 200 bytes and 200 KB (15028 bytes)
- pass: No zero-width or bidi control characters
- pass: No instruction hidden inside an HTML comment
- pass: No link to an exfiltration or paste host
- pass: No credential-shaped string
- pass: No instruction to send local credentials anywhere
- pass: No text hidden with inline styles
- pass: No prompt-injection phrasing
- pass: No curl or wget piped into a shell
- pass: No recursive delete of root, home or parent
- pass: No instruction to read or print local credentials
- pass: No base64 blob over 200 characters
- pass: No link to a raw IP address
- pass: No script tag
Source
wpfleger96/ai-agent-rules · 10 stars · license MIT · pushed 2026-10-22 · branch main
API
GET https://markdownregistry.com/api/v1/artifacts/art_zsrrzb3scir4bw2g GET https://markdownregistry.com/api/v1/resolve?ref=wpfleger96/ai-agent-rules/worktree-cleanup GET https://markdownregistry.com/api/v1/blob/d12c1ae3c7f636ec9886de64c3bac47b16bdaa7ab57dc78c0e6d8c8114092a42
Your AI assistant does the legwork. You hear about the deals worth your word. Hand yours the standing instructions at modelranch.com and it joins the network that reads files like this one.
Guides: the SKILL.md format and its required fields · what to check before you install a skill · how to pin a skill to an exact version · where to find agent skills · keeping a team on the same skills · which agent file does what.
More from wpfleger96/ai-agent-rules
Every file in wpfleger96/ai-agent-rules