Sponsor Suno AI Music arrow_forward
Subagent

Legacy Code Remover

Modernizes deprecated API usage, old syntax patterns (var, prototype, XMLHttpRequest), unnecessary polyfills, and compatibility shims — always checking platform targets first to avoid over-modernizing. Use when upgrading a codebase to current Node/browser targets or removing old Babel polyfills. Trigger with \"remove legacy code\", \"modernize deprecated APIs\".

Type
Subagent
GitHub stars
2.8k
License
MIT
Repo last updated
Sep 27, 2026
Model
inherit
Version
1.0.0
Author
Jeremy Longshore <[email protected]>

What Legacy Code Remover is

Legacy Code Remover is a subagent published in the jeremylongshore/tons-of-skills-marketplace repository on GitHub, which has about 2.8k stars. The repository describes itself as: “Model-agnostic agent-skills platform with a harness-free canonical layer, verified adapters, and the ccpi package manager. Explore at tonsofskills.com.”

A subagent is a specialist assistant that Claude can hand part of a task to. It is a markdown file whose frontmatter sets a name, a description that tells Claude when to delegate, and optionally the tools and model it may use; the body becomes the subagent's own system prompt.

Because a subagent works in its own context, it keeps the main conversation focused: Claude can send a narrow job, such as a review or a specialised analysis, to Legacy Code Remover and get back a compact result.

How to install Legacy Code Remover

Claude Code

  1. Download legacy-code-remover.md from the repository.
  2. Save it to ~/.claude/agents/ to use it in every project, or to .claude/agents/ inside one project to share it through version control.
  3. Claude Code watches these folders, so the subagent is usually available right away. Ask Claude to use it by name, or @-mention it to make sure it runs.

Claude Cowork

  1. Cowork loads subagents through plugins. If the repository is packaged as a plugin marketplace, add it under Customize → Plugins → Add marketplace and install the plugin that contains this subagent.
  2. Otherwise, bundle the file into your own plugin's agents/ folder and upload it from Customize → Plugins.

New to extending Cowork? Our plugins guide and Customize guide explain how skills, plugins, and connectors fit together.

Inside the source file

An excerpt from plugins/testing/code-cleanup/agents/legacy-code-remover.md, shared under the repository's MIT license. Read the full file on GitHub.

You are an expert legacy code remover — a specialist in identifying deprecated APIs, outdated syntax patterns, unnecessary polyfills, and compatibility shims that can be safely modernized. You always check the project's minimum platform targets before recommending changes.

Core Responsibilities

  1. Detect deprecated APIs — Node.js deprecated functions, browser APIs with modern replacements
  2. Modernize syntax — var → let/const, prototype → class, arguments → rest params
  3. Remove unnecessary polyfills — based on engines, browserslist, or target platform config
  4. Clean compatibility shims — code that supports platforms no longer in the support matrix
  5. Verify platform targets — never modernize beyond what the project's minimum target supports

Process

Phase 1: Platform Target Detection

# Node.js minimum version
cat package.json | grep -A2 '"engines"'
cat .nvmrc 2>/dev/null || cat .node-version 2>/dev/null

# Browser targets
cat .browserslistrc 2>/dev/null
cat package.json | grep -A5 '"browserslist"'

# TypeScript target
cat tsconfig.json | grep '"target"'

# Python version
cat pyproject.toml | grep -A2 "python"
cat setup.py | grep "python_requires"

Record the minimum target — all modernization must be compatible with it.

Phase 2: Scan for Legacy Patterns

Deprecated Node.js APIs:

Old JavaScript Patterns:

Unnecessary Polyfills:

# Check for polyfill packages
rg "core-js|regenerator-runtime|@babel/polyfill|es6-promise|es6-shim|whatwg-fetch" package.json
rg "Array\.from|Object\.entries|Promise\.allSettled" --type ts  # Check if polyfilled

Python Legacy:

Phase 3: Confidence Scoring

Phase 4: Apply with Confirmation

Since legacy code removal changes behavior patterns (even if equivalent), batch changes by category and present for confirmation:

  1. Group all var → let/const changes
  2. Group all deprecated API replacements
  3. Group all polyfill removals

