Repolens is a repository intelligence CLI that scans source trees and builds a dependency graph to surface architectural signals such as hubs, coupling, instability, and implementation relationships.
It is designed for fast, practical analysis in real-world codebases and currently supports JavaScript, TypeScript, Python, Java, and Markdown.
- Identify critical files that many others depend on.
- Spot unstable files likely to create churn.
- Find concrete implementations of an interface or base class.
- Export graph data as JSON for custom dashboards and automation.
- Get a concise repository summary without heavyweight setup.
- Multi-language scanning using tree-sitter parsing.
- Dependency graph construction and ranking.
- Circular dependency detection via
--cycles(CI-friendly exit codes). - Architectural health report:
- Top core dependencies by afferent coupling (
$Ca$ ) - Top unstable files by instability (
$I = \frac{Ce}{Ca + Ce}$ ) - Interface implementation lookup via
--implements. - Persistent parse caching with automatic stale-entry pruning.
- JSON export for machine-readable output.
- Runtime indicator at command completion (seconds).
- Verbose mode for parser and scan diagnostics.
Install globally from npm:
npm install -g @anirudw/repolensVerify installation:
repolens --versionRun in the current directory:
repolensRun against a specific repository path:
repolens /path/to/repoPrint architectural health metrics:
repolens /path/to/repo --healthExport analysis as JSON:
repolens /path/to/repo --format json --output repolens-graph.jsonFind files implementing an interface/base class:
repolens /path/to/repo --implements ILoggerCheck for circular dependencies (fails with exit code 1 if any are found):
repolens /path/to/repo --cyclesUse this mode in CI to fail builds when circular dependencies are introduced.
repolens [path] [options]
[path]optional directory to scan (defaults to current working directory)
-v, --verboseenable verbose output-f, --format <format>output format:textorjson(default:text)-o, --output <file>output file path for JSON export-i, --implements <interfaceName>list files implementing an interface/base class--cyclesdetect circular dependencies and exit non-zero when cycles exist--healthprint architectural health metrics and exit-V, --versionprint CLI version-h, --helpshow help
Outputs after I ran repolens on nest repository of nestjs (https://github.com/nestjs/nest.git`)
Found 1 circular dependencies.
a.ts -> b.ts -> c.ts -> a.ts
- JavaScript:
.js,.jsx,.mjs,.cjs - TypeScript:
.ts,.tsx,.mts,.cts - Python:
.py - Java:
.java - Markdown:
.md,.markdown
Clone and install dependencies:
npm installRun in dev mode:
npm run dev -- /path/to/repo --healthBuild distributable CLI:
npm run buildRun tests:
npm run testType check:
npm run lintRepolens stores parsed-file metadata in .repolens-cache.json at the scanned repository root.
- Cache hit: same file path and unchanged mtime reuse prior parse output.
- Cache miss: changed mtime triggers re-parse.
- Stale cleanup: entries for files no longer in the scan set are pruned automatically.
- Repository isolation: each scanned repo has its own independent cache file.
Practical expectation: the first run on a large repository is slower, while repeated runs on unchanged files are significantly faster due to cache hits.
repolens --cycles: exits0when no cycles are found, exits1when cycles are detected.- Other modes return normal CLI success/failure behavior.
Use --cycles in pull-request checks to prevent new circular dependencies:
name: RepoLens Cycles Check
on:
pull_request:
push:
branches: [main]
jobs:
cycles:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npm run build
- run: node dist/index.js . --cyclesThis job fails automatically when the cycle check exits with code 1.
- If a global install appears stale, reinstall the latest version:
npm uninstall -g @anirudw/repolens
npm install -g @anirudw/repolens@latest- Use verbose mode to inspect parse warnings:
repolens /path/to/repo --verbose- Use
--healthor--implementswhen you want focused output (they exit early by design and do not print summary mode).
MIT. See LICENSE.