Sponsor Suno AI Music arrow_forward

CCA-F Study Guide · Tool Design & MCP Integration

S2.5.2 Task 2.5

Grep Each Export to Find All Cross-Module References

When you need to know where a module’s exports are used across a large codebase, Grep each exported function name individually. This identifies every import statement and reference efficiently, without loading every file.

The tracing pattern

Module utils/parser.ts exports parseJSON, parseCSV, parseXML. To find all usage:

  1. Grep("parseJSON") → finds all files importing or calling parseJSON
  2. Grep("parseCSV") → finds all files importing or calling parseCSV
  3. Grep("parseXML") → finds all files importing or calling parseXML

Each search returns matching files and lines — the complete usage map across the codebase.

Why Grep, not Glob?

Grep searches file contents — it finds import statements like import { parseJSON } from './utils/parser' inside files. Glob searches file paths — it finds files named parser.ts, not files that import from parser. A file named formatter.ts might import from parser, while parser-utils.ts might not. Content search is required.

Why not Read everything?

Reading 200+ files into context is wasteful. Grep achieves the same result with targeted searches that return only matching files and lines, consuming a fraction of the context.

Building the dependency graph

After Grep identifies which files use each export:

  • Read the most critical consumers to understand usage patterns
  • Follow the dependency chain further if needed (who calls the callers?)
  • Use this understanding to assess impact of changes (if parseJSON changes, these 12 files are affected)

This is the foundation for safe refactoring: know all consumers before changing an API.


One-liner: Grep each exported function name to find all cross-module references — Grep searches file contents (imports, calls), Glob only searches file names, and reading all files wastes context.

redeem

Your 7-day free trial starts now

Enjoy full access — including unlimited mock exams — free for 7 days from this moment. After that, pick a pass: $9.9 for half a year, $19.9 for one year, or $29.9 lifetime. One payment, nothing auto-renews.

Unlock full access

Your free trial has ended. Pick a pass below and the whole site opens back up — same plans, same prices as the pricing page.

See full pricing details