Skip to main content
Glama

Inspect or force worktree cleanup

cleanup

Inspect and remove stale Git worktrees: plan why one remains, apply safe removals, or review removal history.

Instructions

Cleanup is automatic during poll_workers: landed or unchanged work goes at once, unlanded work after a hold period, with uncommitted edits committed to the worker's branch first; branches and evidence stay. Use this to see why a worktree is still there (plan), remove SAFE ones now (apply, with plan_id and item_ids), or read what was removed (history).

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "action": "<action>"
    },
    "name": "cleanup"
  }
}

Input Schema

NameRequiredDescriptionDefault
limitNo
actionYes
plan_idNo
item_idsNo
task_idsNoplan: limit to these workers; history: the first one
project_rootNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv2.0.1

TDQS

A3.8/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and does well: it discloses the automatic lifecycle (landed/unchanged cleaned immediately, unlanded after a hold period), that uncommitted edits are committed to the worker's branch first, and that branches and evidence are preserved. It does not state whether 'apply' is irreversible, what constraints apply to non-SAFE worktrees, or what these operations return.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two dense sentences with no filler, and the action-to-use-case mapping is front-loaded in the second sentence. The leading sentence about automatic cleanup is valuable context but delays the statement of what this tool does; semicolon-heavy packing makes it slightly harder to scan.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a six-parameter, three-mode tool with no annotations and no output schema, the description covers lifecycle and action routing but leaves gap areas: result shape of plan/history, meaning of limit and project_root, and any safety constraints on apply. Adequate to call it, not complete enough to call it confidently in edge cases.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is only 17% (one of six parameters), so the description must compensate, and it only partly does: it ties plan_id and item_ids to 'apply' and implies task_ids filtering by mentioning plan/history roles obliquely, but limit, project_root, and the plan/history variants of task_ids remain unexplained. The action enum values are the main thing it clarifies beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description names the resource (worktrees) and enumerates three concrete modes with verbs: 'see why a worktree is still there (plan)', 'remove SAFE ones now (apply)', 'read what was removed (history)'. It also distinguishes this tool from the automatic cleanup performed inside poll_workers, so an agent can tell why it would call this instead. It stops short of a crisp one-line statement of what the tool is, since the opening sentence describes automatic behavior rather than the tool itself.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Each action is mapped to a use case ('plan' for diagnosis, 'apply' for immediate removal of safe items, 'history' for auditing), and the implicit alternative (just waiting, since cleanup is automatic during poll_workers) is stated. No explicit when-not-to-use guidance, such as cautions about forcing apply while workers are running.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.