Short answer. To bring AI coding agents into a legacy codebase, start with the chores: documentation, written rules, tests and bug hunting. Keep every AI change on the same pipeline as human code, widen the agent's job one module at a time, and measure each step. Australian guidance from the ASD and the OAIC backs the guardrails.

Key takeaways

  • An agent only knows what is written down, so the first jobs for AI are documentation, rules, tests and bug hunting, not features.
  • AI-written code takes the same road as human code: branch, pull request, CI, review and release.
  • Rules files should be short and cover only non-standard practices. Anything a tool can check belongs in CI.
  • Widen AI's job in four rings, one module at a time, and take a baseline for lead time, change failure rate and reverts first.

Every legacy codebase that people have written by hand for five years or more smells the same. The README was last touched by someone who left in 2021. Half the tests check that a button exists. The real rules live in one senior engineer's head, and the onboarding plan is "ask Dave". Dave is on leave.

Then somebody upstairs reads about AI coding agents and wants them in the team by next sprint. So you point an agent at the repo and ask for a feature. It produces clean, confident, nicely named code that breaks three obvious rules nobody ever wrote down. The review takes longer than writing the thing by hand would have. Someone says, "AI doesn't work on our codebase", everyone nods, and the licences quietly lapse.

We've had our own episode. On a React Native project, we asked an agent for a small change to the profile screen. It spotted the Firebase SDK in the app and did the obvious thing: wrote straight to the database from the phone. The code was tidy and worked first time. It also strolled right past the backend, where every write in that app gets its permissions checked and lands in the audit log. The principle "the app never writes to the database directly" was older than half the team and written down precisely nowhere. Our reviewer caught it, swore quietly, and spent longer explaining the rule than the agent had spent breaking it.

Maybe it isn’t the tool. Maybe you’re just using it in the wrong bloody order. Start AI on the work your engineers have been dodging for years: documentation, rules, tests and bug hunting. That's where AI is genuinely strong, where its mistakes are cheap to catch, and it happens to be the same work that makes AI useful for everything else.

The numbers back this up, awkwardly. Google's 2024 DORA research found that a 25% rise in AI adoption went hand in hand with a 7.5% improvement in documentation quality. It also went with a 7.2% drop in delivery stability. AI is brilliant at the boring work and a liability when you let it loose on delivery without guardrails. Plan accordingly.

Australian guidance has caught up as well. The ASD's Information Security Manual (September 2026 edition) now says that its software development guidelines apply to AI-assisted and AI-driven development, not only to work done by people. The sections below point to the ASD, ACSC and OAIC material that matters when you do this in Australia.

1. Your AI coding agent only knows what is written down

An agent opening your repo sees what a new hire sees on day one, minus the chance to ask questions over coffee. It reads the code, the tests, the README and the commit history. It doesn't see why billing writes straight to the database, which service must never be called synchronously, or why that ugly retry loop exists (something went badly wrong one Friday night, and nobody wrote down what).

So it guesses. AI guesses beautifully. The code compiles, the names are lovely, and the tests it wrote pass. Then a reviewer who knows the history notices that the agent has politely undone a decision that once cost the company a weekend of incident calls. Repeat that on every pull request and you get the familiar verdict: "AI is useless on legacy code."

The verdict is wrong, but you can see where it comes from. The agent was working blind. DORA's 2025 State of AI-assisted Software Development report calls AI an amplifier: it makes strong teams stronger and struggling teams struggle faster. One of the seven capabilities that DORA says amplify the upside is giving AI access to your internal data and knowledge. Hard to give it access to something that only exists in Dave's head.

That sets the order for the rest of this article. First, write the knowledge down, with AI doing most of the typing. Then let AI change things.

2. Keep the model behind your pipeline

When we build AI features into a product, our first rule is boring and non-negotiable: the app never talks to the model directly. Every call goes through the backend, where we control the keys, the permissions, the logs and the off switch.

Bring AI into your development process and the same rule applies with one word changed. Keep the model behind your pipeline. AI-generated code takes exactly the road human code takes: branch, pull request, CI, review, release. No direct pushes to main. No "the AI already tested it". Think of the agent as a very fast, very confident contractor with zero accountability. You wouldn't let a contractor merge to main on day one either.

The dashed box is the model provider, the only link in the chain you don't control. Everything else is yours, including the loop on the right: review comments flow back into rules and docs, so the next AI change starts a little smarter.

