cleanup

cleanup is a command for coding agents from HigorAlves/orc. It costs 39 tokens per session (3,672 once invoked), scanned C, original, MIT.

A cleanup command for finished or abandoned development sessions. A worktree is a separate checkout of a Git branch; this command can remove that checkout, saved session state, its registry entry, and, when safe, the local branch.

In plain words
What is it for?
Use it to close one session by its ID or branch name, or to clean up all sessions marked completed or abandoned.
Why use it?
It removes leftover workspace files and branches after work is complete while previewing the changes and asking for confirmation. Safety checks stop it when a worktree is dirty, a branch is unmerged, or the session is unusual.

Command

Part of the orc plugin — 80 skills, 30 commands, 14 agents, 5 hooks shipped together

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/higoralves/orc/cleanup
Clone the repo
git clone --depth 1 https://github.com/HigorAlves/orc

Or install orc, the plugin that ships this one along with the rest of its 80 skills, 30 commands, 14 agents, 5 hooks.

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 cleanup

README.md
[![agentmods](https://agentmods.dev/badge/commands/higoralves/orc/cleanup.svg)](https://agentmods.dev/commands/higoralves/orc/cleanup)
Your own site
<a href="https://agentmods.dev/commands/higoralves/orc/cleanup"><img src="https://agentmods.dev/badge/commands/higoralves/orc/cleanup.svg" alt="Measured on agentmods" height="20"></a>
Per session 39 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 3,672 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. Scan, not verified.
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 $0.00039 $0.03672
Opus 5 $0.00019 $0.01836
Sonnet 5 $0.00008 $0.00734
Haiku 4.5 $0.00004 $0.00367

Measured 4d ago against content hash f555ff0297a7, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade C, and why

cleanup 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 4d 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.

- Bash(rm -rf .orc:*)
orc/commands/cleanup.md · 276 lines

How it starts

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

/orc:cleanup

Close the loop on finished orc work — remove the workspace state, the worktree, and (if safe) the local feature branch.

Arguments

  • --auto[=guided|full] — autopilot level for this run (overrides interaction_policy; taxonomy in orc:using-orc). Soft-inward gates consult the resolved policy — guided auto-advances mechanical confirms with a printed one-liner; full pre-approves them from settled decisions (orc:state-protocol), stopping only on escalation-only conditions. Hard-outward gates are unaffected at every level.

  • <session-id-or-branch> — optional. Clean up exactly one session. Accepts the sessionId from .orc/orc.json (list via orc-state sessions; schema per orc:state-protocol) or a (sanitized or raw) branch name.

Autopilot: at guided/full, the standard cleanup plan (state dir, clean worktree, merged branch) auto-applies after printing it; anything anomalous — partial workspace merges, unmerged branches, a dirty worktree — still gates at every level.

  • --all-completed — clean up every session whose status in .orc/orc.json is completed or abandoned. Respects all the safety checks below per session.
  • --dry-run — print what would happen but make no changes. Recommended for the first run.
  • --per-repo — workspace mode: clean each linked repo independently as its PR merges, instead of waiting for all to merge. Use only when you intend to abandon some repos (rare).
  • --down-volumes — when tearing down a session's Docker environment, also remove its named volumes (default keeps them: the next boot on that branch reuses DB data).

Workflow

Phase 0 — Detect context

!orc-workspace-detect --banner

Context is injected above (ORC_* vars are exported for any Bash you run — do not re-run detection).

In workspace mode, the registry to read in Phase 2 is ${ORC_STATE_DIR}/orc.json (workspace-level). Workspace sessions have scope: "workspace" and a repos array. For each candidate workspace session, fetch PR merge status for every URL in linkedPRs:

Read the full file on GitHub · 276 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. 4d ago First seen · 276 lines · 39 tokens per session scan C f555ff0297a7

Subscribe to this mod's changes

cleanup is a command published in the GitHub repository HigorAlves/orc (6 stars, last pushed 8d ago), licensed MIT. It adds 39 tokens to every session and 3,672 once invoked, about $0.0002 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-31.