Code Impact Analysis for Smarter, Safer AI-Assisted Changes
Part of the Change Impact guide. Start with Code Change Blast Radius: A Safer Way to Code with AI
The checkAdminOrOwner function takes a membership role and narrows it to an owner or administrator. In cal.diy at revision 54343aa6, its definition occupies three lines, yet its callers reach API services, web components, shared packages, and tRPC handlers. The definition gives you very little warning about the work a signature change might require.
Code impact analysis starts with a proposed change, follows its direct and indirect dependents, identifies the contracts they rely on, and uses that evidence to plan the edit and its verification. I want that investigation attached to the patch. A caller list gives me places to inspect; it doesn't prove those places will break.
Start with one function and follow a path
I build Pharaoh, a hosted MCP server that gives an AI assistant a structural graph of a repository. It supports TypeScript, JavaScript, Python, C and C++, exposes production callers through get_blast_radius, and lets you query a function, file, or module. Its change-impact documentation describes that workflow.
On the same revision, get_blast_radius at its default depth of three lists 14 callers across four modules and two endpoints: the conferencing endpoint and the event-types app endpoint.
Here is the get_unused_code reachability result for repository Pharaoh-so/cal.diy, revision 54343aa6, exactly as the tool returned it:
# Reachability in cal.diy
- checkAdminOrOwner (packages/features/auth/lib/checkAdminOrOwner.ts): reachable: getAtomEventTypeApp → getEventTypesAppIntegration → checkAdminOrOwner
That is enough to begin checking source. Open the service that calls the helper, inspect the argument it passes, follow the controller back to the endpoint, and decide whether the proposed signature preserves the behavior each caller needs.
The impact analysis on a real function records the longer investigation. In its saved runs, the workflow averaged 32.03 seconds without Pharaoh and 16.93 seconds with it, for one prompt about this function, with three runs per condition. A grading correction matters here: all six answers mentioned all eleven expected items once qualified method names were accepted. This supports a time comparison for those sessions, not a claim that native search missed callers or that mentioning a name proves the whole answer correct.
An eight-step workflow before and after the edit
Use the following as a working sequence. The broader code change blast radius guide covers how to interpret the reach you find.
1. Define the seed and the behavior to preserve
Name the function or contract being changed, say what should behave differently, write down what must stay equivalent, and separate required caller updates from cleanup you'd merely like to do. For the role check, preserving the type guard matters alongside preserving the returned boolean.
2. Resolve direct callers, then work outward
Run this from the cal.diy repository root. ripgrep supports literal matching, so use it to locate a definition, find imports, gather candidate references, and begin checking callers.
rg -F 'checkAdminOrOwner' packages apps
The hits are text matches. Follow each relevant call toward its caller, record the path through package boundaries, set a depth you can review, and mark anything beyond that depth as unchecked. Pharaoh's blast-radius query defaults to three hops and supports up to five; the tool reference lists what each tool answers.
3. Inspect contracts around those callers
Check exported signatures, serialized fields, shared schemas, and the assumptions callers make about return values. A function can keep compiling while returning a different value that its consumers weren't written to handle.
ripgrep can also search a field name when the proposed edit changes a serialized key. Inspect each consumer's expected input.
4. Search for indirect wiring separately
ripgrep skips hidden and ignored files by default, so a clean search result has a scope, and that scope may exclude configuration you meant to inspect. Check the relevant configuration explicitly.
Look for string-based dispatch, generated consumers, event handlers, and scheduled entry points that the proposed change might affect. Record unresolved paths as uncertainty. Avoid treating a missing edge as evidence that a consumer cannot exist.
5. Keep deletion decisions separate
For Pharaoh's Dead label, every signal must agree, with no entry point reaching the function, no other file naming it, and no production file importing its file. Possibly unused means it is unreached but named elsewhere or its file is imported. Check those references before deleting it.
ripgrep can help inspect the files that name a candidate, but read the surrounding code, check the search scope if nothing matches, and leave uncertain deletions for another patch.
6. Choose the change sequence
Decide whether the affected callers can move together, whether a compatibility wrapper is needed, whether a serialized field needs a transition period, and who must coordinate consumers outside the repository. Write the sequence before asking the assistant to implement it.
For a local implementation change, that might be one small patch. A shared contract may need separate deployment steps. The impact map helps you decide which case you're holding.
7. Validate behavior at the affected boundaries
Start with tests near the changed logic, add coverage for the contract that moves, exercise the relevant boundary, and run the broader checks your repository requires. Treat the impact set as a guide to investigation rather than permission to skip CI.
Pharaoh's blast-radius results exclude test-file callers. Search for tests separately.
8. Leave an impact note in the PR
Record the seed, list the checked paths and any unresolved consumers, identify the tests you ran, and explain the change sequence if callers cannot move together. Include the source revision and the analysis depth so another reviewer can repeat the check.
ripgrep is useful again when reviewing that note: revisit the named consumers, check any references added by the patch, and compare the proposed scope with the files actually changed.
Two research figures need their context
In the ChangeGuard study, which used 224 manually annotated Python changes, existing project regression testing had 7.6% recall for semantics-changing edits, including cases where tests were missing or builds failed, so the figure doesn't estimate the chance that your passing suite missed a regression. I would use it to question what the tests exercise.
The 2008 PanayaIA study of SAP customization reported a false-positive ratio of 71%, calculated against expected impact, with wrong results as the numerator, rather than as a share of all reported findings, so it cannot establish an error rate for current static-analysis tools.
I also want the irrelevant results called out. Missing a consumer matters, but sending a reviewer through unrelated code has a cost too.
Seven questions before merge
These questions turn the investigation into a review decision. Answer them with paths and evidence, rather than an assistant's assurance that the patch is safe.
- What depends on this? Name direct callers and the indirect paths you checked. Identify consumers outside the inspected repository.
- Which contract changes? Check signatures and serialized data, including assumptions that a type checker won't enforce.
- Is anything being deleted on weak evidence? Explain why an apparently unused path is removable, or defer the deletion.
- Which tests cover the affected behavior? List what ran and the boundary it exercises. Mark missing coverage.
- Who understands the downstream use? Get review from someone responsible for an affected consumer when that consumer's behavior changes.
- What would a failure look like? Consider silent permission changes or altered output alongside compilation errors. Record a rollback plan where needed.
- What remains uncertain? State the revision, traversal depth, unresolved wiring, and anything you checked manually.
Keep the map's limits visible
Pharaoh's interactive graph covers the default branch, excludes unmerged branches and uncommitted edits, re-maps a live repository after default-branch pushes, and can be refreshed through pharaoh_account. Check which source you are reviewing against the available map before relying on a returned relationship.
After the assistant edits a signature, inspect the working tree and validate the patch. The default-branch graph cannot verify new calls in that unmerged change.
For pull requests, PR Guard is available on Pro workspaces. It checks new dead code, breaking signature changes with existing callers, exact function duplicates, and blast radius. Findings are advisory by default, published as a neutral GitHub check. They don't replace the tests or the review decision above.
To try the workflow, connect Pharaoh, install the GitHub App on the owning account or organization, authorize the repository, and connect your client.
In a Claude Code terminal:
npx @pharaoh-so/mcp
npx starts the setup described in the Claude Code connection guide.
The GitHub App reads the repositories you authorize, and its only write is publishing check results. Pharaoh stores structural metadata rather than source code.
Pick a function you already intend to change. Follow one caller back to the feature it serves, check the contract there, and put what you found in the PR.