How to Find Interface Implementations Before Changing a Contract

Kyle · · 26 min read
Find interface implementations—codebase checks before changing a contract

A contract edit looks local until you find interface implementations in a codebase and discover an adapter two modules away still speaks the old shape. AI-assisted edits make this worse when the visible file is only part of the runtime path.

What matters is not every text match. You need the live implementers, the wiring that selects them, and callers typed against the contract. Don’t change the signature before that picture is clear.

Start with these checks:

  • Search explicit and structural implementations
  • Trace DI bindings, factories, and registries
  • Verify interface-level callers and test doubles

Know the blast radius before the edit.

Why Contract Changes Create Hidden Breakage

You change one method on an interface, the local file looks tidy, and ten minutes later you're staring at a test failure in a module you forgot existed. That pattern is common enough that we should treat it as normal engineering work, not bad luck.

Interface edits feel local because the contract is small. The impact usually isn't. In a TypeScript codebase, implementations may live in another package, another repo, or behind a factory that hides the actual concrete type. Callers often only know the interface. The binding happens elsewhere. By the time you notice that, you've already started editing.

A lot of people hear "find interface implementations in a codebase" and think "search for implements." That's only part of the answer.

You also need to know:

  • which concrete types are actually used at runtime
  • where those types are selected or registered
  • which callers invoke the contract through the interface
  • which old code is just noise and shouldn't control your change plan

The goal here is simple: stop guessing. We want a repeatable way to answer who implements this type, who calls it polymorphically, and what really needs to change before the first edit.

Small contract edits create system-level risk when the relationship data is hidden.

What Counts as an Implementation in TypeScript

Before you search, get clear on what you're counting. TypeScript makes this slippery.

This guide covers four kinds of contract surfaces:

  • interfaces
  • abstract classes
  • inherited method contracts from base types
  • exported type shapes that function like contracts even if nobody wrote interface

The easy case is explicit implementation:

class StripeGateway implements PaymentGateway {
  charge(input: ChargeInput): Promise<ChargeResult> { ... }
}

The harder case is structural compatibility. TypeScript can accept a class or object literal because its shape matches the contract, even if it never declares implements PaymentGateway.

const fallbackGateway: PaymentGateway = {
  async charge(input) {
    return { ok: false, reason: "disabled" }
  }
}

That object is a real implementer for change planning purposes. If you only search for the keyword implements, you'll miss it.

There's another wrinkle. Some relationships look close but aren't the same thing:

  • a subinterface extends a contract, but doesn't execute it
  • a subclass may inherit or override an abstract method
  • a proxy or wrapper may delegate to a real implementation without directly owning the behavior

Those distinctions matter when you're tracing blast radius. You're not building a type theory diagram. You're trying to avoid breaking production.

Some tools only surface declared relationships. Typed graph approaches can sometimes include structural compatibility when the index supports it. Don't assume every tool answers the same question.

Start With the Contract You Actually Intend to Change

Don't begin with "we're changing the notifier interface." That's too fuzzy. Anchor on one exact symbol, ideally one method.

Method-level scoping cuts down false positives fast. Interface names are often broad. Method names repeat across unrelated types. If you can scope by path-qualified or symbol-qualified target, do it.

Before you search anything, answer these in a note:

  1. Which interface or abstract method is changing?
  2. Is the change additive, signature-changing, or behavior-changing?
  3. Is the contract public, internal, cross-package, or cross-repo?
  4. Does runtime selection happen through factories, adapters, or plugin registration?

We'd also capture:

  • contract name
  • affected methods
  • repo or package scope
  • expected runtime path
  • likely test suites

That note sounds boring. It's not. It stops you from wandering around the repository collecting irrelevant evidence.

A common failure mode is broad browsing. You open a few classes, spot one implementation, and start editing because it feels close enough. That's how teams miss the registration file three directories over that quietly controls production behavior.

Good discovery starts with exact scope.

Use a Layered Implementation Discovery Workflow

There usually isn't one command that gives a complete answer. Treat this as a staged workflow.

Stage 1: declared implementers

Start with the obvious:

  • implements InterfaceName
  • subclasses of an abstract base
  • overrides of inherited abstract methods
  • generated or framework-owned types if your stack produces them

This gives you the fast first pass. Take the wins.

Stage 2: structural implementers

Now look for the implementers TypeScript lets through without a declaration:

  • concrete classes with matching method signatures
  • object literals assigned to interface-typed variables
  • factory returns typed as the interface
  • adapter objects created inline

This is where change plans usually get more honest.

Stage 3: selection and wiring points

Find where the system chooses implementations:

  • dependency injection bindings
  • registries and handler maps
  • plugin loaders
  • feature-flag branches
  • provider modules

