Help us improve
Share bugs, ideas, or general feedback.
From code-slimming-cleanup-skill
Code slimming and cleanup guidelines. Use when reducing code size, removing dead code, simplifying abstractions, consolidating duplicate logic, or cleaning up after refactors while avoiding risky drive-by changes.
npx claudepluginhub gaopengbin/code-slimming-cleanup-skillHow this skill is triggered — by the user, by Claude, or both
Slash command
/code-slimming-cleanup-skill:code-slimming-cleanupThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
Guidelines for safely making code smaller, simpler, and cleaner without turning cleanup into an uncontrolled refactor.
Provides UI/UX resources: 50+ styles, color palettes, font pairings, guidelines, charts for web/mobile across React, Next.js, Vue, Svelte, Tailwind, React Native, Flutter. Aids planning, building, reviewing interfaces.
Fetches up-to-date documentation from Context7 for libraries and frameworks like React, Next.js, Prisma. Use for setup questions, API references, and code examples.
Explores codebases via GitNexus: discover repos, query execution flows, trace processes, inspect symbol callers/callees, and review architecture.
Share bugs, ideas, or general feedback.
Guidelines for safely making code smaller, simpler, and cleaner without turning cleanup into an uncontrolled refactor.
Tradeoff: This skill favors safe, scoped cleanup over aggressive rewrites. If broader cleanup is needed, get explicit approval first.
Follow this order to avoid wasted work and ensure nothing is missed:
node_modules/. Skip them from all subsequent steps..gitignore, tracked build output, misplaced dependencies.package.json entries against actual imports in source.For small projects (< 500 total source lines), skip steps 3-4 and only perform hygiene, dead code, and dependency checks. In the report, omit the Duplicates and Oversized files categories entirely rather than including empty sections.
Every finding must be tagged with a severity:
| Level | Meaning | Examples |
|---|---|---|
| Critical | Wastes significant resources or blocks correct operation | Missing .gitignore with 300MB+ tracked artifacts; committed secrets |
| Warning | Maintenance burden or code smell that should be fixed soon | 100+ lines of exact duplication; file > 800 lines; unused dependency |
| Info | Worth noting but low urgency | File approaching 400 lines; 3-line utility duplicated twice; dependency that could move to devDependencies |
Order findings by severity in the report. Critical items first.
Never analyze or report generated files as cleanup candidates.
Before scanning, identify and skip:
dist/, build/, dist-electron/, .next/, .output/, out/)assets/bundle.js).exe, .dll, .asar, .pak, .bin)node_modules/, vendor/, lock filesInstead, flag missing .gitignore rules if these artifacts are tracked in version control. The fix is a .gitignore entry, not deleting the files manually.
Name what kind of cleanup is being performed before editing.
Classify the task as one of:
If the task may affect behavior, public APIs, data formats, migrations, or external contracts, stop and confirm the scope.
Slimming means less code, not more structure.
When simplifying:
Ask: "Did this change reduce the amount of code a future reader must understand?"
Do not delete code based on vibes.
Before removing existing code, verify at least one of:
If unsure, mention the suspected dead code instead of deleting it.
Identical logic repeated across files is a maintenance liability, not just a style issue.
Detection strategy:
When scanning for duplication:
Runtime boundary awareness: If duplication exists because of browser/Node isolation (e.g., browser code cannot import a Node module that uses fs or zlib), do NOT recommend "just import the Node version." Instead:
Report duplicates with: function name, file locations, line counts, and whether they are exact or near-matches.
Large files are harder to review, test, and maintain.
Flag files that exceed these thresholds:
| Metric | Warning | Action required |
|---|---|---|
| Single file lines | > 400 | Flag for review |
| Single file lines | > 800 | Recommend splitting |
| Single function lines | > 80 | Flag for extraction |
| Single function lines | > 150 | Recommend splitting |
When recommending a split:
Unused or redundant dependencies add install time, attack surface, and bundle size.
Check for:
dependencies or devDependencies not imported anywhere in source.lodash.get when optional chaining suffices).dependencies that should be devDependencies (build tools, test frameworks, bundlers).Classifying dependencies vs devDependencies:
imported or required at runtime → dependencies.devDependencies.dist/) are referenced by a bundler config (pkg.assets, build.files, copy-webpack-plugin) → it must stay in dependencies for the bundler to resolve it. Do not move it to devDependencies.Tools: npx depcheck, npx knip, or manual grep for package names in src/.
For non-Node projects, substitute equivalent tooling: Python → pip-check/vulture; Go → go mod tidy/staticcheck; Rust → cargo-udeps. The dependency rules apply to the equivalent manifest file (e.g., requirements.txt, go.mod, Cargo.toml).
Tracked files that should be ignored waste repo size and cause noise.
Flag if any of these are committed:
dist/, build/, dist-electron/, .next/, .output/, out/)assets/bundle.js when npm run build generates it).DS_Store, Thumbs.db, .idea/, .vscode/ with user-specific settings).env, *.pem, credentials.json)Recommend adding a .gitignore if one is missing. If artifacts are already tracked, note that git rm --cached is needed to stop tracking without deleting local files.
Do not turn cleanup into a drive-by refactor.
Allowed:
Avoid unless explicitly requested:
The test: every deleted or changed line should have a clear reason tied to the cleanup goal.
A slimming PR should usually be behavior-preserving.
Before and after cleanup:
If the cleanup intentionally changes behavior, state that clearly and treat it as a feature or bug-fix change, not pure cleanup.
When finishing, output findings in this structure:
### [Severity] Category heading
| Location | Lines | Issue | Suggestion |
|----------|-------|-------|------------|
| file:line | N | description | action |
Group by severity (Critical → Warning → Info), then by category within each severity.
Required categories in the report (omit any category with no findings rather than including an empty section):
.gitignore, tracked build artifacts, misplaced dependencies.End with a one-line summary quantifying the total impact, e.g.:
Summary: 3 critical, 5 warning, 2 info. Estimated reduction: ~320 source lines + 380 MB tracked artifacts.
Good cleanup leaves reviewers confident that less code now does the same job.