Comprehensive codebase cleanup across 11 quality dimensions: dead code, duplication, weak types, circular deps, defensive cruft, legacy code, AI slop, type consolidation, security, performance, and…

MITAuto-check passedDevelopment

Install Cleanup Code

skills CLI
$ npx skills add jeremylongshore/tons-of-skills-marketplace --skill cleanup-code -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install jeremylongshore/tons-of-skills-marketplace cleanup-code --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/jeremylongshore/tons-of-skills-marketplace.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/.curated/cleanup-code .claude/skills/cleanup-code && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
cleanup-code
GitHub stars
2.8k
Token cost
~1.7k tokens
SKILL.md length
535 words
Files
5 (incl. references)
Skills in repo
3,342
Repo updated
First seen
Licence
MIT

At a glance

Comprehensive codebase cleanup across 11 quality dimensions: dead code, duplication, weak types, circular deps, defensive cruft, legacy code, AI slop, type consolidation, security, performance, and…

  • Works in 5 steps: Safety Checkpoint → Determine Scope → Execute Dimensions → …
  • Codebase has accumulated tech debt
  • SKILL.md covers Environment Detection, Prerequisites, Overview and Instructions, plus 4 more sections
  • Calls git

What it does

Cleanup Code is an agent skill from jeremylongshore/tons-of-skills-marketplace. Comprehensive codebase cleanup across 11 quality dimensions: dead code, duplication, weak types, circular deps, defensive cruft, legacy code, AI slop, type consolidation, security, performance, and async patterns. Analyzes code with confidence scoring and verifies changes with build/test gates. Use when codebase has accumulated tech debt, after major feature work, before releases, or when code quality metrics are declining. Trigger with "/cleanup-code-code", "clean up the codebase", "remove dead code", "fix code…

Its SKILL.md is about 1.7k tokens, which your agent loads only when the skill is triggered. The skill folder holds 5 other files, including reference files (for example `references/dimensions.md`, `references/patterns.md` and `references/safety.md`). Compatibility notes: Designed for Claude Code

It sits in Development, covering Legacy modernization, Code quality and Code simplification. It works with Git. The repository describes itself as: Model-agnostic agent-skills platform with a harness-free canonical layer, verified adapters, and the ccpi package manager. Explore at tonsofskills.com. The licence is MIT.

When your agent uses it

  • Codebase has accumulated tech debt
  • After major feature work
  • Before releases
  • Code quality metrics are declining

Example prompts

  • “/cleanup-code-code”
  • “clean up the codebase”
  • “remove dead code”
  • “/cleanup-code”

Requirements

  • Python 3
  • Node.js
  • Compatibility (from SKILL.md): Designed for Claude Code
  • Pre-approved tools (allowed-tools): Read, Write, Edit, Glob, Grep, Bash(git:*), Bash(npm:*), Bash(npx:*), Bash(pnpm:*), Bash(python3:*), Bash(tsc:*), Bash(wc:*), Bash(ls:*), AskUserQuestion

Workflow steps

5 steps, taken from the step headings in SKILL.md.

  1. Safety Checkpoint
  2. Determine Scope
  3. Execute Dimensions
  4. Build Verification Gate
  5. Generate Report

What it can do on your machine

Read from SKILL.md and the folder at commit 23ea8d4. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves these tools, so the agent can use them without asking each time:

    • Read
    • Write
    • Edit
    • Glob
    • Grep
    • Bash(git:*)
    • Bash(npm:*)
    • Bash(npx:*)
    • Bash(pnpm:*)
    • Bash(python3:*)

    …and 4 more on the same allowed-tools line.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • git

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md. Its commands use git, which can reach the network depending on how they are called.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

  • Compatibility

    Designed for Claude Code

    From compatibility in the SKILL.md frontmatter.

Context cost

Cleanup Code loads about 1.7k tokens when it runs, and up to ~7.5k if it reads all its reference files. Until then it costs about 135 tokens; SKILL.md has 535 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~135
When it runs · the whole SKILL.md, loaded when a task matches
~1.7k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~7.5k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from jeremylongshore/tons-of-skills-marketplace at commit 23ea8d4, republished under its MIT licence (© jeremylongshore). 535 words, ~1,657 tokens.

