Skip to main content
subagent CX Codex

code-refactoring-legacy-modernizer — Claude Code subagent guide

Plans and executes step-by-step modernization of legacy projects without breaking existing features. Useful for framework migrations, dependency updates, and monolith decomposition.

Install into Claude Code · Plugin marketplace All methods and platforms ↓
/plugin marketplace add wshobson/agents
/plugin install code-refactoring@claude-code-workflows
Open on GitHub

What code-refactoring-legacy-modernizer does

The subagent handles incremental modernization of aging codebases across frameworks such as jQuery, Python 2, and older Java releases. It relies on the strangler fig pattern. Instead of a risky full rewrite, parts of the system get replaced step by step while keeping existing APIs operational.

Preparation comes first. The agent writes tests to capture current legacy behavior before touching production logic. Its deliverables include structured milestone plans, compatibility shims, deprecation notices, and documented rollback steps for each rollout phase. Using feature flags prevents unexpected outages during deployment.

Under the hood, the subagent targets the Sonnet model. Because safe execution is mandatory, it will not perform refactoring on unverified legacy code without setting up a test harness first.

What it helps with

  • Migrate outdated frameworks to modern alternatives
  • Add test suites for legacy behavior before refactoring
  • Decompose monolithic applications into microservices
  • Replace legacy stored procedures with ORMs
  • Build compatibility shims and configure rollout feature flags

Example prompts for the agent

  • Create a migration plan to upgrade our backend from Java 8 to Java 17 with rollback steps.
  • Write a test suite for our legacy jQuery code before we rewrite it in React.
  • Plan how to extract microservices from this monolith using the strangler fig pattern.

How to install code-refactoring-legacy-modernizer

1Plugin marketplace

/plugin marketplace add wshobson/agents
/plugin install code-refactoring@claude-code-workflows

2Manually: put the files in place

.claude/agents/legacy-modernizer.md

For all projects use ~/.claude/agents/. Claude delegates by the description field or an @-mention

Step by step, with commands for each platform: Claude Code subagents: how to create one, call it and keep context clean

Questions about code-refactoring-legacy-modernizer

How do I install code-refactoring-legacy-modernizer in Claude Code?

Add the agent marketplace with /plugin marketplace add wshobson/agents, then run /plugin install code-refactoring@claude-code-workflows.

What does code-refactoring-legacy-modernizer do?

It creates staged modernization plans, drafts compatibility adapters, and rewrites legacy components while preserving system behavior through test coverage.

Which model does this subagent run on?

The subagent specifies the sonnet model in its configuration to handle architectural analysis and test generation.

Source text

legacy-modernizer.md · MIT
---
name: code-refactoring-legacy-modernizer
description: Refactor legacy codebases, migrate outdated frameworks, and implement gradual modernization. Handles technical debt, dependency updates, and backward compatibility. Use PROACTIVELY for legacy system updates, framework migrations, or technical debt reduction.
model: sonnet
---

You are a legacy modernization specialist focused on safe, incremental upgrades.

## Focus Areas

- Framework migrations (jQuery→React, Java 8→17, Python 2→3)
- Database modernization (stored procs→ORMs)
- Monolith to microservices decomposition
- Dependency updates and security patches
- Test coverage for legacy code
- API versioning and backward compatibility

## Approach

1. Strangler fig pattern - gradual replacement
2. Add tests before refactoring
3. Maintain backward compatibility
4. Document breaking changes clearly
5. Feature flags for gradual rollout

## Output

- Migration plan with phases and milestones
- Refactored code with preserved functionality
- Test suite for legacy behavior
- Compatibility shim/adapter layers
- Deprecation warnings and timelines
- Rollback procedures for each phase

Focus on risk mitigation. Never break existing functionality without migration path.

© Seth Hobson · MIT · wshobson/agents

Similar subagents

All subagents for Code review and refactoring →

From the same set508

The whole set →
codebase-cleanup-test-automator A testing subagent that runs the TDD loop, writes tests and wires them into CI. Useful when coverage is thin or failures keep repeating. CX Codex ★ 41,823repo stars tech-debt Inventories codebase technical debt, calculates velocity loss in developer hours, and drafts a prioritized remediation plan based on expected ROI. CX Codex ★ 41,823repo stars refactor-clean This command reviews code for structural issues, SOLID violations, and performance risks, then lays out practical cleanup steps without over-engineering. CX Codex ★ 41,823repo stars context-restore Brings back saved project context and decisions so you can resume a session without re-explaining the task. CX Codex ★ 41,823repo stars doc-generate This command examines a codebase and drafts API, architecture, code, or user documentation. It can also set up checks and publishing workflows for those docs. CX Codex ★ 41,823repo stars code-explain This command explains complex code, algorithms and design patterns with step-by-step breakdowns, Mermaid diagrams and examples. Handy when you inherit unfamiliar code. CX Codex ★ 41,823repo stars code-documentation-tutorial-engineer Turns project source code into step-by-step guides and onboarding materials. The subagent breaks technical concepts into structured lessons with hands-on exercises. CX Codex ★ 41,823repo stars code-documentation-docs-architect Subagent for generating comprehensive technical documentation directly from code. Analyzes architecture, design patterns, and implementation details to produce full-length technical guides and ebooks. CX Codex ★ 41,823repo stars

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor