AI code review · Self-paced workshop

1. Which comments would you leave?

Practise understanding changes, checking AI findings, and making review decisions you can defend.

Workshop index · Download all examples and lessons

Time: 25–35 minutes. Prerequisites: read simple Python or TypeScript and run a terminal command. Outcome: distinguish a confirmed defect, an unsupported claim, and an optional suggestion.

AI can produce review comments faster than you can investigate them. Your job is to decide which claims matter and which survive contact with the code. This lesson uses a recorded response so the exercise works without a model account.

First, understand the promise

Read the booking contract. A workshop has a capacity and a current booked count. A customer requests some seats. The service either confirms the request or returns a reason for rejecting it.

Write one sentence describing successful behaviour, then answer: should someone be allowed to book the last available seat? Establish that expectation before reading implementation details.

Run the baseline

From the repository root, choose a track:

python3 -m unittest discover -s python/tests -v
node --test typescript/tests/booking.test.ts

Both suites consume the same examples. Passing them establishes that your environment works and the examples behave as expected. It does not establish complete coverage of the contract.

Make your own first pass

Open Review A and run its diff and test commands. git diff --no-index returns status 1 when it finds changes; this is expected.

Before proceeding, record:

  1. What the author intends to change.
  2. One behaviour that should remain unchanged.
  3. Whether you would approve now, and what evidence you still need.

Investigate the AI review

The following response is a constructed teaching example, not a transcript of an actual model run:

  1. Blocking: the comparison rejects a request that exactly fills the remaining capacity.
  2. Blocking: calculating remaining mutates the workshop’s capacity, so later customers see fewer seats.
  3. Suggestion: rename remaining to available_seats (Python) or availableSeats (TypeScript).

Do not accept or dismiss the list as a whole. Investigate each claim separately.

ClaimEvidence to look forYour verdict
Exact-fill requests failA concrete input, expected result, and actual resultConfirmed / rejected / unresolved
Capacity is mutatedAn assignment to shared state or another observable mutationConfirmed / rejected / unresolved
A longer variable name helpsA readability benefit and whether it warrants blockingRequired / optional / omit

Create a minimal reproduction of the first claim. Use the existing tests as a guide, but derive the expected value from the contract. Compare the baseline and proposed implementation using the same input.

Hint 1: choose a boundary

Try a workshop with ten seats and eight already booked. Which positive request exactly fills it?

Hint 2: inspect the operators

Compare booked + requested > capacity with requested >= capacity - booked. What happens at equality?

Now review a second change

Open Review B. It is independent of Review A. Evaluate its recorded AI claim against the input contract.

Python annotations and TypeScript types do not themselves validate network input. Here, the exercise explicitly gives you an integer-input precondition. In a real system you would trace the caller to verify that precondition. Do not silently invent a validation layer that you have not inspected.

Write your review

For each patch, prepare a short decision and any comments you would actually send. For a defect, include:

Trigger → observed behaviour → expected behaviour → consequence → requested change.

Do not paste every investigation note into the review. The author needs the verified result and enough evidence to act on it.

If you use a live model, try this after your own first pass:

Review this patch against the supplied contract. Do not edit files. For each possible defect, provide a reachable input, expected and actual behaviour, and the code that supports your claim. Separate assumptions from evidence. It is acceptable to find no defects.

This instruction scopes the task; it is not a security boundary. Use an appropriate tool permission mode and avoid sharing secrets or unrelated private files.

Checkpoint and resume point

You are done when you have a concrete reproduction for any blocking comment, a reason for rejecting unsupported claims, and a decision for both patches. Save your notes before opening the answer key.

Next: Your Emacs review workspace. You can stop here and resume from the unchanged baseline; no fixes or Git commits are required.

2. Your Emacs review workspace →