remove_unowned_worktrees
Remove worktrees that no agent or task owns, such as those list_worktrees marks unowned.
writesidempotentdestructiveMCP toolWorktree
Branches are never deleted.
Calling it#
curl -X POST http://127.0.0.1:8787/komrad.worktree.v1.WorktreeService/RemoveUnownedWorktrees \
-H 'Content-Type: application/json' \
-d '{
"dirs": [
"<dirs>"
]
}'komrad rpc remove-unowned-worktrees \
--dirs '<string>'{
"name": "remove_unowned_worktrees",
"arguments": {
"dirs": [
"<dirs>"
]
}
}Offered by the komrad MCP server to orchestrator agents.
Request#
RemoveUnownedWorktreesRequest#
| Field | Type | Description |
|---|---|---|
dirs | string[]* at most 100 items no repeats each not empty | The worktrees to remove, by the paths |
Response#
RemoveUnownedWorktreesResponse#
Types#
Refusal#
Refusal is a worktree komrad would not remove, and why.
| Field | Type | Description |
|---|---|---|
dir | string | The worktree's path. |
reason | RefusalReason | Why the worktree was kept. |
task_slug | string | The task the reason names. Empty unless the reason is about a task. |
agent_name | string | The agent the reason names. Empty unless the reason is about an agent. |
nested_dir | string | The worktree inside this one. Empty unless the reason is |
error | string | What failed. Empty unless a step broke. |
RefusalReason#
RefusalReason is why komrad kept a worktree it was asked to remove.
| Value | Description |
|---|---|
outside | The path is not under the worktree directories. |
unlisted | The listing of the worktree directories does not hold the path. |
task_holds | The task |
task_live | The task |
task_deleting | The task |
agent_inside | The agent |
agent_beneath | The agent |
nests_worktree | The worktree |
unresolved | Komrad could not resolve the path. |
list_failed | Git could not list the worktrees of the worktree's repository. |
unlock_failed | Git could not unlock the worktree. |
remove_failed | Komrad could not remove the worktree's directory. |