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.

Install it, pinned
mdr add wpfleger96/ai-agent-rules/worktree-cleanup@v1.1.0

Pins 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

The exact contents, by fingerprint
mdr add wpfleger96/ai-agent-rules/worktree-cleanup@sha256:d12c1ae3c7f636ec

The 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.

Badge

mdr badge

[![mdr](https://markdownregistry.com/badge/art_zsrrzb3scir4bw2g.svg)](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.

versioncommittedcommitsizeaudit
v1.1.0 latest2026-07-04 cac8f2d 15,028 BA view · diff
v1.1.02026-06-30 d937493 14,929 BA view · diff
v1.0.12026-06-27 4f79b6e 12,068 BA view · diff
v1.0.12026-06-13 149c6f4 12,135 BA view · diff
v1.0.02026-06-09 c0ea4df 12,134 BA view

Audit of the latest version

A  17 of 17 checks passed. Fixed automatic checks with no AI involved, so the same checks give the same answer every run.
  • 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

GitHub

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

AGENTS.md AGENTS.md file
wpfleger96/ai-agent-rules · AGENTS.md
git:20260929.8dc0b41 · audit A · 10 stars
AGENTS.md@src/ai_rules/config AGENTS.md file
wpfleger96/ai-agent-rules · src/ai_rules/config/AGENTS.md
git:20260930.c325fca · audit A · 10 stars
AGENTS.md@src/ai_rules/config/amp AGENTS.md file
wpfleger96/ai-agent-rules · src/ai_rules/config/amp/AGENTS.md
git:20260704.cac8f2d · audit B · 10 stars
CLAUDE.md@src/ai_rules/config/claude CLAUDE.md file
wpfleger96/ai-agent-rules · src/ai_rules/config/claude/CLAUDE.md
git:20260704.cac8f2d · audit B · 10 stars
AGENTS.md@src/ai_rules/config/codex AGENTS.md file
wpfleger96/ai-agent-rules · src/ai_rules/config/codex/AGENTS.md
git:20260704.cac8f2d · audit B · 10 stars
writing-as-will SKILL.md skill
wpfleger96/ai-agent-rules · src/ai_rules/config/profiles/skills/writing-as-will/SKILL.md · Drafts or edits prose written as Will for human readers, in Will's voice. Use when writing Slack or Buzz messages for…
v1.0.0 · audit A · 10 stars
agents-md SKILL.md skill
wpfleger96/ai-agent-rules · src/ai_rules/config/skills/agents-md/SKILL.md · Create or update AGENTS.md with repo-specific patterns, conventions, commands, and gotchas for LLM coding agents. Use…
v1.0.1 · audit A · 10 stars
code-reviewer SKILL.md skill
wpfleger96/ai-agent-rules · src/ai_rules/config/skills/code-reviewer/SKILL.md · Performs thorough code review on local changes or PRs. Use this skill proactively after implementing code changes to…
v1.2.0 · audit A · 10 stars
continue-crash SKILL.md skill
wpfleger96/ai-agent-rules · src/ai_rules/config/skills/continue-crash/SKILL.md · Continues after a session crash while working on a task
v1.0.0 · audit A · 10 stars
crossfire SKILL.md skill
wpfleger96/ai-agent-rules · src/ai_rules/config/skills/crossfire/SKILL.md · Get multi-model perspectives (Codex + Gemini) on any work product. Use at any development stage — planning, design…
v1.0.0 · audit B · 10 stars
dev-docs SKILL.md skill
wpfleger96/ai-agent-rules · src/ai_rules/config/skills/dev-docs/SKILL.md · Creates or updates PLAN.md based on session - auto-detects create vs update mode
v1.0.1 · audit A · 10 stars
doc-writer SKILL.md skill
wpfleger96/ai-agent-rules · src/ai_rules/config/skills/doc-writer/SKILL.md · Write, update, or review documentation (README, ARCHITECTURE.md, API docs, guides). Use after implementing features to…
v1.0.1 · audit A · 10 stars

Every file in wpfleger96/ai-agent-rules

Other files named worktree-cleanup

worktree-cleanup SKILL.md skill
figelwump/toastty · examples/skills/worktree-cleanup/SKILL.md · Use when the user asks which pull requests or task worktrees are ready to merge, asks to merge specific ready PRs, or…
git:20261010.76cfc50 · audit A · 14 stars

Browse by kind, by grade A, or by owner.