dd-git-cleanup

Detects merged branches and stale worktrees, then guides user-confirmed Git cleanup.

Updated Jun 11, 2026
One-click install
npx skills add https://github.com/marcocpt/trae_skills --skill dd-git-cleanup-marcocpt
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dd-git-cleanup
Source: https://github.com/marcocpt/trae_skills/tree/main/dd-git-cleanup
Command: npx skills add https://github.com/marcocpt/trae_skills --skill dd-git-cleanup-marcocpt

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Long-running repositories accumulate merged branches, stale worktrees, and orphaned worktree metadata, cluttering the workspace and making branch management error-prone. This Skill detects cleanup candidates and enforces a safe, user-confirmed removal process. ## Core Features & Use Cases - Automatic Detection: Identifies merged branches, stale worktrees (inactive over 7 days), orphaned worktree metadata, and locally tracked branches deleted on the remote. - Guided Cleanup Flow: Runs cleanup-suggest.sh to output a CleanupSuggestion JSON, then executes git worktree remove, git branch -d, and git worktree prune only after user confirmation. - Safety Constraints: Never deletes the currently checked-out branch, develop, or main, and never auto-deletes anything without explicit user approval. - Use Case: After several feature branches are merged into develop, ask the agent to scan the repository; it lists merged branches and stale worktrees, you confirm which to remove, and it prunes them safely. ## Quick Start Ask the agent to scan this repository for merged branches and stale worktrees and suggest which ones to clean up.

Frequently Asked Questions about dd-git-cleanup

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I clean up merged Git branches safely?

Run the cleanup-suggest.sh script to list branches already merged into origin/develop, review the CleanupSuggestion JSON, and confirm which ones to delete. The skill then runs git branch -d only on confirmed branches, never deleting anything automatically.

How to remove stale Git worktrees?

Worktrees with no commit activity for over 7 days are flagged as stale and suggested for removal. After user confirmation, the skill runs git worktree remove followed by git worktree prune to clear residual metadata.

What is an orphaned worktree and how do I fix it?

An orphaned worktree occurs when the worktree directory was deleted but its metadata remains in Git. Running git worktree prune removes this stale metadata and restores a clean worktree list.

Which branches are protected from Git cleanup?

The currently checked-out branch, develop, and main are never cleaned up by this skill. Additionally, no branch is ever deleted automatically; every deletion requires explicit user confirmation after reviewing the suggestions.

Does deleting a merged branch lose commit history?

No. When a merged branch is deleted, the merge commits remain in the repository history, preserving the full development trail. Only the branch pointer is removed.