# Wt Cleanup Loop

> Polls for merged PRs and closes the herdr workspaces or tmux windows behind them, on a timer. Args: [tick] [duration], defaults 5m and 3h. Use when the user wants tabs cleaned up as PRs land rather than right now: \"watch and close tabs as PRs merge\", \"wt cleanup-loop\", \"keep sweeping finished worktrees for the next few hours\". Same skill on both multiplexers; there is no herdr-specific vari…

- **Type:** Skill
- **Install:** `agentstack add skill-ondrejdrapalik-worktree-management-skills-wt-cleanup-loop`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [OndrejDrapalik](https://agentstack.voostack.com/s/ondrejdrapalik)
- **Installs:** 0
- **Category:** [Agent Skills](https://agentstack.voostack.com/c/agent-skills)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [OndrejDrapalik](https://github.com/OndrejDrapalik)
- **Source:** https://github.com/OndrejDrapalik/worktree-management-skills/tree/main/skills/wt-cleanup-loop

## Install

```sh
agentstack add skill-ondrejdrapalik-worktree-management-skills-wt-cleanup-loop
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Watch For Merged PRs

```bash
wt cleanup-loop $ARGUMENTS
```

Run it in the background. It prints one line per tick, so the user sees
closures as they happen without the loop blocking you.

```text
wt cleanup-loop            # 5m tick, 3h duration
wt cleanup-loop 2m 1h
wt cleanup-loop 10m        # 10m tick, 3h duration
```

## Why this is a shell loop, not an agent loop

The check is `gh pr list` per open worktree. Pure lookup, no judgement. An
earlier version woke a background subagent every tick to run it, which cost
tokens on every sweep and added a failure mode (an agent mis-transcribing the
safety rules) to a task that has no ambiguity in it. The loop lives in
`wt-cleanup-loop`, which calls `wt clear --merged-only` and sleeps.

Two consequences worth passing on to the user:

- It only closes **merged** PRs. Closed-without-merge often means the work is
  still wanted, so it is left alone; `wt clear` without the flag sweeps those too.
- Nothing is deleted. Checkouts and branches stay in `~/_wt` and git; `wt open
  ` brings any of them back. Deleting is `wt-remove`.

Do not build your own polling wrapper. That re-adds the cost this design removed.

## Source & license

This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [OndrejDrapalik](https://github.com/OndrejDrapalik)
- **Source:** [OndrejDrapalik/worktree-management-skills](https://github.com/OndrejDrapalik/worktree-management-skills)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/skill-ondrejdrapalik-worktree-management-skills-wt-cleanup-loop
- Seller: https://agentstack.voostack.com/s/ondrejdrapalik
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
