Alberta audits and rebuilds legacy code with Claude Code
Alberta's technology ministry put Claude Code agents to work on the province's legacy code, to find and fix security flaws and rebuild what was too old to patch.
Government of AlbertaCanada (Alberta)Local and regional governmentIn production since 2025
- Scale
- Roughly 1,280 applications and 3,400 code repositories across 27 ministries
- Scenario
- Legacy code security review and modernization
- Business function
- Software engineering
- Kind of solution
- Software engineering assistant
- Who built it
- Built in-house (Anthropic)
- Human oversight
- People approve each output
- Organization
- Public sector
- AI types
- Generative AI, Agentic AI
tl;drAbout 50 AI agents reviewed 466 million lines of Alberta government code in about 20 hours.See the results
Alberta’s Ministry of Technology and Innovation, which runs the software of all 27 provincial ministries, has used Anthropic’s Claude Code since 20251. Its agents find and fix security flaws in government code and rebuild applications too old to patch1.
Where the scan found a vulnerability, Claude Code could often write, test and build the fix1. Ministry engineers approved every patch before it shipped1.
The work became public in July 2026. About 50 Claude Code agents, working in parallel, had reviewed more than 466 million lines of government code in about 20 hours, against a team estimate of around 6.5 years1, 2. Some systems too old to patch were rebuilt in as little as four to five days1.
Before the deployment
The ministry maintains the systems of every provincial ministry, from social services to public safety to wildfire response1. Most of that estate had never had a systematic security review1. It had the following problems:
- Size: The estate comes to roughly 1,280 applications and 3,400 code repositories1.
- Sensitive data: The systems hold tax records, government procurement data and social services case files1.
- Technical debt: Insecure code, unaddressed bugs and outdated software add up to a debt that runs into the billions of dollars1.
- Cost of conventional modernization: In July 2026, the province put a conventional modernization of the whole estate at roughly $2 billion and more than a century of work3.
- Failed replacements: Since 2016, three attempts to replace the Ministry of Infrastructure’s two systems for government buildings and construction projects had failed5.
“Albertans trust their government with some of the most sensitive information in their lives, and it is our responsibility to protect it”
In 2025, the ministry set up an internal team to make the systems more secure and easier to maintain over time, working with Claude1. Reading the code by hand would have taken years2.
What was built
The solution has three jobs: a sweep of the whole code estate, fixes for what the sweep finds, and a continuous review of applications in development1. The work is divided as follows:
- Rules engine: Scans each repository first and flags known patterns for Claude to review1.
- Claude Code agents: Around 50 agents worked autonomously and in parallel on the sweep. They looked for security vulnerabilities, weak spots in infrastructure and deployment processes, and gaps in technical documentation. Where they found a vulnerability, they could often generate a fix1.
- Continuous review agents: Specialized agents that Alberta’s cybersecurity team built run throughout the development process. They attack, assess and check each application while it is being developed1.
- Ministry engineers: Review and approve every patch before it ships1. The vulnerabilities were fixed after that human review4.
The sweep covered every repository Alberta owns, and it turned up issues that traditional automated scanning tools had missed1.
Rollout
By July 2026, the ministry had spent 18 months building its own AI tools2. PRISM is a separate ministry team’s project to replace the Ministry of Infrastructure’s two systems, which 643 of its employees used daily by April 20265. The Velocity White Papers are free and open-source, 21 papers by the province’s count and 22 by Microsoft’s2, 6. The Quebec agreement covers AI tools and training and, where practical, source code, tools and documentation7.
By July 2026, Claude was helping the ministry write, review and deploy code for its modernization work1. The ministry plans agents that build entirely new software alongside engineers, and a program from fall 2026 to scale the approach across the provincial government1. One ministry has 185 legacy applications in production, which Claude Code is to analyze and consolidate into 16 reusable applications1, 2.
Technology and architecture
- AI component
- Data
- Trigger or control
- Handoff to people
- Inferred, not documented
Claude Code runs the sweep and the fixes, with both Claude Opus and Claude Sonnet models behind it1. Claude Code is an agent: it plans its own steps and calls tools that read files, run commands and edit code10. That lets it build and test a patch instead of only suggesting one10.
The continuous review agents are built on the Claude Agent SDK1. The SDK gives developers the same tools, agent loop and context management that power Claude Code10.
The following table lists the components of the solution.
| Layer | What they used | Role | Source |
|---|---|---|---|
| Task agent | Claude Code | About 50 parallel agents that review the scanner’s flags and write, test and build fixes or rebuilds | 1 |
| Language model | Claude Opus and Claude Sonnet | The models behind the Claude Code agents | 1 |
| Rules and decision logic | Rules engine | Flags known patterns in each repository before Claude reviews them | 1 |
| Task agent | Red team agent | Probes an application from outside and maps how a weakness could be exploited | 1 |
| Task agent | Blue team agent | Assesses defenses against an international security standard and writes a remediation plan | 1 |
| Task agent | Code quality agents | Check code quality and the clarity of public-facing text | 1 |
| Framework or library | Claude Agent SDK | Base for the continuous review agents | 1, 10 |
In July 2026, Google Cloud’s country managing director said that Google Cloud powers “the agentic layer” of the province’s AI program2.
Data inputs
The agents work from the following inputs:
- Government source code: The code in every repository Alberta owns is the input to the sweep1.
- Applications in development: The red team agent probes each one from the outside, the way an attacker might1.
- Security standard and controls: The blue team agent assesses defenses against an international security standard. Each pass checks an application against roughly 95 security controls1.
How one repository flows through the system
- AI component
- Data
- Trigger or control
- Handoff to people
A repository moves through the sweep in the following steps:
- The rules engine scans the repository and flags code that matches known patterns1.
- A Claude Code agent reviews each flag and cites the exact file and line, so that a developer can verify the finding1.
- If the system lacks the automated tests needed to confirm that a patch is safe, the agent writes the tests first1.
- The agent can often generate a fix, test it and build it1.
- If the code is too outdated or too complex to patch efficiently, the agent rebuilds it in a more modern and maintainable language1.
- The ministry’s engineers review and approve the patch or the rebuild, and only then does it ship1.
Results
The figures date from July 2026, when Anthropic and the province published them1, 2.
| Metric | Before | After | Scope and timeframe | Reported by |
|---|---|---|---|---|
| Time to review government code | Around 6.5 years (the team’s estimate for a conventional review) | About 20 hours | 466 million lines in every repository Alberta owns, reported July 2026 | Government of Alberta and Anthropic, measured; baseline estimated1, 2, 3, 4 |
| Time to rebuild a subsidy program portal | Five months (original hand-coded Java build, about 25 years ago) | As little as four to five days | Systems too outdated or complex to patch, best cases | Anthropic, measured1 |
The figures need the following context:
- Review time: The 20 hours is the time the agents took to read and flag every repository the province owns. The baseline is the team’s estimate for that kind of review done conventionally1. BetaKit gave the province’s estimate for a similar human-led process as more than six years and upwards of $2 billion4.
- Rebuild time: The figure is a best case. Rebuilds took as little as four to five days in some scenarios, including the subsidy portal1.
- Modernization program: The July 2026 release said AI agents had shown the potential to speed up work by as much as 20 times and to cut the time to modernize critical systems by as much as 95 per cent2. Deputy Minister Janak Alford said teams had benchmarked speed gains of as much as 20 times and cost cuts of as much as 95 per cent6.
- PRISM cost: For the separate Infrastructure project, the minister projected about $2.64 million to deliver both systems, against about $54 million for one, a 95% cut. The team had spent $858,000 in ten months5.
Lessons learned
Pairing a rules engine with Claude gave the sweep a cheap first pass and a model to judge its flags, and the file and line on each finding let a developer verify it1. Writing tests before patching code that had none addressed the risk of letting an agent change untested government software1. Covering every repository gave Alberta its first complete picture of the health and security of its systems1, 2.
The documented limit is the one the design builds in: ministry engineers had to review and approve every AI-written patch before it shipped1. That keeps a person responsible for every change.
The ministry’s separate PRISM team made the same point about AI’s limits. The minister wrote that “AI did not build these systems by itself,” and quoted Cohen McLeod, the director who leads PRISM: “AI makes development a lot faster, but not on everything.” After that, the team would “hit something that we just have to do by hand”5.
Every figure comes from the province or from Anthropic, which supplies the models and published the most detailed account as a customer story1, 2. The 6.5-year baseline is the team’s own estimate1. Cole Cioran of Info-Tech Research Group called the papers “the first defensible, in-production blueprint for an agentic public service” in the government’s own release2.
The other versions of the baseline measure different things. BetaKit’s version seems to merge the review estimate with the cost of the whole modernization4. HRD Canada put that cost at roughly $2 billion and more than a century3. The 95% figures are “as much as” or projected numbers, and only the PRISM projection comes with its baseline2, 5, 6.
HRD Canada noted that the province didn’t say when the remaining replacements would be complete, or how many jobs might be affected3. BetaKit pointed out that Anthropic promoted the case shortly after the US government temporarily froze foreign access to Anthropic’s latest models, which made the timing convenient for the company4.
Case study scorecard
- about 20 hours Time for the agents to review 466 million lines of government code1, 2, 3, 4
- four to five days Rebuild of a 25-year-old Java subsidy program portal1
Sources by publication date
- Organization 3
- Vendors and partners 3
- Press, academic, and regulators 4
Build this solution yourself
Analysis
What you need
To build this solution, you need the following in place:
- Central control of the code: You need access to every repository and the mandate to change it. Here one ministry already maintained every ministry’s code, so the agents could reach all of it1.
- Engineers who can judge a machine-written patch: You need people to approve each change, because every patch waited for an engineer’s approval before it shipped1.
- A way to test untested code: You need tests before an agent patches a system, because the tests confirm that a patch is safe. The agents wrote them first where a system had none1.
Reference architecture
Software engineering assistant
A software engineering assistant writes, reviews, tests, or migrates code in the tools that developers already use, and a developer approves its output. A language model writes a change, a test, or a review comment from the code for a task, and automated checks and a checker model build, test, and filter it. A reviewer approves each checked proposal in code review before it merges, and developers do the work that fails the checks by hand.
- Developer tools
- Assistant platform
- Code repository
- Code index
- Deterministic code analysis (documented in this case study)
- Standards and guidelines
- Code and platform map
- Prompts and context
- Language model (documented in this case study)
- Automated checks
- Checker model
A check mark shows a building block that this case study's sources document.
Open the reference architectureOthers who built it
- Google: A large language model generated 74.45% of the code changes in 39 internal code migrations over twelve months, with an estimated 50% time saving against earlier manual migrations8.
- Amazon: Amazon Q Developer helped migrate tens of thousands of Amazon’s production applications from Java 8 or 11 to Java 17, an estimated saving of over 4,500 years of development work9.
In the library
- How Uber scaled coding agents and cut cost per session Uber
- Pictet takes Claude Code from developers to business teams Pictet Group
- TUI cuts external IT staff with AI coding assistants TUI Group
- eBay's Copilot pilot cut pull request merge time by 17% eBay
- Meta's just-in-time LLM tests catch bugs before code lands Meta
- AI coding assistants speed up software work at Deutsche Bank Deutsche Bank
Cite this case study
Enterprise AI Case Studies. "Alberta audits and rebuilds legacy code with Claude Code." Updated Nov 19, 2026. https://case-studies.ai/case-studies/engineering-and-research/ER-013-legacy-code-security-modernization-alberta/
@misc{csai-er-013,
author = {{Enterprise AI Case Studies}},
title = {{Alberta audits and rebuilds legacy code with Claude Code}},
year = {2026},
note = {Updated 2026-11-19},
url = {https://case-studies.ai/case-studies/engineering-and-research/ER-013-legacy-code-security-modernization-alberta/}
}Sources
The following reporting, and every passage quoted from it, belongs to its publisher, not to this site. Sources and ownership
- Source 1:
Supporting excerpts (34)
Since 2025, the Government of Alberta has been using Claude Code with both Opus and Sonnet models to review its systems, find vulnerabilities, and fix them.
scanned 466 million lines of code in 20 hours, remediated security gaps across its systems, and built new tools to make those systems safer.
maintains the systems of all 27 provincial ministries, from social services to public safety to wildfire response.
That includes roughly 1,280 applications and 3,400 code repositories.
Most of it has never undergone a systematic security review
runs into the billions of dollars.
including tax records, government procurement data, and social services case files
So in 2025, the Ministry set up an internal team with a mandate to make these systems more secure and easier to maintain over time
Around 50 agents worked autonomously and in parallel to scan the systems for security vulnerabilities, weaknesses in underlying infrastructure and deployment processes, and gaps in technical documentation.
Claude Code ran a two-stage routine, first scanning each repository with a rules engine to flag known patterns, then reviewing those flags and citing the exact file and line for each finding so developers could verify them.
The scan covered every repository Alberta owns and identified issues that traditional automated scanning tools had missed.
It took about 20 hours for Alberta
the team estimates that that kind of review could otherwise have taken around 6.5 years.
Where the scan identified a vulnerability, Claude Code could often generate a fix, test it, and build it.
In cases where a system lacked the automated tests needed to confirm that a patch was safe, Claude wrote the tests first.
Where the code was too outdated or too complex to patch efficiently in its existing form, Claude rebuilt it in a more modern and maintainable language.
In some scenarios, these systems could be rebuilt in as little as four to five days, including a subsidy program portal that was originally hand-coded in Java roughly 25 years ago and took five months to build the first time.
before any patch shipped, it was reviewed and approved by the team.
agent probes an application from the outside, the way an attacker might, and maps how a vulnerability might be exploited.
defenses against an international security standard, and writes a remediation plan that points to the exact files to fix.
Additional agents check code quality and the clarity of the writing the public sees.
Every application is checked against roughly 95 security controls on each pass.
These agents are built on top of the Claude Agent SDK
One ministry, for example, has 185 legacy applications running in production, which are expensive to maintain and difficult to update.
consolidate them into 16 reusable applications built on modern coding languages and conventions.
Next, it plans to expand that work with AI agents that can build entirely new software and tools alongside engineers.
Albertans trust their government with some of the most sensitive information in their lives, and it is our responsibility to protect it
By using AI to find and fix vulnerabilities across our systems, we accomplished in hours what would have taken a traditional approach years to complete.
also built a set of specialized Claude review agents that run throughout the development process.
run a robust series of checks and analysis for every application.
Today, Claude helps the Ministry write, review, and deploy code that aids in its modernization efforts.
The Government plans to use Claude Code to analyze these systems, understand what they do, and consolidate them
And this fall, it will begin a program to scale its approach across the provincial government.
Alberta has also published a collection of technical white papers documenting its efforts for other governments to learn from
- Source 2:
Alberta sets North American standard for AI
Supporting excerpts (15)
Over the past 18 months, the Ministry of Technology and Innovation has built its own set of AI tools to document and transform decades-old technologies.
In about 20 hours, those agents reviewed more than 466 million lines of government code, giving Alberta its first complete picture of the health and security of its systems.
By hand, that work would have taken years.
replace 185 aging systems with 16 modern applications which the government owns outright.
AI agents have demonstrated the potential of speeding up work by as much as 20 times while reducing the time to modernize critical systems by as much as 95 per cent.
Google Cloud is proud to power the agentic layer of this digital leap
Alberta is sharing everything it has learned along the way with the publication of 21 technical papers
Alberta built and deployed a team of AI agents, software that can work through tasks on its own
What Alberta built demonstrates something governments have long needed: a practical, documented approach to tackling the technical debt and security exposure that accumulates in decades of legacy code.
Brian Peters, head of North America Government Affairs, Anthropic
The Velocity Papers are the first defensible, in-production blueprint for an agentic public service.
Their deeper lesson is that scarcity drives the result: a resource-constrained government reached the same order-of-magnitude gain in software delivery
Cole Cioran, managing partner, Canadian Public Sector, Info-Tech Research Group
Farsad Nasseri, country managing director, Google Cloud Canada
These Velocity White Papers are released as free and open-source resources
- Source 3:
Alberta plans to replace 185 aging systems with AI-built applications
Supporting excerpts (3)
The government said modernizing this technology conventionally would cost roughly $2 billion and take more than a century, versus a targeted 95 per cent cut in time and cost using AI.
The province did not say when remaining replacements will be complete, nor how many jobs, if any, may be affected.
the AI agents reviewed more than 466 million lines of the province's decades-old computer code in about 20 hours
- Source 4:
Alberta is open-sourcing its AI playbook for government
Supporting excerpts (5)
Those vulnerabilities were fixed after human review.
review more than 466 million lines of code in 20 hours for errors and vulnerabilities.
a similar, human-led process could have taken more than six years and cost upwards of $2 billion.
making it convenient timing for the US company to showcase its use by a Canadian province.
the US government temporarily froze all foreign access to Anthropic
- Source 5:
They Said It Would Cost $54 Million. We Said "No Thanks."
Supporting excerpts (19)
The first tracks every government-owned building in the province.
The second tracks construction budgets and timelines for every new hospital, school, and government building being built in Alberta.
Since 2016, there had been three separate attempts to replace these systems.
three separate attempts to replace these systems. All three failed.
the total bill would land around $54 million.
the $54 million only covered one of the two systems
In June 2025, we launched the PRISM Initiative.
Cohen McLeod, a director in the Ministry of Technology and Innovation
Infrastructure had over 50 hours of recorded walkthroughs of their legacy systems.
converted those 50-plus hours of recordings into detailed, structured build specifications in minutes
using Gemini and Google-hosted Claude instances.
Ten months in, the team has spent $858,000.
At that pace, the estimated total cost to fully deliver both systems is approximately $2.64 million.
a 95% cost reduction. Both systems instead of one.
In production and being used every day by 643 government employees across the Ministry of Infrastructure.
AI did not build these systems by itself.
AI makes development a lot faster, but not on everything.
then hit something that we just have to do by hand.
When you factored in the customization, migration, and ongoing implementation costs over a four-year timeline
- Source 6:
Alberta is working to build North America's most AI-enabled public service, in the open
Supporting excerpts (3)
benchmark increasing our speed by as much as 20 times, and reducing our cost proportionately as much as 95 per cent
a series of 22 papers
Janak Alford, Deputy Minister of Technology and Innovation for the Government of Alberta
- Source 7:
Alberta, Quebec sign five-year deal to share AI tools, training
Supporting excerpts (2)
Alberta and Quebec have signed a five-year agreement to share artificial intelligence tools, training programs and governance frameworks across their public services
Where practical, the two governments will also share technological assets such as source code, tools and documentation.
- Source 8:
Migrating Code At Scale With LLMs At Google
Supporting excerpts (2)
Our case study on 39 distinct migrations undertaken by three developers over twelve months shows that a total of 595 code changes with 93,574 edits have been submitted, where 74.45% of the code changes and 69.46% of the edits were generated by the LLM.
estimated a 50% reduction on the total time spent on the migration compared to earlier manual migrations.
- Source 9:
Amazon Q Developer just reached a $260 million dollar milestone
Supporting excerpts (2)
Amazon has migrated tens of thousands of production applications from Java 8 or 11 to Java 17 with assistance from Amazon Q Developer.
This represents a savings of over 4,500 years of development work for over a thousand developers (when compared to manual upgrades)
- Source 10:
Supporting excerpts (2)
An agent is an application that completes a task by planning its own steps and calling tools that read files, run commands, or edit code.
The Agent SDK gives you the same tools, agent loop, and context management that power Claude Code, programmable in Python and TypeScript.
Comments
Start the conversation.
Invited members of the library comment here. Sign in to join the conversation.