remove_unowned_worktrees
Remove worktree directories no agent answers for, which delete_agents cannot reach: a directory under the worktrees directories whose agent row is gone, or whose row is in AGENT_STATE_FAILED_TO_CLEANUP because git can no longer read the registration.
WorktreewritesidempotentdestructiveMCP tool
Each directory goes and, where the repository can still be read, git worktree prune runs in it; no branch is ever touched, since without a row nothing says whether the branch was adopted. A directory outside the worktrees directories, one a live or archived agent still answers for, one an agent works in or under, or one holding another worktree is refused with the reason and the rest go; delete the agent instead for those. Read list_worktrees first and pass only the directories it reports with no agent.
Calling it#
curl -X POST http://127.0.0.1:8787/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 | list of string | The directories to remove, each as list_worktrees spelled it. required |