LegendaryTeam_For_Claude: Command for Claude Code

.claude/commands/refactor-clean.md

refactor-clean is a command for Claude Code from RegardV/LegendaryTeam_For_Claude. It costs 0 tokens per session (2,861 once invoked), scanned A, original, MIT.

A code-cleaning command that finds and removes unused imports, variables, functions, types, code paths, and dependencies. It can scan without changing files and checks the build and tests after cleanup.

In plain words
What is it for?
Use it to clean the whole codebase or a directory, inspect changes first, remove only imports or dependencies, or perform a more aggressive cleanup.
Why use it?
It removes code that is no longer needed, reducing clutter and unnecessary dependencies while checking that the project still works.

Command for Claude Code

Written for Claude Code: installed under .claude/. Also seen: positional $N argument.

This is RegardV/LegendaryTeam_For_Claude's own configuration. It tells Claude Code how to work on LegendaryTeam_For_Claude itself, so it is not a mod to install elsewhere. Copy it as a starting point and replace the rules that are about this project. Everything LegendaryTeam_For_Claude configures →

Reuse

Borrowing it

Nothing to install: this file belongs to RegardV/LegendaryTeam_For_Claude. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.

Copy the file
curl -O https://raw.githubusercontent.com/RegardV/LegendaryTeam_For_Claude/main/.claude/commands/refactor-clean.md
Clone the repo
git clone --depth 1 https://github.com/RegardV/LegendaryTeam_For_Claude

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

README.md
[![agentmods](https://agentmods.dev/badge/commands/regardv/legendaryteam_for_claude/refactor-clean.svg)](https://agentmods.dev/commands/regardv/legendaryteam_for_claude/refactor-clean)
Your own site
<a href="https://agentmods.dev/commands/regardv/legendaryteam_for_claude/refactor-clean"><img src="https://agentmods.dev/badge/commands/regardv/legendaryteam_for_claude/refactor-clean.svg" alt="Measured on agentmods" height="20"></a>
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,861 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 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.00000 $0.02861
Opus 5 $0.00000 $0.01430
Sonnet 5 $0.00000 $0.00572
Haiku 4.5 $0.00000 $0.00286

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

Security

Grade A, and why

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 8d 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.

.claude/commands/refactor-clean.md · 605 lines

How it starts

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

/refactor-clean - Dead Code & Unused Import Detection

Detect and remove dead code, unused imports, and unnecessary dependencies for cleaner, more maintainable codebase.


Usage

# Scan for and remove all dead code
/refactor-clean

# Scan only (no changes)
/refactor-clean --dry-run

# Clean specific directory
/refactor-clean src/components

# Clean unused imports only
/refactor-clean --imports-only

# Clean unused dependencies
/refactor-clean --deps

# Aggressive mode (removes more aggressively)
/refactor-clean --aggressive

What This Command Does

  1. Scans codebase for unused code
  2. Identifies:
    • Unused imports
    • Unused variables
    • Unused functions
    • Unused types/interfaces
    • Dead code paths
    • Unused dependencies
  3. Removes safely (with verification)
  4. Verifies build and tests still pass
  5. Reports what was removed and why

Command Flow

Step 1: Analyze codebase
  → Scan all source files
  → Identify unused code
  → Categorize by type

Step 2: Plan removals
  → Prioritize safe removals
  → Flag risky removals
  → Create backup plan

Step 3: Execute removals
  → Remove unused imports
  → Remove unused code
  → Update references

Step 4: Verify
  → Run build
  → Run tests
  → Confirm no breakage

Step 5: Report
  → List removed code
  → Calculate savings (LOC, bundle size)
  → Provide statistics

Invokes Agent

@RefactorAgent will handle this command with the following context:

Task: Identify and remove dead code
Mode: ${mode} (default: safe, aggressive, dry-run)

Requirements:
1. Scan codebase for unused code
2. Categorize unused code by type
3. Remove unused code safely
4. Verify build and tests pass after each removal
5. Report removals and impact
6. Rollback if any issues detected

Safety:
- Remove only truly unused code
- Preserve public APIs
- Keep code referenced in tests
- Verify build and tests after changes

Output:
- List of removed code
- Lines of code reduced
- Bundle size impact
- Build/test verification status

Read the full file on GitHub · 605 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. 8d ago First seen · 605 lines · 0 tokens per session scan A fdf148e52a43

Subscribe to this mod's changes

refactor-clean is a command published in the GitHub repository RegardV/LegendaryTeam_For_Claude (19 stars, last pushed 1mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,861 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.