Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

impact

Reverse dependency analysis: what depends on a given file or symbol.

Usage

prx impact [options] <file>

Options

FlagDescription
--symbol <name>Narrow to a specific exported symbol
--hops NLimit traversal depth (default: all reachable)
--budget NCap output at N tokens
--plainHuman-readable output

What it returns

  • Target exports — what the file exports
  • Dependent files — files that import the target, with hop distance
  • Symbol attribution — which symbols each dependent uses
  • Stats — direct count, transitive count, test file count

Examples

# What depends on this file?
prx impact src/auth/handler.ts

# What uses this specific function?
prx impact src/auth/handler.ts --symbol authenticate

# Direct dependents only (1 hop)
prx impact src/auth/handler.ts --hops 1

Example output:

{
  "data": {
    "target": "src/auth/handler.ts",
    "exports": ["handleLogin", "handleLogout", "authenticate"],
    "dependents": [
      {
        "file": "src/routes/api.ts",
        "hops": 1,
        "symbols_used": ["handleLogin", "authenticate"]
      },
      {
        "file": "src/middleware/auth.ts",
        "hops": 1,
        "symbols_used": ["authenticate"]
      },
      {
        "file": "src/tests/auth.test.ts",
        "hops": 1,
        "symbols_used": ["handleLogin", "handleLogout"]
      }
    ],
    "stats": {
      "direct": 3,
      "transitive": 7,
      "test_files": 1
    }
  }
}

How it works

prx impact does a reverse walk of the import graph built by prx index. Import edges are extracted from the AST using tree-sitter across 10 language families.

When an import name is ambiguous across many files, resolution falls back to a directory-proximity heuristic and returns the most likely candidates. Treat the output as a high-quality map, not a formal proof of completeness.

Tips

  • Run prx impact before any refactor that touches a shared file. It tells you the blast radius before you make the change.
  • Use --symbol to narrow the analysis when you’re only changing one export. A file might have 10 dependents, but only 2 of them use the symbol you’re changing.
  • Use --hops 1 for a quick check of direct dependents. The transitive closure can be large on central files.
  • The test_files count in stats tells you how many test files will need updating.
  • Run prx index . first to build the import graph. Without an index, impact analysis falls back to a slower on-demand extraction.

See also: context, index, search