Skip to main content
command CX Codex

remove_worktree_prompt — Claude Code command to remove a worktree

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.

no license ★ 1,573 updated 2026-02-08

Install into Claude Code · Manually: put the files in place All methods and platforms ↓
.claude/commands/remove_worktree_prompt.md
Open on GitHub

What remove_worktree_prompt 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.

What it helps with

  • 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 for the agent

  • 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.

How to install remove_worktree_prompt

Manually: put the files in place

.claude/commands/remove_worktree_prompt.md

Call it with /remove_worktree_prompt. For all projects use ~/.claude/commands/

Questions about remove_worktree_prompt

How do I install remove_worktree_prompt in Claude Code?

Place the command file at .claude/commands/remove_worktree_prompt.md.

What does remove_worktree_prompt do?

It finds a worktree under trees/, stops related processes, removes the worktree and its Git branch, then checks the results.

Can I undo the branch deletion?

No. The command deletes the branch permanently, and may force deletion if the regular Git operation fails.

Similar slash commands

All slash commands for Git and GitHub →

From the same set20

The whole set →
load_ai_docs load_ai_docs — a command that downloads documentation from specified URLs and saves it as markdown files via model-specific subagents. Designed for documentation benchmarking and testing AI model capabilities. CX Codex +1 ★ 1,573repo stars t_metaprompt_workflow t_metaprompt_workflow generates structured Claude Code slash commands from a high-level task description while checking Anthropic docs. CX Codex +1 ★ 1,573repo stars scout-report-suggest-fast scout-report-suggest-fast hunts a described problem through a codebase and returns file paths, line numbers and a fix plan. It only reads. CX Codex ★ 1,573repo stars list_worktrees_prompt list_worktrees_prompt inspects git worktrees under the trees/ folder, detects active process ports, and outputs a runtime status report. CX Codex +1 ★ 1,573repo stars create_worktree_prompt create_worktree_prompt sets up a git worktree under trees/ with separate ports, database and hooks, then starts the server and client. Useful for running several copies of the observability system side by side. CX Codex +1 ★ 1,573repo stars worktree-manager-skill The worktree-manager-skill skill handles Git worktrees for parallel development, including creation, status checks, listing, and removal. CX Codex +1 ★ 1,573repo stars Video Processor Video Processor — a skill that handles video files from the agent: pull the audio track, convert to mp4 or webm, transcribe speech with Whisper. Useful when video files show up in a project. CX Codex +1 ★ 1,573repo stars Create New Skills Create New Skills guides the creation of custom Agent Skills for Claude Code. It designs SKILL.md files, configures activation triggers, and organizes helper scripts. CX Codex +1 ★ 1,573repo stars

Project sponsors

Companies that keep this analytics open