# AI agents refactor 300K lines of game code in three weeks for $4K

> CodeScene used AI agents and its CodeHealth MCP server to clean up a 300,000‑line C codebase of Street Fighter III in three weeks, at a token cost of about $4,000.

Oossa · 2026-09-30 · https://oossa.com/en/ai-agents-refactor-300k-lines-of-game-code-in-three-weeks-for-4k

Produced and translated with AI assistance. Check the original sources below.

CodeScene published a case study showing that AI agents can refactor a large legacy codebase quickly and cheaply. Over three weeks, the agents rewrote a 300,000‑line C version of Street Fighter III: 3rd Strike, producing 2,903 commits across 726 files. The work cost roughly $4,000 in AI token usage – about half a month’s developer salary – and moved the Code Health score from 5.6 to a perfect 10.0.

## How the AI did it

The team used the CodeHealth MCP Server as a deterministic quality signal. The server gave each change a score, letting the agents know whether a refactoring helped or hurt the code’s health. A replay‑trace harness compared the game’s frame‑by‑frame state before and after each change, ensuring functional correctness. The agents learned a playbook of 22 refactoring recipes, including familiar patterns like Extract Function and novel ones such as Shared Index Range for loops that differ only in start/end values.

## What practitioners think

Reactions on LinkedIn split along two lines. Some, like CTO Mats Iremark, called the result “almost like cheating” and highlighted the huge productivity gain. Others, such as tech lead Konrad Otrębski, questioned the scope, noting the work was done on an open‑source game rather than a production system and asking whether the changes were merged in a single massive pull request or many smaller ones. CodeScene’s engineers said the changes were merged through 54 pull requests on a fork.

## The facts

- The refactoring covered a 300,000‑line C codebase of Street Fighter III: 3rd Strike.
- The AI work took three weeks and cost about $4,000 in token usage.
- Agents made 2,903 commits, touched 726 files, and modified 252,055 lines of code.
- The Code Health score rose from 5.6 to 10.0 after the uplift.
- 22 refactoring recipes and 82 supporting notes were added to the agents’ playbook.

## Why it matters

For a typical developer, this shows that AI can automate large‑scale clean‑up tasks that would normally take months, potentially lowering the cost and risk of working with legacy code. However, the result depends on having a reliable correctness check, which many real‑world projects lack.

## Sources & references

1. [Agents Refactor 300K Lines in Three Weeks, and Practitioners Ask What It Proves](https://www.infoq.com/news/2026/09/agentic-refactoring-case-study/?utm_campaign=infoq_content&utm_source=infoq&utm_medium=feed&utm_term=AI%2C+ML+%26+Data+Engineering) – InfoQ, 2026-09-30

Last updated: 2026-09-30
