Study FAQ
How do I trace a symbol's callers and aliases with Claude Code?
Also asked as 2
- How can I follow re-exports and wrappers to find the real callers of a function?
- How should Claude Code investigate a symbol that is renamed between its definition and use?
Answer
Start with the symbol's definition, follow its exports and wrappers, then verify each candidate caller against the same symbol. Searching only the original name can miss the public name consumers actually use.
For example, a package may define retry_budget, re-export it as active_budget, and have a worker call active_budget(). Read the definition and export, add both names to the investigation, and inspect the worker's import and call. Do not assume an unrelated function with the same spelling is the same symbol. Do not automatically exclude the definition directory, which may also contain internal callers.
When available, Glob locates likely entry-point and module files, Grep finds definitions, imports and uses, and Read establishes the current surrounding code. A filename match alone does not identify a call. Trace package entry points and intermediate wrappers before deciding the impact of a change. The active search tools depend on platform and session configuration; use the supported available path with equivalent scope checks.
Keep a small map of the definition, exported names, wrappers, confirmed callers and unresolved relationships. For each confirmed caller, retain its source location and the import or binding evidence that links it to the target. If a wrapper transforms arguments or results, inspect that contract before treating it as a transparent alias.
Scope searches to the relevant language and directories, then broaden them when the dependency path requires it. Handle literal text and regex metacharacters correctly. Inspect pagination, truncation, ignored files and denied paths so an incomplete query does not silently omit a caller. Retrieve the necessary source ranges before relying on a partial view.
Supported symbol intelligence can help resolve bindings, subject to index freshness and language support. Generated code, dynamic imports and runtime registration can require compiler or runtime evidence beyond a text search. Report examined paths and unchecked relationships rather than claiming every possible caller was found.
Full explanation
Select and apply built-in tools (Read, Write, Edit, Bash, Grep, Glob) effectively
Learning material · CCAR-F
Read the full explanation