Skip to content

Dependency Analysis

Reflex tracks file-level dependencies by extracting import/require/use statements from your code. This powers reverse lookups, circular dependency detection, hotspot analysis, and more.

See what a specific file imports:

Terminal window
rfx deps src/watcher.rs
Dependencies of src/watcher.rs:
└─ anyhow [external] (line 6)
└─ notify [external] (line 7)
└─ std::collections::HashSet [stdlib] (line 8)
└─ std::path [stdlib] (line 9)
└─ std::sync::mpsc [stdlib] (line 10)
└─ std::time [stdlib] (line 11)
└─ crate::indexer::Indexer [internal] (line 13)
└─ crate::output [internal] (line 14)
└─ super::* [internal] (line 250)
└─ std::fs [stdlib] (line 251)
└─ tempfile::TempDir [external] (line 252)
Found 11 dependencies

Each entry shows the import as written, its type and the line it appears on. Imports are extracted during rfx index, so rfx deps answers from the index without re-parsing.

Find every file that imports a given file:

Terminal window
rfx deps src/content_store.rs --reverse
Files that import src/content_store.rs:
└─ src/background_indexer.rs
└─ src/cli/query.rs
└─ src/query/open_index.rs
└─ src/indexer.rs
└─ src/query/result.rs
└─ src/lib.rs
Found 6 dependents

This answers “what breaks if I change this file?” — essential for safe refactoring.

Explore transitive dependencies (the default depth is 1):

Terminal window
rfx deps src/watcher.rs --depth 3
Dependencies of src/watcher.rs (depth 3):
└─ src/indexer.rs
└─ src/output.rs
└─ src/background_indexer.rs
└─ src/cache.rs
└─ src/content_store.rs
...
└─ src/symbol_cache.rs
└─ src/trigram.rs
Found 27 transitive dependencies
Terminal window
# Tree view (default)
rfx deps src/main.rs --format tree
# Table view (Path / Type / Line columns)
rfx deps src/main.rs --format table
# JSON for scripting (add --pretty for readable output)
rfx deps src/main.rs --json

JSON output is an array of imports, each with import_type, line, path and the imported symbols:

[{"import_type":"external","line":6,"path":"anyhow","symbols":["Context","Result"]}, ...]

Analyze your entire dependency graph. With no flags, rfx analyze prints a summary:

Dependency Analysis Summary
Circular Dependencies: 1 cycle(s)
Hotspots: 68 file(s) with 2+ dependents
Unused Files: 24 file(s)
Islands: 187 disconnected component(s) (2 clusters of 2+ files, 185 isolated files)
Terminal window
rfx analyze --circular
Circular Dependencies Found:
Cycle 1:
→ src/interactive/app.rs
→ src/interactive/ui.rs
→ src/interactive/app.rs (cycle completes)

Finds dependency cycles (A → B → C → A) that can cause build issues and architectural problems. Rust mod declarations are excluded from cycle detection, since they express parent–child ownership rather than usage.

Terminal window
rfx analyze --hotspots
rfx analyze --hotspots --min-dependents 5
Hotspots (Most-Imported Files):
1. src/models.rs (69 imports)
2. src/cache.rs (39 imports)
3. src/parsers/mod.rs (22 imports)

Identifies files with the highest fan-in (most depended upon). These are your highest-impact files — changes here affect the most code. Only files with at least --min-dependents dependents (default 2) are listed.

Terminal window
rfx analyze --unused

Finds files that nothing imports — potential dead code candidates. Files outside the import graph — Markdown, config and other text files — show up here too.

Terminal window
rfx analyze --islands
rfx analyze --islands --min-island-size 3

Detects disconnected clusters of files that have no dependency relationship with the rest of your codebase. --min-island-size (default 2) and --max-island-size (default 500 or 50% of all files) bound which clusters are reported.

Terminal window
rfx analyze --hotspots --sort asc # least important first (default: desc)
rfx analyze --hotspots --count # just the count
rfx analyze --hotspots --format table # Rank / Imports / File columns

--sort applies to hotspots (by import count), islands (by size) and cycles (by length).

For large results, use --limit and --offset:

Terminal window
rfx analyze --hotspots --limit 20 --offset 0
rfx analyze --hotspots --limit 20 --offset 20

Or get everything at once:

Terminal window
rfx analyze --hotspots --all --json

Reflex classifies every dependency into one of four types:

TypeDescriptionExample
internalFiles within your projectuse crate::auth::handler
externalThird-party packagesuse anyhow::Result
stdlibStandard libraryuse std::collections::HashMap
mod_declRust module declaration (parent owns child)mod filter;

Dependency extraction works across all 15 parsed languages. Text, lock and generated files have no imports. See Supported Languages for the full matrix of what import syntax each language supports.

LanguageImport syntax
Rustuse, mod, extern crate
TypeScript/JavaScriptimport, require()
Pythonimport, from...import
Goimport
Java/Kotlinimport
C/C++#include
C#using
PHPuse, require, include
Rubyrequire, require_relative, load
Vue/Svelteimports from <script> blocks
Zig@import()

Add --dependencies to a regular query to see import context alongside search results:

Terminal window
rfx query "hash_content" --kind method --dependencies

This enriches each result with the file’s imports — in text output as a Dependencies: list under the match, and in JSON as a dependencies array on each file — useful for understanding the context around a match. This flag is documented as Rust-only: for other languages Reflex prints a warning.