The rules that make this work are dull on purpose:

  • Small pull requests, labelled. One concern per PR, plus a label when AI did a meaningful chunk of the work. You'll want that label later, when you're counting reverts.
  • Named reviewers for the scary bits. Auth, payments, crypto, data migrations. CODEOWNERS exists for a reason, so use it.
  • Agents live in a sandbox. Dev container, narrowly scoped tokens, no production secrets, no production data. Anything that touches a shared environment waits for a human to say yes.
  • Dependencies get checked. Models invent package names. Researchers who tested 16 code-generating models found that 19.7% of the packages they suggested didn't exist (on average, at least 5.2% for commercial models and 21.7% for open-source ones). The attack, known as slopsquatting, writes itself: register the made-up name, put malware in it, wait for someone's agent to install it. A lockfile, an allow-list and a dependency scanner in CI turn this into a non-event.
  • Approved tools only. In its guidance on AI within the new Essentials, the ASD says the controls for trustworthy software should cover unapproved AI tools, browser extensions, locally run models and agents, including agents that can execute code. Your team's "I just installed this plugin" habit is now a security finding.

Paranoid? The regulators don't think so. In September 2026 the ACSC warned about AI agents taking actions their operators never intended or authorised, and the Five Eyes guidance on agentic AI (published in May 2026 with critical infrastructure in mind, though the logic carries over) says to start with low-risk tasks and widen access gradually. Your main branch is not a low-risk place for an agent to improvise.

3. Have AI document the legacy system you already have

The first AI job in an old codebase should produce exactly zero lines of production code. Point the agent at what you've already got and make it explain.

Engineers hate writing docs. Not because they're lazy (well, not only), but because documenting a system you know by heart feels like giving yourself a guided tour of your own house. AI has no such hang-ups. It will happily read a module nobody has opened since the founder left and have a first draft ready before your standup ends.

The draft will be wrong in places, and that's fine. Hand it to the engineer who knows the subsystem and let them correct it. Every correction is a piece of knowledge that lived in someone's head and now lives in the repo. You get documentation and a knowledge transfer for the price of one review.

What's worth writing down, roughly in this order:

  • Architecture overview: which services exist, what calls what, where the data lives.
  • A README for every module and subsystem: what it does, what it must never do, and where the landmines are.
  • Data flows and API contracts, especially the third-party integrations everyone is scared of.
  • Decision records after the fact: let AI reconstruct why things are the way they are from commits, pull requests and tickets, and label each one "reconstructed, please check". Wrong guesses get corrected fast. Engineers love proving a machine wrong.

One warning. The valuable part is what the code can't tell you: the reasons, the constraints, the business rules, the "we tried that in 2022 and it fell over". A machine-generated tour of your folder structure is not documentation. Researchers from ETH Zurich and LogicStar.ai found that repository overviews, which model providers themselves recommend, didn't help coding agents at all.

Keep the docs in the repo, next to the code, and treat drift as a review item: if a pull request changes behaviour, the doc changes in the same PR. AI is good at spotting the mismatch, so have it flag stale docs as part of every review.

This is also where AI's numbers look best. Of the improvements DORA linked to AI adoption, better documentation was the biggest.

A classic case is the notification system. It starts life as one Cloud Function. Five years later it's a tangle of database triggers, scheduled jobs and one function nobody remembers writing. Users occasionally get the same reminder twice, and every engineer has a theory. Ask an agent to map every path that can send a push notification, and its first draft finds three of them, including one left over from a promo campaign that ended two years ago. The engineer who knows the history fixes a couple of wrong guesses and adds the reasons behind the rest. The duplicate reminders are gone by the afternoon, and the map becomes the first doc in the repo that anyone reads voluntarily.

4. Write the rules down, for people and for agents

Every team has rules. Most of them are stored in the one format nobody can search: pull request comments. "No business logic in controllers." "Use the shared date helper." "Never call the pricing service from the mobile app." Same comments, different PR, every week, for years.

Pull those rules out of the comments and into a file. Better still, get AI to do the digging: give it a few months of review comments and ask which ones keep coming back. You decide what makes the cut. It takes an afternoon and saves your seniors from typing the same sentence until retirement.

Then put the rules where people and agents both read them. AGENTS.md is the closest thing to a standard: a plain Markdown file in the repo that many coding agents read automatically, with extra files for subprojects. Claude Code has CLAUDE.md, Cursor has its rules, Copilot has its instruction files. Pick one source of truth and point the rest at it. New hires will read it too, which is a nice bonus.

Keep it short. Painfully short. The same ETH Zurich study found that context files in general didn't improve agents' success rates and pushed costs up by more than 20%. The agents did follow the instructions, though, and the authors' conclusion is that these files earn their keep in one place: spelling out non-standard practices an agent can't work out from the code. So write down what's peculiar to your team and skip the rest. No essays, no folder maps, no "write clean code".

Anything a tool can check shouldn't live only in prose. Lint rules, type checks, architecture tests in CI. A rule in a Markdown file is a suggestion. A rule in CI is the law.