A type can exist in the repo and still be irrelevant. Wiring tells you if it matters.

Stage 4: polymorphic callers

Now trace the call sites that invoke the contract through the interface or abstract type. These callers feel the contract change even if they never mention a concrete class.

Stage 5: validation

Take your candidate implementers and callers, then verify them with type checks, tests, and source reads.

This workflow is reusable. It works for refactors, monorepo moves, and AI-assisted edits where the assistant only sees slices of the codebase at a time.

Fast First Pass With IDE Navigation

When you're under time pressure, you should use the IDE first. Just don't confuse orientation with proof.

IntelliJ is good for this kind of first pass. Search Everywhere on Shift Shift helps you jump across classes, files, symbols, and actions. [Navigate to Implementation](https://weblogs.asp.net/morteza/How-to-find-the-implementation-of-an-interface-in-Visual-Studio-2013-2015) works for classes and methods, and Find Usages gives you the reverse path from a method or type. Navigate to Test is handy when you want the nearest test around a contract or implementation.

Visual Studio has the same basic pattern. Go To Implementation gets you to concrete types. Call Hierarchy can surface implementations and callers for interface methods.

Use these moves in sequence:

  • jump to the exact contract symbol
  • navigate to implementation
  • inspect one or two concrete types
  • run find usages on the interface method
  • jump to the nearest tests

That's enough to orient yourself.

It's not enough to trust.

IDE navigation tends to favor declared relationships. It may miss structural compatibility, runtime wiring, and anything outside the current repo context. It also won't tell you whether a result is live code or dead weight.

So yes, use the IDE. Then leave it.

Repository Search Patterns That Actually Surface Implementers

Plain repository search is still one of the fastest ways to locate implementers of an interface, especially when you already know what you're hunting.

Run searches in this order:

  • implements InterfaceName
  • extends BaseClass
  • interface-typed constructor parameters
  • interface-typed function parameters
  • return types that expose the interface
  • factory functions returning the interface
  • provider maps and registration files
  • adapter and wrapper classes around the same method contract

TypeScript adds a few search patterns people skip too often:

  • object literals assigned to an interface-typed variable
  • exported constants that satisfy the interface shape
  • method signatures instead of only the interface name

Illustrative search examples:

rg "implements PaymentGateway"
rg "[:(]\s*PaymentGateway[),]"
rg ":\s*PaymentGateway\s*="
rg "createPaymentGateway|getPaymentGateway|paymentGatewayProviders"
rg "async charge\("

That last one matters when structural typing is in play. A clean search for PaymentGateway does not prove there are no implementers. The binding might happen without a direct string reference.

Bucket your findings as you go:

  • definite implementers
  • likely implementers
  • wiring points
  • unresolved candidates

That last bucket is healthy. False certainty is worse than an unresolved note.

Find Polymorphic Callers Before You Edit the Contract

A lot of engineers stop after finding implementers. That's only half the risk.

Polymorphic callers are the code paths that call through the contract type:

  • a service with a gateway: PaymentGateway field
  • a function that receives the interface as a parameter
  • logic that gets an implementation from a factory or registry
  • tests that stub the interface and encode expected behavior

Start with interface-typed variables, parameters, and fields. Then inspect the services that depend on them. After that, trace any selection logic that chooses among concrete classes at runtime.

Keep three buckets in your head:

  • direct concrete calls
  • interface-level calls
  • plugin or reflective dispatch

The second bucket is the one people undercount.

Use this verification checklist:

  • Which callers will fail compilation if the signature changes?
  • Which callers still compile but may break behavior?
  • Which tests target the contract itself, not just one implementation?

Knowing who implements a type tells you where code must change. Knowing who calls the contract tells you where the system will react. That's the blast radius you actually care about.

Illustrative Example: Changing a TypeScript Contract Safely

Let's make this concrete with an illustrative example.

Suppose you have this contract:

export interface PaymentGateway {
  charge(amountCents: number, token: string): Promise<{ ok: boolean }>
}

You want to change it to:

export interface PaymentGateway {
  charge(input: { amountCents: number; token: string; currency: string }): Promise<{ ok: boolean }>
}

Start with the exact method: PaymentGateway.charge.

First pass, declared implementers:

class StripeGateway implements PaymentGateway { ... }

Then repository search surfaces an adapter in another module:

export const legacyGatewayAdapter: PaymentGateway = {
  async charge(amountCents, token) {
    return legacyClient.pay(amountCents, token)
  }
}

That's not noise. It's a real implementer.

Next, inspect wiring. You find a provider selection file:

export function getPaymentGateway(): PaymentGateway {
  return process.env.USE_LEGACY === "1"
    ? legacyGatewayAdapter
    : new StripeGateway()
}

Now you know production can take two paths.

Then trace callers. A checkout service depends on PaymentGateway. So does an admin refund flow. A controller doesn't call StripeGateway directly at all. It only receives the interface from the provider. That's the pattern that breaks quietly.

Tests add one more problem:

const fakeGateway: PaymentGateway = {
  charge: vi.fn().mockResolvedValue({ ok: true })
}

If that mock still mirrors the old shape loosely enough, it can hide the production gap for longer than you'd like.

Mandatory edits in this example:

  • the interface definition
  • StripeGateway
  • legacyGatewayAdapter
  • provider tests around getPaymentGateway
  • service tests that stub PaymentGateway.charge
  • any contract tests that assert input shape

Noise you can ignore:

  • docs mentioning "gateway"
  • unrelated charge methods on other types
  • dead adapters not wired anywhere

Methodical work beats random scanning every time.

ArtifactCategoryWhy it mattersAction
PaymentGateway interface definitionContractThe method signature changes from separate parameters to an input object that adds currencyUpdate
StripeGatewayDeclared implementerIt explicitly implements PaymentGateway and must match the new charge shapeUpdate
legacyGatewayAdapterAdapter implementerIt is a real PaymentGateway implementer in another module, not noiseUpdate
getPaymentGateway provider selectionWiringProduction can take either the legacy adapter path or the StripeGateway pathUpdate provider tests
Checkout serviceInterface-level callerIt depends on PaymentGateway rather than a concrete gatewayReview and update caller
Admin refund flowInterface-level callerIt also depends on PaymentGateway and shares the contract riskReview and update caller
fakeGateway mock and service testsTest doubleA loose mock can still mirror the old shape and hide the production gapUpdate service tests that stub PaymentGateway.charge
Contract tests that assert input shapeVerificationThey must reflect the new charge input object shapeUpdate
Docs mentioning gatewayNoiseThey are mentioned as examples you can ignoreIgnore
Unrelated charge methods on other typesNoiseThey are false positives because they do not belong to PaymentGatewayIgnore
Dead adapters not wired anywhereNoiseThey are not part of the live runtime pathIgnore

Compiler, Tests, and Source Reads Are Your Verification Layer

Search gives you candidates. Verification tells you whether the list is true enough to act on.

Use three layers.

First, the compiler or type checker. It catches direct signature mismatches. If you changed method parameters, this is your first hard filter.

Second, targeted tests. These catch contract behavior and integration assumptions. A passing type check won't tell you whether callers still construct valid input at runtime.

Third, source reads. You still need them for ambiguous wiring, framework registration, or places where the runtime path is hidden behind config.

A practical sequence looks like this:

Verify the impact systematically

  1. Implementers

    Collect candidate implementers.

  2. Callers

    Collect candidate callers.

  3. Draft change

    Make the contract change in a draft branch.

  4. Type checks

    Run type checks.

  5. Relevant tests

    Run the nearest relevant tests.

  6. Manual review

    Read unresolved call sites manually.

Blind spots are real:

  • compilation success doesn't mean no runtime risk
  • sparse tests leave behavioral holes
  • mocks can hide missing production updates

Compiler and tests are proof steps. They are not discovery substitutes.

Where Search and IDEs Break Down in Larger Repositories

At a certain repo size, normal navigation stops feeling reliable. You see too many results, too little context, and not enough certainty.

This shows up fast in:

  • multi-repo systems
  • plugin architectures
  • generated clients
  • codebases with lots of adapters
  • AI coding workflows where the assistant only sees a few files at once

The failure modes are familiar:

  • broad interface names return a flood of matches
  • structural implementers don't show up cleanly
  • dead code pollutes blast-radius review
  • callers cross package boundaries that text search doesn't explain

And yes, there's usually a low-grade anxiety sitting under all of it. You keep searching because you don't trust what you've found. That's not irrational. It's a relationship problem.

The repo doesn't just contain files. It contains bindings, callers, dependency paths, and code that's probably dead but still distracts you. A list of text matches won't sort that out on its own.

Find interface implementations in a large codebase where search and IDE tools break down

A Measured Trade-Off for Graph-Based AI Exploration

A code graph can make structural questions cheaper for an AI coding workflow, but it is not a replacement for source verification. In an evaluation of 31 real-world repositories, a graph-based retrieval system reached 83% answer quality, compared with 92% for a file-exploration agent. The result supports using structural queries to narrow a change surface, then reading the relevant source and running validation rather than treating a graph result as final proof. The study evaluated both approaches on the same repository set.

File exploration scored higher on answer quality in one graph-retrieval evaluation

Across 31 real-world repositories, the evaluated graph-based system achieved 83% answer quality, compared with 92% for a file-exploration agent.

Sources

Codebase-Memory evaluation.

  • This is one system’s preprint evaluation, not a benchmark of Pharaoh or of TypeScript interface discovery specifically.
  • The 83% and 92% figures measure answer quality in the study’s tasks; they do not establish that either workflow finds every runtime binding.
  • The source reports relative token and tool-call reductions, not the underlying raw counts in the supplied evidence.
Exploration approachAnswer quality (%)
Graph-based retrieval83%
File exploration92%

The same evaluation reports that graph-based retrieval used 10 times fewer input tokens and 2.1 times fewer tool calls. That is a meaningful efficiency gain when an agent needs to trace callers or dependencies repeatedly, but the quality gap is a reason to retain the compiler, tests, and source reads in this guide’s verification layer.

When a Code Graph Gives You a Better Answer

This is where a code graph starts to earn its keep.

In this context, a code graph maps relationships among symbols, callers, dependencies, endpoints, environment variable usage, and code that appears dead or unreachable. Instead of inferring architecture from scattered files, you can query the relationships directly.

That's the job Pharaoh is built for. Pharaoh maps repositories into a knowledge graph so developers and MCP clients can inspect dependencies, callers, blast radius, and dead code before making changes. It's especially useful when implementation discovery crosses modules or repos and your AI assistant doesn't have the whole system in view.

A code graph is not a magic interface finder. We wouldn't treat it that way. It won't make dynamic dispatch uncertainty disappear, and it shouldn't replace source reads. What it does give you is structural context before you edit.

A practical pattern looks like this:

  • use the graph to narrow the affected area
  • use source search to confirm literal details
  • use compiler and tests to verify the final impact set

If your team needs deeper audit-style analysis across repos, Pharaoh Pro is the fit. For this workflow, the main point is simpler: relationship context beats file guessing.

A Practical Checklist for Any Contract Change

Use this in PR prep, refactor planning, or before letting an AI assistant edit a contract.

  • Name the exact contract and method changing.
  • Identify declared implementers.
  • Search for structural matches and object-literal adapters.
  • Inspect factories, registries, and dependency bindings.
  • Find interface-level callers, not just concrete calls.
  • Review mocks, stubs, and contract tests.
  • Run type checks.
  • Run the nearest relevant tests.
  • Mark dead or unreachable code separately.

One decision rule matters more than the rest:

If you still can't answer who implements this type or who calls it polymorphically, stop editing and expand discovery first.

Teams should make this normal. The open source AI Code Quality Framework covers the linting and testing side of AI-assisted change safety well. The discovery side still needs discipline.

Common Mistakes That Make Interface Changes Riskier Than They Need to Be

These mistakes are common because they save time right up until they don't.

  • Relying only on implements search
    Fix: add structural search, wiring inspection, and caller tracing.

  • Treating one IDE result as the whole answer
    Fix: use IDE navigation for orientation, then verify with repo search and tests.

  • Updating concrete classes but forgetting interface-typed callers
    Fix: search fields, parameters, and factory outputs typed as the contract.

  • Missing tests because mocks hide production wiring
    Fix: inspect provider and integration tests, not just unit stubs.

  • Ignoring adapters, wrappers, and provider maps
    Fix: search registration files and runtime selection paths.

  • Assuming no search hits means no impact
    Fix: search method signatures and interface-typed assignments too.

  • Failing to separate dead code from live code
    Fix: mark unreachable candidates so they don't distort the change list.

Most painful contract changes aren't caused by hard syntax problems. They're caused by incomplete discovery before the first edit.

Conclusion

To find interface implementations in a codebase safely, you need more than a quick symbol jump. You need a workflow that covers implementers, wiring points, polymorphic callers, and verification.

That's the shift. Stop treating the repo like a pile of files and start treating it like a system of relationships. Once you do that, contract changes get calmer. Not trivial. Just visible.

Pick one interface in your codebase that feels risky to change and run the checklist before your next edit. If your team works with Claude Code, Cursor, Codex, or another MCP client on larger repos, adding a code graph like Pharaoh can make that discovery happen before the regression instead of after it.

Article Record

ReferencesPrimary sources used for this article
  1. Codebase-Memory: Tree-Sitter-Based Knowledge Graphs for LLM Code Exploration via MCP
  2. find_implementations | Kivgraph
  3. Go interfaces: find every implementation and caller
  4. How to find the implementations of an interface in Visual Studio 2013 ...
  5. Enhancing Code Understanding for Impact Analysis by Combining Transformers and Program Dependence Graphs
Update HistoryMeaningful revisions to this article
Initial publication.
← Back to blog