Last week I opened a file to refactor it. No reason, feeling frisky. For forty lines I didn’t blink. Spaghetti is a mild word for what my elbows were in. That’s why I don’t refactor. Better to leave it alone.
Except “better to leave it alone” is the lie. The real reason is worse: somewhere in there, the file turned around and looked at me. That’s what code does, it reads you back. And no living being dares tell you how ugly you look.
Here, look at a function. It’s called doStuff. It takes a parameter named data — bold, narrowing it down to everything. Inside there’s temp, and right below it, because the engineering imagination around here is just through the roof, temp2. The most recent commit message, in full, is “fix”. All clear. PR approved, LGTM.
Now paste that into the AI and ask what it does. You’ll lean back and you’ll say the thing everyone says now: “Nonsense. It has to be hallucinating.”
It’s not hallucinating. It’s doing an impression of you.
The mirror, not the villain
We decided, as an industry, that the great flaw of these models is they make things up. Fine, they do. But what they do is use what is already there. The “hallucination” is a machine doing pattern-completion on a thing with no pattern. It’s guessing fluently, exactly the way you bullshit your way through the morning standup when someone asks if everything is on track. And it’s polite enough not to tell the real truth back, because you’d be insulted.
And it isn’t only you. The number 2 is the absolute peak of engineering imagination. Salesforce has a standard object literally called Product2, which means somewhere there’s a Product we stopped making eye contact with years ago. temp2, Product2, _final_v2 — the 2 always means the same thing: the first one is still broken, and we shipped on top of it anyway because we were lazy.
For years, reading the scary codebase was a solo expedition. Nobody volunteered. Now you have a partner who reads all 800 lines without flinching and never once opens WhatsApp mid-review. I spent a decade asking for help to confront the shitty parts. It showed up. It read my trigger, found a query sitting inside a for loop, and pointed it out with the surgical precision of a QA engineer who just found a critical bug on a Friday at 4:55 PM.
That’s the first reviewer in my career asking for more. Be nice to it. It’s the only one telling you the truth.
Works on my machine
“Works on my machine” is the first excuse every young padawan learns. It has many variations: “works in my sandbox,” “works in my docker,” “works on my phone” — but it’s the same incantation right before production hits with all its wrath.
Here’s the thing about your machine: it knows you. Your local environment is held together by duct tape, pure hope, and a Node version from 2021 you’re too terrified to update. Of course it works. It works because it’s as broken as you are.
But then production comes. You do not know production. Production is the final boss. You tested it in Chrome, on your Mac, logged in with every permission under the sun. The user opened it in a locked-down Edge browser, on Windows, with three extensions which interfere with your software — and the page folded like a deck chair.
But here’s the good news. I am not a better player than you. I’ve just crashed production more times. I come prepared the way you come prepared to meet a dog that already bit you once — calm, slow, with a rollback plan and a sandbox I actually refreshed. You don’t beat the final boss by avoiding it. You beat it by getting defeated enough times that you finally show up with a real test — not the one that asserts true to buy you 75% coverage, but one that would actually be upset if you broke something.
The swamp you keep blessing
Now the big one. The 800-line function. Every codebase has exactly one. It’s our collective Voldemort, you cannot say his name. At the top sits a comment — // TODO: refactor later — dated 2019. Three engineers have since opened that file with honest intentions, read forty lines, stared at the void for four minutes, closed it, and suddenly started googling how to start a brewery. It’s a small, well-attended cemetery.
We tell ourselves the swamp was inherited. Lovely story. It makes you the victim. But there’s a git blame on every line, and it knows whose “temporary” hotfix became permanent. So we don’t drain it. We bless it. “Yeah, it’s gnarly, but it works.” And we pass it on like a family heirloom nobody asked for.
Somebody has to be the one who doesn’t bless it.
I’ll be honest about the cost: nobody will care. You’ll take the extra two days nobody scheduled. You’ll ship it quietly — no applause, no story point.
Because the swamp reads forward. Whoever inherits that file inherits your decision, and the function you quietly fixed on a Thursday is the reason some stranger has a good Monday. You won’t be in the room when it happens. Do it anyway.
And you don’t go in alone anymore. You have a partner who reads every line and never quits halfway. We’ve been asking for that help since the first punch card jammed. Stop waving it away as “hallucinating.”
Five moves. No applause included.
You can’t argue a culture out of a swamp, but you can swamp culture out of argue. Do five small things this week. Each one walks you up to the mirror.
Make the AI read it, not write it. Paste your scariest method in. When it can’t explain
doStuff(), that’s your confirmation that nobody can. Rename it before lunch.Kill one lying name a day.
temp2becomesdiscountedTotal. A bad variable name isn’t a mistake, it’s a booby trap you left for your future self, who is already heavily caffeinated and sleep-deprived.Run it somewhere that doesn’t love you. Refresh the sandbox first. Open it in the browser your client is actually stuck with. Log in as a user with the real permission set, not as System Admin. Survive that and you built software.
Write the test that would be upset. Load 200 records and prove the trigger doesn’t die at row 101. Write the one that fails loudly the day someone breaks the thing you just fixed.
Drain forty lines, with the AI, today. The mythical refactor sprint isn’t coming. Pull forty lines out of the 800-line monster into one well-named method, have your AI partner confirm it still means what you think, and ship it quietly.
Walk up to it
It looks like three problems — the AI talking nonsense, the thing that only works at home, the file nobody will touch. It’s actually one problem. Each is a mirror you’ve been standing slightly to the side of. Ignoring it is like putting duct tape over duct tape that cannot hold anymore.
Avoiding it doesn’t change the face. It just delays the introduction to an incident channel, at 2 a.m., in front of everyone. Walk up to the glass. Recognize the temp2 as your own. Respect production. Open the cursed file, bring your new partner, and leave it better than the mirror found you.
The machine isn’t judging you. It just sees the temp2 and knows exactly what kind of monster you are. Use the damn tool, fix the swamp, and move on.
By order of thebeanengineer.com — be the one who takes the extra two days. Be an engineer. 🚀
