Skip to main content
Rev-dep provides a comprehensive command-line interface for analyzing and managing JavaScript/TypeScript project dependencies. The CLI is designed for both exploratory analysis and automated checks in CI/CD pipelines.

Command Categories

Dependency Analysis

Trace and analyze dependencies between files

Node Modules Management

Manage and optimize npm packages

Configuration

Initialize and run config-based checks

File Discovery

List and filter project files

Dependency Analysis Commands

Commands for exploring and understanding your dependency graph.

resolve

Trace and display the dependency path between files in your project.
rev-dep resolve --file src/utils/helpers.ts
rev-dep resolve --entry-points src/index.ts --file src/utils/math.ts
rev-dep resolve --module lodash --all
Key Flags:
  • -f, --file - Target file to check for dependencies
  • --module - Target node module name to check for dependencies
  • -p, --entry-points - Entry point file(s) or glob pattern(s) to start analysis from
  • -a, --all - Show all possible resolution paths, not just the first one
  • --compact-summary - Display a compact summary of found paths
  • --graph-exclude - Glob patterns to exclude files from dependency analysis

entry-points

Discover and list all entry points in the project. Entry points are files that are not imported by any other file.
rev-dep entry-points
rev-dep entry-points --print-deps-count
rev-dep entry-points --result-exclude "**/*.test.*"
Key Flags:
  • -n, --count - Only display the number of entry points found
  • --print-deps-count - Show the number of dependencies for each entry point
  • --graph-exclude - Exclude files matching these glob patterns from analysis
  • --result-exclude - Exclude files matching these glob patterns from results
  • --result-include - Only include files matching these glob patterns in results

files

List all files in the dependency tree of an entry point.
rev-dep files --entry-point src/index.ts
rev-dep files --entry-point src/main.tsx --count
Key Flags:
  • -p, --entry-point - Entry point file to analyze (required)
  • -n, --count - Only display the count of files in the dependency tree

imported-by

List all files that directly import the specified file.
rev-dep imported-by --file src/utils/helpers.ts
rev-dep imported-by --file src/components/Button.tsx --list-imports
Key Flags:
  • -f, --file - Target file to find importers for (required)
  • -n, --count - Only display the count of importing files
  • --list-imports - List the import identifiers used by each file

circular

Detect circular dependencies in your project.
rev-dep circular
rev-dep circular --ignore-type-imports
Key Flags:
  • -t, --ignore-type-imports - Exclude type imports from the analysis

unresolved

List unresolved imports in the project.
rev-dep unresolved
rev-dep unresolved --ignore-files "**/*.generated.ts"
Key Flags:
  • --ignore - Map of file path to exact import request to ignore
  • --ignore-files - File path glob patterns to ignore in unresolved output
  • --ignore-imports - Import requests to ignore globally in unresolved output
  • --custom-asset-extensions - Additional asset extensions treated as resolvable

Node Modules Commands

Commands for analyzing and managing npm dependencies.

node-modules used

List all npm packages imported in your code.
rev-dep node-modules used
rev-dep node-modules used --entry-points src/index.ts --group-by-module
Key Flags:
  • -p, --entry-points - Entry point file(s) to start analysis from
  • -n, --count - Only display the count of modules
  • --group-by-module - Organize output by npm package name
  • --group-by-file - Organize output by project file path
  • --group-by-entry-point - Organize output by entry point file path
  • --group-by-module-files-count - Organize by package and show count of files using it

node-modules unused

Find installed packages that aren’t imported in your code.
rev-dep node-modules unused
rev-dep node-modules unused --exclude-modules "@types/*"
Key Flags:
  • -i, --include-modules - List of modules to include in the output
  • -e, --exclude-modules - List of modules to exclude from the output
  • --zero-exit-code - Always return zero exit code

node-modules missing

Find imported packages not listed in package.json.
rev-dep node-modules missing
rev-dep node-modules missing --entry-points src/main.ts
Key Flags:
  • -p, --entry-points - Entry point file(s) to start analysis from
  • --group-by-module - Organize output by npm package name
  • --group-by-file - Organize output by project file path

node-modules installed

List all installed npm packages in the project.
rev-dep node-modules installed
rev-dep node-modules installed --include-modules "@myorg/*"
Key Flags:
  • -i, --include-modules - List of modules to include in the output
  • -e, --exclude-modules - List of modules to exclude from the output

node-modules installed-duplicates

Find and optimize duplicate package installations.
rev-dep node-modules installed-duplicates
rev-dep node-modules installed-duplicates --optimize --size-stats
Key Flags:
  • --optimize - Automatically create symlinks to deduplicate packages
  • --size-stats - Print node modules dirs size before and after optimization
  • --verbose - Show detailed information about each optimization
  • --isolate - Create symlinks only within the same top-level node_module directories

