← Back to list

cleanup-patterns
by Linaqruf
Claude Code plugins
⭐ 0🍴 0📅 Jan 19, 2026
SKILL.md
name: cleanup-patterns description: This skill should be used when the user asks about "code cleanup", "remove unused", "dead code", "unused imports", "dependency audit", "technical debt", "refactoring", "codebase maintenance", "orphaned files", "unused assets", or wants guidance on identifying and removing unused code, imports, dependencies, or assets. version: 1.0.0
Cleanup Patterns
Comprehensive patterns and strategies for cleaning up TypeScript/JavaScript codebases. This skill provides guidance on identifying unused code, assets, and dependencies to reduce technical debt and improve maintainability.
Quick Reference
Cleanup Commands
| Task | Command | Agent |
|---|---|---|
| Find unused imports | /cleanup imports | import-analyzer |
| Find dead code | /cleanup deadcode | dead-code-detector |
| Find unused assets | /cleanup assets | asset-tracker |
| Audit dependencies | /cleanup deps | dependency-auditor |
| Clean configs | /cleanup configs | config-cleaner |
| Full analysis | /cleanup all | All agents |
Detection Tools
| Tool | Purpose | Install |
|---|---|---|
| TypeScript | Unused locals/params | Built-in with tsc |
| ESLint | Unused vars, unreachable code | npm install eslint |
| depcheck | Unused npm packages | npm install -g depcheck |
| madge | Circular dependencies | npm install -g madge |
| ts-prune | Unused exports | npx ts-prune |
Import Cleanup
Common Import Issues
- Unused imports - Imported but never referenced
- Duplicate imports - Same module imported multiple times
- Circular imports - Module A imports B, B imports A
- Side-effect only imports - Execute code but export nothing
Detection Strategy
# TypeScript compiler check
npx tsc --noEmit --noUnusedLocals
# ESLint with unused-imports plugin
npx eslint . --rule 'no-unused-vars: error'
# Circular dependency detection
npx madge --circular --extensions ts,tsx src/
Quick Fixes
// Before: Multiple unused imports
import { useState, useEffect, useCallback, useMemo } from 'react';
import lodash from 'lodash';
// After: Only used imports remain
import { useState, useCallback } from 'react';
See references/import-patterns.md for detailed patterns.
Dead Code Detection
Categories
- Unreachable code - Code after return/throw statements
- Unused functions - Defined but never called
- Unused variables - Declared but never read
- Unused exports - Exported but never imported elsewhere
- Unused class members - Methods/properties never accessed
Detection Strategy
# TypeScript checks
npx tsc --noEmit --noUnusedLocals --noUnusedParameters
# Find unused exports
npx ts-prune
# ESLint rules
npx eslint . --rule 'no-unreachable: error'
Confidence Levels
| Level | Criteria | Action |
|---|---|---|
| High | Zero references, private scope | Safe to remove |
| Medium | Only test references | Verify with user |
| Low | Dynamic usage patterns | Manual review required |
See references/dead-code-patterns.md for detailed patterns.
Asset Tracking
Asset Types
| Type | Extensions | Common Locations |
|---|---|---|
| Images | png, jpg, svg, webp, gif | public/, src/assets/ |
| Styles | css, scss, sass, less | src/styles/, public/ |
| Fonts | woff, woff2, ttf, otf | public/fonts/ |
| Data | json, yaml | src/data/, public/ |
Reference Patterns to Search
// Direct imports
import logo from './logo.png';
// HTML/JSX references
<img src="/images/hero.png" />
// CSS references
background-image: url('/images/bg.jpg');
// Dynamic (flag for review)
const img = require(`./images/${name}.png`);
See references/asset-patterns.md for detailed patterns.
Dependency Auditing
Analysis Categories
- Unused packages - In package.json but never imported
- Security vulnerabilities - Known CVEs in dependencies
- Duplicate packages - Same functionality, different packages
- Misplaced dependencies - devDeps vs deps incorrect
- Outdated packages - Behind latest versions
Quick Commands
# Find unused packages
npx depcheck
# Security audit
npm audit
# Check outdated
npm outdated
# Package size analysis
npx package-size lodash moment axios
Common Functional Duplicates
| Category | Packages (pick one) |
|---|---|
| Dates | moment, dayjs, date-fns |
| HTTP | axios, node-fetch, got, ky |
| Utilities | lodash, ramda, underscore |
| UUID | uuid, nanoid, cuid |
| Schema | zod, yup, joi |
See references/dependency-patterns.md for detailed patterns.
Configuration Cleanup
What to Check
- Environment variables - Defined in .env but never used
- Config files - For tools no longer installed
- Feature flags - Stale or always-on flags
- Build configs - Redundant or default options
Common Obsolete Configs
| File | Check If |
|---|---|
| .babelrc | Babel in dependencies |
| tslint.json | TSLint deprecated, use ESLint |
| .travis.yml | Still using Travis CI |
| webpack.config.js | Using Vite/Next.js instead |
Best Practices
Before Cleanup
- Commit current state - Ensure clean git status
- Run tests - Verify tests pass before changes
- Document public APIs - Know what shouldn't be removed
- Backup configs - Save current configuration
During Cleanup
- Start with high confidence - Remove obvious dead code first
- Batch similar changes - Group related removals
- Test incrementally - Run tests after each batch
- Use git diff - Review changes before committing
After Cleanup
- Run full test suite - Verify nothing broke
- Check bundle size - Measure improvement
- Update documentation - Remove references to deleted code
- Commit with clear message - Document what was removed
Common Pitfalls
False Positives to Avoid
- Dynamic usage -
obj[methodName]()patterns - Framework magic - Decorated methods, lifecycle hooks
- External consumers - Public library exports
- Test utilities - Only used in test files
- Generated code - Files with
@generatedcomments
Edge Cases
// Looks unused but called dynamically
export function helper_a() { }
export function helper_b() { }
const fn = helpers[`helper_${type}`];
// Framework-managed lifecycle
@Component({})
class MyComponent {
ngOnInit() { } // Called by Angular
}
// Re-exports for public API
export { Button } from './Button'; // Used by consumers
Report Format
The /cleanup command generates reports in this format:
# Codebase Cleanup Report
## Summary
| Category | Issues | Est. Savings |
|----------|--------|--------------|
| Unused Imports | 23 | - |
| Dead Code | 15 | ~500 LOC |
| Unused Assets | 12 | 2.3 MB |
| Unused Dependencies | 5 | 4.1 MB |
## High Priority (Safe to Remove)
[Detailed findings with file paths and line numbers]
## Medium Priority (Review Required)
[Findings that need verification]
## Low Priority (Manual Review)
[Potential issues with dynamic patterns]
References
references/import-patterns.md- Import analysis patternsreferences/dead-code-patterns.md- Dead code detection strategiesreferences/asset-patterns.md- Asset tracking methodologyreferences/dependency-patterns.md- Dependency audit procedures
Examples
examples/cleanup-examples.md- Before/after cleanup examples
Score
Total Score
65/100
Based on repository quality metrics
✓SKILL.md
SKILL.mdファイルが含まれている
+20
✓LICENSE
ライセンスが設定されている
+10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
✓最近の活動
1ヶ月以内に更新
+10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
✓タグ
1つ以上のタグが設定されている
+5
Reviews
💬
Reviews coming soon
