run-ts-cleanup
Installation
SKILL.md
Run TS Cleanup
A TypeScript codebase accumulates. Features get deprecated but their files stay. A refactor lands half-finished and both abstractions survive. An LLM writes cn for the fourth time in a fourth directory, launders types with as any, duplicates schemas, and blankets properties in defensive ?. optional chains. Dependencies outlive the code that imported them. Types get exported "just in case" and never consumed. This skill sweeps all of it into a clean end state guided by The 4 Pillars of TypeScript Project Cleanup:
- Reachability & Dead Code (Graph Layer): Prune unreferenced files, dead exports, orphaned dependencies, and abandoned zombie features using Knip.
- Encapsulation & Boundary Integrity (Visibility Layer): Decouple test-only leaks, internalize in-file exports, and designate explicit public API entry points (
!). - Type System Rigor & Soundness (Semantic Layer): Eradicate type laundering (
as any,as unknown as T), maintain the type-coverage ratchet, enforce schema inference as single source of truth, and ensure declaration-emit safety. - Module & Build Graph Health (Architecture Layer): Eliminate barrel smog, break cyclic dependency loops via
dpdm/madge, restore tree-shaking, and maintain deterministic lockfiles.
- Every dead symbol, file, export, type, and dependency is found by a real engine, not by guesswork — and each finding is triaged before deletion, never deleted on the engine's word alone.
- Every deletion lands in a reversible causal wave behind a passing verification gate, so any single step reverts with one
git resetorgit revert. - The root cause is addressed, not just the symptom: duplicate helpers get consolidated, circular barrels get untangled, single-use wrappers get inlined — so the same bloat does not regrow.
- The codebase ends more navigable than it started, for the next agent and the next human, without a single behavioural change.
This is a finishing tool. Run it on a green main branch, not mid-feature.
When To Use
Trigger on phrases and repo states like: