rev-dep
v3.0.0
Published
Trace imports, detect unused code, clean dependencies — all with a super-fast CLI
Downloads
434,317
Maintainers
Keywords
Readme
Rev-dep
About 📣
As codebases scale, maintaining a mental map of dependencies becomes impossible. Rev-dep is a high-speed static analysis tool designed to enforce architecture integrity and dependency hygiene across large-scale JS/TS projects.
Consolidate fragmented, sequential checks from multiple slow tools into a single, high-performance engine. Rev-dep executes a full suite of governance checks - including circularity, orphans, module boundaries and more, in one parallelized pass. Implemented in Go to bypass the performance bottlenecks of Node-based analysis, it can audit a 500k+ LoC project in approximately 150ms. See the performance comparison
Automated Codebase Governance
Rev-dep moves beyond passive scanning to active enforcement, answering (and failing CI for) the hard questions:
- Architecture Integrity: "Is my 'Domain A' illegally importing from 'Domain B'?".
- Dead Code & Bloat: "Are these files unreachable, or are these
node_modulesunused?". - Refactoring Safety: "Which entry points actually use this utility, and are there circular chains?".
- Workspace Hygiene: "Are my imports consistent and are all dependencies declared?".
Rev-dep serves as a high-speed gatekeeper for your CI, ensuring your dependency graph remains lean and your architecture stays intact as you iterate.
Why Rev-dep? 🤔
🏗️ First-class monorepo support
Designed for modern workspaces (pnpm, yarn, npm). Rev-dep natively resolves package.json exports/imports maps, TypeScript aliases and traces dependencies across package boundaries.
🛡️ Config-Based Codebase Governance
Move beyond passive scanning. Use the configuration engine to enforce Module Boundaries and Import Conventions. Execute a full suite of hygiene checks (circularity, orphans, unused modules and more) in a single, parallelized pass that serves as a high-speed gatekeeper for your CI.
🔍 Exploratory Toolkit
CLI toolkit that helps debug issues with dependencies between files. Understand transitive relation between files and fix issues.
⚡ Built for Speed and CI Efficiency
Implemented in Go to eliminate the performance tax of Node-based analysis. By processing files in parallel, Rev-dep offers 17x-90x faster execution than alternatives, significantly reducing CI costs and developer wait-states.
Rev-dep can audit a 500k+ LoC project in around 150ms. See the performance comparison
Capabilities 🚀
Governance and maintenance (config-based) 🛡️
Use rev-dep config run to execute multiple checks in one pass for all packages.
Available checks:
moduleBoundaries- enforce architecture boundaries between modules.importConventions- enforce import style conventions (offers autofix).unusedExportsDetection- detect exports that are never used (offers autofix).orphanFilesDetection- detect dead/orphan files (offers autofix).unusedNodeModulesDetection- detect dependencies declared but not used.missingNodeModulesDetection- detect imports missing from package json.unresolvedImportsDetection- detect unresolved import requests.circularImportsDetection- detect circular imports.duplicatedCodeDetection- detect copy-pasted code (repeated blocks and JSX elements).devDepsUsageOnProdDetection- detect dev dependencies used in production code.restrictedImportsDetection- block importing denied files/modules from selected entry points.restrictedImportersDetection- whitelist which entry points may transitively reach a set of files/modules.restrictedDirectImportersDetection- constrain which files may directly import a set of files/modules (non-transitive).
Exploratory analysis (CLI-based) 🔍
Use CLI commands for ad-hoc dependency exploration:
entry-points- discover project entry points.files- list dependency tree files for a given entry point.resolve- trace dependency paths between files (who imports this file).imported-by- list direct importers of a file.circular- list circular dependency chains.duplicated-code- find copy-pasted code blocks and JSX elements.node-modules- inspectused,unused,missing, andinstallednode modules.lines-of-code- count effective LOC.unresolved- list imports that could not be resolved, grouped by file.list-cwd-files- list all source code files in CWDdebug- inspect what rev-dep parses, resolves, and discovers internally.
Installation 📦
Full documentation: rev-dep.com/docs/intro
Install locally to set up project check scripts
yarn add -D rev-depnpm install -D rev-deppnpm add -D rev-depCreate config file for a quick start:
npx rev-dep config initInstall globally to use as a CLI tool:
yarn global add rev-depnpm install -g rev-deppnpm global add rev-depStep-by-step integration guides
Follow the guide that matches your project to get from zero to a working setup:
- Monorepo integration guide - for
pnpm/yarn/npmworkspaces. - Single workspace integration guide - for single-package projects.
Quick Examples 💡
A few instant-use examples to get a feel for the tool:
# Detect circular imports/dependencies
rev-dep circular
# Find copy-pasted code
rev-dep duplicated-code
# Detect unused node modules
rev-dep node-modules unused
# List all entry points in the project
rev-dep entry-points
# Check which files an entry point imports
rev-dep files --entry-point src/index.ts
# Find every entry point that depends on a file
rev-dep resolve --file src/utils/math.ts
# Resolve dependency path between files
rev-dep resolve --file src/utils/math.ts --entry-point src/index.ts
Config-Based Checks 🛡️
Rev-dep provides a configuration system for orchestrating project checks. The config approach is designed for speed and is the preferred way of implementing project checks because it can execute all checks in a single pass, significantly faster than multiple running individual commands separately.
Available checks are:
moduleBoundaries- enforce architecture boundaries between modules.importConventions- enforce import style conventions (offers autofix).unusedExportsDetection- detect exports that are never used (offers autofix).orphanFilesDetection- detect dead/orphan files (offers autofix).unusedNodeModulesDetection- detect dependencies declared but not used.missingNodeModulesDetection- detect imports missing from package json.unresolvedImportsDetection- detect unresolved import requests.circularImportsDetection- detect circular imports.duplicatedCodeDetection- detect copy-pasted code blocks and JSX elements.devDepsUsageOnProdDetection- detect dev dependencies used in production code.restrictedImportsDetection- block importing denied files/modules from selected entry points.restrictedImportersDetection- whitelist which entry points may transitively reach a set of files/modules.restrictedDirectImportersDetection- constrain which files may directly import a set of files/modules (non-transitive).
Checks are grouped in workspaces. You can have multiple workspaces, eg. for each monorepo package.
Getting Started
Initialize a configuration file in your project:
# Create a default configuration file
rev-dep config initBehavior of rev-dep config init:
- Monorepo root: Running
rev-dep config initat the workspace root creates a root workspace and a workspace for each discovered workspace package. - Monorepo workspace package or regular projects: Running
rev-dep config initinside a directory creates config with a single workspace withpath: "."for this directory.
Run all configured checks (dry run, not fixes applied yet):
# Execute all workspaces and checks defined in the config
rev-dep config runList all detected issues:
# Lists all detected issues, by default lists first five issues for each check
rev-dep config run --list-all-issuesFix all fixable checks:
# Fix checks configured with autofix
rev-dep config run --fixConfiguration Structure
The configuration file (rev-dep.config.json(c) or .rev-dep.config.json(c)) allows you to define multiple workspaces, each targeting different parts of your codebase with specific checks enabled.
Quick Start Configuration
{
"configVersion": "2.0",
"$schema": "https://github.com/jayu/rev-dep/blob/master/config-schema/2.0.schema.json?raw=true",
"nodeModulesResolution": { "resolutionType": "entry-package", "includeDevDepsFromRoot": false },
"workspaces": [
{
"path": ".",
"prodEntryPoints": ["src/main.tsx", "src/pages/**/*.tsx"],
"devEntryPoints": ["scripts/**", "**/*.test.*"],
"unusedExportsDetection": {
"enabled": true,
"autofix": true
},
"orphanFilesDetection": {
"enabled": true,
"autofix": true
},
"unusedNodeModulesDetection": {
"enabled": true
},
"circularImportsDetection": {
"enabled": true
},
"devDepsUsageOnProdDetection": {
"enabled": true,
"ignoreTypeImports": true
}
}
]
}Comprehensive Config Example
Here's a comprehensive example showing all available properties:
{
"configVersion": "1.10",
"$schema": "https://github.com/jayu/rev-dep/blob/master/config-schema/1.10.schema.json?raw=true", // enables json autocompletion
"conditionNames": ["import", "default"],
"ignoreFiles": ["**/*.test.*"],
"nodeModulesResolution": { "resolutionType": "entry-package", "includeDevDepsFromRoot": false },
"workspaces": [
{
"path": ".",
"followMonorepoPackages": true,
"prodEntryPoints": ["src/main.tsx", "src/pages/**/*.tsx", "src/server.ts"],
"devEntryPoints": ["scripts/**", "**/*.test.*"],
"ignoreEntryPoints": ["src/legacy/oldDashboard.tsx"],
"moduleBoundaries": [
{
"name": "ui-components",
"pattern": "src/components/**/*",
"allow": ["src/utils/**/*", "src/types/**/*"],
"deny": ["src/api/**/*"]
},
{
"name": "api-layer",
"pattern": "src/api/**/*",
"allow": ["src/utils/**/*", "src/types/**/*"],
"deny": ["src/components/**/*"]
}
],
"importConventions": [
{
"rule": "relative-internal-absolute-external",
"autofix": true,
"domains": [
{
"path": "src/features/auth",
"alias": "@auth",
"enabled": true
},
{
"path": "src/shared/ui",
"alias": "@ui-kit",
"enabled": false // checks disabled for this domain, but alias is still used for absolute imports from other domains
}
]
}
],
"circularImportsDetection": {
"enabled": true,
"ignoreTypeImports": true
},
"orphanFilesDetection": {
"enabled": true,
"ignoreTypeImports": true,
"graphExclude": ["**/*.test.*", "**/stories/**/*"],
"autofix": true
},
"unusedNodeModulesDetection": {
"enabled": true,
"includeModules": ["@myorg/**"],
"excludeModules": ["@types/**"],
"pkgJsonFieldsWithBinaries": ["scripts", "bin"],
"filesWithBinaries": ["scripts/check-something.sh"],
"filesWithModules": [".storybook/main.ts"],
"outputType": "groupByModule"
},
"missingNodeModulesDetection": {
"enabled": true,
"includeModules": ["lodash", "axios"],
"excludeModules": ["@types/**"],
"outputType": "groupByFile"
},
"unusedExportsDetection": {
"enabled": true,
"autofix": true,
"ignoreTypeExports": true,
"graphExclude": ["**/*.stories.tsx"],
"ignore": {
"src/types.ts": "B*",
"**/generated/**/*.ts": "*"
},
"ignoreFiles": ["**/*.generated.ts"],
"ignoreExports": ["default", "unused*"],
},
"unresolvedImportsDetection": {
"enabled": true,
"ignore": {
"src/index.ts": "legacy-*"
},
"ignoreFiles": ["**/*.generated.ts"],
"ignoreImports": ["@internal/*"]
},
"devDepsUsageOnProdDetection": {
"enabled": true,
"ignoreTypeImports": true
},
"restrictedImportsDetection": {
"enabled": true,
"entryPoints": ["src/server.ts", "src/server/**/*.ts"],
"graphExclude": ["some-file-coupling-other-files.ts"],
"denyFiles": ["**/*.tsx"],
"denyModules": ["react", "react-*"],
"ignoreMatches": ["src/server/allowed-view.tsx", "react-awsome-lib"],
"ignoreTypeImports": true
}
}
]
}Available Properties
Root Level Properties
configVersion(required): Configuration version string$schema(optional): JSON schema reference for validationconditionNames(optional): Array of condition names for exports resolutioncustomAssetExtensions(optional): Additional asset extensions treated as resolvable imports (e.g.["glb", "mp3"]). Default list covers common extensions for fonts, images, config files.ignoreFiles(optional): Global file patterns to ignore across all workspaces. Git ignored files are skipped by default.processIgnoredFiles(optional): Global file patterns to process even if they match gitignore orignoreFiles.nodeModulesResolution(optional): Whichpackage.jsoneach third-party import is validated against for themissingNodeModules,unusedNodeModules, andunresolvedImportschecks. Configure it as an object{ "resolutionType": ..., "includeDevDepsFromRoot": ... }- the formrev-dep config initgenerates.resolutionTypeis"entry-package"(default, validates against the workspace's entrypackage.json) or"nearest-package"(validates against thepackage.jsonowning each file - use for pnpm's default layout, where each package resolves only its own dependencies).includeDevDepsFromRoot(defaultfalse) lets package code use dev dependencies declared only at the monorepo root withoutmissingNodeModulesorunresolvedImportsflagging them. A bare string (e.g."nearest-package") is also accepted as a backward-compatible shorthand forresolutionType. Applies to all workspaces. See the docs.workspaces(required): Array of workspace objects
Workspace Properties
Each workspace can contain the following properties:
path(required): Target directory path for this workspace (either.or path starting with sub directory name)followMonorepoPackages(optional): Control monorepo package resolution.truefollows all workspace packages (default),falsedisables it, array follows only selected package names.prodEntryPoints(optional): Workspace-level production entry point patterns for detector defaultsdevEntryPoints(optional): Workspace-level development entry point patterns for detector defaultsignoreEntryPoints(optional): Workspace-level patterns for leftover entry points you no longer care about. Files matching these patterns are not processed as issues - they are never reported as orphan files, and their unused exports are not reported. Useful for files that must stay committed but are no longer wired into the app.moduleBoundaries(optional): Array of module boundary rulescircularImportsDetection(optional): Circular import detection configuration (single object or array of objects)duplicatedCodeDetection(optional): Duplicated code detection configuration (single object or array of objects)orphanFilesDetection(optional): Orphan files detection configuration (single object or array of objects)unusedNodeModulesDetection(optional): Unused node modules detection configuration (single object or array of objects)missingNodeModulesDetection(optional): Missing node modules detection configuration (single object or array of objects)unusedExportsDetection(optional): Unused exports detection configuration (single object or array of objects)unresolvedImportsDetection(optional): Unresolved imports detection configuration (single object or array of objects)devDepsUsageOnProdDetection(optional): Restricted dev dependencies usage detection configuration (single object or array of objects)restrictedImportsDetection(optional): Restrict importing denied files/modules from selected entry points (single object or array of objects)restrictedImportersDetection(optional): Whitelist which entry points may transitively reach a set of files/modules (single object or array of objects)restrictedDirectImportersDetection(optional): Constrain which files may directly import a set of files/modules; non-transitive (single object or array of objects)importConventions(optional): Array of import convention rules
Module Boundary Properties
name(required): Name of the boundarypattern(required): Glob pattern for files in this boundaryallow(optional): Array of allowed import patternsdeny(optional): Array of denied import patterns (overrides allow)
Import Convention Properties
rule(required): Type of the rule, currently onlyrelative-internal-absolute-externalautofix(optional): Whether to automatically fix import convention violations (default: false)domains(required): Array of domain definitions. Can be a string (glob pattern) or an object with:path(required): Directory with the domain filesalias(optional): Alias to be used for absolute imports of code from this domainenabled(optional): Set tofalseto skip checks for this domain (default: true)
Detection Options Properties
Each detection property can be configured as:
- a single object (one detector instance), or
- an array of objects (multiple detector instances evaluated within the same workspace).
CircularImportsDetection:
enabled(required): Enable/disable circular import detectionignoreTypeImports(optional): Exclude type-only imports when building graph (default: false)
DuplicatedCodeDetection:
enabled(required): Enable/disable duplicated code detectionblindIdentifiers(optional): Treat names as wildcards, so a renamed copy still counts (default: false)blindStrings(optional): Treat string and template contents as wildcards (default: false)blindNumbers(optional): Treat numeric literals as wildcards (default: false)minTokens(optional): Smallest duplication to report, in tokens (default: 50)minLines(optional): Smallest duplication to report, in lines (default: 3)minDepth(optional): Smallest nesting depth, counting the block itself. 2 requires at least one nested level (default: 0)minStatements(optional): Smallest statement count; applies only to statement blocks (default: 0)minDuplicates(optional): How many copies a chunk needs before it is reported (default: 2)skipObjects(optional): Do not report duplications that are only object literals (default: false)ignoreFiles(optional): Glob patterns to leave out of the analysissnapshotPath(optional): Path to a committed baseline of acknowledged duplications, relative to the workspace. With it the check reports what changed rather than the total
OrphanFilesDetection:
enabled(required): Enable/disable orphan files detectionvalidEntryPoints(optional): Array of valid entry point patterns. If omitted, defaults toprodEntryPoints + devEntryPointsfrom workspace level.ignoreTypeImports(optional): Exclude type-only imports when building graph (default: false)graphExclude(optional): File patterns to exclude from graph analysisautofix(optional): Delete detected orphan files automatically when runningrev-dep config run --fix(default: false)
UnusedNodeModulesDetection:
enabled(required): Enable/disable unused modules detectionincludeModules(optional): Module patterns to include in analysisexcludeModules(optional): Module patterns to exclude from analysispkgJsonFieldsWithBinaries(optional): Package.json fields containing binary references (eg. lint-staged). Performs plain-text lookupfilesWithBinaries(optional): File patterns to search for binary usage. Performs plain-text lookupfilesWithModules(optional): Non JS/TS file patterns to search for module imports (eg. shell scripts). Performs plain-text lookupoutputType(optional): Output format - "list", "groupByModule", "groupByFile"
MissingNodeModulesDetection:
enabled(required): Enable/disable missing modules detectionincludeModules(optional): Module patterns to include in analysisexcludeModules(optional): Module patterns to exclude from analysisoutputType(optional): Output format - "list", "groupByModule", "groupByFile", "groupByModuleFilesCount"
UnusedExportsDetection:
enabled(required): Enable/disable unused exports detectionvalidEntryPoints(optional): Glob patterns for files whose exports are never reported as unused. If omitted, defaults toprodEntryPoints + devEntryPointsfrom workspace level.ignoreTypeExports(optional): Skipexport type/export interfacefrom analysis (default: false)graphExclude(optional): File patterns to exclude from unused exports analysisignore(optional): Map of file path globs (relative to workspace path directory) to export name/specifier glob(s) to suppress; each value can be a string or array of stringsignoreFiles(optional): File path globs; all unused exports from matching files are suppressedignoreExports(optional): Export names/specifiers (or globs) to suppress globally (supports"default")autofix(optional): Automatically apply fixable unused exports changes when runningrev-dep config run --fix(default: false)
UnresolvedImportsDetection:
enabled(required): Enable/disable unresolved imports detectionignore(optional): Map of file path globs (relative to workspace path directory) to import request glob(s) to suppress; each value can be a string or array of stringsignoreFiles(optional): File path globs; all unresolved imports from matching files are suppressedignoreImports(optional): Import requests (or globs) to suppress globally in unresolved results
DevDepsUsageOnProdDetection:
enabled(required): Enable/disable restricted dev dependencies usage detectionprodEntryPoints(optional): Production entry point patterns to trace dependencies from. If omitted, defaults to workspace-levelprodEntryPoints.ignoreTypeImports(optional): Exclude type-only imports from graph traversal and module matching (default: false)
RestrictedImportsDetection:
enabled(required): Enable/disable restricted imports detectionentryPoints(required when enabled): Entry point patterns used to build reachable dependency graph (workspace-level entry points are not applied here)graphExclude(optional): File patterns to exclude from restricted imports graph analysisdenyFiles(optional): Denied file path patterns (eg. ["**/*.tsx"])denyModules(optional): Denied module patterns (eg. ["react", "react-*"])ignoreMatches(optional): File/module patterns to suppress from restricted import resultsignoreTypeImports(optional): Exclude type-only imports from traversal (default: false)
Performance Benefits
The configuration approach provides significant performance advantages:
- Single Dependency Tree Build: Builds one comprehensive dependency tree for all workspaces
- Parallel Workspace Execution: Processes multiple workspaces simultaneously
- Parallel Check Execution: Runs all enabled checks within each workspace in parallel
- Optimized File Discovery: Discovers files once and reuses across all checks
This makes config-based checks faster than running individual commands sequentially, especially for large codebases with multiple sub packages.
Exploratory Toolkit 🔧
Practical examples show how to use rev-dep CLI commands to explore, debug or build code quality checks for your project.
How to identify where a file is used in the project
rev-dep resolve --file path/to/file.tsYou’ll see all entry points that implicitly require that file, along with resolution paths.
How to check if a file is used
rev-dep resolve --file path/to/file.ts --compact-summaryShows how many entry points indirectly depend on the file.
How to identify dead files
rev-dep entry-pointsExclude framework entry points if needed using --result-exclude.
For example exclude Next.js valid entry points when using pages router, exclude scripts directory - scripts are valid entry-points and exclude all test files:
rev-dep entry-points --result-exclude "pages/**","scripts/**","**/*.test.*"How to list all files imported by an entry point
rev-dep files --entry-point path/to/file.tsUseful for identifying heavy components or unintended dependencies.
How to reduce unnecessary imports for an entry point
List all files imported:
rev-dep files --entry-point path/to/entry.tsIdentify suspicious files.
Trace why they are included:
rev-dep resolve --file path/to/suspect --entry-points path/to/entry.ts --all
How to detect circular dependencies
rev-dep circularHow to detect duplicated code
rev-dep duplicated-codeReports repeated code blocks and JSX elements - units you can extract - rather than repeated lines. Add --blind-identifiers to catch copies whose variables were renamed.
How to find unused node modules
rev-dep node-modules unusedHow to find missing node modules
rev-dep node-modules missingHow to check node_modules space usage
rev-dep node-modules dirs-sizeHow to detect dev dependencies used in production code
rev-dep config runWhen devDepsUsageOnProdDetection is enabled in your config, rev-dep will:
- Trace dependency graphs from your specified production entry points
- Identify all files reachable from those entry points
- Check if any imported modules are listed in
devDependenciesin package.json - Report violations showing which dev dependencies are used where
Example Output:
❌ Restricted Dev Dependencies Usage Issues (2):
lodash (dev dependency)
- src/components/Button.tsx (from entry point: src/pages/index.tsx)
- src/utils/helpers.ts (from entry point: src/pages/index.tsx)
eslint (dev dependency)
- src/config/eslint-config.js (from entry point: src/server.ts)Important Notes:
- Type-only imports (e.g.,
import type { ReactNode } from 'react') are ignored whenignoreTypeImportsis enabled - Only dependencies from
devDependenciesin package.json are flagged - Production dependencies from
dependenciesare allowed - Helps prevent runtime failures in production builds
Working with Monorepo 🏗️
Rev-dep provides first-class support for monorepo projects, enabling accurate dependency analysis across workspace packages.
followMonorepoPackages Flag
The --follow-monorepo-packages flag enables resolution of imports from monorepo workspace packages. By default, this flag is set to false to maintain compatibility with single-package projects.
# Enable monorepo package resolution
rev-dep circular --follow-monorepo-packages
rev-dep resolve --file src/utils.ts --follow-monorepo-packages
rev-dep entry-points --follow-monorepo-packagesWhen enabled, rev-dep will:
- Detect workspace packages automatically by scanning for monorepo configuration
- Resolve imports between packages within the workspace
- Follow package.json exports for proper module resolution
Exports Map Support
Rev-dep fully supports the exports field in package.json files, which is the standard way to define package entry points in modern Node.js projects.
The exports map support includes:
- Conditional exports using conditions like
node,import,default, and custom conditions - Wildcard patterns for flexible subpath mapping
- Sugar syntax for simple main export definitions
- Nested conditions for complex resolution scenarios
Condition Names Flag
To control which conditional exports are resolved, use the --condition-names flag. This allows you to specify the priority of conditions when resolving package exports:
# Resolve exports for different environments
rev-dep circular --condition-names=node,import,default
rev-dep resolve --file src/utils.ts --condition-names=import,node
rev-dep entry-points --condition-names=default,node,importThe conditions are processed in the order specified, with the first matching condition being used. Common conditions include:
node- Node.js environmentimport- ES modulesrequire- CommonJSdefault- Fallback condition- Custom conditions specific to your project or build tools
Example package.json with exports:
{
"name": "@myorg/utils",
"exports": {
".": {
"import": "./dist/index.mjs",
"require": "./dist/index.js",
"default": "./dist/index.js"
},
"./helpers": "./dist/helpers.js",
"./types/*": "./dist/types/*.d.ts"
}
}How Monorepo Resolution Works
Monorepo Detection: When
followMonorepoPackagesis enabled, rev-dep scans for workspace configuration (pnpm-workspace.yaml, package.json workspaces, etc.)Package Resolution: Imports to workspace packages are resolved using the package's exports configuration, falling back to main/module fields when exports are not defined
Dependency Validation: The tool validates that cross-package imports are only allowed when the target package is listed in the consumer's dependencies or devDependencies
Path Resolution: All paths are resolved relative to their respective package roots, ensuring accurate dependency tracking across the entire monorepo
This makes rev-dep particularly effective for large-scale monorepo projects where understanding cross-package dependencies is crucial for maintaining code quality and architecture.
Performance comparison ⚡
Rev-dep can perform multiple checks on 500k+ LoC monorepo with several sub-packages in around 150ms.
It outperforms Madge, dpdm, dependency-cruiser, skott, knip, depcheck and other similar tools.
Here is a performance comparison of specific tasks between rev-dep and alternatives:
| Task | Execution Time [ms] | Alternative | Alternative Time [ms] | Slower Than Rev-dep | |------|--------------------:|-------------|----------------------:|--------------------:| | Find circular dependencies | 151 | knip | 3 040 | 20x | | Find unused exports | 186 | knip | 3 176 | 17x | | Find unused files | 168 | knip | 3 006 | 18x | | Find unused node modules | 170 | knip | 3 069 | 18x | | Find missing node modules | 160 | knip | 3 076 | 19x | | List all files imported by an entry point | 81 | madge | 6 591 | 81x | | Discover entry points | 149 | madge | 13 632 | 92x | | Enforce module boundaries | 164 | dependency-cruiser | 8 140 | 50x | | Find restricted imports | 170 | dependency-cruiser | 10 995 | 65x | | Find restricted importers | 179 | dependency-cruiser | 9 234 | 52x | | Resolve dependency path between files | 221 | please suggest | | Count lines of code | 251 | please suggest | | Analyze node_modules directory sizes | 561 | please suggest |
Platform: WSL Linux Debian Intel(R) Core(TM) i9-14900KF CPU
Measurements:
hyperfine -w 4 -r 8(4 warm-up + 8 measured runs)Project: 580k lines of code, 6024 source code files next.js app
Circular check performance comparison
Table below presents performance comparison between different tools performing circular imports detection.
rev-dep circular check is ~20 times faster than the fastest alternative.
| Tool | Version | Time [ms] | |------|---------|----------:| | 🥇 rev-dep | 3.0.0 | 154 | | 🥈 knip * | 6.29.0 | 3 040 | | 🥉 circular-dependency-scanner | 3.0.1 | 3 355 | | dpdm-fast | 1.0.14 | 6 070 | | dpdm | 4.2.0 | 6 667 | | dependency-cruiser | 18.1.0 | 8 258 | | madge | 8.0.0 | 13 569 | | skott | 0.35.11 | 61 613 |
* knip always ignores type-only import edges and offers no flag to include them. Every cycle in
this codebase contains at least one, so knip reports 0 cycles - its 3 040 ms is a real full
analysis, just of a smaller graph. rev-dep circular -t, which applies the same rule, agrees
exactly (0 cycles) in 143.3 ms ± 10.3.
Platform: WSL Linux Debian Intel(R) Core(TM) i9-14900KF CPU
Measurements:
hyperfine -w 4 -r 8(4 warm-up + 8 measured runs)Project: 580k lines of code, 6024 source code files next.js app
See detailed measurements with mean time and commands used in PERFORMANCE.md.
CLI reference 📖
rev-dep circular
Detect circular dependencies in your project
Synopsis
Analyzes the project to find circular dependencies between modules. Circular dependencies can cause hard-to-debug issues and should generally be avoided.
rev-dep circular [flags]Examples
rev-dep circular --ignore-types-importsOptions
--condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
-c, --cwd string Working directory for the command (default "$PWD")
--follow-monorepo-packages strings Enable resolution of imports from monorepo workspace packages. Pass without value to follow all, or pass package names
-h, --help help for circular
-t, --ignore-type-imports Exclude type imports from the analysis
--process-ignored-files strings Glob patterns to process even if they are ignored by gitignore or exclude patterns
--tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
-v, --verbose Show warnings and verbose outputrev-dep config
Create and execute rev-dep configuration files
Synopsis
Commands for creating and executing rev-dep configuration files.
Options
-c, --cwd string Working directory (default "$PWD")
-h, --help help for configrev-dep config run
Execute all checks defined in (.)rev-dep.config.json(c)
Synopsis
Process (.)rev-dep.config.json(c) and execute all enabled checks (circular imports, orphan files, module boundaries, import conventions, node modules, unused exports, unresolved imports, restricted imports and restricted dev deps usage) per workspace.
rev-dep config run [flags]Options
-c, --cwd string Working directory (default "$PWD")
--fix Automatically fix fixable issues
--format string Output format (json, issues-list)
-h, --help help for run
--lint-config Also lint the config after running; prints only error/warning counts and fails (non-zero exit) on any lint error. Use 'config lint' for details and --fix
--lint-config-rules strings Which lint rules to run with --lint-config (comma-separated). Default: all. Implies --lint-config
--list-all-issues List all issues instead of limiting output
--recheck Run all checks again after '--fix' to validate the final state
--update-snapshot Rewrite every configured duplicated-code snapshot from this run, acknowledging what it found.
-v, --verbose Show warnings and verbose output
--workspaces strings Subset of workspaces to run (comma-separated list of workspace paths)rev-dep config init
Initialize a new rev-dep.config.json file
Synopsis
Create a new rev-dep.config.json configuration file in the current directory with default settings.
rev-dep config init [flags]Options
-c, --cwd string Working directory (default "$PWD")
-h, --help help for initrev-dep config lint
Report (and optionally remove) config glob/path patterns that match nothing
Synopsis
Scan a (.)rev-dep.config.json(c) for "dead" glob and path patterns - ignore patterns, entry point patterns, workspace paths, graph excludes, denied files/modules and similar - that no longer match any discovered file or module. Over time configs accumulate patterns for files that were renamed or deleted; this command surfaces them so the config stays lean.
With --fix, dead patterns are removed in place, preserving all comments and formatting. Some patterns are reported but never auto-removed because deleting them could change a check's behavior or make the config invalid - workspace paths, required entry points / files / modules, and module-boundary selectors. These are marked "not auto-removed"; resolve them by hand.
rev-dep config lint [flags]Options
-c, --cwd string Working directory (default "$PWD")
--fix Remove dead patterns from the config file (preserves comments and formatting)
-h, --help help for lint
--rules strings Lint rules to run (comma-separated): orphan-file-globs, orphan-module-globs, overlapping-globs, trailing-commas, compact. Default: all. orphan-file-globs/overlapping-globs use file discovery; orphan-module-globs parses the dependency tree; trailing-commas and compact only read the config file.
-v, --verbose Show warnings and verbose outputrev-dep config migrate
Upgrade a v2 config to the v3 (2.0) schema
Synopsis
Upgrade a (.)rev-dep.config.json(c) from the v2 schema to v3 (config version 2.0).
It applies the safe, unambiguous changes in place (renaming the top-level 'rules' array to 'workspaces', bumping 'configVersion' to 2.0, and removing the discontinued 'algorithm' option from circular-imports detectors), preserving all comments and formatting. Review the change with git before committing.
It then lists what it could NOT change for you: glob patterns whose match set may have shifted under v3's stricter, gitignore-aligned rules, and behavior changes that no config edit can address. Review those manually - see the v3 breaking-changes guide.
rev-dep config migrate [flags]Options
-c, --cwd string Working directory (default "$PWD")
-h, --help help for migraterev-dep debug
Debugging tools to inspect parser and resolver internals
Synopsis
Debugging tools to inspect how rev-dep parses files and resolves dependencies. Output does not follow semver.
Options
-h, --help help for debugrev-dep debug get-tree-for-cwd
Debug: Show complete dependency tree for analysis
Synopsis
Debugging tool to inspect the complete dependency tree. Output does not follow semver.
rev-dep debug get-tree-for-cwd [flags]Options
--condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
--cwd string Working directory for the command (default "$PWD")
--follow-monorepo-packages strings Enable resolution of imports from monorepo workspace packages. Pass without value to follow all, or pass package names
-h, --help help for get-tree-for-cwd
-t, --ignore-type-imports Exclude type imports from the analysis
--include-dev-deps-from-root Treat the monorepo root package.json devDependencies as available to package code, so they are not reported as missing or unresolved. Mirrors config nodeModulesResolution.includeDevDepsFromRoot
--node-modules-resolution string Which package.json each import is validated against: 'entry-package' (the cwd package.json, default) or 'nearest-package' (each file's own nearest package.json) (default "entry-package")
--tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
-v, --verbose Show warnings and verbose outputrev-dep debug list-cwd-files
List all files in the current working directory
Synopsis
Recursively lists all files in the specified directory, with options to filter results.
rev-dep debug list-cwd-files [flags]Examples
rev-dep debug list-cwd-files --include='*.ts' --exclude='*.test.ts'Options
--count Only display the count of matching files
--cwd string Directory to list files from (default "$PWD")
--exclude strings Exclude files matching these glob patterns
-h, --help help for list-cwd-files
--include strings Only include files matching these glob patternsrev-dep debug parse-file
Debug: Show parsed imports for a single file
Synopsis
Debugging tool to inspect how the parser processes a specific file. Output does not follow semver.
rev-dep debug parse-file [flags]Options
--condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
--cwd string Working directory for the command (default "$PWD")
--file string file to parse
--follow-monorepo-packages strings Enable resolution of imports from monorepo workspace packages. Pass without value to follow all, or pass package names
-h, --help help for parse-file
--include-dev-deps-from-root Treat the monorepo root package.json devDependencies as available to package code, so they are not reported as missing or unresolved. Mirrors config nodeModulesResolution.includeDevDepsFromRoot
--node-modules-resolution string Which package.json each import is validated against: 'entry-package' (the cwd package.json, default) or 'nearest-package' (each file's own nearest package.json) (default "entry-package")
--tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
-v, --verbose Show warnings and verbose outputrev-dep debug parse-tsconfig
Debug: Show parsed TypeScript configuration aliases
Synopsis
Debugging tool to inspect how TypeScript configuration is parsed and what aliases are extracted. Output does not follow semver.
rev-dep debug parse-tsconfig [flags]Options
-h, --help help for parse-tsconfig
--tsconfig string Path to TypeScript configuration filerev-dep duplicated-code
Find code duplicated across (and within) the files of the project
Synopsis
Scans every source file for copy-pasteable chunks - brace blocks and JSX elements, at every level of nesting - and reports the ones that appear more than once.
Comparison ignores formatting and comments entirely, so re-indented copies still match.
Four filters decide what counts as worth reporting. --min-tokens and --min-lines measure size; --min-depth and --min-statements measure complexity, which is what separates a duplicated three-key config object from duplicated logic - no size floor can, because the object's keys and string values may be long. --min-duplicates sets how many copies it takes to qualify.
By default the code must match as written. Each --blind-* flag drops one category of token out of the comparison, and they combine freely:
--blind-identifiers names are wildcards, so a copy whose variables, functions or components were renamed is still reported --blind-strings string and template contents are wildcards --blind-numbers numeric literals are wildcards
rev-dep duplicated-code [flags]Examples
rev-dep duplicated-code --cwd ./src --blind-identifiersOptions
--blind-identifiers Ignore the spelling of names, so a copy whose variables, functions or components were renamed still counts as duplication.
--blind-numbers Ignore the value of numeric literals, so a copy with different constants still counts
--blind-strings Ignore the text of string and template literals, so a copy with different messages or keys still counts
-c, --cwd string Working directory for the command (default "$PWD")
-f, --format string Output format: "human" or "json". JSON reports every finding with its canonical hash and the byte and line range of each occurrence, for comparing against another run or another tool (default "human")
-h, --help help for duplicated-code
--ignore-files strings Glob patterns of files to leave out of the analysis.
--json-snippets Include the source of each finding in JSON output. Off by default because snippets dominate the file size and a comparison keyed on ranges does not need them
--min-depth int Smallest duplication to report, in nesting levels counting the block itself. 1 admits everything; 2 requires at least one nested level, which is what filters out flat objects and single JSX elements however long their keys or strings are
--min-duplicates int How many copies a chunk needs before it is reported. Raise to 3 to ignore code that has only been copied once (default 2)
--min-lines int Smallest duplication to report, in lines of the first occurrence (default 3)
--min-statements int Smallest duplication to report, in statements directly inside the block. Applies only to statement blocks (function and control-flow bodies); object literals and JSX elements are expressions and are not filtered by it - use --min-depth for those
--min-tokens int Smallest duplication to report, in tokens. Tokens rather than characters because the count does not change when a --blind-* flag is applied, so one number means the same amount of code whatever is being ignored (default 50)
--process-ignored-files strings Glob patterns to analyse even when gitignore excludes them.
--skip-objects Do not report duplications that are only object literals.
--snapshot string Path to a JSON snapshot of acknowledged duplications. With it, the command reports what changed since the snapshot instead of everything that exists, and exits non-zero on any difference
--update-snapshot Rewrite the --snapshot file from this run, acknowledging everything it found. Always explicit: nothing updates a snapshot on its ownrev-dep entry-points
Discover and list all entry points in the project
Synopsis
Analyzes the project structure to identify all potential entry points. Useful for understanding your application's architecture and dependencies.
rev-dep entry-points [flags]Examples
rev-dep entry-points --print-deps-countOptions
--condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
-n, --count Only display the number of entry points found
-c, --cwd string Working directory for the command (default "$PWD")
--follow-monorepo-packages strings Enable resolution of imports from monorepo workspace packages. Pass without value to follow all, or pass package names
--graph-exclude strings Exclude files matching these glob patterns from analysis
-h, --help help for entry-points
-t, --ignore-type-imports Exclude type imports from the analysis
--print-deps-count Show the number of dependencies for each entry point
--process-ignored-files strings Glob patterns to process even if they are ignored by gitignore or exclude patterns
--result-exclude strings Exclude files matching these glob patterns from results
--result-include strings Only include files matching these glob patterns in results
--tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
-v, --verbose Show warnings and verbose outputrev-dep files
List all files in the dependency tree of an entry point
Synopsis
Recursively finds and lists all files that are required by the specified entry point.
rev-dep files [flags]Examples
rev-dep files --entry-point src/index.tsOptions
--condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
-n, --count Only display the count of files in the dependency tree
-c, --cwd string Working directory for the command (default "$PWD")
-p, --entry-point string Entry point file to analyze (required)
--follow-monorepo-packages strings Enable resolution of imports from monorepo workspace packages. Pass without value to follow all, or pass package names
-h, --help help for files
-t, --ignore-type-imports Exclude type imports from the analysis
--process-ignored-files strings Glob patterns to process even if they are ignored by gitignore or exclude patterns
--tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
-v, --verbose Show warnings and verbose outputrev-dep imported-by
List all files that directly import the specified file
Synopsis
Finds and lists all files in the project that directly import the specified file. This is useful for understanding the impact of changes to a particular file.
rev-dep imported-by [flags]Examples
rev-dep imported-by --file src/utils/helpers.tsOptions
--condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
-n, --count Only display the count of importing files
-c, --cwd string Working directory for the command (default "$PWD")
-f, --file string Target file to find importers for (required)
--follow-monorepo-packages strings Enable resolution of imports from monorepo workspace packages. Pass without value to follow all, or pass package names
-h, --help help for imported-by
--list-imports List the import identifiers used by each file
--process-ignored-files strings Glob patterns to process even if they are ignored by gitignore or exclude patterns
--tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
-v, --verbose Show warnings and verbose outputrev-dep lines-of-code
Count actual lines of code in the project excluding comments and blank lines
rev-dep lines-of-code [flags]Examples
rev-dep lines-of-codeOptions
-c, --cwd string Directory to analyze (default "$PWD")
-h, --help help for lines-of-coderev-dep list-cwd-files
List all files in the current working directory
Synopsis
Recursively lists all files in the specified directory, with options to filter results.
rev-dep list-cwd-files [flags]Examples
rev-dep list-cwd-files --include='*.ts' --exclude='*.test.ts'Options
--count Only display the count of matching files
--cwd string Directory to list files from (default "$PWD")
--exclude strings Exclude files matching these glob patterns
-h, --help help for list-cwd-files
--include strings Only include files matching these glob patternsrev-dep unresolved
List unresolved imports in the project
Synopsis
Detect and list imports that could not be resolved during imports resolution. Groups imports by file.
rev-dep unresolved [flags]Options
--condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
--custom-asset-extensions strings Additional asset extensions treated as resolvable (e.g. glb,mp3)
-c, --cwd string Working directory for the command (default "$PWD")
--follow-monorepo-packages strings Enable resolution of imports from monorepo workspace packages. Pass without value to follow all, or pass package names
-h, --help help for unresolved
--ignore stringToString Map of file path (relative to cwd) to exact import request to ignore (e.g. --ignore src/index.ts=some-module) (default [])
--ignore-files strings File path glob patterns to ignore in unresolved output
--ignore-imports strings Import requests to ignore globally in unresolved output
--include-dev-deps-from-root Treat the monorepo root package.json devDependencies as available to package code, so they are not reported as missing or unresolved. Mirrors config nodeModulesResolution.includeDevDepsFromRoot
--node-modules-resolution string Which package.json each import is validated against: 'entry-package' (the cwd package.json, default) or 'nearest-package' (each file's own nearest package.json) (default "entry-package")
--process-ignored-files strings Glob patterns to process even if they are ignored by gitignore or exclude patterns
--tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
-v, --verbose Show warnings and verbose outputrev-dep node-modules
Analyze and manage Node.js dependencies
Synopsis
Tools for analyzing and managing Node.js module dependencies. Helps identify unused, missing, or duplicate dependencies in your project.
Examples
rev-dep node-modules used -p src/index.ts
rev-dep node-modules unused --exclude-modules=@types/*
rev-dep node-modules missing --entry-points=src/main.tsOptions
-h, --help help for node-modulesrev-dep node-modules analyze-size
Analyze disk usage of node_modules
Synopsis
Provides detailed size analysis of node_modules directory. Helps identify space-hogging dependencies.
rev-dep node-modules analyze-size [flags]Examples
rev-dep node-modules analyze-sizeOptions
-c, --cwd string Working directory for the command (default "$PWD")
-h, --help help for analyze-sizerev-dep node-modules dirs-size
Calculates cumulative files size in node_modules directories
Synopsis
Calculates and displays the size of node_modules folders in the current directory and subdirectories. Sizes will be smaller than actual file size taken on disk. Tool is calculating actual file size rather than file size on disk (related to disk blocks usage)
rev-dep node-modules dirs-size [flags]Examples
rev-dep node-modules dirs-sizeOptions
-c, --cwd string Working directory for the command (default "$PWD")
-h, --help help for dirs-sizerev-dep node-modules installed-duplicates
Find and optimize duplicate package installations
Synopsis
Identifies packages that are installed multiple times in node_modules. Can optimize storage by creating symlinks between duplicate packages.
rev-dep node-modules installed-duplicates [flags]Examples
rev-dep node-modules installed-duplicates --optimize --size-statsOptions
-c, --cwd string Working directory for the command (default "$PWD")
-h, --help help for installed-duplicates
--isolate Create symlinks only within the same top-level node_module directories. By default optimize creates symlinks between top-level node_module directories (eg. when workspaces are used). Needs --optimize flag to take effect
--optimize Automatically create symlinks to deduplicate packages
--size-stats Print node modules dirs size before and after optimization. Might take longer than optimization itself
--verbose Show detailed information about each optimizationrev-dep node-modules installed
List all installed npm packages in the project
Synopsis
Recursively scans node_modules directories to list all installed packages. Helpful for auditing dependencies across monorepos.
rev-dep node-modules installed [flags]Examples
rev-dep node-modules installed --include-modules=@myorg/*Options
-c, --cwd string Working directory for the command (default "$PWD")
-e, --exclude-modules strings list of modules to exclude from the output
-h, --help help for installed
-i, --include-modules strings list of modules to include in the outputrev-dep node-modules missing
Find imported packages not listed in package.json
Synopsis
Identifies packages that are imported in your code but not declared in your package.json dependencies.
rev-dep node-modules missing [flags]Examples
rev-dep node-modules missing --entry-points=src/main.tsOptions
--condition-names strings List of conditions for package.json imports resolution (e.g. node, imports, default)
-n, --count Only display the count of modules
-c, --cwd string Working directory for the command (default "$PWD")
-p, --entry-points strings Entry point file(s) to start analysis from (default: auto-detected)
-e, --exclude-modules strings list of modules to exclude from the output
-b, --files-with-binaries strings Additional files to search for binary usages. Use paths relative to cwd
-m, --files-with-node-modules strings Additional files to search for module imports. Use paths relative to cwd
--follow-monorepo-packages strings Enable resolution of imports from monorepo workspace packages. Pass without value to follow all, or pass package names
--group-by-file Organize output by project file path
--group-by-module Organize output by npm package name
--group-by-module-files-count Organize output by npm package name and show count of files using it
-h, --help help for missing
-t, --ignore-type-imports Exclude type imports from the analysis
--include-dev-deps-from-root Treat the monorepo root package.json devDependencies as available to package code, so they are not reported as missing or unresolved. Mirrors config nodeModulesResolution.includeDevDepsFromRoot
-i, --include-modules strings list of modules to include in the output
--node-modules-resolution string Which package.json each import is validated against: 'entry-package' (the cwd package.json, default) or 'nearest-package' (each file's own nearest package.json) (default "entry-package")
--pkg-fields-with-binaries strings Additional package.json fields to check for binary usages
--tsconfig-json string Path to tsconfig.json (default: ./tsconfig.json)
-v, --verbose Show warnings and verbose output
--zero-exit-code Use this flag to always return zero exit coderev-dep node-modules prune-docs
Remove markdown/docs-like files from installed node_modules packages
Synopsis
Removes files from installed node_modules packages based on glob patterns. Useful for pruning README/LICENSE/docs files to reduce dependency size.
rev-dep node-modules prune-docs [flags]Examples
rev-dep node-modules prune-docs --defaults
rev-dep node-modules prune-docs --patterns "*.md,README.md,docs/**"
rev-dep node-modules prune-docs --defaults --patterns "*.txt"Options
-c, --cwd string Working directory for the command (default "$PWD")
--defaults Use default prune patterns: LICENSE, README.md, docs/**
-h, --help 