cleanup

cleanup is a command for Claude Code from ai-sdlc-framework/ai-sdlc. It costs 30 tokens per session (1,377 once invoked), scanned C, original, Apache-2.0.

A command that removes Git worktrees after their pull requests are merged, or removes one specified worktree when given a task ID. A worktree is a separate working folder connected to the same Git repository.

In plain words
What is it for?
For sweeping merged worktrees, checking their pull-request status through GitHub, force-removing a chosen task worktree, and cleaning up obsolete worktree markers.
Why use it?
It clears folders that are no longer needed and removes an old project marker left by earlier versions of the workflow.

Command for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: model in frontmatter; reads .claude/ paths; mentions CLAUDE.md.

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 ai-sdlc plugin — 3 skills, 25 commands, 14 agents shipped together

Good fit For sweeping merged worktrees, checking their pull-request status through GitHub, force-removing a chosen task worktree, and cleaning up obsolete worktree markers.

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 ai-sdlc-framework/ai-sdlc
Claude Code
/plugin install ai-sdlc

Made for: Claude Code.

Or install ai-sdlc, the plugin that ships this one along with the rest of its 3 skills, 25 commands, 14 agents.

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/ai-sdlc-framework/ai-sdlc/cleanup/github.svg)](https://agentmods.dev/commands/ai-sdlc-framework/ai-sdlc/cleanup)
Your own site
<a href="https://agentmods.dev/commands/ai-sdlc-framework/ai-sdlc/cleanup"><img src="https://agentmods.dev/badge/commands/ai-sdlc-framework/ai-sdlc/cleanup/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 cleanup

Your own site · 80×15
<a href="https://agentmods.dev/commands/ai-sdlc-framework/ai-sdlc/cleanup"><img src="https://agentmods.dev/badge/commands/ai-sdlc-framework/ai-sdlc/cleanup.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 30 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,377 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.00030 $0.01377
Opus 5.5 $0.00012 $0.00551
Sonnet 5.5 $0.00006 $0.00275
Haiku 4.5 $0.00003 $0.00138

Measured 10d ago against content hash dc136648b8c7, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, 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 10d 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.

It keeps `keep-inflight` (task inflight on the board, or a `.active-task` sentinel younger than 24 h) and `keep-open-pr`. PR state is looked up per branch. A dirty tree does not block removal; the untracked paths are log
ai-sdlc-plugin/commands/cleanup.md · 83 lines

How it starts

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

Companion to /ai-sdlc execute. Two modes:

Mode 1 — Sweep leftover worktrees (no arguments)

When $ARGUMENTS is empty, run the same sweep as the dispatch tick (AISDLC-1108), so the manual and the automatic path agree. A worktree is removed when its disposition is one of:

  • remove-merged: its PR is MERGED.
  • remove-closed: its PR is CLOSED and not merged.
  • remove-no-pr: the branch has no PR and the directory is older than the grace window (default 6 h).
  • remove-stale: the PR is OPEN but the branch head has not moved for 14 days.

It keeps keep-inflight (task inflight on the board, or a .active-task sentinel younger than 24 h) and keep-open-pr. PR state is looked up per branch. A dirty tree does not block removal; the untracked paths are logged, git worktree remove --force runs with its exit code checked, and a refusal falls back to rm -rf plus git worktree prune. Branches are never deleted, locally or on origin: only the worktree directory goes, and a resume recreates it from the branch. Also remove the legacy project-level .worktrees/.active-task sentinel if present (superseded by per-worktree sentinels in AISDLC-81).

rm -f .worktrees/.active-task

if [ ! -d .worktrees ]; then
  echo "No .worktrees/ directory — nothing to sweep."
  exit 0
fi

# >>> plugin-root preamble
unset PLUGIN_SCRIPTS_DIR
for _c in "${CLAUDE_PLUGIN_DIR:-}" "${CLAUDE_PLUGIN_ROOT}" "$(pwd)/ai-sdlc-plugin" "$(node -e 'const f=require("fs"),p=require("path"),r=(d)=>{try{return f.realpathSync(d)}catch(e){return d}};try{const g=JSON.parse(f.readFileSync(p.join(require("os").homedir(),".claude/plugins/installed_plugins.json"))).plugins,s=[];for(const k in g)if(k.startsWith("ai-sdlc@"))s.push(...g[k]);const o=[];for(let d=process.cwd(),u;u!==d;d=p.dirname(d)){u=d;for(const e of s)if(e.scope!="user"&&e.scope!="managed"&&e.projectPath&&r(e.projectPath)==d)o.push(e)}for(const e of s)if(e.scope=="user")o.push(e);console.log(o.find((e)=>f.existsSync(e.installPath)).installPath)}catch(e){}' 2>/dev/null)"; do
  [ -n "$_c" ] && [ -d "$_c" ] && PLUGIN_SCRIPTS_DIR="$_c/scripts" && break
done
[ -n "${PLUGIN_SCRIPTS_DIR:-}" ] || { echo "ERROR: plugin not found: set CLAUDE_PLUGIN_DIR or CLAUDE_PLUGIN_ROOT, or install it (see ~/.claude/plugins/installed_plugins.json)" >&2; exit 1; }
# <<< plugin-root preamble
if [ -z "${PIPELINE_CLI_BIN:-}" ]; then
  if [ -f "$PLUGIN_SCRIPTS_DIR/resolve-pipeline-cli.sh" ]; then
    PIPELINE_CLI_BIN=$(bash "$PLUGIN_SCRIPTS_DIR/resolve-pipeline-cli.sh") || { echo "ERROR: @ai-sdlc/pipeline-cli not found; export PIPELINE_CLI_BIN=/path/to/pipeline-cli/bin" >&2; exit 1; }
  else
    PIPELINE_CLI_BIN="$(pwd)/pipeline-cli/bin"
  fi
fi
# Optional preview: node "$PIPELINE_CLI_BIN/cli-hierarchy.mjs" sweep-worktrees --dry-run
node "$PIPELINE_CLI_BIN/cli-hierarchy.mjs" sweep-worktrees

Read the full file on GitHub · 83 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. 10d ago Changed dc136648b8c7
  2. 12d ago Changed · +6 lines 25dc0ba5be69
  3. 26d ago Changed · -3 lines scan A → C cf933d21bc95
  4. 1mo ago Changed · +2 lines 2127cff3d755
  5. 1mo ago Changed · -10 lines 9d1ac7323bd4
  6. 1mo ago Changed 55dcabc323ab
  7. 1mo ago Changed · +11 lines 33a683d58dba
  8. 3mo ago First seen · 77 lines · 30 tokens per session scan A f3495c501981

Subscribe to this mod's changes

cleanup is a command published in the GitHub repository ai-sdlc-framework/ai-sdlc (464 stars, last pushed yesterday), licensed Apache-2.0. It adds 30 tokens to every session and 1,377 once invoked, about $0.0001 per session on Opus 5.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.

Related

cleanup compared with commands from other repositories

cleanup next to 6 commands from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
cleanupai-sdlc-framework/ai-sdlcCommand464yesterdayApache-2.0C30Claude Code
code-reviewGoldziher/ai-rulezCommand1822d agoMITA11Claude Code
repo-audittractorjuice/arc-kitCommand2.3kyesterdaynoneA29Claude Code
evidenceairblackbox/airblackboxCommand259d agoApache-2.0A14Claude Code
releaseGoldziher/ai-rulezCommand1822d agoMITA4Claude Code
shipGoldziher/ai-rulezCommand1822d agoMITA4Claude Code
convergelugassawan/swe-workbenchCommand3todayMITA62Claude Code