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.
Per-file dependencies with rfx deps
Section titled “Per-file dependencies with rfx deps”See what a specific file imports:
rfx deps src/watcher.rsDependencies 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 dependenciesEach 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.
Reverse dependencies
Section titled “Reverse dependencies”Find every file that imports a given file:
rfx deps src/content_store.rs --reverseFiles 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 dependentsThis answers “what breaks if I change this file?” — essential for safe refactoring.
Deeper traversal
Section titled “Deeper traversal”Explore transitive dependencies (the default depth is 1):
rfx deps src/watcher.rs --depth 3Dependencies 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 dependenciesOutput formats
Section titled “Output formats”# 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 --jsonJSON 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"]}, ...]Codebase analysis with rfx analyze
Section titled “Codebase analysis with rfx analyze”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+ dependentsUnused Files: 24 file(s)Islands: 187 disconnected component(s) (2 clusters of 2+ files, 185 isolated files)Circular dependencies
Section titled “Circular dependencies”rfx analyze --circularCircular 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.
Hotspots
Section titled “Hotspots”rfx analyze --hotspotsrfx analyze --hotspots --min-dependents 5Hotspots (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.
Unused files
Section titled “Unused files”rfx analyze --unusedFinds files that nothing imports — potential dead code candidates. Files outside the import graph — Markdown, config and other text files — show up here too.
Isolated subgraphs
Section titled “Isolated subgraphs”rfx analyze --islandsrfx analyze --islands --min-island-size 3Detects 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.
Sorting, counting and formats
Section titled “Sorting, counting and formats”rfx analyze --hotspots --sort asc # least important first (default: desc)rfx analyze --hotspots --count # just the countrfx analyze --hotspots --format table # Rank / Imports / File columns--sort applies to hotspots (by import count), islands (by size) and cycles (by length).
Pagination
Section titled “Pagination”For large results, use --limit and --offset:
rfx analyze --hotspots --limit 20 --offset 0rfx analyze --hotspots --limit 20 --offset 20Or get everything at once:
rfx analyze --hotspots --all --jsonDependency types
Section titled “Dependency types”Reflex classifies every dependency into one of four types:
| Type | Description | Example |
|---|---|---|
internal | Files within your project | use crate::auth::handler |
external | Third-party packages | use anyhow::Result |
stdlib | Standard library | use std::collections::HashMap |
mod_decl | Rust module declaration (parent owns child) | mod filter; |
Supported languages
Section titled “Supported languages”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.
| Language | Import syntax |
|---|---|
| Rust | use, mod, extern crate |
| TypeScript/JavaScript | import, require() |
| Python | import, from...import |
| Go | import |
| Java/Kotlin | import |
| C/C++ | #include |
| C# | using |
| PHP | use, require, include |
| Ruby | require, require_relative, load |
| Vue/Svelte | imports from <script> blocks |
| Zig | @import() |
Adding dependency context to searches
Section titled “Adding dependency context to searches”Add --dependencies to a regular query to see import context alongside search results:
rfx query "hash_content" --kind method --dependenciesThis 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.
Next steps
Section titled “Next steps”- AI Integration — dependency data is available through MCP tools
- CLI Commands — full
rfx depsandrfx analyzereference - Architecture — how the dependency index works internally