Skip to content
Fallow home
All docs pages

Docs home

fallow trace

fallow trace shows the callers of a symbol, the import path between two modules, and the use of a package.

Show the callers and callees of one exported symbol, the shortest import path between two modules, or how the code uses a package.

For a walk from a finding to its cause, read Trace a finding.

Synopsis

fallow trace [OPTIONS] [FILE:SYMBOL]

Options

ArgumentDescription
[FILE:SYMBOL]Target symbol, formatted as FILE:SYMBOL (e.g. src/utils.ts:formatDate). Omitted when --path or --dependency is used

Tracing

OptionDescription
--dependency <PACKAGE>How the code uses each imported name of a package: file and call counts, one hop through project wrappers, and a count of each use that the trace cannot resolve. --sites, --specifier, --limit and --cursor page the usage sites.
--path <FROM TO>Shortest import path between two modules, as two file paths (e.g. --path src/app.ts src/db.ts). Mutually exclusive with the symbol target and the call-chain flags
--eager-onlyWith --path, follow only static value imports, so the route explains why TO loads before FROM runs. import(), lazy globs, worker loads and import type do not qualify.
--callersWalk up to callers (modules that import the symbol). When neither --callers nor --callees is set, both directions are walked
--calleesWalk down to callees (the symbol's module's import-symbol edges plus unresolved call sites). When neither flag is set, both are walked
--depth <N>Chain depth bound for both directions (default 2). Symbol-level is best-effort, so a shallow bound keeps the trace legible

Scope

OptionDescription
--specifier <NAME>With --dependency, report only these imported names (repeatable or comma-separated). Turns on the site page

Output

OptionDescription
--sitesWith --dependency, list the usage sites with file, line and column
--limit <N>With --dependency, the largest number of sites on a page (1 to 500, default 50). Turns on the site page
--cursor <TOKEN>With --dependency, the next_cursor of the previous page. Turns on the site page

The global options are in these groups: Project, Output, Scope, Baselines, Gates, Duplication, Type-aware, Performance.

FILE in the target is a path from the project root. A file with the exact path wins, so src/api.ts never selects packages/x/src/api.ts. When no file has the exact path, fallow accepts a path suffix and takes the first match, so use the full path in a monorepo. --path and --dependency replace the target. The walk is syntactic: fallow does not use the TypeScript type checker.

Option details

  • --path cannot go with the target, --callers, --callees or --depth. --dependency cannot go with the target, --path or --callees.
  • For --path, an exact path wins over a suffix match. Fallow accepts a short path only when it names one module. A missing or ambiguous endpoint exits with code 2.
  • With --dependency, --callers adds closure: the files that import the files that use the package, up to --depth.
  • The results are not part of the ranked review brief, and they do not change its order. fallow inspect --symbol-chain gives the same call chain as one part of its evidence.

Output

Call chain

fallow trace src/services/orders.ts:createOrder
Symbol-level call chain (best-effort, syntactic; OFF the ranked path)

  symbol: src/services/orders.ts:createOrder
  found:  true
  depth:  2

Callers (up): 1
  [1] src/index.ts (imported as createOrder -> local createOrder)

Resolved callees (down): 1
  [1] src/services/catalog.ts (imported as lookupPrice -> local lookupPrice)

Unresolved callees (reported, not dropped): 0

Callers are the files that import the symbol. Resolved callees are the imports of the file of the symbol. The walk follows re-exports, and it does not follow an import that has only side effects (import './setup'). An unresolved callee is a call that fallow cannot follow inside the project, for example Math.round, or parse imported from a package such as yaml. With --format json, the fields are file, symbol, symbol_found, depth, callers, callees, unresolved_callees, best_effort and reason. When two export * sources give the same name, the barrel file exports nothing under that name. symbol_found is then false, and star_export_ambiguity lists the sources (the files that declare the name, sorted) and the namespaces (type, value or both). So you can tell a collision from a wrong name. To fix it, rename the name in all sources but one, or replace the export * statements with named re-exports.

Import path between two modules

fallow trace --path src/index.ts src/lib/format.ts
Shortest import path (syntactic; OFF the ranked path)

  from:      src/index.ts
  to:        src/lib/format.ts
  reachable: yes
  hops:      2

  [1] src/index.ts:2 -> src/lib/index.ts
  [2] src/lib/index.ts:1 -> src/lib/format.ts

Each hop gives the importing file, the line of the import, and the imported file. A hop through import() or a worker has the tag [dynamic]. A pair without a path has reachable: no. That is a result, and the exit code stays 0. With --eager-only, fallow follows only the static imports that load a value at startup. With --format json, the fields are schema_version, from, to, reachable, hops, path and reason. Each hop in path has from, to, import_line, type_only and dynamic. A type-only hop stays in the path with type_only: true, so a path that exists only for the type checker shows. A trace from a module to itself gives reachable: true and hops: 0. A pair without a path also gives hops: 0, so read reachable.

Usage of a package

fallow trace --dependency zod
  USED zod (1 import(s))

  Imported by:
    -> src/index.ts

  Usage by imported name (syntactic):
    NAME  FILES  TYPE-ONLY  CALLS  UNRESOLVED
    z         1          0      3  -

Each row gives one imported name: the number of files that import it, the files that import only its type, the calls, and the uses that fallow cannot follow. With --format json, the fields are package_name, is_used, import_count, imported_by, type_only_imported_by, used_in_scripts and usage. usage holds these fields:

FieldContent
specifiersOne entry for each imported name: name, file_count, type_only_file_count, call_site_count, unresolved and wrappers. wrappers lists the project exports that wrap the name, such as export const useAppSelector = useSelector.withTypes<RootState>(), with their files and calls. The trace follows one wrapper step.
unresolvedThe uses that the trace cannot follow, counted and not dropped. The unresolved object of a name counts value_alias, non_call_reference, jsx_element, re_export, nested_wrapper and binding_without_site. The top-level object counts dynamic_import, require, side_effect_import, star_re_export and unattributed_file.
confidence"syntactic".
sitesA page of the use sites: items (sorted by file, line and column, each with a kind), total, limit and next_cursor. Present when the site page is on. Pass next_cursor to --cursor for the next page.
closureThe files that import the users, with --callers.

fallow dead-code --trace-dependency gives the same output without usage.

Each mode has kind: "trace". The JSON output reference has each field.

Exit codes

CodeMeaning
0The trace completed, also when the symbol is not found or no import path exists.
2Invalid input, for example a file that is not in the project, or a --path endpoint that matches more than one file.

See Exit codes.

Examples

# Show the callers of a symbol, one level deep
fallow trace src/api.ts:fetchUser --callers --depth 1

# Show why one module imports another
fallow trace --path src/app.ts src/db.ts

# Show only the imports that load at startup
fallow trace --path src/app.ts src/db.ts --eager-only

# Show where the code calls one function of a package
fallow trace --dependency date-fns --specifier format --sites