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.
/plugin marketplace add wshobson/agents
/plugin install code-refactoring@claude-code-workflowsWhat 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-workflows2Manually: put the files in place
.claude/agents/legacy-modernizer.mdFor all projects use ~/.claude/agents/. Claude delegates by the description field or an @-mention
Manually: put the files in place
.codex/agents/legacy-modernizer.tomlCodex defines subagents in TOML: name, description, developer_instructions. Move the Markdown text into developer_instructions by hand. For all projects use ~/.codex/agents/
Manually: put the files in place
.cursor/agents/legacy-modernizer.mdCursor also reads .claude/agents/
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