AI Pulse by Inblix

Shopify used AI agents to refactor 2M lines of legacy code into something readable

The Register AI · Apr 28, 2026 · 2 min read · Read original article →

Curated by the Inblix editorial team


Featured image for article: Shopify used AI agents to refactor 2M lines of legacy code into something readable

Shopify just pulled off something that sounds like a developer fever dream: they unleashed AI agents on their sprawling codebase and watched them clean house. The company had roughly two million lines of code that nobody wanted to touch — the kind of legacy spaghetti that makes senior engineers update their résumés. Instead of throwing humans at the problem, they built a multi-agent system where one AI writes the code, another reviews it, and a third runs the tests. The result was thousands of successful refactors that actually made the codebase more maintainable.

Tobi Lütke, Shopify’s CEO, has been publicly bullish about AI-assisted development for a while, but this went further than Copilot autocomplete. The agents weren’t just generating new features — they were untangling years of technical debt. The key insight? AI agents crave the same things human developers do. Clean interfaces, explicit contracts between components, and tests that clearly define expected behavior. Give an agent a messy file with no tests and it’ll hallucinate garbage. Give it a well-structured module with clear boundaries and it thrives.

What’s interesting is how this flips the traditional AI narrative. Most companies pitch AI as a way to write more code faster. Shopify’s experiment suggests the real leverage might be in the opposite direction: using AI to delete and simplify. The agents reduced complexity, removed dead paths, and standardized patterns across the codebase. That’s not glamorous work. It’s the kind of grunt refactoring that gets deprioritized in every sprint planning meeting forever.

Shopify hasn’t open-sourced the full system, but the pattern is already spreading. If AI can reliably pay down technical debt, the economics of software maintenance shift dramatically. The question nobody has a good answer for yet: what happens when companies realize their competitive advantage isn’t in the code they’ve written, but in how cleanly an AI can rewrite it from scratch?

💡 Key Takeaways

  1. Shopify deployed a multi-agent AI system — one agent writes code, another reviews, a third tests — to refactor roughly 2 million lines of legacy code into a cleaner, more maintainable state.
  2. The agents performed best when given clear interfaces and explicit contracts, mirroring what human developers need, and struggled with messy, untested code — exactly where humans also fail.
  3. The project's real value wasn't generating new features but deleting and simplifying existing code, suggesting AI's biggest ROI may be in technical debt reduction rather than greenfield development.

Keep reading: See related articles below for more coverage on this topic.

Get smarter about AI

The sharpest AI news, curated daily. Delivered free to your inbox.

Learn more

Glossary terms

← Back to all articles