Claude-skill-registry code-cleanup

install
source · Clone the upstream repo
git clone https://github.com/majiayu000/claude-skill-registry
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/code-cleanup" ~/.claude/skills/majiayu000-claude-skill-registry-code-cleanup-d550fc && rm -rf "$T"
manifest: skills/data/code-cleanup/SKILL.md
source content

Code Cleanup Skill

Scan projects for redundant code and generate cleanup reports.

Quick Start

# Scan for dead code (unused imports, functions, variables)
python scripts/scan_dead_code.py backend/

# Scan for stale code (old TODOs, debug statements, commented code)
python scripts/scan_stale_code.py src/

# Check unused dependencies
python scripts/scan_unused_deps.py .

Scripts

ScriptDetectsConfidence
scan_dead_code.pyUnused imports, functions, classes, variablesHigh
scan_stale_code.pyCommented code, old TODOs, debug statementsMedium
scan_unused_deps.pyUnused packages in requirements.txt/package.jsonLow

Usage

scan_dead_code.py

python scripts/scan_dead_code.py <dir> [--format json|text] [--ignore "test_*"]

Detects:

  • Unused imports (high confidence, safe to remove)
  • Unused functions/classes not starting with
    _
    (medium confidence)
  • Unused top-level variables (medium confidence)

scan_stale_code.py

python scripts/scan_stale_code.py <dir> [--todo-days 90] [--no-debug]

Detects:

  • Commented-out code blocks
  • TODOs/FIXMEs older than N days (default: 90)
  • Debug statements:
    print(
    ,
    console.log(
    ,
    debugger
    ,
    pdb

scan_unused_deps.py

python scripts/scan_unused_deps.py <dir> [--type python|node|all]

Checks:

  • requirements.txt vs actual imports
  • package.json dependencies vs actual imports

Output Format

All scripts output JSON by default:

{
  "target": "backend/",
  "issues": [
    {
      "type": "unused_import",
      "file": "services/user.py",
      "line": 3,
      "code": "import os",
      "confidence": "high",
      "suggestion": "Remove unused import: os"
    }
  ],
  "summary": {
    "total": 15,
    "high": 10,
    "medium": 5,
    "low": 0
  }
}

Confidence Levels

LevelMeaningAction
highDefinitely unusedSafe to remove
mediumLikely unusedReview before removing
lowPossibly unusedManual inspection needed

Cleanup Workflow

  1. Run scan scripts on target directory
  2. Review JSON output, filter by confidence
  3. For each issue: remove, keep, or defer
  4. Apply changes (Claude can help edit files)
  5. Run tests to verify nothing broke

Safety Notes

  • Scripts are read-only (scan only, no modifications)
  • Always backup before bulk cleanup
  • Run tests after cleanup
  • Some "unused" code may be used dynamically (reflection,
    __getattr__
    , lazy imports)
  • Ignore
    __init__.py
    re-exports

References

  • Detection patterns:
    references/detection-patterns.md
  • Cleanup examples:
    references/cleanup-examples.md