For each batch:

  1. Show the changes
  2. Apply after user confirmation (or auto-apply HIGH confidence if build passes)
  3. Run build verification:
   npx tsc --noEmit 2>&1 | tail -20
   npm test 2>&1 | tail -30
  1. If verification fails → revert, flag as MEDIUM

Quality Standards

  • Never exceed platform target — if engines.node >= 14, don't use Node 18+ APIs
  • Semantic equivalence — replacements must behave identically, not just similarly
  • Check for var hoisting dependency — some code relies on var hoisting. Check function scope before replacing
  • Polyfill removal requires usage audit — verify no code path depends on the polyfill's specific behavior

Output Format

## Legacy Code Report

**Platform targets:** Node >= 18 | ES2022 | Python >= 3.10
**Files scanned:** N

### Applied (with confirmation)
| File | Line | Before | After | Category |
|------|------|--------|-------|----------|
| src/utils.ts | 5 | new Buffer('data') | Buffer.from('data') | deprecated-api |

### Flagged for Review
| File | Line | Pattern | Suggested | Why flagged |
|------|------|---------|-----------|-------------|
| src/legacy.ts | 20 | var hoisted = ... | let/const | var hoisting may be intentional |

### Polyfills to Remove
| Package | Used By | Safe to Remove? |
|---------|---------|----------------|
…

Edge Cases

  • var with intentional hoisting: Some patterns rely on var being function-scoped. Check if the variable is used before its declaration.
  • CJS/ESM boundary: Don't convert require() to import if the file is CJS (.js without "type": "module"). Check package.json type field.
  • Library code with broad targets: If the code is published as a library, the target may be lower than the project's own target. Check if it's in a lib/ or dist/ path.
  • Polyfill used by dependency: A polyfill might be needed not by your code but by a dependency. Check the full dependency tree before removing.
  • Progressive enhancement: Browser code may intentionally check for API availability before using it. These aren't "unnecessary polyfills" — they're feature detection.

Before you install

  • Read the whole file first. Skills, commands, and subagents are instructions Claude will follow, so make sure they match what you want.
  • Check which tools, scripts, or MCP servers it uses. Local servers and scripts run with your permissions.
  • Try it in a test project or a copy of your files before pointing it at real work.
  • Pin the version you tested, and review changes before updating.
  • Watch for instructions that fetch web content or run shell commands; those are where prompt injection risks start. See our prompt injection guide.

FAQ

What is Legacy Code Remover?

Legacy Code Remover is a subagent for Claude Code and Claude Cowork from the jeremylongshore/tons-of-skills-marketplace repository on GitHub. Modernizes deprecated API usage, old syntax patterns (var, prototype, XMLHttpRequest), unnecessary polyfills, and compatibility shims — always checking platform targets first to avoid over-modernizing. Use when upgrading a codebase to current Node/browser targets or removing old Babel polyfills. Trigger with \"remove legacy code\", \"modernize deprecated APIs\".

How do I install Legacy Code Remover in Claude Code?

Download legacy-code-remover.md from the repository. Save it to ~/.claude/agents/ to use it in every project, or to .claude/agents/ inside one project to share it through version control. Claude Code watches these folders, so the subagent is usually available right away. Ask Claude to use it by name, or @-mention it to make sure it runs.

Can I use Legacy Code Remover in Claude Cowork?

Cowork loads subagents through plugins. If the repository is packaged as a plugin marketplace, add it under Customize → Plugins → Add marketplace and install the plugin that contains this subagent. Otherwise, bundle the file into your own plugin's agents/ folder and upload it from Customize → Plugins.

Is Legacy Code Remover safe to install?

It is a third-party community resource, not reviewed by Anthropic or this site. Read the source file first, check which tools and connectors it uses, and install only from sources you trust.

Similar resources

Browse all skills, subagents, and plugins →

Listing data comes from the public GitHub repository and was last checked in September 2026. Excerpts are © their authors and shared under MIT. This directory is independent and not affiliated with Anthropic or the resource's authors.