Installation

Homebrew (macOS / Linux)

brew tap pererikbergman/noupling
brew install noupling

From source

git clone https://github.com/pererikbergman/noupling.git
cd noupling
cargo install --path crates/noupling-cli

Prebuilt binaries

Download from GitHub Releases. Available for Linux (x86_64, aarch64), macOS (Apple Silicon, Intel), and Windows.

Quick Start

# 1. Scan your project
noupling scan /path/to/project

# 2. See the health score
noupling audit /path/to/project

# 3. Generate an interactive HTML report
noupling report /path/to/project --format html

# 4. Gate in CI
noupling scan . --diff-base origin/main
noupling audit . --fail-below 80

A .noupling/settings.json is auto-created on first run with sensible defaults. Edit it to customize thresholds, ignore patterns, and source extensions.

Health Score

The health score is a single number (0–100) that quantifies your architecture's coupling risk:

Score = 100 × (1 - TRI / (total_modules × max_weight))

TRI (Total Risk Index) is the sum of all violation RRIs. Each violation's RRI (Relationship Risk Index) is computed as direction_weight × density, where direction_weight reflects the severity of the dependency direction and density captures how many imports exist between the pair. See RRI and TRI for details.

RangeStatusAction
90–100HealthyMaintain
70–89WarningInvestigate new violations
0–69Needs attentionPrioritize decoupling

Every Issue that scores carries its score impact — the points it takes off. Summed over all Issues the impacts equal the points lost, so the breakdown every format prints (Points lost: 4.7 (Coupling Violation 0.9, Cycle 3.8)) adds up.

Findings: Issues & Metrics

Everything the audit says about a codebase is a Finding, and every Finding is either an Issue or a Metric. An Issue names specific modules or edges and asks for a change; a Metric (fan-in, instability, blast radius, critical path, …) describes without asking. Reports may include or omit Metrics freely, but every Issue-listing report carries every Issue — the same Issues, with the same wording, whichever format you open. The full vocabulary lives in CONTEXT.md.

The nine Issue kinds

KindShapeMeaningScores?
Coupling ViolationedgeAn import between sibling directories (or from a child to its parent) that the audit disallows. A mutually-dependent pair is never a Coupling Violation; it is part of a Cycle.yes
CycleringAn ordered ring of directories that depend on each other back to the start. Surfaces exactly once; its reason names the cheapest break edge and its recommendation is to cut it.yes
Rule ViolationedgeAn import forbidden by an explicit dependency_rules entry.no
Layer ViolationedgeAn import from a layered module into a higher layer (or, with hand-written layers, into no layer at all).no
Gravity WellmoduleA module whose aggregate RRI is disproportionate to its neighbours; everything nearby bends toward it.no
Red FlagedgeA named structural anti-pattern: fused sibling (a pair far tighter than its peers) or trapped child (a child importing its parent).no
Stability Violationedge (directories)A more-stable directory depending on a less-stable sibling or cousin (Stable Dependencies Principle). A directory and its own ancestor are never compared: an entry point reaching into its packages is composition.no
Zone FlagdirectoryA directory far enough off the main sequence to land in the Zone of Pain (concrete yet stable) or the Zone of Uselessness (abstract yet unstable).no
Low CohesiondirectoryA Package whose direct children barely depend on each other.no

The Issue card

Every Issue is presented the same way in every format: kind, severity band (critical / high / medium / low, assigned once by the audit — Coupling Violations and Cycles step to critical at critical_severity, and are never banded below what they cost the score — 10 points is critical, 5 at least high, 1 at least medium; Rule and Layer Violations are high; Gravity Wells and Red Flags map their RRI; Stability Violations and Zone Flags are medium; Low Cohesion is low), subject (one module, one from → to edge, or a ring), a one-sentence reason with this instance's numbers, a one-sentence recommendation, and its score impact. When you audit with --baseline, accepted Issues are additionally marked baselined: still listed, not counted by the CI gate.

scan

Discover source files, parse imports, resolve dependencies, store in SQLite.

noupling scan <PATH> [--diff-base <BRANCH>]
FlagDescription
--diff-baseFilter results to files changed vs. this branch. Scans full project for resolution.

audit

Analyze the latest snapshot and print the health score, Top Actions, and every Issue as an Issue card (all nine kinds), followed by the Metric sections.

