Lesson 4 of 9 · 24m
Scoping a Change That Can Actually Land
Turn vague intentions into a narrow behavioral change with explicit non-goals, test coverage, migration awareness, and a mergeable shape.
Most stalled pull requests fail before the first review because their scope was never real. They are not changes; they are directions. "Improve caching," "clean up errors," or "make onboarding better" cannot be evaluated. A mergeable contribution has a crisp before/after behavior, a bounded blast radius, and proof that the project still works.
Write the outcome before the patch
Use a one-paragraph contract with yourself:
When a workspace owner removes a member, remove that member's queued
invitations for the same workspace. Existing accepted memberships remain
unchanged. Pending invitations for other workspaces are unaffected.That paragraph exposes nouns, state transitions, and non-goals. It also tells you what tests must exist. If you cannot write it yet, you are still in exploration mode, not implementation mode.
Separate behavior change from cleanup
A patch that fixes a bug, renames three functions, upgrades a dependency, and reformats a file is four reviews disguised as one. Split mechanical changes from semantic changes:
PR 1: add focused regression coverage for invite revocation
PR 2: fix revocation behavior
PR 3: rename ambiguous helper and update call sitesSometimes one PR is still correct, especially when the cleanup is required to make the fix possible. The rule is not "small at all costs"; it is "every line must help a reviewer verify the intended behavior."
Inventory compatibility before editing
Real projects have hidden consumers. Check:
rg "removeMember|remove_member|InvitationStatus::Pending" -nAsk whether public APIs, stored data, event payloads, CLI output, configuration files, and generated clients change. A technically local fix can be a breaking ecosystem change.
Decide the test shape first
Choose evidence proportional to the risk:
unit test invariant in one function or state machine
integration test interaction across service and persistence boundary
migration test old data converts correctly and rollback is understood
CLI/output test user-visible behavior and exit codes stay stable
manual evidence workflow automation cannot coverIf the behavior is asynchronous, test the final state rather than sleeping for a magic number of milliseconds. If the behavior is security-sensitive, include the negative case: unauthorized actor cannot trigger the transition.
Know when to ask before writing
Ask first when the change adds dependencies, changes public APIs, alters data models, affects performance-sensitive paths, or creates a new product behavior. Do not ask permission for every typo fix. The social contract is proportional: bigger blast radius means earlier design alignment.
Field notes
- "It only affects one file" is not the same as low risk; central files amplify small edits.
- A failing test that already fails on main is evidence, not an excuse. Identify and isolate it.
- Do not silently expand scope because the neighboring code is ugly. File a separate issue if the ugliness matters.
- If the fix depends on undefined product intent, a PR may be premature no matter how clean the code is.
Was this lesson helpful?