$ recombobulate _
home / tips / use-claude-to-incrementally-replace-legacy-code-with-the-strangler-fig-pattern
68

Use Claude to Incrementally Replace Legacy Code with the Strangler Fig Pattern

recombobulate @recombobulate · Mar 29, 2026 · Workflows
use-claude-to-incrementally-replace-legacy-code-with-the-strangler-fig-pattern

Rewriting legacy code all at once is how projects fail. The Strangler Fig pattern — replacing old code incrementally while both versions run side by side — is safer but tedious to set up. Claude Code handles the wiring so you focus on the new implementation.

I want to replace the old OrderProcessor with a new one, but both need to 
run simultaneously during the migration. Set up the strangler fig pattern: 
route to the new implementation when a feature flag is on, fall back to 
the old one when it's off, and log which path each request takes.

Claude reads the old code, creates the new interface, and wires up the routing:

// Claude creates a facade that routes between old and new
class OrderProcessorFacade {
  async process(order) {
    if (featureFlags.isEnabled('new-order-processor')) {
      logger.info('routing to new processor', { orderId: order.id });
      return this.newProcessor.process(order);
    }
    logger.info('routing to legacy processor', { orderId: order.id });
    return this.legacyProcessor.process(order);
  }
}

Use this for different migration scenarios:

# Replace one method at a time
Migrate the OrderService to the new pattern, starting with just the 
createOrder method. Keep all other methods on the legacy implementation 
until we're ready to migrate them.

# Run both and compare
Route all requests through both the old and new implementations. 
Compare the results and log any differences — but return the old 
result to users until we've verified the new one matches.

# Gradual percentage rollout
Route 5% of traffic to the new implementation. If the error rate 
stays flat for a week, increase to 25%, then 50%, then 100%.

# Clean up after migration
The new OrderProcessor has been handling 100% of traffic for 2 weeks 
with no issues. Remove the legacy implementation, the feature flag, 
the facade, and the comparison logging.

Big rewrites fail. Incremental replacements succeed — let Claude set up the dual-running infrastructure so you can migrate one piece at a time.

via Claude Code

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Run Claude Code in GitHub Actions to Automatically Review Every Pull Request

Set up Claude Code as an automated reviewer in your CI pipeline — on every pull request, it reads the diff, checks for bugs, security issues, missing tests, and convention violations, then posts its findings as a PR comment. Your human reviewers get a head start because the obvious issues are already flagged before they look.

recombobulate @recombobulate · 1 day ago
0
Ask Claude to Build a Deployment Checklist from Your Actual Infrastructure

Before deploying, tell Claude to read your project — migrations, environment variables, queue workers, scheduled tasks, caching, third-party integrations — and generate a deployment checklist that's specific to your app. Not a generic "did you run migrations?" list, but one that knows YOUR infrastructure and catches the things YOUR deploy can break.

recombobulate @recombobulate · 1 day ago
0
Ask Claude to Generate a README from Your Actual Codebase — Not a Template

Instead of writing a README from memory or copying a template, tell Claude to read your project and generate one that's actually accurate — real setup instructions from your config, real architecture from your directory structure, real API examples from your routes, and real prerequisites from your dependency files.

recombobulate @recombobulate · 1 day ago