noupling audit [PATH] [--fail-below N] [--baseline] [--snapshot ID] [--module NAME]
FlagDescription
--fail-belowExit code 1 if score is below this. Use in CI.
--baselineMark Issues accepted by .noupling/baseline.json as baselined (still listed) and exit 1 only when there are Issues not in the baseline.
--snapshotAudit a specific snapshot instead of the latest.
--moduleShow results for one module only (monorepo).

report

Generate a report file from the latest snapshot.

noupling report [PATH] --format <FORMAT> [--module NAME] [--baseline]

Formats: text, json, xml, md, html, sonar, mermaid, dot, bundle, dashboard, pr, briefing, strategy, explorer, all. Add --baseline to mark accepted Issues. See Report Formats.

trend

Show health score history across snapshots.

noupling trend [PATH] [--last N]

baseline

Record every current Issue — all nine kinds — as accepted. audit --baseline and report --baseline then show those Issues marked baselined (dimmed in html and the Explorer, (baselined) in text) and count them separately; audit exits 1 only when an Issue is new.

noupling baseline save [PATH]

Each Issue is identified by its kind and identity (its subject, or the directory pair for Coupling Violations and Red Flags), so adding or removing an import between the same two directories does not make an accepted Issue look new. Baseline files written before 0.9.0 covered only coupling violations; they load as “nothing baselined” with a one-line warning until you re-run baseline save.

Pro-Tip: Commit .noupling/baseline.json to your repo. New team members inherit the accepted Issues and only see the ones they introduce.

hook

Install a git pre-commit hook that fails on new violations.

noupling hook install [PATH]
noupling hook uninstall [PATH]

Bypass with git commit --no-verify.

Thresholds

{
  "thresholds": {
    "score_green": 90.0,
    "score_yellow": 70.0,
    "critical_severity": 0.5,
    "minimum_severity": 0.2,
    "hotspot_fan_in": 10,
    "min_cohesion": 0.1
  }
}

minimum_severity hides low-severity violations to reduce noise. critical_severity is the step to the critical severity band for Coupling Violations and Cycles (the high and medium steps scale with it at 0.4× and 0.2×), and the critical_violations header counts the Coupling Violations and Cycles whose band is critical. Severity is mostly a depth measure, so the band is also floored by the Issue's score impact: an Issue costing 10 or more points is critical, 5 or more at least high, 1 or more at least medium, whatever its severity. On a small project a single shallow Cycle can take 40 points; it reads as critical, not low.

Risk Weights

Risk weights control how heavily each dependency direction contributes to the RRI score. Configure in .noupling/settings.json:

{
  "risk_weights": {
    "downward": 2,
    "sibling": 4,
    "upward": 6,
    "external": 8,
    "transitive": 9,
    "circular": 10
  }
}
DirectionWeightDescription
Downward2Dependency follows the declared layer order. Low risk, but still tracked.
Sibling4Dependency between modules at the same level. Creates horizontal coupling.
Upward6Dependency flows against the layer order. Inverts the architecture.
External8Dependency on a third-party (unresolved) import. High risk due to external coupling.
Transitive9Indirect dependency through intermediate modules. Near-circular risk level.
Circular10Part of a dependency cycle. Highest risk; prevents independent deployment.
Pro-Tip: Adjust weights to match your team's priorities. If upward dependencies are your biggest pain point, increase the upward weight to surface them more aggressively in the health score.

Layer Inference

When layers is empty, the audit infers a layer set from well-known path segments (ui, domain, data, infra, …) and switches to actionable coupling mode so coarse sibling coupling inside an inferred layer doesn't dominate the score. Every command and every report format sees the same inferred layers (ADR 0001); the text report notes it with a Layers: inferred… line and the Explorer shows a banner with a ready-to-paste snippet.

Inference is sticky in one direction: once a snapshot has inferred layers, a later snapshot where a fresh detection finds nothing keeps the previous set while it still covers at least half the entry threshold of files. A commit that adds a few unrelated files near the 30% line therefore does not flip the audit between layered and unlayered (and the score, the baseline and the trend stay comparable), while new or renamed layer directories are picked up as soon as detection finds them. The inferred set is recorded per snapshot in history.db; a fresh database (a CI runner, say) has no history and detects from scratch.

