git-clean-worktrees
Remove already-preserved linked worktrees and local branches from one repository, only through an explicit plan the user approves by digest.
Skill by lucaspimentel
Install
Works with Claude Code, Claude apps, Codex, Cursor, Gemini CLI, GitHub Copilot, VS Code, OpenCode, Goose, Windsurf. Read the repository before you give any tool access to your data.
npx agentmarket install skill/lucaspimentel-git-clean-worktrees
Asks which of your tools to add it to (Claude Code, Codex, Cursor, VS Code, Windsurf, Gemini CLI, Claude Desktop) and shows the change first. See https://agentmart.dev/cli.
Get the weekly diff
The weekly diff: one email a week with new agent tools, notable updates and grade changes, plus security alerts for tools you follow. Double opt-in, one-click unsubscribe.
About
Reviews
Write a reviewNo reviews yet. Installed it? Reviews come from verified installers only. How reviews work
Permissions
What this skill can do and what it asks for, from its SKILL.md. Checked Oct 25, 2026.
- Tools
- No tools found
- Secrets
- None asked for
- Install scripts
- None found
- Runs as
- Python package
Network hosts it talks to 1
codeload.github.com· found in install command
Files it touches
~/.claude/skills/git-clean-worktrees
What's inside
- Skill name
git-clean-worktrees- Description
- Remove already-preserved linked worktrees and local branches from one repository, only through an explicit plan the user approves by digest.
- License
- MIT
- Instructions
- 63 lines in SKILL.md · view on GitHub
Before installing
- Ships executable scripts
Files (3)
- SKILL.md
- safety.md · references/
- git_clean_worktrees.py · scripts/
SKILL.md (first lines)
# git-clean-worktrees Inspect one repository, propose an exact cleanup plan, and remove only the worktrees and local branches the user approves. The helper proves preservation for every exact branch tip before anything is deleted, and it never forces, prunes, unlocks, or touches a remote. ## Before starting 1. **Pick a Python 3.11+ interpreter.** Try `python3`, then `python`, then `py -3` on Windows. Check `--version` and stop if it is older than 3.11. 2. **Resolve the helper path** as `scripts/git_clean_worktrees.py` relative to this skill's own directory. Use that absolute path for every phase; do not resolve it against the current working directory. 3. **Confirm access.** The helper needs filesystem access to the repository and its worktrees, plus network access for `git fetch` and, when needed, the `gh api` merged-PR lookup. In pi, if the sandbox cannot reach the repository or the network, run the commands with the `host_bash` tool instead of the sandboxed `bash` tool. Keep Git, `gh`, and Python in the same environment; the helper does not translate paths between WSL and native Windows. 4. **Keep artifacts outside removal targets.** Write the snapshot, plan, and result JSON somewhere outside every worktree that may be removed, for example the main checkout's `.git` directory or a temporary directory. 5. Run the helper with `--help` if you need the exact flags for the current version. ## Phase 1: inspect ```console python3 <skill-dir>/scripts/git_clean_worktrees.py inspect [<repository-path>] --output <snapshot.json> ``` The optional repository path defaults to the current directory. It must be inside the main (non-bare) working tree; a linked worktree is rejected. Inspection removes nothing, but it does fetch the remote's actual default branch into its origin remote-tracking ref, so it writes Git objects, as documented in `references/safety.md`. The snapshot lists every registered worktree and every local branch with an eligibility decision and an explicit reason. Read it, then decide which targets to propose. - Worktree ids are the registered absolute paths. - Branch ids are the short branch names (`topic/x`, not `refs/heads/topic/x`). - `--allow-ignored` is valid only together with removing that same worktree, and only when the snapshot shows the worktree needs the ignored-file override. ## Phase 2: plan ```console python3 <skill-dir>/scripts/git_clean_worktrees.py plan --snapshot <snapshot.json> \ [--remove-worktree <id> ...] [--delete-branch <id> ...] [--allow-ignored <id> ...] \ --output <plan.json> ``` Worktree removal and branch deletion are separate selections. Removing a worktree never authorizes deleting its branch; select `--delete-branch` explicitly. Show the user the complete plan and its digest, then wait for explicit approval before continuing. If the user changes any target or ignored-file override, rebuild the plan: the digest changes and the old approval no longer applies. ## Phase 3: apply ```console python3 <skill-dir>/scripts/git_clean_worktrees.py apply --plan <plan.json> --approved-digest <sha256> ``` Apply revalidates the repository, refreshes the default branch again, rechecks every lock, file protection, fingerprint, and preservation proof, and skips any target that changed or became unsafe. It continues with the other independent approved actions. Exit codes: `0` every approved action succeeded, `2` some target was skipped or failed, `1` the run aborted before any action. ## Report Summarize the result for the user: removed worktrees, deleted branches with their recorded SHAs, and every skipped or failed target with the helper's reason. Note that deleting a ref removes its reflog, so a recorded SHA is only recoverable while its objects remain. ## Non-negotiables - Never select or apply a target that is not in the approved plan, and never widen the approved digest. - Never use `--force`, `git worktree unlock`, `git worktree prune`, or hand-rolled deletion. - Never switch GitHub accounts. If `gh` authentication cannot see the origin repository, leave those targets retained. - Never delete a remote branch. Detailed safety and concurrency contracts, limitations, and recovery notes live in [references/safety.md](references/safety.md).
From lucaspimentel/agent-skills, MIT.
More from lucaspimentel/agent-skills
- 0.565score
atlassian
lucaspimentel
Use when working with Jira, Confluence, or other Atlassian products via the Atlassian CLI (acli) or the Atlassian MCP server: authentication, searching with…
SkillAFreshness: AClaude Code +9 - 0.565score
git-commit
lucaspimentel
Commit pending changes to git, optionally pushing after.
SkillAFreshness: AClaude Code +9 - 0.561score
grill-me
lucaspimentel
A relentless interview about a design that continues until no ambiguities remain.
SkillAFreshness: AClaude Code +9 - 0.561score
plan
lucaspimentel
Produce a self-contained implementation plan as a handoff prompt.
SkillAFreshness: AClaude Code +9 - 0.561score
address-pr-comments
lucaspimentel
Interactively walk through and address PR review comments one at a time, asking the user what to do for each, committing after each code change, and…
SkillAFreshness: AClaude Code +9 - 0.561score
ship
lucaspimentel
Run one or more release actions: version, changelog, docs, commit, tag, push, watch, release.
SkillAFreshness: AClaude Code +9 - 0.561score
add-todo
lucaspimentel
Create or append tasks to TODO.md in the current working directory.
SkillAFreshness: AClaude Code +9 - 0.561score
simplify
lucaspimentel
Review recently changed code for simplification and apply clarity improvements.
SkillAFreshness: AClaude Code +9 - 0.561score
chezmoi-diff
lucaspimentel
Help resolve differences between chezmoi-managed dotfiles and local files, including which direction changes should flow and what the chezmoi file naming…
SkillAFreshness: AClaude Code +9 - 0.558score
update-docs
lucaspimentel
Update project documentation based on recent changes and current codebase state.
SkillAFreshness: AClaude Code +9 - 0.558score
update-github-actions
lucaspimentel
Update outdated GitHub Actions in workflow files and pin them to commit hashes for supply-chain security.
SkillAFreshness: AClaude Code +9 - 0.558score
update-pr-description
lucaspimentel
Update the PR's title and description to accurately reflect the changes.
SkillAFreshness: AClaude Code +9
Signals
- Stars
- 0
- Forks
- 0
- Open issues
- 0
- Last commit (this folder)
- Oct 23, 2026 (5 days ago)
From GitHub (fetched Oct 24, 2026).
Details
- License
- MIT
- Repository
- github.com/lucaspimentel/agent-skills
- First seen
- Oct 24, 2026
- Last checked
- Oct 24, 2026
- Source
- GitHubgithub-graphql
More from lucaspimentel
- 0.565score
git-commit
lucaspimentel
Commit pending changes to git, optionally pushing after.
SkillAFreshness: AClaude Code +9 - 0.565score
atlassian
lucaspimentel
Use when working with Jira, Confluence, or other Atlassian products via the Atlassian CLI (acli) or the Atlassian MCP server: authentication, searching with…
SkillAFreshness: AClaude Code +9 - 0.561score
plan
lucaspimentel
Produce a self-contained implementation plan as a handoff prompt.
SkillAFreshness: AClaude Code +9 - 0.561score
chezmoi-diff
lucaspimentel
Help resolve differences between chezmoi-managed dotfiles and local files, including which direction changes should flow and what the chezmoi file naming…
SkillAFreshness: AClaude Code +9 - 0.561score
add-todo
lucaspimentel
Create or append tasks to TODO.md in the current working directory.
SkillAFreshness: AClaude Code +9 - 0.561score
ship
lucaspimentel
Run one or more release actions: version, changelog, docs, commit, tag, push, watch, release.
SkillAFreshness: AClaude Code +9
Cite this page
git-clean-worktrees skill. Agent Mart. https://agentmart.dev/skills/lucaspimentel-git-clean-worktrees (last updated 2026-10-24)