Skip to content
Development
Command

/clean

Remove the git worktrees review checked PR code out into. Each one is a full checkout on disk; nothing else is touched.

From plugin
open-pr
195 skills5 commands
Install
$ npx -y skills add TOMOSIA-VIETNAM/open-pr --agent claude-code

How it fires

How this command gets triggered: by you, by Claude, or both.

  • Fires itselfClaude auto-loads it when your prompt matches the work.
  • You can call itInvoke it directly when you want it.
  • Slash command/clean

Context preview

What this command does when you run it.

Remove the git worktrees review checked PR code out into. Each one is a full checkout on disk; nothing else is touched.

Command definition

clean.md
argument-hint: "[repo name...]"
description: Remove the git worktrees review checked PR code out into. Each one is a full checkout on disk; nothing else is touched.

> **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/*' -not -path '*/worktrees/*/*' 2>/dev/null

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, so consent covers a list the user has read:

  • `Remove all N (Recommended)` — detail: the reclaimed total; review re-creates a worktree next run, so

nothing is lost but disk — 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 plain `rm -rf` leaves the reviewed repo registering a worktree that no longer exists:

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

`--force` because the checkout is detached and holds untracked review scratch files.

That first command failing (the repo was moved or deleted) ⇒ the registration is already orphaned: `rm -rf "<worktree>"` instead.

Finish with `git -C "<repo>" worktree prune` per distinct repo, which drops any stale registration left by an earlier manual delete.

Step 5 — Report

Per repo: how many worktrees went and how much disk came back. Then, once: `notebooks/review/` still holds this repo's memory and settings — only the checkouts were removed.

ARGUMENTS: $ARGUMENTS

Read more
Ships withopen-pr

One AI reviewer for GitHub PRs and GitLab MRs. Learns each repo's conventions. Claude Code · Cursor · Codex · Gemini CLI · Antigravity.

Get the whole plugin, auto-invoked
Stats
19
Stars
0
Views
9
Forks
Active
Maintenance
Python
Language
MIT
License
1d ago
Last commit
25d ago
Created

Repo: TOMOSIA-VIETNAM/open-pr