A Python application had grown into a 5,552-line module. It still worked and its tests passed, but the file combined UI state, workflow phases, dialogs, and helpers in a way that made changes increasingly difficult to reason about.

I used the refactor as a bounded comparison of two enterprise-approved AI coding assistants. The objective was not to declare a universal winner. It was to observe how different assistants handled the same architectural task under equal starting conditions—and to identify the review controls that still belonged to the engineer.

Keeping the comparison bounded

Both assistants received the same repository snapshot, the same task, separate worktrees, and the same test suite. The instruction was deliberately direct: split the monolith into smaller modules, preserve behavior, preserve compatible imports, and keep the tests passing.

I evaluated the first completed result from each workflow rather than giving one assistant additional cleanup rounds. That made the comparison narrower but fairer. Additional prompting would have measured my ability to steer each tool, not only its initial implementation choices.

Three focused review passes supplemented the implementation work:

  • one examined candidate module boundaries and dependency direction;
  • one looked specifically for import, compatibility, and test risks;
  • one compared the proposed outcome with the actual diff.

The important pattern was separation of duties. “Review this refactor” is vague. “Find compatibility risks introduced by moved imports” creates a review task with a clear failure condition.

What the tests established—and what they did not

Both assistants produced a recognizable modular structure: workflow-phase modules, UI components, dialogs, and a compatibility layer. Both preserved the tested behavior.

That result was necessary, but it was not sufficient. Passing tests showed that known behavior remained intact. They did not establish that the new dependency graph was easy to understand, that imports were minimal, that responsibilities were well separated, or that the diff would be maintainable.

The two results illustrated that gap. One output was approximately 6,939 lines across the resulting package; the other was approximately 9,600. Lines of code were not the score—splitting a module often adds imports and compatibility wrappers—but the difference was a useful inspection signal. The larger result retained considerably more scaffolding and repeated import structure.

This was an observed field comparison, not a general benchmark. It showed where to inspect, not which tool would perform better on another repository or prompt.

The engineering review loop

The experiment reinforced a review sequence I now use for material AI-assisted changes:

  1. Define invariants before generation. State the behavior, interfaces, import paths, and tests that must remain stable.
  2. Isolate the work. Use separate branches or worktrees so outputs can be compared without cross-contamination.
  3. Run automated checks. Tests, static analysis, formatting, and import validation provide different kinds of evidence.
  4. Inspect architecture, not just correctness. Review dependency direction, module ownership, duplication, compatibility layers, and the size and shape of the diff.
  5. Assign focused reviewers. Give each human or agent reviewer one explicit risk to investigate.
  6. Require human acceptance. The engineer remains accountable for whether the result makes the system easier to change.

What I would measure next

A stronger follow-up would add repeated runs, explicit maintainability criteria, static-analysis results, review time, defects found after the initial pass, and the number of corrective prompts required. Those measures would evaluate the full engineering workflow rather than a single generated diff.

The practical lesson is straightforward: AI can accelerate a refactor, but it does not remove the need to design the evaluation. Tests protect behavior. Structured review protects the codebase.