skills/code-quality/cleanup-legacy/SKILL.md
Find and remove deprecated, legacy, and fallback code paths with zero callers. Verifies callers via repo grep + LSP before deletion. Removes unreachable fallback branches. Use when the user asks to remove deprecated code, clean up legacy paths, drop fallbacks, or simplify code branches.
npx skillsauth add raintree-technology/claude-starter cleanup-legacyInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Find code marked deprecated/legacy/old/v1 and verify it's truly unused before deletion. Also find unreachable fallback branches (e.g., feature flag defaults that have flipped, version checks for unsupported runtimes).
@deprecated JSDoc/TSDoc# deprecated Python comments, warnings.warn(DeprecationWarning)// Deprecated: Go convention#[deprecated] Rust attributelegacy/, old/, v1/, _old.tselse branches deleted.grep -rn --include="*.ts" --include="*.tsx" --include="*.js" --include="*.py" --include="*.go" --include="*.rs" \
-E "(@deprecated|# ?deprecated|// ?Deprecated|#\[deprecated|warnings\.warn.*Deprecation|TODO.*remove|FIXME.*legacy)" \
--exclude-dir=node_modules --exclude-dir=dist . > /tmp/deprecated.txt
# Files/dirs with legacy naming
find . -type d \( -name "legacy" -o -name "old" -o -name "v1" -o -name "_archive" \) -not -path "*/node_modules/*" > /tmp/legacy-dirs.txt
find . -type f \( -name "*_old.*" -o -name "*-legacy.*" -o -name "*.deprecated.*" \) > /tmp/legacy-files.txt
For each deprecated symbol, count references using ts-server / LSP if available, fall back to grep:
# For function `oldFn` exported from `lib/old.ts`:
grep -rn "oldFn" --include="*.ts" --include="*.tsx" . | grep -v "lib/old.ts" | wc -l
grep -rn "from .*old_mod import\|import old_mod" --include="*.py" .
Look for patterns:
if (process.env.NEW_FEATURE === 'true') { /* new */ } else { /* old */ } — if env always true in all configs, old branch is dead.if version >= 2: /* new */ else: /* old */ — if min version bumped past threshold.if (typeof window === 'undefined') in a browser-only package).Write .claude/cleanup-reports/cleanup-legacy-{YYYY-MM-DD}.md:
# Legacy Code Assessment — YYYY-MM-DD
## Summary
- Deprecated symbols found: N
- HIGH (zero callers): X — safe to delete
- MEDIUM (1-5 callers): Y — needs migration
- LOW (heavy use): Z — deprecated in name but actively used
- Legacy directories: M
- Dead fallback branches: K
## Findings
### HIGH — `packages/utils/src/format-old.ts`
- Marked `@deprecated` since commit abc123 (2024-08-15).
- Exports: `formatV1`, `parseV1`. Repo grep shows zero usages outside the file.
- Action: delete file.
### HIGH — `apps/app/lib/feature-flags.ts:45-60`
- Branch: `if (NEW_DASHBOARD_ENABLED) { ... } else { renderOldDashboard() }`.
- Flag is `true` in all envs (`.env`, `.env.staging`, `.env.production`) and has been for 6+ months per git log.
- Action: remove the else branch + the flag check + the `renderOldDashboard` function (cascade).
### MEDIUM — `domains/billing/legacy.ts`
- 8 callers across 3 packages.
- Marked deprecated 3 months ago. Migration path documented in inline comment to use `domains/billing/v2`.
- Recommendation: do NOT delete. Provide a migration list to the human; this needs sequencing.
### LOW — `lib/utils/oldHelper.ts`
- Marked `@deprecated` but has 47 active callers.
- Either the deprecation is aspirational with no migration plan, or it was incorrectly marked. Flag for human review of the deprecation.
## Critical Assessment
[2-3 paragraphs: what's the pattern of deprecation in this codebase? Are deprecations followed by deletion? Are there feature flags that should have been cleaned up months ago? Are "legacy" directories accumulating but not draining?]
Auto-delete HIGH only.
HIGH (auto-delete):
legacy/ or _archive/ directories with zero references in non-legacy code.MEDIUM (report only):
LOW (note only):
chore(cleanup): cleanup-legacy — removed N deprecated symbols and M dead branches.npm run check 2>&1 || (npx tsc --noEmit && npx eslint .)
npm test 2>&1
pytest 2>&1
go test ./... 2>&1
cargo test 2>&1
# If knip is installed, run it — newly-orphaned exports may surface
npx knip 2>&1 || true
If verify fails: revert and downgrade. The cascade step is the most likely failure source — a "dead" helper might have been used by something the initial grep missed.
@deprecated symbol while it has any callers, even if the migration looks "obvious.".env*, config/*.json, flag service settings).legacy/ directories that other production code still imports — verify first.development
Whop platform expert for digital products, memberships, and community monetization. Covers memberships API, payments, courses, forums, webhooks, OAuth apps, and checkout integration. Build SaaS, course platforms, and gated communities. Triggers on Whop, memberships, digital products, course platform, community monetization, Whop API, license keys.
development
Token-Oriented Object Notation (TOON) format expert for 30-60% token savings on structured data. Auto-applies to arrays with 5+ items, tables, logs, API responses, database results. Supports tabular, inline, and expanded formats with comma/tab/pipe delimiters. Triggers on large JSON, data optimization, token reduction, structured data, arrays, tables, logs, metrics, TOON.
development
Plaid banking API expert for financial data integration. Covers Plaid Link, Auth (account/routing numbers), Transactions, Identity verification, Balance checking, and webhooks. Build fintech apps with bank connections, ACH transfers, and transaction history. Triggers on Plaid, banking API, Plaid Link, bank connection, ACH, financial data, transaction history.
development
Helius Solana RPC and API expert. High-performance infrastructure for Solana including RPC nodes, DAS API for NFTs/tokens, LaserStream real-time streaming, webhooks, Priority Fee API, Enhanced Transactions, and ZK Compression. Triggers on Helius, Solana RPC, DAS API, Digital Asset Standard, NFT metadata, Solana webhooks, priority fees, LaserStream, ZK compression.