Download SKILL.mdSave it as .claude/skills/cleanup-code/SKILL.md (or your agent's skills folder). This skill also uses 4 other files; get the full folder from GitHub.
name
cleanup-code
description
Comprehensive codebase cleanup across 11 quality dimensions: dead code, duplication, weak types, circular deps, defensive cruft, legacy code, AI slop, type consolidation, security, performance, and async patterns. Analyzes code with confidence scoring and verifies changes with build/test gates. Use when codebase has accumulated tech debt, after major feature work, before releases, or when code quality metrics are declining. Trigger with "/cleanup-code-code", "clean up the codebase", "remove dead code", "fix code quality".
allowed-tools
Read, Write, Edit, Glob, Grep, Bash(git:*), Bash(npm:*), Bash(npx:*), Bash(pnpm:*), Bash(python3:*), Bash(tsc:*), Bash(wc:*), Bash(ls:*), AskUserQuestion
compatibility
Designed for Claude Code
version
1.7.0
author
Jeremy Longshore <jeremy@intentsolutions.io>
license
MIT
tags
code-quality, cleanup, refactoring, dead-code, deduplication, type-safety, security
argument-hint
[scope] [--dimensions d1,d2,...] [--changed]

Codebase Cleanup

Systematic code cleanup across 11 quality dimensions, ordered by risk. Each finding includes confidence scoring (HIGH/MEDIUM/LOW) and all changes are verified through build/test gates.

Environment Detection

!git rev-parse --show-toplevel 2>/dev/null && echo "---" && git diff --stat HEAD~5 2>/dev/null | tail -5 !ls package.json pyproject.toml Cargo.toml go.mod Makefile 2>/dev/null | head -5 !cat package.json 2>/dev/null | head -3; echo "---"; ls tsconfig.json .eslintrc* 2>/dev/null

Prerequisites

  • Git repository with clean working tree (no uncommitted changes)
  • Language toolchain installed (Node.js/Python/Go/Rust as applicable)
  • Optional: knip, madge, jscpd, ruff, bandit for tool-verified scanning

Overview

This skill orchestrates cleanup across 11 dimensions, each with a dedicated agent. Dimensions are ordered LOW → HIGH risk. See dimensions reference for full detection criteria, verification steps, and risk profiles.

The 11 Dimensions (by risk level):

#DimensionKeyRiskAuto-apply?
1Dead code removaldeadLOWYes (after build)
2AI slop removalslopLOWComments only
3Weak type eliminationtypesMEDYes (after typecheck)
4Security cleanupsecurityMEDFlag only
5Legacy code removallegacyMEDWith confirmation
6Type consolidationtypeconsMEDYes (after typecheck)
7Defensive code cleanupdefensiveMEDFlag only
8Performance optimizationperfMEDFlag only
9DRY deduplicationdryHIGHFlag only (>=10 lines)
10Async pattern fixesasyncHIGHFlag only
11Circular dep untanglingcircularHIGHFlag only

Instructions

Step 1: Safety Checkpoint

Before any changes:

  1. Verify clean git state: git status --porcelain must be empty (or stash changes)
  2. Record baseline: git rev-parse HEAD as rollback point
  3. Run existing tests to confirm green baseline
  4. See safety protocol for revert procedures
Step 2: Determine Scope

Parse user arguments to set scope:

  • Full codebase (default): scan all source files
  • Specific path: cleanup src/api/ — limit to directory
  • Changed files only: --changed flag — git diff --name-only HEAD~10
  • Specific dimensions: --dimensions dead,types,security
  • Single dimension: cleanup --dimensions dry

Exclude from all scans: node_modules/, dist/, build/, .git/, vendor dirs, generated files.

Show full SKILL.md (221 more words)Show less
Step 3: Execute Dimensions

For each selected dimension (in risk order):

  1. Scan using patterns from patterns reference
  2. Score confidence — HIGH (certain, safe to fix), MEDIUM (likely, needs review), LOW (possible, flag only)
  3. Apply or flag based on the dimension's auto-apply policy (see table above)
  4. Verify — run build/typecheck/tests after each dimension with auto-apply

Use tools reference for language-specific tool commands (knip, madge, ruff, jscpd, etc.).

Step 4: Build Verification Gate

After each auto-applied dimension:

text
# TypeScript/JavaScript
npx tsc --noEmit 2>&1 | tail -20
npm test 2>&1 | tail -30

# Python
python3 -m py_compile <changed_files>
python3 -m pytest --tb=short 2>&1 | tail -30

# General
git diff --stat  # Show what changed

If verification fails, revert that dimension: git checkout -- .

Step 5: Generate Report

Produce a cleanup report in this format:

## Cleanup Report

**Scope:** [path or "full codebase"]
**Baseline:** [commit hash]
**Dimensions:** [list of dimensions run]

### Summary
| Dimension | Findings | Applied | Flagged | Confidence |
|-----------|----------|---------|---------|------------|
| dead      | 12       | 10      | 2       | HIGH       |
| types     | 8        | 8       | 0       | HIGH       |
| security  | 3        | 0       | 3       | MEDIUM     |

### Changes Applied
- [file:line] description of change

### Flagged for Review
- [file:line] description + reasoning + suggested fix

### Lines Removed: N | Lines Modified: N | Files Touched: N

Output

A structured cleanup report containing:

  • Summary table with findings per dimension (count, applied, flagged, confidence)
  • List of changes applied with file:line references
  • List of flagged items with reasoning and suggested fixes
  • Stats: lines removed, lines modified, files touched

Error Handling

ErrorRecovery
Dirty git stateAsk user to commit or stash first
Build fails after cleanupgit checkout -- . to revert dimension
No test command foundSkip verification, flag all as "unverified"
Tool not installedFall back to grep patterns (see references/patterns.md)
Confidence unclearDefault to flag-only, never auto-apply

Examples

Full cleanup:

/cleanup-code

Security-focused:

/cleanup-code --dimensions security,async

Changed files only:

/cleanup-code src/api/ --changed

Single dimension deep-dive:

/cleanup-code --dimensions dead

Resources

© jeremylongshore, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 4 other files (references) in skills/.curated/cleanup-code of jeremylongshore/tons-of-skills-marketplace.

  • SKILL.md
  • references/dimensions.md
  • references/patterns.md
  • references/safety.md
  • references/tools.md

Open the folder on GitHubat commit 23ea8d4

Compare with similar skills

Cleanup Code next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Cleanup Code compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Cleanup Code this skilljeremylongshore/tons-of-skills-marketplace2.8k—~1.7kAutomated safety check: PassMIT
Code Refactoring Workflowluongnv89/claude-howto42k—~3.1kAutomated safety check: PassMIT
Codebase Health Refactoringkucherenko/jscpd6.4k—~2.5kAutomated safety check: PassMIT
DRY Refactoring With jscpdkucherenko/jscpd6.4k—~2.1kAutomated safety check: PassMIT
Fowler-Style Refactoringlhfer/claude-howto-zh-cn2.3k—~156Automated safety check: PassMIT
Tech Debt Auditcode-yeongyu/oh-my-openagent70k—~2.4kAutomated safety check: NotesCustom licence

Similar skills

  • Code Refactoring Workflow

    luongnv89/claude-howto

    Guides systematic, test-backed refactoring in the style of Martin Fowler, moving through research, planning and small incremental changes with your approval at each phase.

    42k GitHub stars~3.1k tokensUpdated 7 days ago
    DevelopmentAuto-check passed
  • A three-part cleanup guided by jscpd: measure health, then fix duplicated code, remove dead code and simplify the most complex files, finishing by re-measuring the score.

    6.4k GitHub stars~2.5k tokensUpdated today
    DevelopmentAuto-check passed
  • Removes copy-paste duplication found by jscpd, starting with exact clones and hotspots, then renamed and near-miss copies, using proven refactoring strategies.

    6.4k GitHub stars~2.1k tokensUpdated today
    DevelopmentAuto-check passed
  • Fowler-Style Refactoring

    lhfer/claude-howto-zh-cn

    基于 Martin Fowler 方法论做系统化重构。Use when users ask to refactor code, improve structure, reduce technical debt, clean up legacy code, or improve maintainability.

    2.3k GitHub stars~156 tokensUpdated 2 mo ago
    DevelopmentAuto-check passed
  • Tech Debt Audit

    code-yeongyu/oh-my-openagent

    Audits a codebase for technical debt across nine dimensions and writes TECH_DEBT_AUDIT.md with file-cited findings, severity, effort estimates and priorities.

    70k GitHub stars~2.4k tokensUpdated today
    DevelopmentAuto-check: notes
  • Code Simplifier

    TwiTech-LAB/devchain

    Review a change set for reuse, simplification, efficiency, and altitude problems, then apply the fixes while preserving exact behavior.

    101 GitHub stars~2k tokensUpdated yesterday
    DevelopmentAuto-check passed

More from jeremylongshore/tons-of-skills-marketplace

All 3,342 skills in this repo
  • Performing Security Code Review

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill enables AI assistant to conduct a security-focused code review using the security-agent plugin.

    2.8k GitHub starsUsed in 2 repos~1.3k tokens
    Auto-check: notes
  • Analyzing Text With NLP

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill enables AI assistant to perform natural language processing and text analysis using the nlp-text-analyzer plugin.

    2.8k GitHub starsUsed in 1 repo~819 tokens
    Auto-check passed
  • Building Neural Networks

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill allows AI assistant to construct and configure neural network architectures using the neural-network-builder plugin.

    2.8k GitHub starsUsed in 1 repo~1k tokens
    Auto-check passed
  • Detecting Data Anomalies

    jeremylongshore/tons-of-skills-marketplace

    Process identify anomalies and outliers in datasets using machine learning algorithms.

    2.8k GitHub starsUsed in 1 repo~1.4k tokens
    Auto-check passed
  • Explaining Machine Learning Models

    jeremylongshore/tons-of-skills-marketplace

    Build this skill enables AI assistant to provide interpretability and explainability for machine learning models.

    2.8k GitHub starsUsed in 1 repo~1k tokens
    Auto-check passed
  • Optimizing Prompts

    jeremylongshore/tons-of-skills-marketplace

    Execute this skill optimizes prompts for large language models (llms) to reduce token usage, lower costs, and improve performance.

    2.8k GitHub starsUsed in 1 repo~1k tokens
    Auto-check passed

Works with

Categories

Questions about Cleanup Code

What does Cleanup Code do?

Comprehensive codebase cleanup across 11 quality dimensions: dead code, duplication, weak types, circular deps, defensive cruft, legacy code, AI slop, type consolidation, security, performance, and…. Cleanup Code is an agent skill from jeremylongshore/tons-of-skills-marketplace. Comprehensive codebase cleanup across 11 quality dimensions: dead code, duplication, weak types, circular deps, defensive cruft, legacy code, AI slop, type consolidation, security, performance, and async patterns.

When should I use Cleanup Code?

Cleanup Code fits situations like: codebase has accumulated tech debt; after major feature work; before releases; code quality metrics are declining.

How do I install Cleanup Code in Claude Code?

Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill cleanup-code -a claude-code`. Or copy the skill folder (skills/.curated/cleanup-code in jeremylongshore/tons-of-skills-marketplace) into .claude/skills/cleanup-code in your project. Claude Code loads it when a task matches its description.

How do I install Cleanup Code in Codex?

Run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill cleanup-code -a codex`. Or copy the skill folder (skills/.curated/cleanup-code in jeremylongshore/tons-of-skills-marketplace) into .agents/skills/cleanup-code in your project. Codex loads it when a task matches its description.

Can I use Cleanup Code in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add jeremylongshore/tons-of-skills-marketplace --skill cleanup-code -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/cleanup-code, .gemini/skills/cleanup-code, .github/skills/cleanup-code and .opencode/skills/cleanup-code in your project.

What does Cleanup Code need to run?

Going by SKILL.md and its folder, Cleanup Code needs the command-line tools its instructions call (git). Our summary lists: Python 3; Node.js. Its frontmatter pre-approves these tools: Read, Write, Edit, Glob, Grep, Bash(git:*), Bash(npm:*), Bash(npx:*), Bash(pnpm:*), Bash(python3:*), Bash(tsc:*), Bash(wc:*), Bash(ls:*), AskUserQuestion. Compatibility (from SKILL.md): Designed for Claude Code.

Does Cleanup Code access the network?

SKILL.md contains no URLs. Its commands use git, which can reach the network depending on how they are called. This is read from the text; nothing was executed.

Is Cleanup Code safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Cleanup Code use?

Cleanup Code is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Cleanup Code use?

About 1.7k tokens (SKILL.md is roughly 6.6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 5.9k tokens, read only when the agent opens those files.

What are the alternatives to Cleanup Code?

Skills that share tags, products or a category with Cleanup Code: Code Refactoring Workflow (luongnv89/claude-howto, 42k stars), Codebase Health Refactoring (kucherenko/jscpd, 6.4k stars), DRY Refactoring With jscpd (kucherenko/jscpd, 6.4k stars) and Fowler-Style Refactoring (lhfer/claude-howto-zh-cn, 2.3k stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Cleanup Code?

jeremylongshore (a GitHub user) maintains it in jeremylongshore/tons-of-skills-marketplace, which has 2,821 GitHub stars. The repository holds 3,342 skills in this directory. The repository was last updated on October 8, 2026.

Source: jeremylongshore/tons-of-skills-marketplace on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.