मुख्य सामग्री पर जाएं

मुफ़्त पहला पाठ

The PR Nobody Understands

A 900-line pull request written mostly by an AI assistant can pass every test and still stall a reviewer.

6 में से पाठ 16 मिनट का पाठ

इस पाठ में आपपूरा पाठ दिखाएँ

As the engineer, you write a design note before prompting, split the work into pull requests a reviewer reads in one sitting, and explain each line you ship.

  1. Write a design note before the first prompt: the problem, your approach, what you rejected and what could go wrong
  2. Split AI-written code into pull requests that each do one thing and that a reviewer can read in one sitting
  3. Review your own diff line by line, and write at least one test from a risk you named and watched fail

5 में से 1What went wrong with a 900-line pull request that passed every test?

What went wrong with a 900-line pull request that passed every test?

On Tuesday, September 8, Elena Marsh opened a pull request of about 900 lines. Elena is fictional: a software engineer with four years in the job, at a 300-person company that sells invoicing software. The change retried failed card payments on a schedule. Her AI coding assistant had written most of it in one afternoon, across 14 files, and every test was green.

On Thursday the senior reviewer left one comment. "I stopped at file 9. Before I go on: why does next_retry_delay back off exponentially, and what is the cap for?"

Elena read the function three times. She could say what it did. She could not say why it did it that way, because she had not decided. The assistant had.

Green tests did not show that problem. An AI tool makes code cheap to write. Reading it, reviewing it and running it in production cost what they did before. So the work that marks a senior engineer sits in three places: what you decide before you prompt, how much you ask a reviewer to read at once, and whether you can explain each line you ship.

Her last performance review had said "more ownership." The reviewer's comment said the same thing about one function.

Why does a big AI pull request cost the team more than it saved you?

Count the hours. The assistant saved Elena most of a week of typing. The reviewer then spent two hours on nine files and stopped, with five still to go. The change did not merge. Elena spent the next two days reading her own pull request to learn what was in it.

The reviewer's side has a thread of its own on r/ExperiencedDevs. Its title asks what to do when a developer submits AI-generated code they clearly don't understand. A reviewer in that spot has two poor choices. They can approve code they have not followed, or they can do the author's thinking for them, one line at a time.

Size is what forces that choice. Google's public code-review guide says small changes are reviewed faster and more thoroughly, and are less likely to introduce bugs. It gives about 100 lines as a reasonable size for one change and 1,000 lines as too large in most cases, and it leaves the call to the reviewer. The guide predates AI coding tools and is one company's practice.

A small pull request is a change that does one thing and that a reviewer can read with care in one sitting. Elena's team had no number, so she set her own: under 200 lines, one behavior each.

To split the 900 lines, she listed what they did. She found three behaviors: work out when the next retry is due, run the retry, and pick up the payments that are due. Those became three pull requests of 180, 160 and 190 lines.

The other 370 lines fit under none of the three. The assistant had built a configuration layer with three retry strategies, and the feature used one. Elena had not asked for it and could not defend it, so she deleted it.

900 lines held three small changes and 370 lines she did not ask for
Elena's 900-line pull request became three pull requests of 180, 160 and 190 lines, and the other 370 lines, a configuration layer she had not asked for, were deleted.
lines
  • Work out when the next retry is due180
  • Run the retry160
  • Pick up the payments that are due190
  • Configuration layer, deleted370Three retry strategies; the feature used one
Her own limit: under 200 lines, one behavior each.

मुख्य शब्द

Small pull request

One behavior per pull request, small enough to read with care in one sitting. Delete what you did not ask for and cannot defend.

आप मेहमान के तौर पर पढ़ रहे हैं।अपनी जगह सुरक्षित करें

What do you write before the first prompt?

Before Elena rebuilt the third pull request, she wrote five sentences in its description box. She had not opened the assistant yet.

The first sentence said what was broken and for whom. The next two said what she would build, in plain words. The fourth named an option she had weighed and turned down. The last listed what could go wrong and the test for each risk.

Those five sentences are a design note: a short written statement of the problem, your approach and what you rejected, made before the code exists. Half a page is plenty for a change this size.

When you write it matters more than how long it is. Written first, the note records a decision. Written afterward, it describes whatever the tool produced, and you are back to explaining choices you did not make.

The note keeps working after you write it. Pasted into the prompt, it tells the assistant what to build and what to leave out. In the pull request, it tells the reviewer what to check the code against. Months later, it tells the engineer on call why the code is the way it is.

Elena wanted to skip the rejected line, and it was the line her reviewer read first. "I considered a queue and did not build one, because we would have to run a new service" shows that a choice was made. It also saves the reviewer from proposing the queue.

मुख्य शब्द

Design note

Before the first prompt, write the problem, your approach, what you rejected and what could go wrong. Written first, it records your decision.

Can you explain every line you are about to ship?

Then Elena reread the function.

def next_retry_delay(attempt: int) -> int:
    # seconds to wait before retry number `attempt`, from 0
    return min(3600 * 2 ** attempt, 86400)

She said each part out loud. Wait one hour after the first failure, then double the wait each time. Five retries take 31 hours in all, which fits the product lead's request to finish inside two days. The min holds any single wait to one day, in case someone later raises the number of retries.

Reading your own change this way, before a reviewer sees it, is a self-review: you go through the diff line by line and say what each line does and why it is there. A line you cannot explain leaves you three options. You work it out, you rewrite it until you can explain it, or you delete it.

Tests get the same treatment. The assistant had written 41 tests for the 900 lines, and all 41 passed. They were written from the code, so they confirmed that the code did what the code did. The two-worker test was different. Elena wrote it from a risk a person had named, the reviewer's question about the approach, and she watched it fail before she added the claim step. A test written on purpose starts from a risk you named, and you have seen it fail.

मुख्य शब्द

Self-review

Go through your own diff and say what each line does and why. Write at least one test from a named risk and watch it fail.

How do you do your next pull request this way?

Take the next change you would hand to an AI tool, in whatever editor and assistant your team uses. Before the first prompt, write the note in the pull request description or a scratch file: problem, approach, rejected, what could go wrong. If the note runs past half a page, the change is more than one pull request, and the note shows you where to cut.

Then prompt from the note. Read every line that comes back and settle each one you cannot explain. Write one test from each risk in the note, and run it once against code you know is wrong. At the top of the pull request, keep the note and add one line that says what the assistant wrote and what you checked.

The work this helps most is the kind a tool finishes fast: a new endpoint, a migration, a job like Elena's. Those are the changes where 900 lines can appear in an afternoon.

This is general information about working with AI coding tools, not legal or career advice. Your company's AI-code policy and its legal team come first.

मुख्य बातें

  • Design note: Before the first prompt, write the problem, your approach, what you rejected and what could go wrong. Written first, it records your decision.
  • Small pull request: One behavior per pull request, small enough to read with care in one sitting. Delete what you did not ask for and cannot defend.
  • Self-review: Go through your own diff and say what each line does and why. Write at least one test from a named risk and watch it fail.

स्व-जाँच

जो अभी पढ़ा, उसे जाँचें

1 छोटा सवाल। कोई उत्तर चुनें और जानें कि वह सही है या गलत, और क्यों। कुछ भी सहेजा नहीं जाता।

  1. सवाल 1 / 1

    Which line belongs in the rejected part of a design note?

आगे बढ़ें

कोर्स जारी रखें

मुफ़्त खाता आपकी जगह सुरक्षित रखता है। फिर 14 दिन मुफ़्त जारी रखें, कार्ड की ज़रूरत नहीं, या पेड प्लान देखें।

कोर्स जारी रखेंपूरा कोर्स देखें