Coding with Claude: how to reduce your technical debt with AI
AI is starting to write code, and it’s changing how developers build, test and think about their work.
Our web development team has been experimenting with Claude, an AI chatbot that can understand, generate and improve code, making it a valuable partner for building and improving new applications.
But AI tools like Claude aren’t just helping developers write new code; they’re helping them modernize the old. By reading, refactoring, testing and upgrading brownfield applications with AI, teams can unlock a faster path to cleaner, more maintainable systems without rewriting everything from scratch.
When we talk about brownfield code, we mean the legacy systems you inherit, which are often messy, complicated and weighed down by years of technical debt or limited testing. Greenfield projects, in contrast, start from a blank slate and are built with modern frameworks, clean architecture and up-to-date practices. Understanding this distinction is key because AI can help you move brownfield systems closer to greenfield quality — but only when treated like junior teammates who need guidance, guardrails, structured tasks and feedback.
Here’s how we’ve used Claude to bring brownfield code closer to greenfield quality and what’s worked best along the way.
1. Provide background on your app
To start, tell Claude to read through your app’s brownfield code — the existing legacy code that any new code must be developed around — and give it some background, such as what it does and how it’s used.
Also tell it if you have any special tools it should be aware of, such as the Symfony binary, Drupal’s drush or WordPress’s WP CLI, or if you have special ways to interact with the database. For example, if only you can run root commands for DDL or you have specific formatting needs, let the AI know so you don’t have to backtrack later. Giving Claude instructions and all the background information you have will save time and avoid rework in the future.
Tools like Claude usually support special instruction files, such as CLAUDE.md. This file is the ideal place to document project-specific guidelines. Be thorough and keep it up to date. For example, if you prefer one tab in CSS and four spaces in JavaScript, note that here. Similarly, if your style guide requires Title Case for button text, your database uses snake_case for naming or you’re stuck on PHP 7.4 or Node 14, include those details in this file as well.
2. Add unit testing
Second, add unit testing. If you are using a framework like Symfony or Laravel this might be easy. However, if you are using vanilla PHP, this might be more complicated, but don’t sweat it. Let Claude sweat it.
Avoid making too many changes to the application, if possible, and always review the changes. Do not address bugs at this point unless they will affect testing. Your goal is to get tests to run 100% clean for the way the code is written today.
3. Include code coverage
Next, add code coverage, and ensure the output is available for both you and Claude to inspect. Code coverage is not necessarily a sign of application or code quality, but it should give you an idea of how well the code tested.
Review the coverage report and have AI add more tests as needed. This is subjective, but the more coverage you have, the more likely it is your future refactors will be correct.
4. Refactor and repeat the previous steps
You may reach a point where you have large functions or methods that aren’t covered by the tests. If this happens, have AI refactor these into multiple pieces that are more easily tested. Focus on one function or method at a time, and ensure the AI knows this is the plan, too.
5. Add logging and repeat the previous steps
If you don’t have error logging, now’s the time to add it.
The goal of logging is to allow Claude to see the errors and correct them in a loop. If you skip this step, you may end up in a tedious cycle of trial-and-error testing: running the code, checking the console and server logs, fixing one thing and breaking another.
6. Consider additional tests
This is optional and will depend on your application. Our recommendation is to add one or more tests to see how well they work for your app.
Remember: these tools are not necessarily for you. They’re for Claude to use to write better code.
Examples of other tests include PHP CS, PHPStan, Psalm and Infection. Consider adding these one at a time, probably on a dedicated branch, and see what they report. Depending on your code style, some of these might not be a good fit, and that’s okay. Coding standards like PSR and PER are subjective.
That said, if you can use some of these tools, they might help you find potential issues.
7. Find bugs
Once you have a stable testing environment, you can instruct AI to suggest changes. Keep it simple to start. No need for sweeping changes just yet.
If you do make small changes, ensure you understand and test them all too. This is not AI’s app. It’s yours, and Claude or other AI platforms are just tools.
If you do not understand a change AI is recommending, ask the system why it’s proposing it. Don’t just blindly accept the change — vibe coding is not encouraged here!
8. Upgrade
Once you’ve addressed any bugs in the code, it’s time to upgrade your app.
Upgrades might include PHP, libraries, frameworks or the server infrastructure itself. What you choose to upgrade is wholly dependent on your specific application. Take baby steps here. Tell your AI platform to perform each upgrade and run each of the tests. This is where having more tests and coverage can be helpful.
We strongly discourage running AI as root and letting it perform server-level upgrades, however. Although code can be easily rolled back, infrastructure changes are harder to revert, and it can be difficult to identify these changes between upgrades.
It's best to upgrade your app at this stage so you can address any future features or bugs against the most recent version of your dependencies. Depending on the application, this might go very quickly or painfully slowly.
Either way, don’t skip the upgrade stage. Somewhere out there is a bug or security hole that was fixed in the next version of one of your dependencies. This is the time to bite the bullet and get as up to date as you can.
9. Welcome to greenfield
Okay, you might not technically have greenfield code, but you should be familiar enough with the code (whether for the first time or once again) that you can easily work with it. You can now continue to bug hunt, add features or ask AI where to go next. You can even vibe code at this point but keep it on a dedicated branch for easy delineation.
Whatever you do, always ask AI to test whatever you’re working on and always run tests before it considers the task complete. If you have good tests and error logging, the AI should be able to loop until the problem is solved.
A caution on AI looping
One danger of AI loop testing is that the AI tool may cheat. For example, we’ve seen Claude run tests and say something like “skip the XYZ test so that everything passes testing.” The platform probably took the instruction that it “must pass all tests” as a prime directive. We had to pause the testing and tell Claude that it was cheating — something we humans would never do, right?
In any case, loop testing can be a useful approach for continually checking for errors and bugs. Just be aware this method isn’t perfect yet.
Collaboration, not automation
AI-assisted coding isn’t about automation. It’s about collaboration. The better structured your project is, and the clearer your instructions, the better your AI collaborator will perform.
Tools like Claude won’t replace human developers, creativity or judgment anytime soon. But for now, AI coding platforms are excellent partners for the tedious, test-heavy tasks developers face each day — and they’re only going to get better with time.
If your organization’s website or apps need some code modernization, Vendi can help.
Our web development team blends human expertise with the latest AI tools to modernize legacy systems, reduce technical debt and streamline development processes, all while keeping your systems secure, stable and maintainable. Whether you’re upgrading brownfield code or exploring AI-assisted workflows, our developers can help you move faster with confidence.