{
  "infer_layers": false
}

Set infer_layers to false to audit an unlayered project as-is (strict mode, no Layer Violations). Declaring your own layers also disables inference; setting a top-level coupling_mode keeps your mode but still uses the inferred layers.

Coupling Mode

The coupling_mode setting controls which dependencies are treated as violations:

{
  "coupling_mode": "strict"
}
ModeBehavior
strict (default)All sibling coupling is a violation. Every cross-module dependency at the same level is flagged.
actionableOnly circular dependencies are violations. Sibling coupling is tracked but not penalized, reducing noise in projects where lateral dependencies are acceptable.
Guardrail: Start with strict mode on greenfield projects. Switch to actionable for legacy codebases where fixing all sibling coupling at once is impractical—focus on breaking cycles first.

Ignore Patterns

{
  "ignore_patterns": [
    "**/.git/**", "**/build/**", "**/node_modules/**",
    "**/generated/**", "**/__pycache__/**"
  ]
}

Glob patterns (gitignore-style). Any matching file is excluded from analysis.

Architectural Layers

Define layers so dependencies flowing downward (earlier → later) aren't flagged as coupling.

{
  "layers": [
    { "name": "presentation", "pattern": "**/ui/**" },
    { "name": "domain", "pattern": "**/domain/**" },
    { "name": "data", "pattern": "**/data/**" }
  ]
}
  • presentation → domain: allowed (downward)
  • data → presentation: violation (upward)

Layer-specific thresholds

Each layer can override sibling coupling behavior with per-layer threshold fields:

{
  "layers": [
    {
      "name": "presentation",
      "pattern": "**/ui/**",
      "allow_sibling": false,
      "max_sibling_density": 3,
      "reduced_sibling_weight": 2
    },
    { "name": "domain", "pattern": "**/domain/**" },
    { "name": "data", "pattern": "**/data/**" }
  ]
}
FieldTypeDescription
allow_siblingboolIf false, sibling coupling within this layer is always flagged. Default: true.
max_sibling_densityintegerMaximum import count between siblings before the violation is escalated. Exceeding this density triggers a higher severity.
reduced_sibling_weightintegerOverride the sibling risk weight for dependencies within this layer. Use a lower value to de-prioritize expected lateral coupling.
Guardrail: Layers suppress coupling violations but don't eliminate dependencies. If you find yourself adding many layers to make violations disappear, the real problem is your module boundaries.

Dependency Rules

{
  "dependency_rules": [
    {
      "from": "**/ui/**",
      "to": "**/data/**",
      "allow": false,
      "message": "UI must not depend on data layer directly"
    }
  ]
}

Inline Suppression

Suppress a specific import with a noupling:ignore comment on the same line or the line above:

import com.example.legacy.Helper // noupling:ignore

// noupling:ignore
import com.example.legacy.OtherHelper

Works with //, #, and -- comment styles. Disable globally with "allow_inline_suppression": false.

Pro-Tip: Treat noupling:ignore like @SuppressWarnings—use it sparingly for genuinely acceptable coupling, not to silence inconvenient truths.

Monorepo Support

Define independent modules, each analyzed separately with its own health score. Every module goes through the same audit as a single-module project — risk weights, your layers and dependency_rules, layer inference — so audit, audit --module X and report --module X agree, and the multi-module summary lists each module's Issue cards.

{
  "modules": [
    { "name": "app", "path": "app/src", "depends_on": ["lib-core"] },
    { "name": "lib-core", "path": "lib/core/src", "depends_on": [] }
  ]
}

depends_on declares the allowed cross-module import graph. Unlisted imports are flagged as cross-module violations.

# Multi-module summary
noupling audit .

# Single module detail
noupling audit . --module app

The overall score is a weighted average by file count. Files outside all modules are ignored. If modules is empty, the project is analyzed as a single module (backward compatible).

XS Metric

XS (Excess) quantifies the refactoring cost of violations.

  • Coupling violations: XS = number of import statements (the weight)
  • Circular dependencies: XS = break cost at the weakest link
  • Total XS: sum across all violations = total imports to remove

The weakest link is the hop in a cycle with the fewest imports—the cheapest edge to cut. The HTML report shows per-hop XS counts in expandable cycle details.

