agents/skills/clean-worktrees/SKILL.md
Audit and clean Codex-created Git worktrees and leftover worktree directories safely. Use when disk usage appears inflated by ~/.codex/worktrees, Git worktree metadata, detached Codex worktrees, stale branch worktrees, or when the user asks to map worktrees to pull requests before deletion.
npx skillsauth add jxnl/dots clean-worktreesInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use this skill when ~/.codex/worktrees or repository .git/worktrees directories are large, or when the user asks which worktrees are safe to remove.
Measure disk first:
df -h / /System/Volumes/Data
du -sh ~/.codex ~/.codex/worktrees 2>/dev/null
Audit before cleanup. Prefer the bundled script:
python3 ~/.codex/skills/clean-worktrees/scripts/clean_worktrees.py \
--repo ~/path/to/repo \
--root ~/.codex/worktrees \
--audit-dir ~/.codex/worktree-cleanup-audit \
--min-age-hours 24
Interpret risk:
Apply cleanup only after the audit result is clear:
python3 ~/.codex/skills/clean-worktrees/scripts/clean_worktrees.py \
--repo ~/path/to/repo \
--root ~/.codex/worktrees \
--audit-dir ~/.codex/worktree-cleanup-audit \
--apply \
--include-dirty \
--min-age-hours 24
Prune repository metadata after removals:
git -C ~/path/to/repo worktree prune
Verify:
git -C ~/path/to/repo worktree list --porcelain
du -sh ~/.codex ~/.codex/worktrees 2>/dev/null
df -h / /System/Volumes/Data
For named branch worktrees, map branches to PRs before deletion:
gh -C <repo> pr list --head <branch> --json number,title,url,state,headRefName,baseRefName
Detached worktrees do not map cleanly to PRs by branch. Treat them as not PR-backed unless the worktree has a named branch or a remote branch can be inferred from local metadata.
rm or rm -rf.~/.codex/worktree-cleanup-audit.git status --porcelaingit diff --binary24 hours, to avoid deleting active sessions.worktree remove --force for registered worktrees.~/.Trash/codex/<timestamp>/ instead of deleting them directly.tools
Use only when the user explicitly asks to stage, commit, push, and open a GitHub pull request in one flow using the GitHub CLI (`gh`).
development
Use when Codex needs to write, rewrite, critique, or reply on Twitter/X in Jason Liu's personal voice. Trigger for requests like "tweet like me", "write this in my style", "make this sound like Jason", "draft a reply", or when Jason asks for Twitter copy about Codex, product building, feedback, launches, quote-tweets, or operator/value takes.
development
Build or refine single-file information-first HTML artifacts, especially index.html or text.html pages, with strong information hierarchy, restrained styling, accessible semantics, and minimal AI-generated frontend tells. Use when creating static HTML reports, research pages, explainers, briefs, dashboards, note indexes, or simple front ends whose goal is comprehension rather than marketing conversion.
development
Codex-specific, session-driven self-improvement for Codex behavior and project instructions. Use when the user asks to inspect past Codex sessions, run a "dream" pass over prior interactions, mine repeated user corrections/preferences, improve or draft skills, update repo/project `AGENTS.md` guidance, or propose durable edits to global `~/.codex/AGENTS.md`.