Quick Installation
Needs Node 22.12 or later
npm install -D tdependWhat It Does
Rules, and the graph that makes them trustworthy
Architecture Rules
Forbid imports between files or layers, keep a component's internals private, ban npm packages from parts of the code, and stop import cycles. Every violation names the file, line and import to fix.
A Graph That Matches the Compiler
Every import is resolved by TypeScript's own resolver: tsconfig paths, package exports, project references and workspace packages, built or not. If tsc can follow an import, so can tdepend.
Runtime or Type-Only
tdepend knows which imports really load their target at runtime and which ones the compiler erases, so a cycle made only of type imports isn't reported as a runtime cycle.
Presets
NestJS, React, Express, Fastify and plain Node projects are detected per package.json. Each preset brings sensible skips, components and recommended rules, and you can write your own.
Baselines
Adopt a rule in a codebase that already breaks it. The baseline accepts today's violations with a count, so only new ones fail the build.
Cycles With Proof
Cycles are found between files, components and packages. Each one comes with its shortest loop and the exact import behind every step.
Coupling Metrics
Afferent and efferent coupling, instability, abstractness and distance from the main sequence, for every file, component and package. Metrics inform; they never fail a build.
CLI, Library and JSON
Run it from the command line or call it from Node. The JSON output is sorted and has no timestamp, so two runs on the same code are byte-identical.
Use as CLI or Library
Choose the approach that fits your workflow
CLI Usage
tdepend init # write a starter config
tdepend analyze # components, metrics, cycles
tdepend check # evaluate the rules
tdepend baseline # accept today's violations
tdepend explain src/main.ts Library Usage
import { check } from 'tdepend';
const report = await check({ root: '.' });
for (const violation of report.actionable) {
console.log(violation);
}
process.exitCode = report.exitCode;