komrad

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>"
  ]
}'

Request#

RemoveUnownedWorktreesRequest#

FieldTypeDescription
dirsstring[]*

at most 100 items

no repeats

each not empty

The worktrees to remove, by the paths list_worktrees returns.

Response#

RemoveUnownedWorktreesResponse#

FieldTypeDescription
removedstring[]

The worktrees removed.

refusedRefusal[]

The worktrees kept, each with the reason.

Types#

Refusal#

Refusal is a worktree komrad would not remove, and why.

FieldTypeDescription
dirstring

The worktree's path.

reasonRefusalReason

Why the worktree was kept.

task_slugstring

The task the reason names. Empty unless the reason is about a task.

agent_namestring

The agent the reason names. Empty unless the reason is about an agent.

nested_dirstring

The worktree inside this one. Empty unless the reason is nests_worktree.

errorstring

What failed. Empty unless a step broke.

RefusalReason#

RefusalReason is why komrad kept a worktree it was asked to remove.

ValueDescription
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_slug names owns the worktree. Deleting the task removes it.

task_live

The task task_slug names is live. Archiving it comes before deleting its worktree.

task_deleting

The task task_slug names is being deleted, which removes the worktree.

agent_inside

The agent agent_name names is working in the worktree.

agent_beneath

The agent agent_name names is working somewhere under the worktree.

nests_worktree

The worktree nested_dir names sits inside this one. Removing that worktree comes first.

unresolved

Komrad could not resolve the path. error says why.

list_failed

Git could not list the worktrees of the worktree's repository. error says why.

unlock_failed

Git could not unlock the worktree. error says why.

remove_failed

Komrad could not remove the worktree's directory. error says why.