Lesson 10 of 32Technical rounds
Code Review Rounds
Review a pull request live under a time limit: find what matters in the right order, label and phrase comments well, and ask the questions seniors ask.
"Here is a pull request from a teammate. Review it as you would at work. You have 40 minutes." More loops now include a round like this, especially for mid-level and senior roles, and the reason is simple: with AI assistants writing a growing share of code, the ability to read a diff and spot what is wrong is worth more than ever. Some companies hand you a human-written PR with planted problems, some hand you code an AI produced and ask whether you would ship it. Either way, the interviewer is not counting comments. They are watching what you notice first, whether you can tell a data leak from a naming quibble, and whether your comments would help or annoy a real colleague. This lesson is about that round. Giving Good Code Review covers reviewing at work; here the clock, the planted bugs and the scoring change how you spend your time.
What the round looks like
Formats vary, so ask the recruiter which one you will get:
- Live review. You share your screen, read the PR out loud and discuss findings as you go. Usually 30 to 45 minutes of review plus discussion.
- Async written review. You get a link or a repo and an hour or so to leave comments, then a follow-up call to talk through them.
- AI-generated PR. "An assistant wrote this feature. Would you merge it?" Same skills, with extra attention to invented APIs and tests that only confirm what the code already does.
The PR is usually 200 to 400 lines: big enough that you cannot read every line with equal care, small enough to finish. It typically contains 6 to 12 planted issues across several severities, plus some genuinely good code. The rubric rewards, roughly in this order: finding the serious issues, prioritising them correctly, communicating clearly and kindly, and seeing the big picture (is this the right approach at all, and how would it ship safely?).
The most common way to fail is spending 25 minutes on variable names and formatting while a missing authorisation check sits three files away. The second most common is a list of 20 comments with no sense of which three matter.
Spend your time in passes
You cannot read 400 lines carefully in 40 minutes and also discuss them. Work in passes, and say the plan out loud so the interviewer knows you are not skimming by accident.
| Minutes | Pass | What you do |
|---|---|---|
| 0-5 | Context | Read the description and ticket. Say in one sentence what the PR is for. Ask what you do not know. |
| 5-12 | Map | Skim every file. Which is the core change? Where does user input enter? What touches money, auth or data? |
| 12-32 | Hunt | Read the risky parts line by line, in the order of attention below. Note findings as you go. |
| 32-40 | Summarise | Give a verdict, the top issues in order, and the big-picture questions. |
The map pass is what juniors skip and seniors never do. It is how you find out that the dangerous change is in the route file, not in the "core logic" file the description talks about.
The order of attention
When you hunt, look for problems in order of how much they cost if they ship. Higher layers first, because a perfectly named function that leaks data is still a leak.
Correctness first. Try the boundaries in your head: empty, zero, the first page, the last page, a value of exactly the limit.
Put these review concerns in the order you should look for them.
- Tap the steps below in the right order.
The exercise: review this PR
Here is a realistic PR. The description says: "Adds an order history endpoint with pagination and filters, and a refund endpoint for support staff. Tested locally." Read it as if you were in the round. Find as many issues as you can and rank them before you read the answer key.
PAGE_SIZE = 20
def list_orders(db, user, page=1, filters={}):
if user["role"] != "admin":
filters["customer_id"] = user["id"]
where = " AND ".join(f"{k} = '{v}'" for k, v in filters.items()) or "1 = 1"
offset = page * PAGE_SIZE
rows = db.execute(
f"SELECT id, customer_id, total_pence FROM orders WHERE {where} "
f"ORDER BY id LIMIT {PAGE_SIZE} OFFSET {offset}"
).fetchall()
result = []
for r in rows:
name = db.execute("SELECT name FROM customers WHERE id = ?", (r[1],)).fetchone()[0]
result.append({"id": r[0], "customer": name, "total_pence": r[2]})
return result
def refund(db, user, order_id, amount_pence):
order = db.execute(
"SELECT total_pence, refunded_pence FROM orders WHERE id = ?", (order_id,)
).fetchone()
db.execute(
"UPDATE orders SET refunded_pence = refunded_pence + ? WHERE id = ?",
(amount_pence, order_id),
)
try:
send_refund_email(order_id, amount_pence)
except Exception:
pass
db.commit()
return {"ok": True}def test_list_orders_returns_orders(db, admin):
assert len(list_orders(db, admin)) > 0
def test_refund_ok(db, support_user):
assert refund(db, support_user, order_id=1, amount_pence=500) == {"ok": True}Both tests pass. Write your list now. Then run the probe below: a reviewer who suspects a bug should prove it, and in a live round you can often say "let me check that" and run the code. The probe builds a tiny database, counts queries, and pokes at the cases a reviewer would worry about.
Press Run (⌘ Enter) to see what happens.Every line of output is a finding. Line 3 is the subtle one: after a customer called list_orders, the admin only sees that customer's orders. The mutable default filters={} is shared between calls, so customer_id stuck to it. On a real server, this is the kind of bug that shows one user's data in another user's session, and no test with a single call will ever catch it.
Answer key: ten findings, labelled and ranked
Each comment uses a label so the author knows what must change before merge. The format follows Conventional Comments: a label, an optional decoration such as (blocking), then the comment.
- issue (blocking), security: SQL injection in
list_orders. Filter values are pasted into SQL with an f-string. A customer can sendpaid' OR 1=1 --and read every order in the system (probe line 4). "Could we build theWHEREfrom an allow-list of column names and pass values as?parameters, like the refund query already does?" - issue (blocking), security: missing authorisation in
refund. Any authenticated user can refund any order (probe line 6). "Who should be allowed to call this? The description says support staff, so I'd expect a role check here, and a test that a customer gets a 403." - issue (blocking), correctness: mutable default
filters={}. Because the function writescustomer_idinto it, the scope from one customer's call leaks into later calls (probe line 3). "Can we default toNoneand copy the caller's dict, so we never mutate shared or caller-owned state?" - issue (blocking), correctness: off-by-one pagination. With 1-based pages,
offset = page * PAGE_SIZEskips the first 20 orders (probe line 1). "I think this should be(page - 1) * PAGE_SIZE. A test that page 1 starts with the oldest order would lock it in." - issue (blocking), correctness: no validation of the amount. A refund can be negative, zero, or larger than the order total (probe line 6 shows 999999 on a 1001 order). "What should happen above
total_pence - refunded_pence? I'd reject it with a clear error." - issue (blocking), data integrity: check-then-act race. Even after adding a limit check in Python, two refunds arriving together could both read the same
refunded_penceand both pass. "Could the limit go into theUPDATEitself, for exampleWHERE id = ? AND refunded_pence + ? <= total_pence, and treat zero affected rows as 'over limit'?" - suggestion, error handling: swallowed exception.
except Exception: passhides a broken mail server forever (probe line 5 says ok). "At minimum log it with the order id. Ideally send the email after the commit, through a queue or outbox, so a mail failure cannot affect the money and a retry is possible." - issue (blocking), tests: only happy paths, with weak assertions.
> 0would pass with the wrong page, and nothing tests authorisation, over-refund or pagination boundaries. "Could we add tests for page 1 and 2, a customer calling refund, and a refund above the total?" - suggestion, performance: N+1 queries. One query per row for the customer name, 21 queries per page (probe line 2). "A
JOIN customerswould make this one query. Not urgent at 20 rows, but this endpoint will be called a lot." - nitpick (non-blocking): naming and unused value.
r[0],r[1]are hard to read, andorderinrefundis fetched and never used (which is itself a hint that a check was meant to be there). "Maybe unpackorder_id, customer_id, total = row."
And one more, because good reviews include it:
- praise: "Nice that the refund queries use parameters, and that
PAGE_SIZEis a named constant instead of a magic number."
A strong verdict: "Request changes. The blocking items are the SQL injection and missing authorisation, which are security issues, then the pagination and mutable-default bugs and the refund limit with its race. Happy to pair on the query builder."
What does this print?
log = []
def query(sql):
log.append(sql)
if "orders" in sql:
return [(i, i % 3) for i in range(1, 11)]
return [("someone",)]
rows = query("SELECT id, customer_id FROM orders LIMIT 10")
names = [query(f"SELECT name FROM customers WHERE id = {c}")[0][0] for _, c in rows]
print(len(log), len(set(log)))Write comments people would want to receive
The interviewer reads your comments as if they were the author. Three habits make them land:
- Label every comment so severity is never a guess. Conventional Comments, which Giving Good Code Review also uses, gives a shared vocabulary:
issue,suggestion,question,nitpick,praise, with a(blocking)or(non-blocking)decoration. Even a simple "Blocking:" or "Nit:" prefix works. - Ask, explain, offer. "Could we pass these as parameters? As written, a filter value can change the SQL (example below)." A question with a reason and a concrete example beats "This is wrong" every time. Questions also cover you when you misread something: "Am I right that this runs for every row?"
- Praise real things. Pointing out a good choice is not filler. It tells the author what to keep doing, and it tells the interviewer you see quality as well as defects.
Match each comment to the label it deserves.
The big-picture questions
Juniors review lines. Seniors also review the decision behind the lines. Save a few minutes for questions like these, and ask them as questions, because the author may know something you do not:
- Is this the right approach? "Should refunds go through the payment provider's refund API first, with our table recording the result? As written, our database says refunded but no money moves."
- Does it fit the architecture? "Other endpoints use the repository layer. Is there a reason this one writes SQL directly?"
- Is it reversible? "If this goes wrong in production, how do we turn it off? Could the refund endpoint ship behind a feature flag?"
- How does it roll out? For schema changes, ask about the migration order. Adding
refunded_pencewhile old code is still running needs a default; renaming or dropping a column needs the expand and contract pattern (add the new column, deploy code that writes both, backfill, switch reads, then remove the old one). - How will we know it works? "Is there a metric or log line for refunds issued and refunds failed?"
These questions are often what moves a review from "hire" to "strong hire" for senior roles, because they show you think about the system and the team, not just the diff.
Reviewing AI-generated code in a round
When the interviewer says an assistant wrote the PR, they are testing whether you trust output without checking it. Giving Good Code Review lists the same smells for review at work. In a round, look harder at four things:
- APIs that look right but do not exist in the library version the project uses. If you are not sure a method exists, say so and say how you would check.
- Tests that mirror the implementation, such as asserting the function returns whatever the function returns, or mocking the very thing under test. They pass by construction.
- Missing context: the code works in isolation but ignores the project's auth middleware, error format or logging conventions.
- Over-engineering: an interface, a factory and a config option for something used once.
Say your verification plan out loud: "I'd run it, add a test for the boundary, and check that method against the docs before approving." That is the habit companies want from engineers working with AI every day.
- blocking comment
- A review finding that must be fixed before the change can merge, such as a bug or a security hole.
- Conventional Comments
- A labelling convention for review comments: a label such as issue, suggestion, question, nitpick or praise, plus an optional decoration like blocking.
- N+1 query
- Running one query for a list and then one more query per item, instead of fetching the related data in one go.
- check-then-act race
- A bug where code checks a condition and then acts on it, but another request changes the data in between.
- authorisation
- Checking that the authenticated caller is allowed to perform this action on this specific resource.
- expand and contract
- A safe schema change pattern: add the new structure, migrate code and data to it, then remove the old structure in a later release.
- feature flag
- A runtime switch that turns a code path on or off without a deploy, used to roll out gradually and roll back fast.