Getting it into your agent
One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.
npx agentmods add skills/stuartshields/claude-setup/clean-worktreesnpx skills add stuartshields/claude-setup --skill clean-worktreesgit clone --depth 1 https://github.com/stuartshields/claude-setupWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/skills/stuartshields/claude-setup/clean-worktrees)<a href="https://agentmods.dev/skills/stuartshields/claude-setup/clean-worktrees"><img src="https://agentmods.dev/badge/skills/stuartshields/claude-setup/clean-worktrees.svg" alt="Measured on agentmods" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5 | $0.00034 | $0.00608 |
| Opus 5 | $0.00017 | $0.00304 |
| Sonnet 5 | $0.00007 | $0.00122 |
| Haiku 4.5 | $0.00003 | $0.00061 |
Grade B, and why
clean-worktrees scanned grade B with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 4d ago.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Reads agent configuration directoriesmediumAgent snooping
.claude/, .codex/, .gemini/ hold keys, settings and other credentials a mod has no legitimate need for.
WORKTREE_DIRS=$(find .claude/worktrees -maxdepth 1 -type d -name 'agent-*' 2>/dev/null | wc -l | tr -d ' ') How it starts
The opening of the file, as written. The whole thing — 73 lines — stays where its author put it; the contents beside it link to each section on GitHub.
Clean Stale Agent Worktrees
Remove worktree directories and orphaned worktree-agent-* branches left behind by agent isolation mode.
Based on community patterns from claude-codex-settings and claude-code-ultimate-guide, adapted for Claude Code's agent worktree pattern.
Related upstream issue: anthropics/claude-code#26725
Process
1. Inventory
Run these commands and report counts:
# Count worktree directories
WORKTREE_DIRS=$(find .claude/worktrees -maxdepth 1 -type d -name 'agent-*' 2>/dev/null | wc -l | tr -d ' ')
# Count git worktree registrations (excluding main)
GIT_WORKTREES=$(git worktree list 2>/dev/null | grep 'worktree-agent-' | wc -l | tr -d ' ')
# Count orphaned branches
ORPHANED_BRANCHES=$(git branch --list 'worktree-agent-*' 2>/dev/null | wc -l | tr -d ' ')
Report:
## Worktree Inventory
- Worktree directories: {WORKTREE_DIRS}
- Git worktree registrations: {GIT_WORKTREES}
- Orphaned branches: {ORPHANED_BRANCHES}
If all counts are 0: report "No stale worktrees found." and stop.
2. Dry Run Check
If $ARGUMENTS contains --dry-run: report the inventory and stop. Do not delete anything.
3. Clean Up
Run in this order:
# Prune stale git worktree references
git worktree prune
# Remove registered worktrees that match agent pattern
git worktree list | grep 'worktree-agent-' | awk '{print $1}' | while read wt; do
git worktree remove --force "$wt"
done
# Delete orphaned branches (allowed by block-git-commit.sh for worktree-agent-* only)
git branch --list 'worktree-agent-*' | xargs git branch -D
4. Report
## Cleanup Complete
- Removed {N} worktree directories
- Deleted {N} orphaned branches
- Pruned git worktree references
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- 4d ago First seen · 73 lines · 34 tokens per session scan B a9b09ec37532
clean-worktrees is a skill published in the GitHub repository stuartshields/claude-setup (2 stars, last pushed 3mo ago), licensed MIT. It adds 34 tokens to every session and 608 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it B with 1 finding (reads agent configuration directories). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.
Other skills, from other repositories
memory
Claude Mind - Search and manage Claude's persistent memory stored in a single portable .mv2 file.
bearing-diagnosis
Complete bearing fault diagnostic workflow using vibration analysis and the predictive-maintenance-mcp server. Use this skill when the user says "diagnose bearing", "bearing fault", "bearing check", "detect bearing damage", "bearing vibration analysis", "inner race fault", "outer race fault", "ball defect", "cage…
prognostics
Prognostic assessment workflow: trend analysis, degradation onset detection, and Remaining Useful Life (RUL) estimation using the predictive-maintenance-mcp server. Use this skill when the user says "trend analysis", "degradation trend", "RUL", "remaining useful life", "prognosis", "prognostics", "failure prediction"…
signal-management
Signal loading, generation, and cache management using the predictive-maintenance-mcp server. Use this skill when the user says "load signal", "import signal", "list signals", "available signals", "generate test signal", "create test data", "synthetic signal", "clear cache", "signal info", "what signals are loaded"…
anomaly-detection
ML-based anomaly detection and model training for vibration signals using the predictive-maintenance-mcp server. Use this skill when the user says "anomaly detection", "train model", "detect anomalies", "outlier detection", "normal vs abnormal", "machine learning", "one-class SVM", "LOF", "local outlier factor"…
gear-diagnosis
Gear fault diagnosis workflow using vibration analysis via the predictive-maintenance-mcp server. Use this skill when the user says "gear fault", "gear diagnosis", "gear mesh", "gearbox analysis", "gear vibration", "tooth damage", "gear defect", "diagnose gear", "gear mesh frequency", "sideband analysis", or wants to…