clean

clean is a command for Claude Code from TOMOSIA-VIETNAM/open-pr. It costs 26 tokens per session (757 once invoked), scanned C, original, MIT.

A command that removes temporary Git worktrees created during open-pr code reviews. A Git worktree is a separate folder containing another checkout of the same repository.

In plain words
What is it for?
Use it to clean up completed review checkouts, after confirming which repositories and folders may be removed.
Why use it?
It reclaims disk space after reviews while limiting deletion to the designated review-worktree folders.

Command for Claude Code

Written for Claude Code: argument-hint in frontmatter.

Runs only inside its plugin — its command needs a path that Claude Code sets for a plugin’s own hooks and for nothing else. Install the plugin, not this.

Part of the open-pr plugin — 5 commands shipped together

Good fit Use it to clean up completed review checkouts, after confirming which repositories and folders may be removed.

Compare 6 commands from other repositories ↓
Install

Getting it into your agent

This one installs as part of its plugin. Adding the marketplace and installing the plugin brings it with everything else the plugin ships.

Claude Code
/plugin marketplace add TOMOSIA-VIETNAM/open-pr
Claude Code
/plugin install open-pr

Made for: Claude Code.

Or install open-pr, the plugin that ships this one along with the rest of its 5 commands.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for clean

README.md
[![agentmods](https://agentmods.dev/badge/commands/tomosia-vietnam/open-pr/clean/github.svg)](https://agentmods.dev/commands/tomosia-vietnam/open-pr/clean)
Your own site
<a href="https://agentmods.dev/commands/tomosia-vietnam/open-pr/clean"><img src="https://agentmods.dev/badge/commands/tomosia-vietnam/open-pr/clean/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for clean

Your own site · 80×15
<a href="https://agentmods.dev/commands/tomosia-vietnam/open-pr/clean"><img src="https://agentmods.dev/badge/commands/tomosia-vietnam/open-pr/clean.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 26 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 757 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00026 $0.00757
Opus 5 $0.00013 $0.00378
Sonnet 5 $0.00005 $0.00151
Haiku 4.5 $0.00003 $0.00076

Measured 9d ago against content hash 384ea89838b8, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade C, and why

clean scanned grade C with 1 finding against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

Per worktree, in this order — a bare `rm -rf` leaves a stale worktree registration behind:
src/commands/clean.md · 70 lines

How it starts

The opening of the file, as written. The whole thing — 70 lines — stays where its author put it; the contents beside it link to each section on GitHub.

CRITICAL: Read "${CLAUDE_PLUGIN_ROOT}"/core/guardrails.md FIRST — shared rules, not repeated here. On top of those:

  • Deletes ONLY directories under notebooks/review/*/worktrees/. FORBIDDEN, in the same tree and unrecoverable: memory.md, memories/, templates/, ALWAYS_RULE.md, settings.json, notebooks/review/.git, and any path outside notebooks/review/*/worktrees/.
  • FORBIDDEN: deleting anything before the user answers Step 3.
  • Reads no PR and needs no vendor CLI.

This CRITICAL block is the SOLE enforcement layer — no allowed-tools backs it (deliberate).

Step 1 — Find the worktrees

Same layout /open-pr:upgrade searches: notebooks/review/ sits wherever /open-pr:review ran, from pwd or one level down. FORBIDDEN: cd.

find . -maxdepth 6 -type d -path '*/notebooks/review/*/worktrees/*' 2>&1 | grep -Ev '^\./.*/worktrees/[^/]+/'

None → say there is nothing to clean, STOP.

Step 2 — Narrow, then size

ARGUMENTS non-empty ⇒ keep only worktrees whose <repo> segment it names, case-insensitive; 0 matched ⇒ STOP, listing the <repo>s found. Over what remains — never over what was just dropped, since each is a full checkout and du walks all of it:

du -sh <each worktree>

Step 3 — Show what would go, then ask

ONE CHOICE per core/guardrails.md, EXACTLY 2 options. Its body lists every worktree by path with its size and the total ⇒ consent covers a list the user has read:

  • Remove all N (Recommended) — detail: the reclaimed total; review re-creates a worktree next run ⇒ only disk is lost, unless /open-pr:fix committed there and never pushed
  • Keep them — detail: nothing deleted

Subset wanted (free text, or a re-run naming those repos) ⇒ honour it, those only. Keep them ⇒ STOP.

Step 4 — Remove

Per worktree, in this order — a bare rm -rf leaves a stale worktree registration behind:

git -C "<worktree>" rev-parse --git-common-dir     # ABSOLUTE <repo>/.git; <repo> = that minus /.git
git -C "<repo>" worktree remove --force "<worktree>"

Read the full file on GitHub · 70 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 9d ago First seen · 70 lines · 26 tokens per session scan C 384ea89838b8

Subscribe to this mod's changes

clean is a command published in the GitHub repository TOMOSIA-VIETNAM/open-pr (42 stars, last pushed 3d ago), licensed MIT. It adds 26 tokens to every session and 757 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.