node-modules analyze-size

Analyze disk usage of node_modules.
rev-dep node-modules analyze-size

node-modules dirs-size

Calculate cumulative files size in node_modules directories.
rev-dep node-modules dirs-size

node-modules prune-docs

Remove markdown/docs-like files from installed node_modules packages.
rev-dep node-modules prune-docs --defaults
rev-dep node-modules prune-docs --patterns "*.md,README.md,docs/**"
Key Flags:
  • --patterns - Glob patterns of files to remove
  • --defaults - Use default prune patterns (LICENSE, README.md, docs/**)

Configuration Commands

Commands for config-based codebase governance.

config init

Initialize a new rev-dep.config.json file.
rev-dep config init
Creates a configuration file with default settings based on your project structure.

config run

Execute all checks defined in your configuration file.
rev-dep config run
rev-dep config run --fix
rev-dep config run --list-all-issues
rev-dep config run --rules packages/ui,packages/api
Key Flags:
  • --fix - Automatically fix fixable issues
  • --list-all-issues - List all issues instead of limiting output
  • --rules - Subset of rules to run (comma-separated list of rule paths)

File Discovery Commands

Commands for listing and filtering project files.

list-cwd-files

List all files in the current working directory.
rev-dep list-cwd-files
rev-dep list-cwd-files --include "*.ts" --exclude "*.test.ts"
Key Flags:
  • --include - Only include files matching these glob patterns
  • --exclude - Exclude files matching these glob patterns
  • --count - Only display the count of matching files

lines-of-code

Count actual lines of code in the project excluding comments and blank lines.
rev-dep lines-of-code

Shared Flags

These flags are available across most commands:

Working Directory

  • -c, --cwd - Working directory for the command (default: current directory)

Configuration Files

  • --package-json - Path to package.json (default: ./package.json)
  • --tsconfig-json - Path to tsconfig.json (default: ./tsconfig.json)

Import Resolution

  • --condition-names - List of conditions for package.json imports resolution (e.g. node, imports, default)
  • --follow-monorepo-packages - Enable resolution of imports from monorepo workspace packages. Pass without value to follow all, or pass specific package names

Type Imports

  • -t, --ignore-type-imports - Exclude type imports from the analysis

Output Control

  • -v, --verbose - Show warnings and verbose output
  • -n, --count - Only display the count (available on many commands)

Monorepo Support

Rev-dep provides first-class monorepo support with the --follow-monorepo-packages flag:
# Enable for all workspace packages
rev-dep circular --follow-monorepo-packages

# Enable for specific packages
rev-dep resolve --file src/utils.ts --follow-monorepo-packages=@myorg/core,@myorg/ui
When enabled, rev-dep will:
  • Detect workspace packages automatically
  • Resolve imports between packages within the workspace
  • Follow package.json exports for proper module resolution

Conditional Exports

Control which conditional exports are resolved using --condition-names:
rev-dep circular --condition-names=node,import,default
rev-dep resolve --file src/utils.ts --condition-names=import,node
Common conditions include:
  • node - Node.js environment
  • import - ES modules
  • require - CommonJS
  • default - Fallback condition

Exit Codes

Most rev-dep commands use exit codes to indicate results:
  • 0 - Success or no issues found
  • > 0 - Number of issues found (for detection commands like circular, unused, missing)
Some commands support --zero-exit-code to always return 0, useful for CI pipelines where you want to log issues without failing the build.

Performance Tips

  1. Use config-based checks - Running rev-dep config run is faster than running individual commands sequentially
  2. Exclude unnecessary files - Use --graph-exclude to skip test files or build artifacts
  3. Use glob patterns - Specify multiple entry points with patterns instead of running commands multiple times
  4. Leverage parallel execution - The config approach runs all checks in parallel for maximum speed

Common Workflows

Find and Remove Unused Code

# Find entry points (potential dead files)
rev-dep entry-points --result-exclude "pages/**,scripts/**,**/*.test.*"

# Find unused exports (via config)
rev-dep config run --fix

Reduce Bundle Size

# List all files imported by entry point
rev-dep files --entry-point src/index.ts

# Check why a heavy file is included
rev-dep resolve --file src/heavy-component.tsx --entry-points src/index.ts --all

# Find unused dependencies
rev-dep node-modules unused

Enforce Architecture

# Use config for module boundaries
rev-dep config run

# Check circular dependencies
rev-dep circular --ignore-type-imports

Debug Import Issues

# Find unresolved imports
rev-dep unresolved

# Find missing dependencies
rev-dep node-modules missing

# Trace dependency path
rev-dep resolve --file src/problem.ts --all

Next Steps

Configuration Guide

Learn about config-based checks

Configuration Commands

Detailed documentation for configuration commands

Build docs developers (and LLMs) love