ccc-refactor-clean

ccc-refactor-clean is a command for Claude Code from KevinZai/commander. It costs 43 tokens per session (1,230 once invoked), scanned A, a copy of refactor-clean, MIT.

A guided process for finding unused code and removing it with tests run after each deletion.

In plain words
What is it for?
Use it to find unused files, exports, dependencies, utilities, components, routes, and other potentially dead code.
Why use it?
It reduces clutter while checking that removing code has not broken the project. It also separates safer findings from areas that need more investigation.

Command for Claude Code

Written for Claude Code: $ARGUMENTS substitution. Also seen: names the AskUserQuestion tool; positional $N argument; mentions Codex.

Good fit Use it to find unused files, exports, dependencies, utilities, components, routes, and other potentially dead code.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/kevinzai/commander/ccc-refactor-clean
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.

Clone the repo
git clone --depth 1 https://github.com/KevinZai/commander

Made for: Claude Code.

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 ccc-refactor-clean

README.md
[![agentmods](https://agentmods.dev/badge/commands/kevinzai/commander/ccc-refactor-clean/github.svg)](https://agentmods.dev/commands/kevinzai/commander/ccc-refactor-clean)
Your own site
<a href="https://agentmods.dev/commands/kevinzai/commander/ccc-refactor-clean"><img src="https://agentmods.dev/badge/commands/kevinzai/commander/ccc-refactor-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 ccc-refactor-clean

Your own site · 80×15
<a href="https://agentmods.dev/commands/kevinzai/commander/ccc-refactor-clean"><img src="https://agentmods.dev/badge/commands/kevinzai/commander/ccc-refactor-clean.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 43 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,230 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin 89% copy Near-identical to another mod 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.00043 $0.01230
Opus 5.5 $0.00017 $0.00492
Sonnet 5.5 $0.00009 $0.00246
Haiku 4.5 $0.00004 $0.00123

Measured 5d ago against content hash 4bd808bfa585, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

ccc-refactor-clean scanned grade A with 0 findings 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 5d 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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

89% identical to refactor-clean — 135 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

commands/ccc-refactor-clean.md · 98 lines

How it starts

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

/ccc-refactor-clean — remove dead code under test

CC Commander · /ccc-refactor-clean · detects dead code, sorts it by risk, deletes the safe items one at a time with a green test run after each, and reports what was removed.

Arguments

$ARGUMENTS: optional path to limit the scan. Default: the repository root.

What happens

  1. Check the starting state.

    git status --porcelain
    

    A revert in step 5 restores files from HEAD, which would discard uncommitted edits. If the tree is dirty, ask with AskUserQuestion (Codex: plain-text question):

    • 🟢 Stop so I can commit first — nothing is changed.
    • Continue on clean files only — files with uncommitted changes are excluded from deletion.
  2. Name the test command and establish a baseline. Use the project's own script first (npm test, pnpm test, pytest, go test ./..., cargo test, or the Makefile/justfile target). Run it. If the baseline is not green, report the failures and stop; dead-code removal needs a passing suite to prove anything.

  3. Detect dead code with the tools that fit the stack and are available (run through npx only when the project already uses npm):

    Tool Finds Command
    knip Unused exports, files, dependencies npx knip
    depcheck Unused npm dependencies npx depcheck
    ts-prune Unused TypeScript exports npx ts-prune
    vulture Unused Python code vulture <src>
    deadcode Unused Go code deadcode ./...
    cargo-udeps Unused Rust dependencies cargo +nightly udeps

    If no tool is available, find exported names and count their references:

    rg --no-filename -o -r '$1' '^export (?:const|function|class|type|interface) (\w+)' <path> | sort -u
    rg -n --fixed-strings '<name>' --glob '!<defining-file>' <path>
    

    A name with zero references outside its defining file is a candidate.

  4. Categorize every finding:

    Tier Examples Action
    SAFE Unused utilities, test helpers, internal functions Delete in the loop below
    CAUTION Components, API routes, middleware Run the CAUTION checks in step 6 first
    DANGER Config files, entry points, type definitions, public package API Report only; do not delete

Read the full file on GitHub · 98 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. 5d ago Changed · +13 lines · +29 tokens per session 4bd808bfa585
  2. 1mo ago First seen · 85 lines · 14 tokens per session scan A faf32cd5e23a

Subscribe to this mod's changes

ccc-refactor-clean is a command published in the GitHub repository KevinZai/commander (6 stars, last pushed today), licensed MIT. It adds 43 tokens to every session and 1,230 once invoked, about $0.0002 per session on Opus 5.5. A static security scan graded it A with 0 findings. It is 89% identical to refactor-clean, differing in 135 lines, and is treated as a copy.