lean-code-cleanup

$npx mdskill add huggingface/paperswithcode/lean-code-cleanup

This skill helps make a codebase smaller, clearer, and easier to change. The goal is not to chase clever minimalism; it is to remove code whose purpose is gone, duplicated, speculative, unreachable, or much more complex than the current product needs.

SKILL.md

.github/skills/lean-code-cleanupView on GitHub ↗
---
name: lean-code-cleanup
description: Find and remove code that makes a codebase larger or harder to maintain without adding value. Use this skill whenever the user asks to clean up code, make code leaner or more concise, reduce bloat, remove unused or obsolete code, simplify overbuilt implementations, prune stale compatibility paths, or run a regular cleanup pass across a repo or folder. Trigger even if the user phrases it casually, such as "tidy this up", "trim dead code", "make this less bloated", or "look for stuff we can delete".
---

# Lean Code Cleanup

This skill helps make a codebase smaller, clearer, and easier to change. The goal is not to chase clever minimalism; it is to remove code whose purpose is gone, duplicated, speculative, unreachable, or much more complex than the current product needs.

## Cleanup Philosophy

Prefer boring, evidence-backed reductions:

- Delete code only when you can explain why it is unused, obsolete, duplicated, or safely replaceable.
- Simplify code when the simpler version preserves behavior and matches the local style.
- Keep public contracts, persisted data, migrations, operational scripts, and compatibility paths unless the user has made it clear they no longer matter.
- Avoid broad rewrites during cleanup passes. A small clean diff is better than a heroic refactor that mixes risk with deletion.
- Treat untracked generated files, logs, caches, and local outputs differently from source code. They may be local noise rather than committed bloat.

## First Pass

Start by understanding the target scope:

1. Identify the folder, package, feature area, or file set the user wants cleaned.
2. Check the git working tree before edits. If files are already modified, assume those changes belong to the user and work around them.
3. Map the main entry points and ownership boundaries before deciding code is dead.
4. Separate candidates into:
   - **Source cleanup**: unused functions, duplicate wrappers, obsolete branches, stale examples, uncalled helpers.
   - **Generated/local noise**: logs, outputs, caches, build artifacts, pycache, vendored dumps.
   - **Risky historical code**: migrations, one-off database scripts, public API compatibility, data import tools.

For broad repo exploration, use a read-only exploration subagent when available. Ask it for evidence, not just opinions.

## Evidence Checklist

Before deleting code, gather at least two relevant signals when practical:

- Exact reference search for the symbol, route, script name, or file path.
- Import graph or entry-point check.
- Tests or docs that cover the replacement path.
- Runtime registration check, such as router inclusion, CLI command registration, cron workflow references, package exports, or config references.
- Git tracking check for artifacts that look generated.
- Linter or dead-code detector output, treated as a hint rather than proof.

If evidence is mixed, keep the code and report it as a candidate instead of deleting it.

## What To Clean Up

Good regular-cleanup targets:

- Unused imports, variables, helper parameters, and private functions.
- Duplicate wrappers that call a richer canonical path with fewer options.
- Stale example scripts that are not referenced by docs, tests, CI, or workflows.
- Old compatibility code for unshipped branch work.
- Repeated inline logic that already has a local helper.
- Comments that narrate obvious code or document behavior that no longer exists.
- Defensive fallback branches that cannot happen under current invariants.
- Generated files that are accidentally tracked, after confirming they are not intentional fixtures.

Be cautious with:

- Database migrations and data repair scripts.
- Public API endpoints and response fields.
- CLI scripts called by cron, deployment, or docs.
- Test fixtures and snapshots.
- Legacy data importers when the repo still documents them.
- Backwards compatibility for shipped behavior.

## Editing Workflow

Use this order:

1. Make a short candidate list with evidence and risk level.
2. Pick the lowest-risk candidates first.
3. Edit narrowly. Prefer deleting a whole unused file, function, endpoint wrapper, or parameter over reshaping unrelated code.
4. Preserve user changes in dirty files. If cleanup touches an already-modified file, inspect the diff first and edit only around the target.
5. After edits, search for deleted symbols and paths again.
6. Run the cheapest meaningful checks:
   - Linter for edited files.
   - Compile/typecheck for edited language when available.
   - Focused tests for affected behavior.
7. If a relevant test tool is missing, say so and include the checks that did run.

## Reporting Back

Keep the report concise and action-oriented:

- State what was removed or simplified.
- Mention anything intentionally left alone because it was too risky or still referenced.
- List verification commands and results.
- If further cleanup remains, give a short candidate list with risk levels.

Do not create standalone summary markdown files unless the user explicitly asks for documentation.

## Regular Cleanup Cadence

When the user says they want to run this regularly, default to a conservative maintenance pass:

1. Scan for newly introduced local/generated clutter.
2. Check for obvious unused code in the requested area.
3. Remove only low-risk items.
4. Leave a concise note of higher-risk candidates for a later, explicit cleanup pass.