Diff Mode

noupling scan . --diff-base origin/main
noupling audit .

Scans the full project (needed for import resolution) but filters audit results to only violations touching changed files. Use in PRs to only fail on new issues.

CI Integration

GitHub Actions

- name: Install noupling
  run: |
    curl -sL "https://github.com/pererikbergman/noupling/releases/latest/download/noupling-linux-x86_64" -o noupling
    chmod +x noupling
    sudo mv noupling /usr/local/bin/

- name: Scan (diff mode)
  run: noupling scan . --diff-base origin/main

- name: Audit
  run: noupling audit . --fail-below 80

SonarCloud

noupling report . --format sonar

Add to sonar-project.properties:

sonar.externalIssuesReportPaths=.noupling/noupling-sonar.json

PR Comment Bot

Copy .github/workflows/noupling-pr.yml from the noupling repo. It posts a health score comment on every PR and updates it on force-pushes.

Report Formats

FormatClassFileBest for
textIssue-listing.noupling/report.txtWhat audit prints, saved to a file
htmlIssue-listing.noupling/report/Interactive drill-down, sharing with team
jsonIssue-listing.noupling/report.jsonProgrammatic consumption, custom dashboards
xmlIssue-listing.noupling/report.xmlEnterprise CI, XSLT pipelines
mdIssue-listing.noupling/report-md/GitHub wiki, documentation sites
sonarIssue-listing.noupling/noupling-sonar.jsonSonarCloud/SonarQube integration
mermaidGraph.noupling/report.mermaidEmbed in Markdown, quick overview
dotGraph.noupling/report.dotGraphViz rendering, custom pipelines
bundleGraph.noupling/bundle.htmlZoomable sunburst with dependency edges
dashboardIssue-listing.noupling/dashboard.htmlExecutive dashboard with all metrics, scorecard, risk matrix
prIssue-listing.noupling/pr.mdTight Markdown summary to post as a PR comment
briefingIssue-listing.noupling/briefing.mdSprint planning: top 10 ROI-ranked refactorings
strategyTrend.noupling/strategy.htmlMulti-snapshot trend report for executive review (--last N)
explorerIssue-listing.noupling/explorer.htmlInteractive single-file Explorer: layered structure map, drill-down, issues, matrix and composition views, click-to-source (--editor, --title, --no-history, --output)
all—all of the aboveOne command to generate every report format

Format classes

Two rules, asserted by the test suite on a fixture that produces every kind:

  • Issue-listing formats (text, json, xml, sonar, md, html, dashboard, pr, briefing, explorer) carry every Issue kind that has members. They may summarise (pr names each kind with a count and lists the top five) but never silently omit a kind.
  • Graph formats (mermaid, dot, bundle) accent every edge-shaped Issue — Coupling, Rule, Layer and Stability Violations and every hop of a Cycle — with a distinct style per kind and a legend, and may omit the node-shaped kinds. Baselined edges are muted.

The trend format (strategy) shows how the score and the Issue count per kind move across snapshots, not individual Issues.

The issues array (Issue cards)

Every format that carries data — json, xml, sonar, and the Explorer's embedded Data Contract (each card extended with participants, the node ids it is about) — lists the same Issues, serialised once as Issue cards. In report.json they are the top-level issues array, in canonical order: severity band descending, then kind, then subject path. Filter by kind; every kind is present when the audit found one. Since 0.9.0 this is the only Issue array: the former coupling_violations, circular_dependencies, gravity_wells, red_flags, stability_violations, distance and cohesion arrays are gone (the changelog has the field mapping). The Metric arrays hotspots, abstractness, instability and directory_tree are unchanged.

