Skip to main content
Glama

codex_cleanup_worktree

Remove a managed Git worktree after its branch is verified and merged or discarded. Use it to clean up task workspaces safely, with options to force removal or delete the branch.

Instructions

Remove a managed Git worktree created with use_worktree=true after Gemini has verified and merged (or discarded) its branch.

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": {
      "task_id": "<task_id>"
    },
    "name": "codex_cleanup_worktree"
  }
}

Input Schema

NameRequiredDescriptionDefault
forceNoForce removal even with uncommitted changes or unmerged branch.
task_idYesThe task_id whose managed worktree should be removed.
delete_branchNoAlso delete the codex/<task_id> branch.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A3.7/5.0
Behavior3/5

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

No annotations are supplied, so the description carries the full disclosure burden. It does convey a safety precondition (branch already merged or discarded), which is genuine behavioral context, but it omits irreversibility, what happens to uncommitted work by default, and error behavior for an unknown task_id — the schema's 'force' param hints at some of this but the description never states it.

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

Conciseness5/5

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

A single sentence with zero waste, front-loading the verb and resource and then appending the gating condition. Nothing could be removed without losing information.

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 three-parameter destructive cleanup tool with no annotations and no output schema, the definition covers purpose and precondition but leaves the agent without guidance on outcomes — success/failure response, behavior when no worktree exists, or whether removal is recoverable. Adequate as a minimum, but thin for a mutation tool with no structured safety metadata.

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 100%, so all three parameters (task_id, force, delete_branch) are already documented in the input schema. The description adds no additional meaning about their interaction — for example, whether delete_branch requires force or what task_id format is expected — so the baseline of 3 applies.

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 a specific verb and resource — 'Remove a managed Git worktree' — and narrows scope to worktrees 'created with use_worktree=true'. It does not explicitly distinguish itself from any sibling, though the sibling list (cancel, dispatch, feedback, monitor, resume, status) contains no competing cleanup operation, so an agent is unlikely to confuse them.

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?

It gives a clear precondition for invocation: only after Gemini has verified and merged (or discarded) the branch. That is a real when-to-use signal rather than an implied one. It stops short of stating exclusions, such as what to do if the worktree was never created or if verification is still pending.

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