How I used AI to fix a 2014 back office application in days instead of months
Before I start this post, I want to make a disclaimer: I use AI sparingly on production systems, and I give the same advice to anyone thinking of using it to build or fix a website. If you let AI write code that you cannot read, you have no way of knowing whether it is correct, whether it is safe, or what it will do when something unexpected happens. You then own a live system that you do not understand, and the first person to find out where it breaks may be one of your customers. Nobody should ship anything they do not understand, however convincing it looks.
This project was different because of my own background. I have 19 years of experience in web development, and I understand how this PHP application works, so I could read every change Claude proposed and judge whether it was safe. That let me reject or correct anything that was not right, and it is the reason I trusted the finished result.
One of my clients runs an internal back office application that was written in 2014. It tracks sales, customers and billboard sites, and it emails a manager whenever a sale is created. The staff use it every day, so nobody wanted to touch it, and the longer it went untouched, the less safe it became.
The first sign of trouble was that adding a sale took around five minutes and then failed with "MySQL server has gone away". The application sent the notification email before it wrote anything to the database. The mail connection hung, the database connection timed out in the meantime, and the sale was never saved. Moving the database writes ahead of the email fixed that.
Looking at the code closely showed me how much else needed attention. Values from forms went straight into database queries, one endpoint would update any column it was asked to, and errors printed raw database messages into the browser. The files sat inside the public web root, next to the database credentials. The front end was built on jQuery 1.9.1 loaded from a CDN, along with a pile of abandoned plugins.
I estimated that fixing all of it properly would take weeks and probably closer to months, mostly because of the reading involved. I did it in two days instead, working with Claude on 12 and 14 November. The history shows 24 merged changes, with a little over nine hours between the first and last merge on each day.
What changed
Before touching anything, I saved a snapshot of production as it stood. After that, the first real change was to move the application into a public folder and load the database configuration from outside the web root, so the credentials can no longer be served by accident. I then added proper error logging, so failures are recorded on the server instead of being shown to whoever triggered them. The queries that took values from forms were moved to prepared statements, which means a submitted value is always treated as data and can never become part of the SQL itself.
The next stage was the data. Dates were stored as text in more than one style, with a workaround that treated 1970 as "no end date", and prices and rental periods had the same problem. Claude wrote the conversion scripts, with checks before and after, and I rehearsed them on a scratch copy of the database before running them on the live one. Comments containing UTF-8 text that had been stored as latin1 were repaired row by row. Once I had confirmed that the live data had no 1970 dates left, the workaround was deleted. Dates are now real dates, prices are real numbers, and blank values are stored as nothing.
The largest block of work was the front end, which is where most of the age showed. jQuery went from 1.9.1 on a CDN to 3.7.1 hosted on the same server, and jQuery UI, Bootstrap, FullCalendar, moment and DataTables were brought up to current versions. Four abandoned plugins were removed, and the browser's own date inputs replaced the old date picker. The 15 pop-up forms were rebuilt on a single set of helpers, and a shared form kit replaced three copies of the same customer form. The Areas admin page had 506 hidden edit pop-ups, and it now uses three shared ones.
Several bugs surfaced and were fixed along the way. Edit mode used to disable every input on the page instead of only the ones belonging to the record. Adding more than one billboard to a new sale did not work, because the buttons on later rows had no click handler. Uploaded files were never removed from disk when they were replaced or deleted, and now they are. Only managers and admins can now change which salesperson a sale belongs to.
Where Claude helped, and where it got things wrong
Claude did the reading, which is where most of the time goes on an old application. It explained what each file did, found where one part depended on another, and wrote the changes while I reviewed them. It also wrote the conversion scripts, which I rehearsed on a scratch copy before they went near live data.
It also made a mistake, and the process caught it. One of its edits left a stray $1 where the date picker call should have been, which caused a script error that stopped every script on the sale page. I had set up a baseline that listed the expected script errors for each page, and that check showed the problem within minutes. The next change restored the code and recorded the baseline in the repository, so every later change was checked against it.
AI makes this kind of work much faster, but it still needs someone who can decide what the application should do, test every change, and take responsibility for the live system.
What this means if you have an old system
Many businesses run an application like this one, and many have been told that the only answer is a full rewrite. Sometimes it is the right answer. For this client it was not, because the application did the job and mainly needed to be made safe and reliable. If you have a system like this and you are unsure whether it can be saved, get in touch and I will tell you what I think.