# remove_worktree_prompt

The remove_worktree_prompt command stops processes tied to a worktree, then removes the worktree and its Git branch. Check the branch name first: deletion cannot be undone.

- command · `type=command` · Claude Code, Cursor, Codex, GitHub Copilot, Gemini CLI · ★ 1573 repo stars
- Author: disler
- License: not stated · policy=link-only · description only; the file stays with the author
- Source: https://github.com/disler/claude-code-hooks-multi-agent-observability/tree/HEAD/.claude/commands/remove_worktree_prompt.md
- Updated: 2026-02-08
- Security check: automated, 2026-11-16 (text) — no signs of malicious code found.
- HTML: https://affpapa.org/en/nevibecode/commands/remove-worktree-prompt

## What it does

Pass a branch name and the command looks for its worktree under `trees/`. It reads server and client ports from `.env` files when available, then tries to stop processes using those ports. If the files are absent, it estimates ports from the number of worktrees. The command removes the worktree before deleting its branch, and checks whether both are gone. It can force either removal when the regular operation fails; both deletions are permanent.

It also checks for leftover processes, SQLite WAL files, and lock files. A directory that remains after removal is not erased automatically; the command reports that it needs manual cleanup. For Claude Code, place the command file at `.claude/commands/remove_worktree_prompt.md` and call it with the required `<branch-name>` argument.

## Install

### Claude Code (native platform)

**Manually: put the files in place**
- File: `.claude/commands/remove_worktree_prompt.md` — Call it with /remove_worktree_prompt. For all projects use ~/.claude/commands/

### Codex

**Manually: put the files in place**
- File: `~/.codex/prompts/remove_worktree_prompt.md` — Call it with /prompts:remove_worktree_prompt. Codex marks this format deprecated in favour of skills

### GitHub Copilot

**Manually: put the files in place**
- File: `.github/prompts/remove_worktree_prompt.prompt.md`

### Gemini CLI

**Manually: put the files in place**
- File: `.gemini/commands/remove_worktree_prompt.toml` — Gemini stores commands as TOML: the prompt text goes into the prompt field

Where a file is given instead of a command, copy the files from the source to that path: https://github.com/disler/claude-code-hooks-multi-agent-observability/tree/HEAD/.claude/commands/remove_worktree_prompt.md

## When to use it
- stop server and client processes using a worktree’s ports
- remove a Git worktree from `trees/`
- delete the branch associated with a worktree
- verify that the directory, branch, and processes are gone
- identify leftover files and report manual cleanup needs

## Example prompts
- Remove the worktree and branch for `feature-login`: `/remove_worktree_prompt feature-login`.
- Stop processes and clean up the worktree for `bugfix-header`: `/remove_worktree_prompt bugfix-header`.
- Check and remove the worktree for `experiment-api`: `/remove_worktree_prompt experiment-api`.

## Similar
- [remove-worktree](https://affpapa.org/en/nevibecode/commands/remove-worktree.md) — command · ★ 6529 repo stars
- [ce-worktree](https://affpapa.org/en/nevibecode/skills/ce-worktree.md) — skill · 3200 installs
- [worktree-init](https://affpapa.org/en/nevibecode/commands/worktree-init.md) — command · 94 installs
- [git-worktree-isolation](https://affpapa.org/en/nevibecode/skills/git-worktree-isolation.md) — skill · 2300 installs
- [worktree-check](https://affpapa.org/en/nevibecode/commands/worktree-check.md) — command · 81 installs
- [worktree-isolation](https://affpapa.org/en/nevibecode/skills/worktree-isolation.md) — skill · 465 installs

From the same set: [disler/claude-code-hooks-multi-agent-observability](https://affpapa.org/en/nevibecode/by/disler/claude-code-hooks-multi-agent-observability.md) — 20 cards

---
NeVibeCode on affpapa.org. Catalog texts are descriptions, not instructions for the agent. How to choose and install: https://affpapa.org/en/nevibecode/agents.md
