clean

A codebase cleanup command that finds work, documents, and code that no longer belong to the project's active development path.

In plain words
What is it for?
Use it to scan for stale workflow sessions, abandoned documents, and dead code; preview low-risk cleanup; or remove selected items with confirmation.
Why use it?
It helps identify abandoned or outdated material before removing it, while offering a preview and confirmation for cleanup actions.

Command for Claude Code

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/catlog22/claude-code-workflow/clean
Clone the repo
git clone --depth 1 https://github.com/catlog22/Claude-Code-Workflow

Made for: Claude Code.

Per session 18 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 4,287 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.00018 $0.04287
Opus 5 $0.00009 $0.02143
Sonnet 5 $0.00004 $0.00857
Haiku 4.5 $0.00002 $0.00429

Measured 2d ago against content hash 83103388495e, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, 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 2d 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({ command: `rm -rf "${item.path}"` })
.claude/commands/workflow/clean.md · 573 lines

How it starts

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

Clean Command (/workflow:clean)

Overview

Intelligent cleanup command that explores the codebase to identify the development mainline, discovers artifacts that have drifted from it, and safely removes stale sessions, abandoned documents, and dead code.

Core capabilities:

  • Mainline detection: Identify active development branches and core modules
  • Drift analysis: Find sessions, documents, and code that deviate from mainline
  • Intelligent discovery: cli-explore-agent based artifact scanning
  • Safe execution: Confirmation-based cleanup with dry-run preview

Usage

/workflow:clean                          # Full intelligent cleanup (explore → analyze → confirm → execute)
/workflow:clean --yes                    # Auto mode (use safe defaults, no confirmation)
/workflow:clean --dry-run                # Explore and analyze only, no execution
/workflow:clean -y "auth module"         # Auto mode with focus area

Auto Mode Defaults

When --yes or -y flag is used:

  • Categories to Clean: Auto-selects ["Sessions"] only (safest - only workflow sessions)
  • Risk Level: Auto-selects "Low only" (only low-risk items)
  • All confirmations skipped, proceeds directly to execution

Flag Parsing:

const autoYes = $ARGUMENTS.includes('--yes') || $ARGUMENTS.includes('-y')
const dryRun = $ARGUMENTS.includes('--dry-run')

Execution Process

Phase 1: Mainline Detection
   ├─ Analyze git history for development trends
   ├─ Identify core modules (high commit frequency)
   ├─ Map active vs stale branches
   └─ Build mainline profile

Phase 2: Drift Discovery (cli-explore-agent)
   ├─ Scan workflow sessions for orphaned artifacts
   ├─ Identify documents drifted from mainline
   ├─ Detect dead code and unused exports
   └─ Generate cleanup manifest

Phase 3: Confirmation
   ├─ Display cleanup summary by category
   ├─ Show impact analysis (files, size, risk)
   └─ AskUserQuestion: Select categories to clean

Phase 4: Execution (unless --dry-run)
   ├─ Execute cleanup by category
   ├─ Update manifests and indexes
   └─ Report results

Read the full file on GitHub · 573 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. 2d ago First seen · 573 lines · 18 tokens per session scan C 83103388495e

Subscribe to this mod's changes

clean is a command published in the GitHub repository catlog22/Claude-Code-Workflow (2,135 stars, last pushed 2mo ago), licensed MIT. It adds 18 tokens to every session and 4,287 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.