← Back to catalog
Applied and Generative AI

AI-Assisted Refactoring and Code Quality

Level: Practitioner2 daysVirtual / In-person

Use AI tools to refactor safely and raise code quality, with techniques for legacy code, tests, and review.

Overview

AI makes it easy to change a lot of code quickly. That is exactly why it can be dangerous: speed without discipline turns a tidy codebase into a subtly broken one. This course is about the opposite outcome, using AI to make code measurably better while keeping it working the whole way.

This is a hands-on, practitioner course. Rather than march through a catalog of every refactoring, it goes deep on the loop that keeps change safe and teaches you to apply it with an AI assistant doing the heavy lifting. We start from first principles: what refactoring actually is, what code quality means, and the safety net that has to be in place before you change anything. Only then do we let the AI loose, first on small, verifiable refactorings, then on the hard case everyone actually has, untested legacy code. Throughout, the emphasis is on judgment: reviewing what the AI produces and catching the subtle behavior changes it can introduce. Every module builds on the one before and ends with hands-on practice.

Who Should Attend

  • Developers who want to improve existing code, not just write new code, with AI help
  • Engineers who maintain legacy or unfamiliar codebases
  • Technical leads raising code-quality standards across a team

This is not an introduction to AI coding tools. Learners who have never used one should take Foundations of AI Coding Assistants first.

Prerequisites

  • Comfortable using an AI coding assistant for everyday tasks
  • Working proficiency in at least one programming language
  • Basic familiarity with automated tests and version control

What You'll Be Able to Do

  • Diagnose the quality problems in a piece of code, and name what to fix first
  • Build a safety net of AI-generated tests around code before you change it
  • Use AI to explain a legacy module, then verify the explanation before trusting it
  • Perform small, safe refactorings in a tight change-and-verify loop, without breaking behavior
  • Bring untested legacy code under characterization tests, then refactor a seam incrementally
  • Review an AI-produced refactor critically, catch subtle behavior changes, and judge the quality change

Course Outline

Day one: foundations and safe change

  • Refactoring and Code Quality, Reframed for AI
    • What refactoring is: behavior-preserving change, and what it is not
    • What we mean by code quality: readability, simplicity, coupling, and tests
    • How AI changes the economics of refactoring, and what it does not change
    • Lab: assess a piece of code and name its quality problems
  • The Safety Net: Tests and Version Control
    • Why you never refactor without a safety net, doubly so with AI
    • Using AI to strengthen test coverage before you change anything
    • Small commits and reversibility as guardrails
    • Lab: use AI to add tests around code you are about to change
  • Understanding Before Changing
    • Using AI to read and explain unfamiliar or legacy code
    • Mapping dependencies and risk before touching anything
    • Lab: have the AI explain a legacy module, then verify the explanation

Day two: from small refactors to legacy code

  • Small, Safe AI-Assisted Refactorings
    • The change-and-verify loop: one small step at a time
    • Common refactorings with AI: rename, extract, simplify, remove duplication
    • Keeping the AI on a short leash and reviewing every step
    • Lab: perform a series of small refactorings, verifying after each
  • Refactoring Legacy Code with AI
    • Characterization tests: pinning down behavior you do not fully understand
    • Finding seams and breaking dependencies incrementally
    • Larger structural change without a big-bang rewrite
    • Lab: bring untested legacy code under test, then refactor a seam
  • Reviewing AI's Work and Raising Quality
    • Reading AI output critically and spotting subtle behavior changes
    • Improving readability and naming, reducing complexity and duplication
    • Recognizing when an AI suggestion makes things worse
    • Lab: review and correct an AI-produced refactor, and judge the quality change

Extended Version

The three-day version keeps the same gradient and adds room to work at larger scale:

  • Folding refactoring into everyday flow and pull requests
  • Larger, multi-file refactoring campaigns with AI
  • Simple code-quality metrics and tracking improvement over time
  • A capstone that takes one real legacy component from tangled and untested to clean and covered

Common questions

How long is AI-Assisted Refactoring and Code Quality?
2 days, expandable to 3 days.
Is AI-Assisted Refactoring and Code Quality available online or in person?
It is delivered live by the instructor, virtual and in-person.
What experience level is AI-Assisted Refactoring and Code Quality for?
Practitioner. Some working experience is assumed.
Who teaches AI-Assisted Refactoring and Code Quality?
Erik Gross, a working software architect and CTO with 35 years as a technology educator and author.
Can AI-Assisted Refactoring and Code Quality be customized, and how do I book it?
Yes, every course can be tailored to your team. To book or ask questions, email erik.d.gross@gmail.com or book a call at https://calendly.com/erikgross/ilt-call.