Choose your region

    Lists show the case studies of your region first. Browse and search still hold every case study.

    Europe
    North America

    AI-written code changes speed code migrations at Google

    Google Ads had to widen dozens of ID types that were running out of room, so Google paired its code index with a Gemini model fine-tuned on its own code to write the edits, and builds and tests to check them.

    GoogleUnited StatesInternet platforms and advertisingScaled
    Scale
    595 code changes across 39 ID migrations in twelve months
    Scenario
    Large-scale code migration
    Business function
    Software engineering
    Who built it
    Built in-house
    Human oversight
    People approve each output
    Organization
    Enterprise, part of Alphabet
    AI types
    Generative AI
    Users
    three

    Sources and their publishers

    This case study draws on reporting by the following publishers. Enterprise AI Case Studies combined these accounts and added its own explanation. The reporting, and every passage quoted from it, belongs to whoever published or supplied it.

    1. arXiv

    2. Google

    3. The Register

    4. O'Reilly Media

    5. Amazon Web Services

    6. InfoQ

    7. Google Cloud

    tl;drThe LLM generated 74.45% of 595 code changes, and developers estimated a 50% time saving.See the results

    View the solutionBuild this solution yourself

    Google uses a version of its Gemini model, fine-tuned on Google’s own code, to write the edits in large code migrations1. The first workstream widened dozens of Google Ads ID types from 32-bit to 64-bit integers in C++ and Java1, 3.

    Kythe, Google’s code index, finds the references to each ID, and Gemini writes the edits. Builds and unit tests reject any change that breaks something before an engineer and the code’s owners review it1, 2, 3.

    A study of 39 ID migrations, published in April 2025 and accepted at FSE 2025, followed three developers over twelve months2. The LLM generated 74.45% of the 595 code changes they submitted2. The developers estimated that the work took 50% less time than earlier manual migrations2.

    Before the deployment

    Google Ads runs on more than 500 million lines of code, in code bases more than 20 years old1. Its IDs had to move to 64 bits to avoid negative rollover scenarios that could cause outages1. Google expected them to overflow 32 bits much sooner than first assumed1.

    A central team drove the migration, because tracking the changes would have been very difficult if each team had migrated its own code1. Some of the ID work started by hand, before Google decided to use an LLM-powered migration flow1.

    The manual route had the following problems:

    • Scale: The IDs sat in tens of thousands of code locations across thousands of files. A manual migration was expected to take hundreds of software engineering years1.
    • Hard to find: Most IDs were declared as generic numbers, int32_t in C++ or Integer in Java, so static tools had no distinctive type to search for1. Regular expressions matched short ID names to unrelated IDs and missed references that needed updating2.
    • Hard to change: Class interfaces had to change across several files at once, and tests needed values that prove the code handles 64-bit IDs1.
    • Slow by hand: About three years before the 2025 paper, developers migrated one ID by hand with regular expressions, which took around two years2. One ID typically means hundreds to thousands of changes, and each failed regression test needed a manual investigation2.
    • Standard tooling fell short: Google’s large-scale change infrastructure uses Kythe, Code Search, and tools such as ClangMR. It works for uniform changes but runs into limits when interfaces change across components or tests need updates3.

    What was built

    The toolkit splits each migration into three stages: targeting the locations to change, generating and validating the edits, and reviewing and rolling out the changes3. The model’s main job is edit generation, and deterministic techniques on the abstract syntax tree (AST) handle most of the search and the checks1. The goal is to let the engineer focus on the hard parts of a migration without taking them out of the process3.

    The work is divided as follows:

    • Fine-tuned Gemini: Writes the edits as diffs, predicts whether a file needs migrating, judges whether a change was necessary, and proposes build and test fixes. It doesn’t plan the migration or act as an agent1, 2, 3.
    • Code migration toolkit: Runs nightly on its own until no locations are left. It updates tests where needed and promotes only the changes that pass every validation1, 2.
    • Migration engineer: An expert engineer from Ads picks the ID and finds the files and locations to migrate with Code Search, Kythe, and custom scripts. The same engineer checks each change and fixes the files where the model failed or made a mistake1.
    • Code owners: Receive the changes in shards and review LLM-generated code like any other code, adding any missing tests. They accept and submit each change through Critique, Google’s web-based code review system1, 2.

    A prompt tells the model that it’s a software engineer with a task. It lists informal rules for the change instead of a precise pattern to match in the syntax tree1.

    The workflow is built from reusable steps such as file discovery, validation, and build repair. A new migration mostly needs new prompts and its own validation settings1.

    Alternatives considered

    Google weighed the following options and chose against them:

    • Deterministic code change tools: The contextual clues and the changes vary too much to write out in a fixed transformation pass1. For the JUnit tests, a purely AST-based migration was judged infeasible because it had too many edge cases1.
    • Precise program analysis: Data flow analysis and AST parsing could fix the accuracy problems of a broad reference search. They’re computationally expensive and need logic for countless code variations, so a conservative Kythe search with the LLM bridging the gaps does the work2.
    • LLM planning: Planning capabilities were often not needed and added a layer of complexity, so the toolkit relies on agent-less techniques1.
    • Share of AI-written code as the goal: A migration counts as a success only if AI saves at least 50% of the end-to-end time, including finding the places to migrate, the reviews, and the rollout1. The share of committed AI code is a good proxy in most cases, but it doesn’t always capture all the value1.

    Rollout

    The Google Core Developer, Google Ads, and Google DeepMind teams built the toolkit together3. By July 2024, it had produced hundreds of change lists in the ID and other migrations3. Landed changelists across Ads and other product areas grew steadily through the first three quarters of 20241.

    The toolkit ran the following migrations:

    • IDs: The int32 to int64 migration in Google Ads was the first workstream3.
    • JUnit3 to JUnit4: A list of every JUnit3 test already existed, so running the toolkit over all of them was simple1.
    • Joda time: The team clusters the files that must change together and starts only in directories where reviewers are ready. The migration was still ongoing in January 20251.
    • Experiment flags: Google’s experimentation engine lists the stale flags, and the LLM works out which test flags to delete1.

    In May 2026, Google still listed the ID, JUnit, and Joda time migrations among the workflows it has brought AI into8.

    Technology and architecture

    Figure 1Where the fine-tuned Gemini model sits in Google's migration toolkit
    Where the fine-tuned Gemini model sits in Google's migration toolkitThe seed ID field goes to Kythe and Code Search, which find direct and indirect references. Reference categorizers sort those references, and the nightly migration toolkit passes files with line hints to a fine-tuned Gemini model. The model's diffs go through a validation chain that builds the code and runs unit tests, and build or test failures go back to the model for repair. Passing changes, and files that failed, go to the migration engineer, then through the Critique code review system to the code owners, who submit them to the monorepo. Each night the submitted changes update the remaining references. Every element is documented in the sources.find references (data) · Documented in sources [1] [2]potential references (data) · Documented in source [2]files with line hints (data) · Documented in sources [1] [2]candidate diffs (data) · Documented in sources [1] [2]build and test (trigger or control) · Documented in sources [1] [2]failures for repair (feedback) · Documented in sources [1] [3]passing and failed files (handoff to people) · Documented in source [2]code change (handoff to people) · Documented in source [2]review request (handoff to people) · Documented in sources [1] [2]accept and submit (trigger or control) · Documented in source [2]nightly update (feedback) · Documented in source [2]FINDING THE CODEMIGRATION TOOLKIT, RUNS NIGHTLYREVIEW AND LANDINGSeed ID field · Data · Documented in sources [1] [2]DATASeed ID fieldKythe and Code Search · System · Documented in sources [1] [2] [3]SYSTEMKythe andCode SearchReference categorizers · Step · Documented in sources [1] [2]ReferencecategorizersFine-tuned Gemini · AI model · Documented in sources [1] [2] [3]AI MODELFine-tunedGeminiValidation chain · Decision · Documented in source [2]DECISIONValidationchainBuilds and unit tests · System · Documented in sources [1] [2] [3]SYSTEMBuilds andunit testsMigration engineer · Person · Documented in sources [1] [2]PERSONMigrationengineerCritique code review · Application · Documented in source [2]APPLICATIONCritiquecode reviewCode owners · Team · Documented in sources [1] [2]TEAMCode ownersMonorepo · Data · Documented in sources [2] [3]DATAMonorepofind referencespotentialreferencesfiles withline hintscandidate diffsbuild and testfailuresfor repairpassing andfailed filescode changereview requestacceptand submitnightly updateWhere the fine-tuned Gemini model sits in Google's migration toolkitThe seed ID field goes to Kythe and Code Search, which find direct and indirect references. Reference categorizers sort those references, and the nightly migration toolkit passes files with line hints to a fine-tuned Gemini model. The model's diffs go through a validation chain that builds the code and runs unit tests, and build or test failures go back to the model for repair. Passing changes, and files that failed, go to the migration engineer, then through the Critique code review system to the code owners, who submit them to the monorepo. Each night the submitted changes update the remaining references. Every element is documented in the sources.find references (data) · Documented in sources [1] [2]potential references (data) · Documented in source [2]files with line hints (data) · Documented in sources [1] [2]candidate diffs (data) · Documented in sources [1] [2]build and test (trigger or control) · Documented in sources [1] [2]failures for repair (feedback) · Documented in sources [1] [3]passing and failed files (handoff to people) · Documented in source [2]code change (handoff to people) · Documented in source [2]review request (handoff to people) · Documented in sources [1] [2]accept and submit (trigger or control) · Documented in source [2]nightly update (feedback) · Documented in source [2]FINDING THE CODEMIGRATION TOOLKIT, RUNS NIGHTLYREVIEW AND LANDINGSeed ID field · Data · Documented in sources [1] [2]DATASeed ID fieldKythe and Code Search · System · Documented in sources [1] [2] [3]SYSTEMKythe and Code SearchReference categorizers · Step · Documented in sources [1] [2]Reference categorizersFine-tuned Gemini · AI model · Documented in sources [1] [2] [3]AI MODELFine-tuned GeminiValidation chain · Decision · Documented in source [2]DECISIONValidation chainBuilds and unit tests · System · Documented in sources [1] [2] [3]SYSTEMBuilds and unit testsMigration engineer · Person · Documented in sources [1] [2]PERSONMigration engineerCritique code review · Application · Documented in source [2]APPLICATIONCritique code reviewCode owners · Team · Documented in sources [1] [2]TEAMCode ownersMonorepo · Data · Documented in sources [2] [3]DATAMonorepofind referencespotential referencesfiles with line hintscandidate diffsbuild and testfailures for repairpassing and failed filescode changereview requestaccept and submitnightly update
    • AI component
    • Data
    • Trigger or control
    • Handoff to people
    • Feedback
    Sources [1][2][3]
    Gemini writes the edits, while Kythe finds the references, the validation chain filters every change, and people review and submit it.

    The following table lists the components of the solution.

    Layer What they used Role Source
    Language model Gemini, fine-tuned on internal Google code Writes the edits as diffs, judges whether a change was needed, repairs build and test failures 1, 2, 3
    Training pipeline DIDACT Trained the model on data from Google’s monorepo and development processes 1, 3, 9
    Workflow engine Code migration toolkit Runs nightly; expands and groups files, prompts the model, tries prompt combinations, validates and scores 1, 2
    Search and vector index Kythe Finds direct and indirect references to each ID field 1, 2
    Developer tools Code Search Helps the engineer find candidate files and locations 1, 3
    Rules and decision logic Reference categorizers Sort each location into not-migrated, irrelevant, relevant or left-over 1, 2
    Guardrails Validation chain Rejects failed, whitespace-only, malformed, unneeded, unbuildable or test-breaking changes 2
    Review workbench Critique Code owners accept and submit each change 2

    The model is an internal version of Gemini, fine-tuned with DIDACT on Google’s code and data2, 3. DIDACT is Google’s method of training models on the process of software development, such as edits, builds, repairs, and reviews, rather than only on finished code9. The training included a large set of failed builds and tests paired with the diffs that fixed them, which the repair step draws on3.

    For the FSE study, the team kept one fixed model version at temperature 0.0 for stability2. It used prompting only, with no fine-tuning for the migration task2. The IDs already had privacy protections, and the model changes their type without altering or surfacing them3.

    Data inputs

    The model works from the following data:

    • Seed field: Each migration starts from the protocol buffer field that defines the ID. Protocol buffers are Google’s standard format for structured data1.
    • Files to migrate: The toolkit adds related tests, interfaces, and other dependencies to the engineer’s file set by using symbol cross-references1. Each query carries whole files grouped with their relatives, with a natural-language instruction on each line expected to change1, 2.
    • Prompts and examples: One or two prompts describe the change. Few-shot examples help the model decide whether a file needs migrating at all1.
    • Build and test errors: A failure goes back to the model with the changed files and a request for a fix1, 3.
    • Conversion functions: For Joda time, an auxiliary class of conversion functions is the only extra context1.

    Integrations

    The toolkit connects to the following systems:

    • Kythe: Indexes Google’s entire codebase2. The January 2025 report repeats its search for references to references three times, and the FSE paper goes to a maximum distance of five1, 2. The search is deliberately conservative, a superset that avoids missing references at the cost of finding many that don’t need changing2.
    • Build and regression test system: Builds each changed file and runs its tests. A failure goes back to the model for repair or marks the file for manual work1, 2.
    • Large Scale Changes system: Split the JUnit changelists into smaller sets for the owners of the tests1. Its tool Rosie shards a large change by project and ownership, and TAP, Google’s CI framework, tests each shard5. The ID changes most likely reach their reviewers by the same route.
    • Monorepo: Accepted changes land there, and the next nightly run uses them to update the remaining references2.

    How one ID migration flows through the system

    The FSE paper walks through a toy example, an inventory record with a 32-bit toy_id field2. The following steps follow that example and the real migrations:

    1. The engineer changes the field to 64 bits in its protocol buffer definition and gives the system the field as its seed2.
    2. Kythe finds every line that reads or sets toy_id, the lines that contain those, and the lines that call them2.
    3. The categorizers sort each location by confidence. Regular expressions catch casts to 32 bits and test values that still fit in 32 bits, and a parser drops definitions that don’t need changing1, 2.
    4. A developer decides on each left-over location. The verdict goes into the system’s configuration, so the next run files the location correctly1, 2.
    5. The toolkit tries several prompt combinations in parallel for each group of files, because too many location hints sometimes work worse than one1, 3. In the FSE study, each file got three rounds, and one successful attempt was picked at random2.
    6. The model returns a diff that widens the types and moves the bit check to the top of a 64-bit number. It also gives the tests values beyond the 32-bit range. A fuzzy diffing algorithm applies the diff to the file and absorbs small errors2.
    7. The validation chain runs six checks, from the cheapest to the most expensive, and ends with the build and the regression tests2. A file that fails any check is discarded and marked for a developer to migrate by hand2.
    8. A failed build or test can first trigger a repair, in which the model sees the changed files and the error1, 3. If several candidates survive, the toolkit scores them on the validations and keeps the best1.
    9. The engineer groups the changed files into code changes, looks over each one, and makes any final edits. The code owners then review, accept, and submit each change in Critique2.
    Figure 2One ID migration, from seed field to submitted change
    One ID migration, from seed field to submitted changeThe migration engineer gives the toolkit a seed ID field. Each night, until no references remain, the toolkit finds and sorts references, sends each file with line hints to the fine-tuned Gemini model, receives a diff, and runs the build, tests and other checks on it. A change that passes every check goes to the engineer as ready for review, and a file that fails is handed back to the engineer to change by hand. The engineer sends the code change to the code owners in Critique, who accept and submit it. Every step is documented.LOOPeach night, until none remainALTpasses every checkelse: fails a check1. seed ID field · Documented in sources [1] [2]1Migration engineerMigration toolkitseed ID field2. find and sort references · Documented in source [2]2Migration toolkitfind and sort references3. file with line hints · Documented in source [2]3Migration toolkitFine-tuned Geminifile with line hints4. diff for the file · Documented in source [2]4Fine-tuned GeminiMigration toolkitdiff for the file5. validate the change · Documented in source [2]5Migration toolkitBuild, tests and checksvalidate the change6. pass or fail · Documented in source [2]6Build, tests and checksMigration toolkitpass or fail7. change ready for review · Documented in source [2]7Migration toolkitMigration engineerchange ready for review8. file to change by hand · Documented in source [2]8Migration toolkitMigration engineerfile to change by hand9. code change in Critique · Documented in source [2]9Migration engineerCode ownerscode change in Critique10. accept and submit · Documented in source [2]10Code ownersaccept and submitOne ID migration, from seed field to submitted changeThe migration engineer gives the toolkit a seed ID field. Each night, until no references remain, the toolkit finds and sorts references, sends each file with line hints to the fine-tuned Gemini model, receives a diff, and runs the build, tests and other checks on it. A change that passes every check goes to the engineer as ready for review, and a file that fails is handed back to the engineer to change by hand. The engineer sends the code change to the code owners in Critique, who accept and submit it. Every step is documented.LOOPeach night, until none remainALTpasses every checkelse: fails a check1. seed ID field · Documented in sources [1] [2]1seed ID field2. find and sort references · Documented in source [2]2find and sortreferences3. file with line hints · Documented in source [2]3file with line hints4. diff for the file · Documented in source [2]4diff for the file5. validate the change · Documented in source [2]5validate the change6. pass or fail · Documented in source [2]6pass or fail7. change ready for review · Documented in source [2]7change readyfor review8. file to change by hand · Documented in source [2]8file to changeby hand9. code change in Critique · Documented in source [2]9code change in Critique10. accept and submit · Documented in source [2]10accept andsubmitMigration engineer · Person · Documented in sources [1] [2]MigrationengineerMigration toolkit · System · Documented in sources [1] [2]MigrationtoolkitFine-tuned Gemini · AI model · Documented in sources [1] [2]Fine-tunedGeminiBuild, tests and checks · System · Documented in source [2]Build, testsand checksCode owners · Team · Documented in sources [1] [2]Code ownersOne ID migration, from seed field to submitted changeThe migration engineer gives the toolkit a seed ID field. Each night, until no references remain, the toolkit finds and sorts references, sends each file with line hints to the fine-tuned Gemini model, receives a diff, and runs the build, tests and other checks on it. A change that passes every check goes to the engineer as ready for review, and a file that fails is handed back to the engineer to change by hand. The engineer sends the code change to the code owners in Critique, who accept and submit it. Every step is documented.LOOPeach night, until none remainALTpasses every checkelse: fails a check1. seed ID field · Documented in sources [1] [2]1seed ID field2. find and sort references · Documented in source [2]2find and sortreferences3. file with line hints · Documented in source [2]3file with line hints4. diff for the file · Documented in source [2]4diff for the file5. validate the change · Documented in source [2]5validate the change6. pass or fail · Documented in source [2]6pass or fail7. change ready for review · Documented in source [2]7change readyfor review8. file to change by hand · Documented in source [2]8file to changeby hand9. code change in Critique · Documented in source [2]9code change in Critique10. accept and submit · Documented in source [2]10accept and submitMigration engineer · Person · Documented in sources [1] [2]MigrationengineerMigration toolkit · System · Documented in sources [1] [2]Migration toolkitFine-tuned Gemini · AI model · Documented in sources [1] [2]Fine-tunedGeminiBuild, tests and checks · System · Documented in source [2]Build, testsand checksCode owners · Team · Documented in sources [1] [2]Code ownersOne ID migration, from seed field to submitted changeThe migration engineer gives the toolkit a seed ID field. Each night, until no references remain, the toolkit finds and sorts references, sends each file with line hints to the fine-tuned Gemini model, receives a diff, and runs the build, tests and other checks on it. A change that passes every check goes to the engineer as ready for review, and a file that fails is handed back to the engineer to change by hand. The engineer sends the code change to the code owners in Critique, who accept and submit it. Every step is documented.LOOPeach night, until none remainALTpasses every checkelse: fails a check1. seed ID field · Documented in sources [1] [2]1seed ID field2. find and sort references · Documented in source [2]2find and sortreferences3. file with line hints · Documented in source [2]3file with line hints4. diff for the file · Documented in source [2]4diff for the file5. validate the change · Documented in source [2]5validate the change6. pass or fail · Documented in source [2]6pass or fail7. change ready for review · Documented in source [2]7change ready for review8. file to change by hand · Documented in source [2]8file to change by hand9. code change in Critique · Documented in source [2]9code change in Critique10. accept and submit · Documented in source [2]10accept and submitMigration engineer · Person · Documented in sources [1] [2]MigrationengineerMigration toolkit · System · Documented in sources [1] [2]Migration toolkitFine-tuned Gemini · AI model · Documented in sources [1] [2]Fine-tunedGeminiBuild, tests and checks · System · Documented in source [2]Build, testsand checksCode owners · Team · Documented in sources [1] [2]Code owners
    • AI component
    • Data
    • Trigger or control
    • Handoff to people
    Sources [1][2]
    The toolkit loops every night until no references remain, and only code owners can accept a change into the codebase.

    Results

    The following table lists the results of each migration.

    Metric Before After Scope and timeframe Reported by
    Code changes generated by the LLM Not disclosed 74.45% of 595 39 ID migrations by three developers over twelve months Google engineers, measured2
    Edits made by the LLM Not disclosed 69.46% of 93,574 Same 39 migrations Google engineers, measured2
    Total time spent on a migration Earlier manual migrations 50% less ID migrations, including review and landing Google engineers, estimated1, 2
    AI-authored code in landed changelists Not disclosed 80% First int32 to int64 workstream Google engineers, measured1, 3
    AI-generated character changes landing in the monorepo Not disclosed more than 75% Average across hundreds of change lists, by July 2024 Google Research, measured3
    JUnit3 tests moved to JUnit4 Not disclosed 5,359 files, more than 149,000 lines 3 months Google engineers, measured1
    AI-generated JUnit4 code committed unchanged Not disclosed 87% End of the JUnit migration Google engineers, measured1
    Time saved on small Joda time clusters Purely manual approach 89% Estimate by team technical leads, migration ongoing Google engineers, estimated1

    The metrics measure the following:

    • Code changes generated by the LLM: A change counts if the model created it, even if a developer edited it afterwards. The 74.45% is 214 changes that the LLM wrote alone and 229 that developers then edited, and people wrote the other 1522.
    • Edits made by the LLM: Counts the characters that the model changed against those that people changed. It uses Levenshtein edit distance, the number of characters inserted, deleted, or replaced2.
    • AI-authored code in landed changelists: The 80% compares the model’s first version of each changelist with the committed version, character by character1.

    The developers also valued the automated validations, which spared them from creating each change and waiting for its checks, and the nightly runs that kept the migration’s state current2. Because a single engineer could generate all the changes, the communication overhead of a cross-team migration fell1.

    Lessons learned

    The ID results rest on scale and on a narrow role for the model. The 74.45% counts every code change in 39 migrations over twelve months, reviewed as usual on well over a hundred teams2. Because deterministic search and a chain of checks surround the model, people saw only changes that already built and passed their tests1, 2.

    Review, not generation, set the pace. In the JUnit migration, the team capped weekly changes because review speed was the bottleneck, and Google slowed other migration work for the same reason1. Engineers still spent time on analysis and review, and the system gave no help with the slow, watched rollout of the two largest IDs2, 3.

    People had to undo some of the model’s work. In the first workstream, a human needed to revert some of its changes in most cases, so Google invested in LLM-driven verification1. In the ID study, the model sometimes only reformatted code, added comments, or made irrelevant changes, and developers handled 25.55% of the code changes and 30.54% of the edits by hand2.

    The model’s training and its surroundings set other limits. Dart was poorly supported because the model hadn’t seen enough Dart code, and some large files didn’t fit the context window2. Pre-existing test failures kept successful changes out of review, and sorting the references still needed people because so many locations were ambiguous1, 2.

    Token costs can quickly add up even as prices fall, because migrations touch thousands of files1. Fine-tuned models, which Google has used for generating edits and fixing build failures, carry their own cost1. Bespoke tooling also has the hidden cost of training engineers to use it and maintaining tools that few people use1.

    All of the figures are Google’s own, from the engineers who built and used the system1, 2, 3. The FSE paper has no controlled experiment, and its 50% rests on estimates by developers who helped shape the system, which might bias them2. The Register noted that no specifics supported the 89% Joda figure, and the three shares of AI-written code measure different things1, 3, 4.

    Case study scorecard

    Build this solution yourself

    Analysis

    What you need

    To migrate code the way Google did, you need the following in place:

    • A code index of the whole repository: Kythe indexed the entire codebase, so a seed field could be traced to every reference2.
    • Builds and tests that you trust: They rejected a bad edit before anyone looked at it, so people saw only changes that worked2.
    • A model that knows your code: Google’s model was tuned on its own code and on failed builds paired with their fixes3. It knew the house APIs and could repair its own breakages3.
    • Reviewer time: The code had owners who reviewed every change, and their capacity set the throughput1.

    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.

    A check mark shows a building block that this case study's sources document.

    Open the reference architecture

    Others who built it

    • Amazon: By August 2024, Amazon had moved tens of thousands of production applications from Java 8 or 11 to Java 17 with Amazon Q Developer6. It estimated the savings at over 4,500 years of development work6.
    • Airbnb: By March 2025, Airbnb had converted nearly 3.5K React test files from Enzyme to React Testing Library with an LLM pipeline7. That condensed an estimated 1.5-year project into six weeks7.

    Cite this case study

    Enterprise AI Case Studies. "AI-written code changes speed code migrations at Google." Updated Nov 19, 2026. https://case-studies.ai/case-studies/engineering-and-research/ER-002-legacy-code-modernization/

    @misc{csai-er-002,
      author = {{Enterprise AI Case Studies}},
      title = {{AI-written code changes speed code migrations at Google}},
      year = {2026},
      note = {Updated 2026-11-19},
      url = {https://case-studies.ai/case-studies/engineering-and-research/ER-002-legacy-code-modernization/}
    }

    Sources

    The following reporting, and every passage quoted from it, belongs to its publisher, not to this site. Sources and ownership

    1. Source 1:

      How is Google using AI for internal code migrations?

      AcademicarXiv, Jan 12, 202512 Jan 2025By Stoyan Nikolov, Daniele Codecasa, Anna Sjövall, Maxim Tabachnyk, Satish Chandra, Siddharth Taneja, and Celal ZiftciAccessed Nov 16, 202616 Nov 2026

      Supporting excerpts (111)
      • Stoyan Nikolov1, Daniele Codecasa1, Anna Sjövall1, Maxim Tabachnyk1, Satish Chandra1,
      • Siddharth Taneja2, Celal Ziftci2
      • This article is an experience report on using LLMs for code migrations at Google.
      • It is not a research study, in the sense that we do not carry out comparisons against other approaches or evaluate research questions/hypotheses.
      • Mature (20+ years), large code bases.
      • The Google Ads business is one of the largest in the world and is built on a code base of 500+M lines of code.
      • need to be converted to 64 bits to avoid negative rollover scenarios that could cause outages.
      • Google Ads has dozens of numerical unique
      • for users, merchants, campaigns, etc.
      • these IDs were originally defined as 32-bit integers in C++ and Java.
      • we expect them to overflow the 32-bit capacity much sooner than originally expected.
      • The IDs are often defined as generic numbers (int32_t in C++ or Integer in Java) and are not of a unique, easily searchable type, which makes the process of finding them through static tooling non-trivial.
      • There are tens of thousands of code locations across thousands of files where these IDs are used.
      • Tracking the changes across all the involved teams would be very difficult if each team were to handle the migration in their data themselves.
      • Changes in the class interfaces need to be taken into account across multiple files.
      • Tests need to be updated to verify that the 64-bit IDs are handled correctly.
      • Constants are sometimes expressed as C++ macros. IDs are occasionally serialized as text, away from where they are used.
      • The full effort, if done manually was expected to require hundreds of software engineering years and complex cross-team coordination.
      • The approach Google has had for such cases is to have a central team that drives the migration.
      • Although some migration was done initially manually, we decided to employ an LLM-powered code migration flow
      • An expert engineer from Ads finds the ID they want to migrate and, using a combination of Code Search, Kythe
      • and custom scripts, identifies a (best effort) superset of files and locations to migrate.
      • An LLM-based migration toolkit, triggered by an expert, runs autonomously and produces verified changes that only contain code that passes unit tests. When necessary, tests are also updated to reflect the changes to the code.
      • The same engineer then manually checks the change and potentially updates files where the model failed or made a mistake. The changes are then sharded and sent to multiple reviewers who own the part of the codebase affected by the change.
      • We found that 80% of the code modifications in the landed CLs were fully AI-authored, and the rest were human-authored or edited from the AI suggestions.
      • The first version (known internally as snapshot) of the changelist is the one generated by the LLM-powered tooling. The version actually committed to the repo is compared to this and a per-character difference is calculated.
      • We discovered that in most cases, the human needed to revert at least some changes the model made that were either incorrect or not necessary.
      • Given the complexity and sensitive nature of the modified code, effort has to be spent in carefully rolling out each change to users.
      • This observation led to further investment in LLM-driven verification (described later) to reduce this burden.
      • The total time spent on the migration was reduced by an estimated 50% as reported by the engineers doing the migration, when compared to a similar exercise carried out without LLM assistance.
      • In this calculation, we take into account the time needed to review and land the changes.
      • There was also a significant reduction in communication overhead, as a single engineer could generate all necessary changes.
      • First, we start with the manual identification of the protocol buffer fields for an ID, called a
      • This process is repeated 3 times where references-to-references are also automatically found
      • First, we pass the locations through regular expressions to identify if production code contains any casting in different languages
      • One approach is to parse the source code to check whether a given location contains an actual call relevant to the seed or not.
      • The human involvement in the process decreased during the development of the workflow but still remained high due to the prevalence of ambiguous locations to change.
      • The LLM role is focused on the edit generation. The parts where we need to identify locations at which to make changes, and where we need to validate that the right thing took place, are handled mostly using deterministic AST techniques with a few cases supported by the LLM as well.
      • Humans review the LLM-generated code the same way as any other code and they add any missing tests to cover the changed lines.
      • the review and rollout phases, which are still largely human-driven.
      • for each migration described we have defined success as AI saving at least 50% of the time for the end-to-end work. This time is not only the change generation itself (the code rewrite), but also finding the places to migrate, doing reviews and rolling out the changes.
      • We found that while the ratio of code generated by AI that gets committed is a good proxy for the time savings in most cases, it does not always capture all the value.
      • Anecdotal remarks from developers suggest that even if the changes are not perfect, there is a lot of value in having an initial version of the changelist already created
      • anchoring the success metric on the whole development journey offers a clearer impact goal and is aligned with the business outcome, rapid completion of the migrations.
      • we relied on the expert engineers estimating a time-saving for a set of changelists created by the tools and we extrapolated from that.
      • Currently the quality is assured through the manual review process of the code
      • Where rule refers to an informal description of what needs to be accomplished; as opposed to a precise AST-level pattern matching and transformation.
      • The use of LLMs alone through simple prompting is not sufficient for anything but the simplest of migrations.
      • a combination of AST-based techniques, heuristics, and LLMs are needed to achieve success.
      • This is because the contextual clues and the actual changes to be made have quite a bit of variance, and these are difficult to write out in a deterministic code transformation pass.
      • This approach allows us to quickly onboard new use cases, because we built a palette of reusable sub-steps which we can combine and adapt.
      • We discovered that LLM planning capabilities are often not needed and add a layer of complexity that should be avoided when possible.
      • approaches in this paper rely on agent-less techniques.
      • through 2024 the number of changelists (similar to pull requests in Git) from migration efforts across Ads and other product areas has steadily increased
      • Landed changelists of AI-powered migrations for the first 3 quarters for 2024.
      • Building on the success of the Ads experience, the number of different migration initiatives around Google has been increasing.
      • This has created an ecosystem that allows the teams to employ economies of scale, slotting new migrations into already proven workflows.
      • To generate and validate the code changes we leverage a version of the Gemini model that we fine-tuned on internal Google code and data.
      • Our LLM was trained following the DIDACT
      • the main target is usually one or more fields defined in a protocol buffer
      • One or two prompts that describe the change.
      • Few-shot examples to decide if a file actually needs migration.
      • The migration toolkit automatically expands this set with additional relevant files that can include: test files, interface files, and other dependencies.
      • we provide the model with few-shot examples and ask it to predict if a file needs to be migrated.
      • At inference time, we annotate each line where we expect a change is needed with a natural language instruction as well as a general instruction for the model.
      • In each model query, the input context contains one or multiple files related to each other, for example implementation files with headers, tests, interface declarations etc..
      • The model predicts differences (diffs) between the files where changes are needed and will also change related sections so that the final code is correct.
      • In the predicted unified diff, the model correctly also fixes the private field and usages within the class.
      • we implement a mechanism that generates prompt combinations that are tried in parallel for each file group.
      • The two most common validations are building the changed files and running their unit tests. Each of the failed validation steps can optionally run an ML-powered
      • For each of the build/test failures that we encounter, we prompt the model with the changed files, the build/test error and a prompt that requests a fix.
      • we score them based on the validations and at the end decide which change to propagate back to the final change list
      • A group of teams at Google had a substantial set of test files that used the now old JUnit3 library.
      • They are technical debt and tend to replicate themselves, as developers might inadvertently copy old code to produce new one.
      • doing so with purely AST-based techniques was deemed infeasible as there are just too many edge cases.
      • We already had a list of all the JUnit3 tests in the repository, so running over all of them was simple.
      • While we modified each test file, the internal system for Large Scale Changes
      • split the resulting changelists into smaller sets that were sent to the owners of the tests for review.
      • The version of Gemini that we used was fine-tuned on the internal Google code base so it already had seen quite some JUnit4 tests.
      • This allowed us to have a relatively simple set of prompts that essentially consisted of a list of rules
      • Any failures were sent again to the model for fixing
      • With this technique we were able to migrate 5,359 files modifying more than 149,000 lines of code in 3 months.
      • The bottleneck in the process was the speed at which engineers could review the changes.
      • We purposefully limited the number of changes we generate every weak to avoid overwhelming reviewers.
      • 87% of the code generated by AI ended up committed without any change.
      • Some parts of the codebase still use the Joda time library for Java instead of the standard java.time package.
      • this dependency remains and is still widespread with thousands of occurrences.
      • We start with the directories (which very roughly correspond to components and projects) where we have reviewers ready.
      • To answer these questions we built a clustering solution through Kythe where we categorize the potential changes.
      • When there is a dependency, ideally we migrate all files in one prompt.
      • as Gemini offers a huge context window we can comfortably fit many of the clusters into the context window.
      • The only additional context, apart from the files to migrate we offer, is an auxiliary class with conversion functions that sometimes need to be used.
      • 89% of the time it would have taken humans to do the change in the small clusters.
      • The number is calculated across multiple changes where human experts (team technical leads) have compared their experience with the AI-powered tooling to the previous purely-manual approach.
      • This migration is still ongoing, and we have challenges to solve.
      • We need to improve some of the call-graph logic as connections are sometimes missed when components depend on each other through Guice
      • Another challenge is the presence of switch statements that use dynamic typing.
      • The experimentation engine tracks all experiments and flags across Google and can list all the stale flags
      • we decided to use the LLM to tell us which test flag we need to delete.
      • The most challenging part is cleaning up the right tests.
      • In our observations, the LLMs are very good at fixing a well defined problem which complements their first attempt at a change.
      • Although the cost per token for predictions has steadily decreased, migrations often require touching thousands of files and the costs might quickly add up.
      • Code reviews and change rollouts still require a human operator and can quickly become bottlenecks in the larger code migration process.
      • We needed to slow down some of the migration work to avoid overwhelming the teams that had to do the reviews
      • The use of generative AI widely, with bespoke techniques, comes with a hidden cost: that of having to train a number of engineers in the use of these techniques.
      • Building elaborate tooling to completely hide the use of AI behind tools is expensive
      • while fine-tuned models can be useful, they also come with a cost
      • We have currently used fine-tuned models for generating edits and fixing build failures.
      • Whether there is a long-term impact on quality remains to be seen.
      • rely on LLMs tend to be much cheaper computation-wise.
      • the speed-up provided by the AI on the code changes alone was higher
    2. Source 2:

      Migrating Code At Scale With LLMs At Google

      AcademicarXiv, Apr 13, 202513 Apr 2025By Celal Ziftci, Stoyan Nikolov, Anna Sjövall, Bo Kim, Daniele Codecasa, and Max KimAccessed Nov 16, 202616 Nov 2026

      Supporting excerpts (80)
      • This is a preprint of a paper accepted at the ACM International Conference on the Foundations of Software Engineering (FSE) 2025.
      • 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
      • 74.45% of the code changes and 69.46%
      • The developers reported high satisfaction with the automated tooling, and estimated a 50%
      • reduction on the total time spent on the migration compared to earlier manual migrations.
      • An instance of this migration for a specific ID has been undertaken at Google three years ago
      • where developers used regular expressions, regex for short
      • and manually changed all the direct and indirect references to the ID across the entire codebase.
      • This effort took around two years to complete
      • it will likely find extra references that do not need changing, or will miss references that potentially need to be updated.
      • some ID names are quite short, and can match other unrelated IDs across the codebase.
      • There are typically hundreds to thousands of changes across the codebase when migrating an ID
      • This system runs nightly until all locations are processed and there are no outstanding locations left to be migrated.
      • a code indexing system called Kythe (Google, 2012) that indexes the entire codebase in the repository.
      • Using Kythe, we first find the direct references to the ID, then find the direct references to those references, and keep finding other indirect references to the ID in the entire codebase for a maximum total distance of five.
      • we opt to be conservative to avoid missing any references and use a super-set of the locations that require changing.
      • After finding the potential references, we categorize them into buckets based on confidence on whether they need to be migrated or not.
      • Left-over: This is a location that is not categorized into any of the previous categories and is left over to be investigated by developers manually.
      • In the next run of the system, the investigated location is moved into the dictated category, not-migrated or irrelevant.
      • we leverage an internal version of the Gemini (Team et al., 2023) model fine-tuned on internal Google code and data
      • using the DIDACT framework (Maniatis and Tarlow, 2023)
      • with multiple tasks for software engineering, including code-review comment resolution, edit prediction, variable renaming, code-review comment prediction, and build-error repair
      • we used the same fixed version of it with temperature=0.0 throughout the course of our study for stability, we did not fine-tune the model for our specific task, and only used prompting for the code modifications.
      • The passed line numbers are suggestive, and the LLM has flexibility on making changes in other lines anywhere in the file.
      • The line suggestions are represented in the model prompt as comments instructing the model of what should be changed in the given line.
      • toy_id should be of type long. Update the code and respective references properly.
      • Migrating Identifiers From 32-bits To 64-bits
      • toy_id is a 32 bit integer to uniquely identify a toy
      • The LLM outputs changes in the form of diffs
      • which are applied to the original file using a fuzzy diffing algorithm.
      • This finds the locations of code to replace by using edit distance to minimize simple LLM errors.
      • three rounds of modifications are attempted for each file, and a random change from among the successful attempts is chosen for each file.
      • Success: If the LLM did not return a successful completion, the change is invalid.
      • Whitespace: If the LLM only changed whitespaces, i.e. it simply reformatted the code, the change is invalid.
      • AST parser: If the changed file cannot be parsed with an AST parser, i.e. it is malformed, or the AST of the changed file is identical with the original, the change is invalid.
      • We pass the files' contents before and after the change, and ask the LLM whether the change was necessary.
      • Build: If the changed file causes build breakages during compilation, the change is invalid.
      • Test: If the changed file causes regression test failures, the change is invalid.
      • The validations are conducted in the listed order from less expensive to more expensive.
      • If the changed file fails any of the validations, it is discarded without running further validations, and marked to be migrated manually by developers.
      • If the file is successfully modified by the LLM and passes all validation steps, it is marked to be ready for review.
      • each change is visually investigated by developers for verification, any necessary final changes are manually performed within the code change by developers, and finally each code change is sent to the owners of the code for final acceptance and submission through Critique
      • the web-based code review system used at Google
      • Our system ran nightly, and promoted the code changes that passed all validations to be reviewed by developers.
      • of the code changes (LLM-Only and LLM-then-Human) have been generated by the LLM
      • LLM-Only 214 (35.97%
      • LLM-then-Human 229 (38.48%
      • Human-Only 152 (25.55%
      • # reviewers 306306 # teams 149149 # offices 3737 # time zones 1212
      • we use the number of characters edited by humans and LLMs to complete an ID migration.
      • Between each snapshot, there are character edits to change the code to the new snapshot, shown in Figure 2, where we use Levenshtein
      • as a proxy to measure the effort required to make the modifications.
      • conducted interviews with the three developers that performed the migrations using our system.
      • We do not have concrete wall-clock effort measurements on the total time spent
      • as our system runs nightly and updates the remaining left-over references automatically using the submitted code changes
      • the developers reported to have a continuously renewed state of the migration, providing a sense of progress towards the completion of the migration.
      • Our system only promotes those code changes that pass all validation steps that are ready for review, decreasing the tedious work developers need to undertake.
      • the LLM correctly identifies and changes not only code but also its counterpart in the SQL string.
      • developers could not anticipate how many retries would be needed before resorting to manual changes
      • they started with smaller, localized IDs.
      • As they gained more experience, they moved on to larger, more spread IDs, with higher use of automation.
      • The LLM sometimes had hallucinations, where it simply reformatted the code as in Figure 6, only added comments to the code as in Figure 6, or made entirely irrelevant changes.
      • Developers had to manually handle such cases, constituting 25.55%
      • of the code changes and 30.54%
      • Dart was not well supported, as the LLM was not trained on enough Dart code.
      • some edits were not performed by the LLM as the entire contents of a large file did not fit into the context window
      • This is mitigated in the latest Gemini versions with a much larger context window.
      • If the regression test suite has pre-existing failures unrelated to the code change under review, validation of the code change fails
      • even though the LLM has been successful in some of the code changes, those code changes were not promoted for review
      • As our automated system did not support running such tools, tests using goldens sometimes failed
      • large, distributed IDs, a total of 2 out of the 39 migrated, namely ID-30 and ID-32, required attention from the code owners before they were rolled out into production.
      • As the impact of such IDs potentially spanned across several teams
      • changes were rolled out slowly to observe any adverse effects. Our system provided no automation or benefits for this step.
      • Our case study does not involve a controlled experiment comparing the LLM-based approach to other techniques
      • Our study uses an LLM developed to be used internally at Google.
      • time savings is based on developer perception and estimations, and not on precise time tracking data.
      • The developers involved in the case study were also involved in the development of the system by providing feedback, potentially introducing bias in their assessment of the system's effectiveness.
      • It is possible to overcome these accuracy problems in the identified potential references using approaches such as data flow analysis
      • However, these techniques are potentially computationally expensive, and require implementing and maintaining logic to predict and cover many potential code variations written in different styles by thousands of developers over many years
      • This list contains code locations that do not necessarily need to be modified during the migration
    3. Source 3:

      Accelerating code migrations with AI

      OrganizationGoogle, Jul 18, 202418 Jul 2024By Stoyan Nikolov and Siddharth TanejaAccessed Nov 16, 202616 Nov 2026

      Supporting excerpts (22)
      • Stoyan Nikolov, Senior Staff Software Engineer, Google Core, and Siddharth Taneja, Senior Engineering Manager, Google Ads
      • For years, Google has employed special infrastructure for large scale changes to execute complex code migrations. The infrastructure uses static analysis and tools like Kythe and Code Search to discover which locations need to be changed along with their dependencies. Tools like ClangMR are then employed to make the changes.
      • This approach works well for changes that are uniform in their structure and have a limited set of edge cases.
      • Yet static analysis and simple migration scripts run into limitations when migrating code that has a complex structure
      • changing interfaces and their usages across multiple components and their dependencies or updating their tests.
      • The goal is to assist the engineer and let them focus on the complex aspects of the migration without isolating them from the process.
      • Targeting the locations in the codebase that needed modifications
      • Edit generation and validation
      • Change review and rollout
      • To generate and validate the code changes we leverage a version of the Gemini model that we fine-tuned on internal Google code and data.
      • Our model was trained following the DIDACT methodology on data from Google's monorepo and processes.
      • the generated changes might not be aligned with the initial locations requested, but they will solve the intent.
      • In some cases providing too many locations where one might expect a change results in worse performance than specifying a change in just one place in the file
      • This is similar to a pass@k strategy where instead of inference temperature we modify the prompting strategy.
      • The model has also been trained on a large set of failed builds and tests paired with the diffs that then fixed them.
      • Note that the IDs used in the internal code base have appropriate privacy protections already applied. While the model migrates them to a new type, it does not alter or surface them, so all privacy protections will remain intact.
      • For this workstream we found that 80% of the code modifications in the landed CLs were AI-authored, the rest were human-authored.
      • The total time spent on the migration was reduced by an estimated 50% as reported by the engineers doing the migration.
      • Engineers still needed to spend time on the analysis of the files that needed changes and on their review.
      • We found that in Java files our model predicted the need to edit a file with 91% accuracy.
      • The toolkit has already been used to create hundreds of change lists in this and other migrations. On average we achieve >75% of the AI-generated character changes successfully landing in the monorepo.
      • This work is the result of a collaboration between the Google Core Developer, Google Ads and Google DeepMind teams.
    4. Source 4:

      Google reports halving code migration time with AI help

      IndependentThe Register, Jan 16, 202516 Jan 2025Accessed Nov 16, 202616 Nov 2026

      Supporting excerpts (3)
      • reports dogfooding its own AI concoction
      • Even with the need to double-check the LLM's work, the authors estimate that the time required to complete the migration was reduced by 50 percent.
      • As for the Joda-Java time framework switch, the authors estimate a time saving of 89 percent compared to the projected manual change time, though no specifics were provided to support that assertion.
    5. Source 5:

      Software Engineering at Google: Large-Scale Changes

      OrganizationO'Reilly Media, 2020Accessed Nov 16, 202616 Nov 2026

      Supporting excerpts (4)
      • LSCs at Google are almost always generated using automated tooling.
      • infrastructure teams might routinely need to change hundreds of thousands of individual references to the old pattern or symbol.
      • Rosie takes a large change and shards it based upon project boundaries and ownership rules into changes that can be submitted atomically.
      • Each independent shard is tested by running it through TAP, Google's CI framework.
    6. Source 6:

      Amazon Q Developer just reached a $260 million dollar milestone

      OrganizationAmazon Web Services, Aug 1, 20241 Aug 2024Accessed Nov 16, 202616 Nov 2026

      Supporting excerpts (3)
      • 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)
      • we estimated the time saved by looking at the number of Java dependencies we migrated.
    7. Source 7:

      How Airbnb Used LLMs to Accelerate Test Migration

      IndependentInfoQ, Mar 28, 202528 Mar 2025Accessed Nov 16, 202616 Nov 2026

      Supporting excerpts (2)
      • updating its codebase to adopt React Testing Library (RTL) and converted nearly 3.5K React test files originally using Enzyme.
      • Overall, leveraging LLMs for test migration condensed an estimated 1.5-year engineering project into just six weeks while preserving the original test intent and code coverage.
    8. Source 8:

      Pioneering AI-assisted code migration: How Google achieved 6x faster migration from TensorFlow to JAX

      OrganizationGoogle Cloud, May 7, 20267 May 2026By Jamie Rogers and Parthasarathy RanganathanAccessed Nov 16, 202616 Nov 2026

      Supporting excerpts (2)
      • Google is already addressing this challenge by incorporating AI into many migration workflows
      • int32 to int64 identifiers (to avoid running out of ids); JUnit3 to JUnit4 (for testing); and Joda-Time to java.time (a modern time library).
    9. Source 9:

      Large sequence models for software development activities

      OrganizationGoogle, May 31, 202331 May 2023By Petros Maniatis and Daniel TarlowAccessed Nov 16, 202616 Nov 2026

      Supporting excerpts (2)
      • The novelty of DIDACT is that it uses the process of software development as the source of training data for the model, rather than just the polished end state of that process, the finished code.
      • DIDACT is a multi-task model trained on development activities that include editing, debugging, repair, and code review.

    More in Engineering & Research

    View all