The Deska blog
Agent Refactoring Test: The Results
We share our agent refactoring test results after running Claude Code, Codex CLI, and OpenCode through complex codebase migrations to evaluate performance.
11 min read
Automating large scale code modifications has moved beyond simple regex replacements. In our latest agent refactoring test, we evaluated how modern AI coding agents handle structural changes across multiple files while maintaining logic integrity. The goal was to determine if current autonomous tools can reliably manage technical debt or if they still require constant manual intervention during the execution phase.
The Scope of the Refactoring Experiment
Refactoring is a high stakes task for any automated system. Unlike greenfield development where the agent starts with a blank slate, refactoring requires a deep understanding of existing dependencies and side effects. We focused our test on three specific scenarios that represent common developer pain points: converting a legacy Class based component architecture to functional components with hooks, migrating a large utility library from JavaScript to TypeScript, and decoupling tightly coupled services in a monolithic backend.
These tasks were chosen because they require more than just local syntax changes. They demand context awareness across the entire project structure. We monitored how agents navigated the file system, how they handled compilation errors, and how they reacted when a change in one file broke a test in another.
Evaluating the Leading Agents
For this experiment, we utilized three distinct tools: Claude Code, Codex CLI, and OpenCode. Each takes a different approach to interacting with the codebase. Claude Code often excels at reasoning through complex logic paths. Codex CLI focuses on high speed execution of terminal commands. OpenCode provides an extensible framework for specialized coding tasks.
In a traditional setup, running these side by side involves juggling multiple terminal tabs and IDE windows. To streamline the observation, we utilized Deska to place these agents in an infinite canvas. This allowed us to view the terminal output of all three agents simultaneously while keeping a code editor panel open to verify changes in real time. Because Deska is local-first, the agents operated directly on the source files without code leaving the machine.
Performance Across Migration Scenarios
The results varied significantly based on the complexity of the dependency graph. In the JavaScript to TypeScript migration, the agents generally performed well with basic type inference. However, they struggled with complex generics and circular dependencies.
- Claude Code: Demonstrated the highest accuracy in preserving business logic. It spent more time analyzing files before making edits, which resulted in fewer linting errors.
- Codex CLI: Was the fastest to generate code but required more frequent manual corrections when the file structure was nested deeply.
- OpenCode: Showed strengths in repetitive pattern matching, making it ideal for the component architecture migration where the changes followed a predictable template.
One observation from the test was the "context collapse" phenomenon. When an agent is asked to refactor too many files at once, the probability of introducing a regression increases exponentially. Successful refactoring usually required breaking the task into smaller, verifiable chunks.
Interaction and Workspace Control
The efficiency of a refactoring agent is often limited by how the developer interacts with it. Typing long prompts to fix minor mistakes can be slower than just fixing the code manually. During the test, we explored using Ask Deska to manage the environment through voice and chat commands. Instead of manually navigating directories to check if a test passed, we could ask the assistant to run the test suite and report the results while the agents were still working.
This type of workspace orchestration is a significant shift in how developers work with AI. Rather than the AI being a simple autocomplete feature inside a text editor, it becomes a participant in a broader workspace. Using panels to isolate different parts of the refactoring process helped us maintain a clear overview of the experiment.
Comparative Framework: Agent Capabilities
The following table summarizes how the agents handled different aspects of the refactoring test.
| Capability | Claude Code | Codex CLI | OpenCode |
|---|---|---|---|
| Dependency Mapping | High | Medium | Medium |
| Execution Speed | Moderate | High | High |
| Error Recovery | Robust | Basic | Moderate |
| Large File Support | Excellent | Good | Good |
Practical Limitations and Reliability
Despite the progress in agentic workflows, our agent refactoring test highlighted several persistent challenges. None of the agents could fully replace a human reviewer for architectural decisions. They can move code, rename variables, and update types, but they do not yet understand the "why" behind certain design patterns.
Security and privacy also remain concerns for many teams. Using tools that support a BYOK model ensures that you maintain control over your API usage and costs. Furthermore, keeping the execution environment local is critical for teams working on proprietary codebases where data exfiltration is a risk.
Frequently Asked Questions
Can AI agents refactor an entire monolithic codebase?
While agents can process many files, attempting to refactor a whole monolith in a single pass is not recommended. It is better to use coding agents for specific modules or layers to avoid context errors and ensure that each step can be verified by existing test suites.
How do I monitor agents running in the background?
Monitoring background tasks is easier when you use a dedicated workspace. With the mobile app, you can monitor the progress of a long refactoring job from your phone through a secure relay. This allows you to check if the agent has finished or if it is stuck on a specific error without being tied to your desk.
Is it safe to let agents run terminal commands?
Safety depends on the environment. Most agents are designed to run in your local terminal. Using a tool that provides isolated terminals within a controlled canvas allows you to see exactly what commands are being executed. Always review the plan an agent proposes before allowing it to run write operations or delete files.
Start Your Own Refactoring Experiment
If you are looking to integrate autonomous agents into your workflow, the best approach is to start with a contained task. Setting up a dedicated environment where you can see your code, your terminals, and your agents side by side is essential for maintaining control. You can explore how to manage these various tools by visiting our guide on getting started.
The tools for autonomous refactoring are ready for production use, provided they are used with the right level of oversight. You can download the desktop application for Mac, Windows, or Linux to begin building your own multi agent workspace at /download.