# Remove Git Worktrees Safely

Abandoned Git worktrees can leave stale files and local branches behind. This skill runs a focused cleanup script for a named branch.

## Install

```bash
npx skillstore add akabanakk/remove-git-worktree
```

## Metadata

- Status: approved
- Slug: akabanakk-remove-git-worktree
- Skillstore revision: r1
- Version status: missing
- Tree hash: 153175b71048bef196f731c033b1a6c6a3325c31196f98d42e128d8b2b91a253
- Author: AKABANAKK
- GitHub username: AKABANAKK
- License: MIT
- Repository: https://github.com/AKABANAKK/claude-code-marketplace/tree/main/akb7/skills/remove-git-worktree
- Ref: 0519034dad657fb1f7706e0550e962beeda73fdf
- Supported tools: Claude, Codex, Claude Code
- Audit status: complete
- Agent install advisory: allowed
- Manual install advisory: allowed
- Artifact signature: available
- Audit attestation: unavailable
- Human verification: not\_verified
- Risk factors: external\_commands, filesystem
- Quality score: 67
- Public page: https://skillstore.pages.dev/skills/akabanakk-remove-git-worktree
- Manifest: https://skillstore.pages.dev/api/skills/akabanakk-remove-git-worktree/manifest

## Capabilities

- Shows the command for removing a worktree by branch name.
- Converts branch slashes to hyphens for the expected worktree folder name.
- Finds the current repository root with Git.
- Removes the matching worktree with Git worktree commands.
- Deletes the matching local branch when it exists.

## Use Cases

- Clean Up Completed Feature Work: Remove a feature worktree and its local branch after merge work is finished.
- Recover From Accidental Worktree Creation: Delete a mistakenly created worktree that follows the repository worktree naming convention.
- Keep Local Repositories Tidy: Standardize cleanup of old local worktrees during repository maintenance.

## Prompt Templates

### Remove One Worktree

```
Use the remove-git-worktree skill to remove the worktree for branch feature/new-login.
```

### Clean After Merge

```
After confirming branch feature/cart-checkout is merged, remove its local worktree and matching local branch.
```

### Verify Path Before Removal

```
For branch bugfix/header-layout, show the resolved worktree path first. Continue only if it matches the expected sibling worktrees directory.
```

### Review Cleanup Risk

```
Before removing branch experiment/payment-flow, check whether local work may be lost and explain the cleanup impact.
```

## Limitations

- Assumes worktrees live in a sibling directory named after the repository.
- Does not ask for confirmation before removing the worktree.
- Does not check for uncommitted changes before cleanup.
- Does not delete remote branches or remote tracking references.

## Best Practices

- Run the skill from the correct Git repository.
- Confirm the branch name and resolved worktree path before cleanup.
- Commit, stash, or back up local changes before removing a worktree.

## Anti Patterns

- Do not run cleanup with a guessed or partial branch name.
- Do not use this skill on worktrees that may contain unsaved work.
- Do not expect this skill to remove remote branches.

## Security Audit

- Audited at: 2026-07-09T12:44:18.124\+00:00
- Summary: Most command-execution findings are expected for a Git cleanup script and are false positives because commands are hardcoded and quoted. The parent-relative worktree path and later delete operations are real risks because the skill can remove a sibling worktree directory and force-delete a local branch without confirmation. No evidence found for prompt injection or network behavior.

## Stats

- Views: 209
- Downloads: 9
- Favorites: 0
- Popularity score: 0