And treat the rules file like code, because attackers already do. In 2025 Pillar Security demonstrated a "Rules File Backdoor": instructions hidden in invisible Unicode characters inside rules files, which GitHub Copilot and Cursor obeyed while the humans saw nothing odd. Changes to these files go through review, and nobody copies a rules file from a random repo off the internet.

5. Let AI write the tests nobody wrote

Old code without tests is a minefield with a "trust me" sign on it. Everyone knows which modules are scary, so nobody touches them, so they never get tests, because writing tests for scary code is, well, scary.

This is perfect work for AI: lots of it, no glory, easy to check. Start with characterisation tests, a term from Michael Feathers' Working Effectively with Legacy Code. You don't test what the code should do. You pin down what it does right now, quirks included, so that the next change can't quietly alter behaviour.

Two rules stop this from going sideways.

Test the paths that pay the bills. Login, checkout, onboarding: whatever costs money when it breaks. Coverage percentage is a vanity metric. I've ranted about testing hypocrisy before, so I'll spare you the sermon.

Review the assertions, not the green tick. AI-written tests fail in predictable ways. They mirror the implementation, mock everything in sight and assert things the code does anyway. Worst of all, they can lock in a bug as "expected behaviour". A test that blesses a bug is worse than no test, because now the bug has a bodyguard.

Want proof the tests catch anything? Run mutation testing. Tools like Stryker deliberately break your code and check that some test fails. If the suite stays green while the code is wrong, it's decoration.

And a note on order. Rules come before tests for a reason: an agent that has read your rules writes tests the way your team writes them. One that hasn't written them the way the internet does.

The classic candidate is the pricing module: one enormous function that knows about discounts, promo codes and GST, and that nobody has dared to touch since its author left. Give an agent a few hundred anonymised real orders and ask for characterisation tests. By lunch you have a suite that pins down every price the module currently produces. Somewhere in it sits a test asserting that GST is rounded on every line instead of on the total. Bug or rule? That question goes to a human, and the answer goes into the docs. A week later someone finally refactors the monster, the suite stays green, and people stop tiptoeing around that file.

6. Point AI at bugs, with real context and clean data

Debugging is where AI really pays for its subscription. It reads the stack trace, the logs and the code at the same time, without getting bored or defensive, and offers three hypotheses before you've finished complaining in Slack.

Good jobs to hand over:

  • reading stack traces and log dumps and suggesting likely causes;
  • finding other places in the code with the same pattern as the bug;
  • untangling flaky tests;
  • working out what broke after a dependency upgrade;
  • triaging static analysis findings, most of which are noise.

The workflow that keeps AI honest is simple: failing test first, fix second. Ask the agent for a test that reproduces the bug. Watch it fail. Only then let it change the code until the test passes. This stops AI from patching the symptom and calling it a day, and you get a regression test thrown in.

A human still confirms the root cause. AI is very good at confident explanations, and a confident wrong explanation can eat a whole afternoon.

Production logs are full of personal information: names, emails, addresses, sometimes worse. Pasting them into a chatbot to "see what it thinks" means sending your customers' data to a third party. Congratulations: that's a privacy problem with extra steps.

The OAIC's guidance says that, as a matter of best practice, organisations shouldn't put personal information into publicly available generative AI tools. It also explains that entering personal information into a chatbot can count as a disclosure that has to comply with Australian Privacy Principle 6. Scrub the logs first, use only approved tools with known retention terms, and if you can't do either, debug the old-fashioned way.

7. Expand AI's role in rings, and measure each one

Once the chores are done, it's tempting to hand the agent the keys to everything. Don't. Widen its job in rings, and move to the next ring only when the data says so.

  • Ring 1, chores: docs, rules, tests, bug hunting. Everything above.
  • Ring 2, small changes in well-kept modules: refactors, migrations, dependency upgrades, but only in modules that already have docs, rules and tests.
  • Ring 3, features in those same modules.
  • Ring 4, background agents: test maintenance, ticket triage and other jobs that run on their own, still behind the pipeline from section 2.

Promote module by module, not the whole codebase at once. Your payments module and your marketing page don't deserve the same level of trust, and neither does the AI working on them.

What to measure: the DORA metrics you should be tracking anyway (lead time, change failure rate, time to restore), plus review time and the revert rate on AI-labelled pull requests. What not to measure: lines of code, prompts sent, or "percentage of code written by AI". That last one looks fantastic right up until the incident review.

And measure, don't ask. In METR's 2025 study, experienced open-source developers took 19% longer on tasks when they could use AI, while believing it had made them 20% faster. METR then tried to repeat the experiment with late-2025 tools and couldn't get a clean answer: too many developers refused to work without AI, or quietly held back the tasks they didn't want to do without it, and the results got skewed. METR now thinks developers probably are faster with AI, but calls its own data very weak evidence of by how much. If a research lab can't pin the number down, your team's gut feeling won't either. Take a baseline before you start, and compare.