{
  "kind": "cycle",                       // machine id, one of the nine kinds below
  "kind_name": "Cycle",                  // glossary name
  "severity": "critical",                // critical | high | medium | low
  "subject": { "type": "ring", "members": ["src/ring/alpha", "src/ring/beta", "src/ring/alpha"] },
                                         // or { "type": "edge", "from": "…", "to": "…" }
                                         // or { "type": "module", "path": "…" }
  "reason": "src/ring/alpha -> src/ring/beta -> src/ring/alpha form a cycle of 2 directories (2 imports in the ring); the cheapest break is src/ring/alpha -> src/ring/beta (1 import).",
  "recommendation": "Cut the cycle at src/ring/alpha -> src/ring/beta by removing 1 import or moving that code behind an interface.",
  "score_impact": 4.5,                   // points this Issue takes off the score; 0 for kinds that do not score
  "baselined": false,                    // true when .noupling/baseline.json accepts it (run with --baseline)
  "fingerprint": "cycle:src/ring/alpha -> src/ring/beta -> src/ring/alpha",
  "detail": { … }                        // per-kind numbers, see table
}
kindSubject shapedetail fields
coupling_violationedgedir_a, dir_b, line_number, depth, imports, raw_severity, rri, direction
cycleringorder, depth, raw_severity, rri, hop_import_counts, hops[] (from_file, to_file, line_number), weakest_link, break_cost
rule_violationedgeline_number, message
layer_violationedgeline_number, from_layer, to_layer
gravity_wellmoduletotal_rri, relationship_count, direction_count, downward_rri, sibling_rri, upward_rri, circular_rri
red_flagedgeflag_type (fused_sibling | trapped_child), modules, dir_a, dir_b, rri, imports, median_density
stability_violationedge (directories)from_instability, to_instability
zone_flagmodule (directory)zone (pain | uselessness), abstractness, instability, distance
low_cohesionmodule (directory)cohesion, n_children, internal_deps

The XML report carries the same cards as <issues>/<issue> elements (scalar detail fields become attributes of <detail/>); the Sonar report emits one generic issue per card with ruleId noupling:<kind> and the band mapped to CRITICAL / MAJOR / MINOR / INFO.

RRI (Relationship Risk Index)

Each violation is assigned an RRI score that reflects both the severity of the dependency direction and the density of imports between the pair:

RRI = direction_weight × density

direction_weight comes from the risk weights configuration (e.g., 4 for sibling, 10 for circular). density is the number of import statements between the two modules.

Higher RRI means higher architectural risk. A single circular dependency with 3 imports scores 10 × 3 = 30, while a sibling coupling with 1 import scores only 4 × 1 = 4.

TRI (Total Risk Index)

The project-level risk metric, computed as the sum of all violation RRIs:

TRI = ∑ RRIi  (for all violations i)

Lower is better. TRI feeds directly into the health score formula. Track TRI over time with noupling trend to ensure architectural risk is decreasing.

Pro-Tip: TRI is additive, so you can compare modules directly: a module contributing 80% of the TRI is the obvious place to start refactoring.

Gravity Wells

A gravity well is a module whose total RRI exceeds 2× the median RRI across all modules. These are "God Objects" that pull the system into their orbit—everything depends on them, or they depend on everything.

Gravity wells are flagged in the audit output and highlighted in the dashboard. They represent the highest-leverage refactoring targets: reducing a gravity well's coupling has outsized impact on the overall health score.

Guardrail: A module can be a gravity well even with individually low-severity violations if it has many of them. Watch for modules that accumulate dozens of small couplings.

Red Flags

Red flags are specific anti-patterns detected by the risk framework:

Red FlagDetectionWhy it matters
Fused SiblingSibling coupling density > 2× median densityTwo modules so tightly coupled they are effectively one. Consider merging them or extracting a shared abstraction.
Trapped ChildModule has upward dependencies (child depends on parent layer)Inverts the dependency hierarchy. The "child" cannot be tested, deployed, or understood without its parent.
Pro-Tip: Red flags are intentionally opinionated. If a flagged pattern is correct for your architecture, suppress it with inline suppression or adjust your layer definitions.

Module Independence

For each top-level directory, the ratio of internal dependencies to total dependencies.

independence = internal_deps / (internal_deps + external_deps)

A module with independence 0.95 can be extracted into its own repo. One with 0.40 is deeply entangled. Modules below 70% are flagged in audit output.

Pro-Tip: Use this to answer "Can team X own this module independently?" High independence = ready to extract. Low independence = needs decoupling first.

Blast Radius

For each module, the count of other modules transitively affected if it changes. Computed via BFS on the reverse dependency graph.

If A imports B and B imports C, then C's blast radius is 2 (changing C affects both B and A). The top 10 highest blast radius modules are shown in audit output.

Use this before approving refactoring plans: low blast radius = safe to change, high = ripples through the codebase.

