Blog AI

Working With AI as a Senior Developer: Guardrails, Not Guesswork

An AI amplifies whatever it's pointed at. Here's how I build the guardrails (architecture, tests and a rules file) that make it a fast, safe pair programmer.

Published
Reading time
2 min
Written by
Alex Tweedie
A glowing circuit-board brain

I've been writing PHP since version 3, and AI assistants are the first tool in 25 years to genuinely change how I work. But an AI amplifies whatever it's pointed at. Give it a clean, well-tested codebase and it's a fast, capable pair programmer. Give it untested code with no conventions and it'll produce more mess, faster than any junior could. The difference isn't the model; it's the environment you build around it.

Architecture first

Don't ask an AI to "build the app" from a blank folder. You'll get something that runs, plus a hundred decisions nobody actually made.

Decide the shape yourself: where domain logic lives, what controllers may do, how money and dates are handled. Then enforce it with strict static analysis and architecture tests. A Pest arch test that fails when a controller touches the database beats any wiki page, because the AI can't argue with a red test.

Tests are the contract

My projects run hundreds of unit and feature tests in seconds. That's what makes AI safe.

An AI doesn't know why your odd-looking rounding exists, and when it "tidies up" it removes exactly that. Tests encode that knowledge in a form it can't ignore. Name them by intent, pin down the edge cases, and keep the suite fast enough to run after every change.

Teach it the mistakes it keeps making

"Training" your AI really means context: a rules file (CLAUDE.md, AGENTS.md or similar) it reads every session. My rule is simple: if it makes the same mistake twice, it goes in the file.

The most important line in mine: never modify an existing test to make it pass. An AI that can't get a test green will quietly rewrite the assertion and report success. Others cover things like never storing prices as floats and always running the full suite before reporting done.

Work inside defined parameters

For every feature, the tests come first:

  1. I write or approve the tests. This is where senior judgement goes.
  2. The tests become read-only for the task.
  3. The AI implements until the whole suite, static analysis and arch tests pass.
  4. I review the diff for design, not regressions.
  5. Anything I correct twice goes into the rules file.

The AI never decides what the software does, only how, within constraints that are executable. On a recent discount-codes feature, I specified a test for two customers redeeming the last use at the same moment. The AI would never have thought of it; with it in place, the implementation took twenty minutes.

What seniority means now

AI hasn't made experience less valuable; it's made it more visible. A developer who sets clear boundaries gets the output of a small team, safely. One who doesn't generates technical debt at an unprecedented rate.

So don't start by asking the AI to write code. Build the guardrails first, then let it run inside them.

Inherited a codebase where AI-generated code has outrun the tests? That's what FreshSyntax's website rescue service is for. Get in touch.

Need a hand with something like this?

Upgrades, rescues and new builds: tell me what you need and I'll reply within 24 hours.

Talk to me ← All posts