Two habits make the rings work.

Close the loop. Every review comment on an AI change is a candidate rule or doc fix. Feed it back and the next change starts smarter. Better docs and rules, better AI output, less review pain, round and round.

Name the owner. The engineer who merges the code owns it, whoever typed it. Write a one-page team policy: which tools are approved, what never goes into a prompt, who signs off on what. Australia's Guidance for AI Adoption starts with exactly this: its first practice is "decide who is accountable".

8. If your product is regulated, three things change

Everything above applies to any codebase. If you build FinTech, RegTech or EdTech products in Australia, three of these points matter more than the rest.

Evidence of who approved what. The pipeline from section 2 is also your change record. Branch, pull request, CI and review show who approved each change. An agent that writes around the pipeline, like the one that wrote straight to the database from the phone, skips the permission check and the audit log along with the review.

Personal information stays out of prompts. Production data is the usual way it leaks in. The OAIC guidance in section 6 recommends against pasting personal information into public tools, so scrubbed logs and approved tools matter even more in a regulated product.

Named accountability for agents. The ASD's Essentials guidance says AI agents and integrations should be limited to the minimum data and permissions they need, and the Guidance for AI Adoption starts with deciding who is accountable. The one-page team policy from section 7 is where you write both down.

Before you widen AI's role: a checklist

Print it, paste it into your tracker, argue about it in standup. If you can't tick an item, that's your next task, not the agent's next feature.

  • Every subsystem has a short, current doc in the repo that explains the why as well as the what.
  • Team rules live in one short file that both people and agents read.
  • Rules a tool can check run in CI.
  • Changes to rules files go through review like any other code.
  • AI-written code takes the same road as human code: branch, pull request, CI, review.
  • Pull requests are labelled when AI did a meaningful part of the work.
  • Auth, payments and data migrations have named reviewers.
  • Agents run in a sandbox with no production secrets or credentials.
  • New dependencies are checked before they land.
  • The team uses an approved list of AI tools.
  • Nobody pastes production data with personal information into a prompt.
  • Critical user paths have tests that pin current behaviour.
  • AI-written tests are reviewed for what they assert. A green run on its own proves nothing.
  • Every bug fix starts with a failing test.
  • You have a baseline for lead time, change failure rate and reverts, and you widen AI's role one module at a time.

None of this will impress anyone at a conference. It will, however, get AI working in your codebase without wrecking it, and it might even give Dave his weekends back.

How we can help

If your product was built by hand and you want AI in the workflow without the drama, we start where this article does: an audit of what's documented, which rules live only in people's heads, where the tests are missing and what your pipeline actually checks. Then we walk the rings with your team, one module at a time.

Start with Technical Advisory if you want the audit and a plan before anyone touches the code. It has two routes. The Release Readiness Review suits teams whose product is already built or heading for release. The Technical Architecture Workshop suits teams planning a new build or the next stage of an existing one. If you need hands on keyboards, our web and mobile team builds with AI in the loop, and pipelines and checks are bread and butter for our managed services and SRE people.

Frequently Asked Questions

Yes, but not by starting with features. An agent only knows what is written down, so on an old codebase it guesses. Start with documentation, written rules, tests and bug hunting, keep its code on the same pipeline as human code, and widen its job one module at a time.

Document the system. Ask the agent to map the architecture, write a README for each module, trace data flows and API contracts, and reconstruct past decisions from commits and tickets, each labelled for checking. The engineer who knows each subsystem corrects the draft. This first job should produce no production code.

Only in one place. A study by researchers from ETH Zurich and LogicStar.ai found that context files did not generally improve task success and raised costs by more than 20%. They help when they spell out non-standard practices an agent cannot work out from the code, so keep them short and specific.

Not without scrubbing them first. The OAIC recommends, as best practice, that organisations do not put personal information into publicly available generative AI tools, and entering it can count as a disclosure under Australian Privacy Principle 6. Scrub the logs, use approved tools with known retention terms, or debug the old way.

The ASD's Information Security Manual applies its software development guidelines to AI-assisted and AI-driven development. ASD's Essentials guidance asks that trustworthy-software controls cover unapproved AI tools, browser extensions, local models and agents. The ACSC has warned about agents acting without authorisation, and the National AI Centre's guidance starts with accountability.

Read more

A Clickable Prototype Proves the Story, Not the System

1 min18 November 2026
Read the article

SaaS: Streamlining Modern Business Operations through Cloud Technology

1 min11 May 2026
Read the article

AUSTRAC: What It Expects from Modern Product Teams

1 min28 April 2026
Read the article

Need a technical read on your next product decision?

Tell us what is changing in the product, delivery plan or live system. We will help identify the right next conversation.