Skip to content
Ameen Abozaid
MID-072

AI-assisted engineering at codebase scale

  • 6 Lessons
  • 2.5 h practice (estimate)
On this page 8 topics

Overview

Topics

  • AI-assisted debugging
  • refactoring
  • and test generation on large codebases
  • review discipline
  • measuring quality

Learn first

2.5 h of practice (estimate)

Learning outcomes

  1. Give an AI assistant the right context on a large codebase (relevant files, tests, conventions, failing output) instead of whole repositories.
  2. Use AI to form debugging hypotheses from stack traces, logs, and profiles, and confirm them with evidence before changing code.
  3. Refactor with AI in small steps under a green test suite, rejecting changes that alter behavior.
  4. Generate tests that add value (edge cases, regression tests) and discard tests that merely restate the implementation.
  5. Measure the effect of AI assistance on review time, defect rate, and test quality rather than lines produced.

Lessons

  1. 01AI assistants on large codebases
  2. 02AI-assisted debugging with evidence
  3. 03Refactoring with AI under a safety net
  4. 04Generating tests worth keeping
  5. 05Review discipline and measuring quality
  6. 06Demo: an AI-assisted refactor of the order saga under green tests

Lab and exercises

Lab

MID-072-LAB1 · AI-assisted refactor

Outcomes: 1–5 · Time: ~2.5 h

  1. Pick one Shop Platform service module; give an AI assistant a focused context (files, tests, conventions).
  2. Refactor in small steps under a green suite; commit each step.
  3. Add regression tests for a past incident; run mutation testing on the new tests.
  4. Submit a pull request with a prompt log, accepted and rejected suggestions, and mutation results.

Acceptance: behavior unchanged (all tests and contracts green); reviewer can trace every AI-originated change.

Exercises (assessment: review an AI-generated pull request; five exercises)

IDOutcomeTask
MID-072-EX011Write a prompt to add a feature to inventory: goal, files, constraints, existing pattern, failing test; redact anything sensitive from a sample log.
MID-072-EX022From a stack trace with a LazyInitializationException-style error, list three hypotheses and the evidence that would confirm each.
MID-072-EX033Plan a refactor of a 300-line method into five small steps, each with a verification.
MID-072-EX044Review five AI-generated tests; keep, change, or discard each with a reason.
MID-072-EX055Define three metrics to judge an AI rollout in your team and how you would collect them.
Show solutions
  • EX01 Context limited to the relevant files and the pattern to follow; constraints stated; secrets and personal data replaced with synthetic values.
  • EX02 Hypotheses such as access outside a transaction, a changed fetch mode, or a recent refactor; confirm by reproducing, inspecting the transaction boundary, and checking recent diffs.
  • EX03 Characterization test, extract validation, extract pricing, extract persistence, rename; run tests and commit after each.
  • EX04 Keep tests with edge cases and requirement-based expectations; discard those mirroring implementation or asserting a known bug; change tests with wrong expected values.
  • EX05 Review time per PR, escaped defects or change failure rate, mutation score or flaky test rate; collect from the Git host, incident log, and CI.
  • Outcome 5 is also covered by the lab's mutation results and the practical review.

Quiz

Outcomes: O1 context for assistants · O2 debugging with evidence · O3 refactoring under tests · O4 useful generated tests · O5 measuring effect.

A self-check for you: nothing is graded, saved or sent anywhere. Choose an answer, then check it. You can try again as often as you like.

  1. 1Best context for an assistant:O1
  2. 2Which must never be put in a prompt?O1
  3. 3An AI-suggested cause of a bug should be:O2
  4. 4The best first request when debugging:O2
  5. 5Safe refactoring with AI means:O3
  6. 6An AI step turns tests red. You:O3
  7. 7A generated test that mirrors the implementation:O4
  8. 8A surviving mutant means:O4
  9. 9A good measure of AI assistance:O5
  10. 10Who is responsible for AI-written code in a PR?O5

Practical part

Five exercises MID-072-EX01 to EX05 plus the lab. Pass: at least four exercises correct, and a review of an AI-generated pull request that decides what to accept, change, or reject with reasons.

Common mistakes

Large unreviewable AI diffs; accepting generated tests that assert current bugs; pasting secrets or customer data into prompts; measuring success by volume of generated code.

Assessment

Review an AI-generated pull request and decide what to accept, change, or reject, with reasons.

Career relevance

Rolling out AI tools across teams (SRB-022) and AI governance at Staff level (STF-021).

Type to search levels, phases, modules and lessons.