Read the diff before you run it

Module 1 : Code with AI, and check every line

Plan du cours

Cette leçon n'est pas encore dans votre langue, la voici donc en anglais.

Trouvez les erreurs

Guess first, no penalty. You asked an AI agent: "Add up to 3 retries to fetch_user. No new dependencies." It says "Done, tests pass." Tap the three lines of its diff a reviewer should stop on.

The diff, line by line

0 sur 3 trouvées

A diff is the list of lines a change adds and removes. An agent's summary says what it meant to do. The diff shows what it did. "Tests pass" only proves what the tests check.

Read the diff before you run or merge anything, with five checks:

  1. Scope. Did it change only what you asked? Watch for extra files and new dependencies (outside packages your code now needs).
  2. Errors. Are failures handled, or swallowed so nobody hears about them?
  3. Edge cases. What happens with empty input, a timeout or a missing field?
  4. Your codebase. Does it use your naming and helpers, or invent new ones?
  5. Security. Secrets in the code, SQL built from strings, a skipped permission check?

A worked example

The review comment for the diff above:

Three changes before this can merge:
1. Scope: remove "import tenacity". We agreed no new dependencies.
2. Security: read API_KEY from the environment. Rotate the key that's
   in this diff, since it's now in the branch history.
3. Errors: catch requests.RequestException only, and raise after the
   third failure so callers know the fetch failed.
Fine as is: the retry loop and the 5-second timeout.

Complétez les trous

Fill the gaps.

Review note

Before I merge, I read the . I check it changed only , that errors are , and that no are in the code.

Try it

Vos étapes, environ 2 minutes

0 sur 1
  1. 1.Read the diff of the last change an AI made for you with the five checks, one line per check. Add the five checks to your kit.2 min

Exercices

Question 1 sur 2

An agent's summary says 'Added input validation.' Which tells you what it really changed?

Tuteur IA

Posez vos questions sur cette leçon et faites-vous guider dans l'exercice « Essayez ». Le tuteur fait partie de Learn Pro.

Voir Learn Pro