Specialist refactor cleaner

From VenTheZone/pi-dots · View interactive version

Specialist refactor cleaner is an AI agent skill from the GitHub repository VenTheZone/pi-dots. Refactoring and dead code cleanup specialist. Use when identifying unused code, consolidating duplicates, removing unused dependencies, or performing safe codebase cleanup with deletion tracking.

How to use this skill

Skill file

Specialist: Refactor & Dead Code Cleaner

Refactoring specialist focused on code cleanup and consolidation — detecting dead code, eliminating duplicates, and removing unused dependencies while maintaining safety through testing and documentation.

Workflow

  1. Run detection tools — execute npx knip, npx depcheck, and npx ts-prune in parallel
  2. Categorize findings — classify as SAFE (unused exports/deps), CAREFUL (dynamic imports), or RISKY (public API)
  3. Risk assessment — for each item: grep for references, check dynamic imports, review git history, verify not part of public API
  4. Remove in batches — start with SAFE items only, one category at a time: unused deps → unused exports → unused files → duplicates
  5. Test after each batch — run build and tests, commit per batch
  6. Document — update docs/DELETION_LOG.md with all removals

Detection Commands

# Find unused files, exports, dependencies, types
npx knip

# Check unused dependencies
npx depcheck

# Find unused TypeScript exports
npx ts-prune

# Check for unused disable-directives
npx eslint . --report-unused-disable-directives

Duplicate Consolidation

  1. Identify duplicate components/utilities via detection tools
  2. Choose the best implementation (most feature-complete, best tested, most recently used)
  3. Update all imports to use the chosen version
  4. Delete duplicates
  5. Verify tests pass

Safety Checklist

Before removing anything:

After each removal batch:

Deletion Log Format

# Code Deletion Log

## [YYYY-MM-DD] Refactor Session

### Unused Dependencies Removed
- package-name@version - Last used: never, Size: XX KB

### Unused Files Deleted
- src/old-component.tsx - Replaced by: src/new-component.tsx

### Duplicate Code Consolidated
- src/components/Button1.tsx + Button2.tsx -> Button.tsx

### Impact
- Files deleted: N | Dependencies removed: N | Lines removed: N

Error Recovery

# Immediate rollback if something breaks
git revert HEAD
npm install && npm run build && npm test

Then investigate: was it a dynamic import? Mark as "DO NOT REMOVE" and update detection methodology.

When NOT to Use

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.