worktree-cleaner
यह क्या करती है
यह स्किल किसी repository के git worktrees की सूची बनाती है, दिखाती है कि हर एक में क्या है, और सिर्फ़ वही हटाती है जिसकी आप मंज़ूरी दें। यह उन डेवलपर्स के लिए है जिनके प्रोजेक्ट में समानांतर कामों से बहुत सारे worktrees जमा हो गए हैं।
कब इस्तेमाल करें
- ✓जब git worktree list लंबी हो गई हो और आप उसे साफ़ करना चाहते हैं।
- ✓जब आपके एजेंट या किसी समानांतर workflow ने हर काम के लिए worktree बनाया और कोई हटाया नहीं गया।
- ✓जब आप जानना चाहते हैं कि कौन-से worktrees merge हो चुके हैं, पुराने हैं, या अभी भी बिना push काम रखते हैं।
Skill का लिंक
https://github.com/davila7/claude-code-templates/blob/main/cli-tool/components/skills/git/worktree-cleaner/SKILL.mdइसे कॉपी करके अपने AI (Claude, ChatGPT या Cursor) में पेस्ट करें और निर्देशों का पालन करने को कहें।
कैसे इस्तेमाल करें
सबसे आसान तरीका: मैसेज कॉपी करके अपने AI में पेस्ट करें। वह skill पढ़कर निर्देशों का पालन करेगा।
पेस्ट करने के लिए तैयार मैसेज
Claude Code, Codex या Cursor के लिए: प्रोजेक्ट फ़ोल्डर में चलाएँ और skill इंस्टॉल हो जाएगी।
SKILL.md डाउनलोड करें और अपने एजेंट के skills फ़ोल्डर में रखें।
AI से क्या माँगें: उदाहरण
“मेरे repo में दर्जनों बचे हुए worktrees हैं। दिखाइए कि कौन-से हटाना सुरक्षित है, और कुछ भी हटाने से पहले पूछिए।”
हर हफ़्ते 5 नई skills, 1 मिनट में पढ़ें।
यह कैसे काम करती है
एजेंट हर worktree के लिए सबूत इकट्ठा करता है, जैसे merge स्थिति, pull request की स्थिति और बिना commit बदलाव, फिर बताता है क्या हटाना चाहिए, और हर कदम की मंज़ूरी के बाद ही हटाता है।
तकनीकी सामग्री (मूल SKILL.md)
लेखक का मूल टेक्स्ट, अंग्रेज़ी में, सीधे GitHub से।
Worktree Cleaner
Agents and parallel workflows create one git worktree per task, and nobody removes them. This skill finds them, shows the user what each one holds, and removes only what the user approves, checking the result after every step.
The user decides. You gather evidence, recommend, and execute exactly what was approved. Nothing is removed in bulk without the user seeing the list first.
Hard rules
- Ask before every destructive command.
git worktree remove,git worktree prune,git worktree unlockandgit branch -d/-Deach need the user's approval for that worktree or that named group. Approval of one group does not carry to the next. - Never
--forceon work that would be lost. If a worktree has uncommitted changes, untracked files, or commits that exist nowhere else, show the exact files and commits and ask a separate, explicit question ("remove it and lose these changes?"). A general "yes, clean everything" is not that confirmation. - Never touch the main worktree, the worktree you are running in, or a worktree with live processes inside it (another Claude Code session, an editor, a dev server). Report them and move on.
- Never delete a remote branch (
git push --delete,git push origin :branch, API calls). Remote branches are out of scope; mention them in the report if they look stale. - Deleting the local branch is a separate question, asked after the worktree is gone. Removing a worktree never deletes its branch.
- Re-check right before acting. State changes while you talk to the user: re-run the inventory for that one path immediately before removing it, and stop if the verdict got worse.
- Verify after every action and report what you checked. If a check fails, stop and tell the user; do not retry with stronger flags.
Step 1: Inventory (read-only)
Run the bundled script from anywhere inside the repository. It changes nothing; --fetch only runs git fetch --prune so the merged/pushed checks use fresh remote refs. Ask before fetching if the user is offline or on a metered connection; otherwise fetch.
bash "${CLAUDE_SKILL_DIR}/scripts/worktree-inventory.sh" --fetch
If CLAUDE_SKILL_DIR is not set, the script is at .claude/skills/worktree-cleaner/scripts/worktree-inventory.sh (project install) or ~/.claude/skills/worktree-cleaner/scripts/worktree-inventory.sh (user install).
Flags: --path <worktree> reports a single worktree (use it for the re-check in rule 6; it exits 3 with an error when no worktree matches, so a typo never looks like an empty result), --no-gh skips the GitHub CLI PR lookup, --repo <dir> targets another repository. The fetch never prompts for credentials; if it cannot authenticate it reports fetch: FAILED.
It prints a header (default_branch, whether the fetch worked, whether gh and git merge-tree were available) and then one block per worktree. Key fields:
| Field | Meaning |
|---|---|
modified_tracked, untracked_files, changed_paths |
Uncommitted work. git worktree remove refuses these without --force. |
ignored_local_files |
Gitignored files and directories that are not regenerable artifacts (dependencies, build output and caches such as node_modules/, dist/, .venv/ are left out): .env, .dev.vars, local settings, keys, a whole secrets/ directory. git worktree remove deletes ignored files without warning, so these must be shown to the user. |
commits_not_on_any_remote |
Commits reachable from this worktree's HEAD and from no remote-tracking ref. On a branch, removing the worktree keeps them on the branch, but deleting the branch afterwards loses them. On a detached worktree there is no branch: removing it makes them unreachable (the script marks it AT_RISK). |
git_error |
git could not read the worktree (broken .git file, safe.directory ownership, permissions). Nothing else in the block is reliable. |
head_merged_into_default |
HEAD is an ancestor of the default branch (merge or fast-forward). |
content_already_in_default |
Merging HEAD into the default branch would change nothing (git merge-tree). This catches squash and rebase merges, where the commits differ but the content landed. |
pr |
#N STATE url from gh, none, or unknown when gh is not available. |
processes_inside |
Running processes whose working directory is inside the worktree. |
claude_session_hours_ago |
Hours since a Claude Code |
अक्सर पूछे जाने वाले सवाल
क्या यह मेरा काम मिटा देगी?
स्किल हर विनाशकारी कमांड से पहले मंज़ूरी माँगती है, और बिना commit या बिना सहेजे commits वाली किसी चीज़ को हटाने से पहले अलग से पूछती है।
क्या यह remote branches हटाती है?
नहीं। स्किल remote branches को दायरे से बाहर मानती है, हालाँकि अपनी रिपोर्ट में पुरानी शाखाओं का ज़िक्र कर सकती है।
क्या यह उस worktree को छूती है जिसमें मैं काम कर रहा हूँ?
नहीं। यह मुख्य worktree, उस worktree को जिसमें यह चल रही है, या चल रही प्रक्रियाओं वाले किसी worktree को कभी नहीं छूती।
जानकारी
लेखक का मूल विवरण
Inventory the git worktrees of the current repository, classify each one with evidence (merged, PR state, uncommitted or unpushed work, locked, stale, in use by a running session) and remove them one at a time or by group, always asking the user first and verifying every removal. Use when worktrees have piled up (for example one per Claude Code task or thread), when `git worktree list` is long, or when the user asks to clean up, prune or tidy worktrees.
लोकप्रियता
- GitHub स्टार
- 33k
- रैंकिंग में स्थान
- #8856
- लाइसेंस
- MIT
- अपडेट की गई
- 2/11/2026
कमेंट
- …
इस repository की और skills
owasp-security
33kआपके एजेंट को वेब ऐप, API, मोबाइल, कंटेनर और AI एजेंट्स के लिए OWASP सुरक्षा मार्गदर्शन सिखाती है, ताकि वह आम कमज़ोरियाँ पहचान सके और सुधार सुझा सके।
agent-management
33kआपके एजेंट को AI Maestro कमांड-लाइन से AI एजेंट बनाने, सूची देखने, hibernate और wake करने, नाम बदलने और हटाने देती है, हर एजेंट के जीवन-चक्र को संभालते हुए।
agent-messaging
33kAgent Messaging Protocol का उपयोग करके AI एजेंट्स के बीच हस्ताक्षरित संदेश भेजने, प्राप्त करने और उनका जवाब देने देती है, ज़्यादातर आपकी अपनी मशीन पर।
docs-search
33kआपके एजेंट को फ़ंक्शन सिग्नेचर, क्लास परिभाषा और कमेंट के लिए ऑटो-जनरेटेड कोड डॉक्यूमेंटेशन खोजने देती है, ताकि कोड बदलने से पहले वह असली API जाँच सके।
मिलती-जुलती skills
openclaw-update
394kयह आपके एजेंट को चल रहे OpenClaw Gateway को अपडेट करने में मदद करती है, इंस्टॉल के तरीके के अनुसार सही विधि चुनकर और सेशन बनाए रखकर।
diagnose-gateway
394kयह आपके एजेंट को सेटिंग्स, चैनल और पोर्ट जांचकर पता लगाने देती है कि OpenClaw Gateway क्यों फ़ेल हो रहा है, बिना कुछ बदले।
crabbox-apps
394kयह आपके एजेंट को किसी अस्थायी क्लाउड मशीन पर ऐप खोलने और चलाने देती है, फिर उसका व्यू आपके चैट के साइड पैनल में दिखाती है।