The setup
We wrote a deliberately messy TypeScript codebase: an order system with 840 lines, 11 modules, and 67 tests. It carries the debt you find in legacy code. A duplicated pricing engine. Deep nesting. Magic numbers. Dead code. We copied the codebase into two identical repositories. The same coding agent, with the same model and the same prompt, refactored both. The MCP run could call the aipatterns MCP server and read its skills. The plain run had no server and no skills. One static analyzer scored both results after the runs. This was a small test: one run per condition. We say more about that below.