Knowledge card L3 · Workflows informational

Change the Contract First, Then the Callers

What it is

A multi-file editing pattern where, to change something used in many places, you have Claude change the definition — the type, signature, or interface — first, then work through the call sites the change surfaces, rather than editing scattered usages by hand.

signature, then ripplesNew signatureCompiler findscallersFix each siteTypes green
Define the new contract once; let the callers follow from it.

Why it works

Change callers first and you're guessing at a contract that doesn't exist yet; you'll revise them again once the real signature lands. Change the definition first and, in a typed language, the compiler enumerates exactly which sites broke — a precise, complete worklist. Claude can then update each site knowing the true new shape, and 'zero type errors' becomes a clear finish line.

When to use it

Renaming or reshaping anything with many consumers — a function signature, a shared type, a config key, an event payload. Especially in typed codebases where the compiler can drive the worklist.

When not to use it

Dynamically typed code with no compiler to catch call sites — there you need a different safety net (tests or a thorough search) before trusting the propagation. Also skip for changes touching only one or two sites, where the ceremony isn't worth it.

Prompt

I need to change <thing> from <old shape> to <new shape>. It's used across the codebase.

Step 1: change the definition/signature only, and show me it. Step 2: list every call site that this breaks (use the type errors / a search). Step 3: update them one file at a time, keeping each change minimal, until types are clean. Don't guess at callers before the new signature is fixed.

Example

You're adding a required currency argument to formatMoney. Claude changes the signature first; the type checker flags 23 call sites; Claude walks them in small batches, threading the right currency through each, and stops at zero errors — nothing missed, nothing edited twice.

Advanced version

For risky changes, ask Claude to add the new parameter as optional first, migrate callers incrementally, then make it required in a final commit. This keeps every intermediate state compiling and deployable, so a large propagation can land in reviewable pieces instead of one all-or-nothing diff.

Common mistakes

  • Editing call sites before the definition is settled, then redoing them when the real signature differs.
  • Trusting the compiler to find sites in a dynamically typed language where it can't — silent runtime breakage follows.
  • Doing a project-wide find-and-replace on a name that's ambiguous, catching unrelated matches.

Related