Instability (Martin's I)

Robert C. Martin's metric:

I = fan_out / (fan_in + fan_out)
  • I = 0.0: Maximally stable. Many depend on it; it depends on nothing. Should be abstract.
  • I = 1.0: Maximally unstable. Depends on many; nothing depends on it. Should be concrete.

The Zone of Pain: stable (I < 0.3) modules with high fan-in (≥ 5) are foundational but hard to change with wide impact. These are flagged separately.

Abstractness (Martin's A)

A = abstract_declarations / (abstract_declarations + concrete_declarations)

Counted per file by the language parser and summed per directory. Abstract: interfaces, abstract classes, Rust traits, Kotlin/Java interfaces and abstract classes. Concrete: classes, objects, enums, structs, and module-level functions (declared or arrow in TypeScript, free fn in Rust, top-level fun in Kotlin), so a file of React or Compose components or free functions counts as implementation even when it also declares a Props interface. Type aliases count as neither. A directory with no declarations at all has no A and no Zone Flag.

Dependency Depth

The longest transitive dependency chain in the project, computed via topological sort on the dependency DAG.

Deep chains mean changes at the bottom ripple through many layers. Shallow chains mean the architecture is flat and manageable. The audit output shows the maximum depth and the critical path (the actual chain of files).

Violation Age

Violations are classified by how long they have existed across snapshots:

  • New: first appearance in the latest snapshot — urgent regressions
  • Recent: 2–4 snapshots — recent debt
  • Chronic: 5+ snapshots — accepted long-term debt

This helps prioritize: new regressions need immediate attention; chronic debt gets planned work.

Technical Leader Dashboard

An executive single-page HTML report combining all metrics:

noupling report . --format dashboard
  • Score badge with project-level health
  • Metric cards: Health Score, Total XS, Lowest Independence, Highest Blast Radius
  • Sortable scorecard table: per-module score, files, violations, circular, XS, independence, instability
  • Risk matrix: Instability vs Blast Radius scatter plot, color-coded
  • Architecture map: zoomable sunburst with dependency edges (gray) and violations (red)
  • Violation charts: by age, by type, plus quick-win refactoring targets
  • Dependency depth with critical path

Built for presenting to CTOs and tech leads. Self-contained HTML, dark or light theme, print-friendly.

Coupling Violations

A coupling violation occurs when sibling directories depend on each other. Each violation is scored using the RRI (Relationship Risk Index), which replaces the earlier depth-based severity model:

RRI = direction_weight × density

The direction_weight reflects the dependency direction (see Risk Weights) and density counts the import statements between the pair. Multiple imports between the same pair increase the RRI proportionally.

Pro-Tip: Not all coupling is bad. Use Layers to declare intended dependency directions so legitimate downward dependencies aren't flagged.

Circular Dependencies

A cycle exists when imports form a loop: A → B → C → A. Cycles are detected using Tarjan's SCC (Strongly Connected Components) algorithm to find all components, followed by mutual pair enumeration to surface the individual circular relationships within each SCC.

Each circular dependency receives the highest risk weight (default: 10) and its RRI scales with the density of imports in the cycle.

Cycles are grouped by order: 2 (mutual), 3 (triangular), N. Each includes the weakest link and break cost via the XS metric.

Hotspots & Cohesion

Hotspots are modules with high fan-in (many dependents). Changes to hotspots ripple widely. Default threshold: 10 incoming imports.

Cohesion measures how much files within a directory depend on each other:

cohesion = internal_deps / (file_count × (file_count - 1))

Low cohesion (< 0.1) suggests a directory groups unrelated code that might belong in separate packages.

Agentic Developer Experience

When using noupling with AI coding assistants, describe features in terms of intent rather than API:

  • "Check if my project has circular dependencies" → noupling scan . && noupling audit .
  • "Only fail the PR if I introduced new coupling" → noupling scan . --diff-base main && noupling audit . --fail-below 80
  • "Show me the easiest cycle to break" → look for the lowest break_cost in noupling audit output
  • "Suppress this known violation" → add // noupling:ignore on the import line
  • "This dependency is architecturally correct" → define it in layers or depends_on
Pro-Tip: Feed the JSON report to your AI assistant for codebase-aware architectural advice: noupling report . --format json, then share .noupling/report.json as context.