This keeps routine cleanup cheap and prevents it from becoming a surprise refactor.

More from huggingface/paperswithcode

SkillDescription
add-benchmarkAdd or update benchmark datasets/leaderboards in the paperswithcode repo database. Use this whenever the user asks to add a benchmark, add a leaderboard, set default/featured benchmarks for a task, link benchmarks to tasks, add Accuracy or other metrics for a benchmark, or fix benchmark source links. This is repo-specific and should trigger even if the user only names benchmark titles and a task page.
add-conferenceAdd or update conference rows in the paperswithcode repo database. Use this whenever the user asks to add a conference, create a conference page, import accepted papers for a venue (CVPR, ICLR, NeurIPS, ICML, ICRA, etc.), set conference dates/venue/description/hero image, or link papers to a conference edition. Trigger even for casual phrasing like "add CVPR 2027", "create the ICLR 2026 page", "import conference papers from this CSV", or "set the conference thumbnail".
add-evalsAdd evaluation results to the paperswithcode database from any source — Hugging Face model cards, arXiv/HF/PapersWithCode paper text, or GitHub repository READMEs — restricted to benchmarks that already exist with a task association and the exact leaderboard metric already configured. Use this whenever the user shares a Hugging Face model URL or repo id, an arXiv id / HF paper / PapersWithCode paper, a GitHub repository URL, or a model release page and asks to add evaluation results, benchmark scores, or leaderboard entries — even when phrased casually like "add scores from this model", "import benchmarks from <hf url>", "ingest the eval table from this paper into the DB", "grab the benchmarks from this repo's README", or "add evaluations for this release". By default import only the model(s) the source paper introduces — never post comparison-table baselines onto other papers as external evals unless the user explicitly asks. If the source is not backed by an arXiv paper, first use the add-external-paper skill to create or update the `source = 'external'` paper row, then attach evaluation rows to that paper. This skill must skip source-only metrics, component scores, subscores, and alternate metric labels unless that metric is already configured for the exact leaderboard; use it instead of generic ingestion guidance whenever the user is trying to populate evaluation results from a model, paper, or repository source.
add-external-paperAdd non-ArXiv external papers/resources to the paperswithcode repo database. Use this whenever the user asks to add, index, submit, or populate a paper/resource/release that does not have an arXiv paper, including Hugging Face model cards, GitHub repositories, blog posts, vendor technical reports, external PDFs, project pages, or release announcements. This skill should trigger even when the user casually says "add this repo/model/blog to paperswithcode" or gives a URL such as GitHub, Hugging Face, a company blog, a PDF, or a technical report and wants it to appear as a paper page with tasks, methods, code, project links, HF artifacts, and a thumbnail.
add-methodAdd or update AI/ML method taxonomy rows in the paperswithcode repo database. Use this whenever the user asks to add a method, technique, architecture, attention mechanism, training method, model-family method, or source/visual metadata for a method; says phrases like "make GPT-4 a method", "add X as a method", "similarly add this method", "link papers that cite the source paper", or "update the method source to point to the paper page"; or gives a method name plus a paper, arXiv id, PapersWithCode URL, Hugging Face report, GitHub explainer, blog post, or image for the method thumbnail.
add-taskAdd or update AI/ML task taxonomy rows in the paperswithcode repo database. Use this whenever the user asks to add a task, create a new benchmark category, add a subtask under an existing task, set task description/keywords/area/image, or expand task coverage; says phrases like "add X as a task", "create a task page for", "similarly add this task", or "we need a task for"; or names a research area (ASR, object detection, agents, tabular learning) that should become a browsable /tasks/ page with keywords and a hero image. After adding the task, recommend standard benchmarks to link next (use add-benchmark when the user wants them ingested).
complete-task>-
complete-task-based-on-hfComplete or audit a Papers With Code task using Hugging Face model popularity as the discovery signal. Use this whenever a user asks to scan the most downloaded or trending Hugging Face models for a pipeline/task, resolve their canonical technical reports, and add missing paper-native evaluations to existing Papers With Code benchmarks. Trigger for requests like "complete this task from HF", "check popular Hub models for missing evals", or a Hugging Face models URL with `pipeline_tag` and `sort`; use `add-evals` instead for one already-known model or paper, and `complete-task-v2` for a holistic field survey beyond Hugging Face.
complete-task-v2>-
create-thumbnailCreate, replace, audit, and publish Papers With Code paper thumbnails for one paper or every paper on a benchmark page. Use this whenever a user asks to add a thumbnail, fix an "Untitled resource" card, use artwork from a source/project/GitHub README, regenerate a paper preview, or find papers on a benchmark with missing, generic, stale, or broken thumbnails. This is the repo-specific end-to-end workflow for source selection, portrait composition, cache-safe publication, and live visual verification.