Quick start

Install, scan, audit. Everything noupling knows about a project lives in .noupling/ next to the code; commit settings.json and baseline.json, ignore history.db and the generated reports.

brew install pererikbergman/noupling/noupling   # or: cargo install --path crates/noupling-cli

cd /path/to/project
noupling scan .          # parse imports, store a snapshot in .noupling/history.db
noupling audit .         # health score + every Issue as an Issue card

The first run creates .noupling/settings.json with defaults. If the project has no layers configured, noupling infers a set from path names (ui, domain, data, …) and tells you so on a Layers: inferred… line.

# .gitignore
.noupling/history.db
.noupling/report*
.noupling/*.html
.noupling/*.md
.noupling/*.mermaid
.noupling/*.dot

Try it on an example

The repository ships three tiny Kotlin projects under examples/, each built to trigger one outcome: kotlin-clean (100.0, nothing to report), kotlin-coupled (a one-way sibling Coupling Violation), and kotlin-circular (a three-package Cycle). Its README lists the expected output for each.

git clone https://github.com/pererikbergman/noupling.git
cd noupling
noupling scan examples/kotlin-circular
noupling audit examples/kotlin-circular     # one Cycle, weakest link named

Read the audit

The text output has three parts. The headline block, the Top Actions, then Issues (N) with one card per Issue in canonical order (critical first), followed by the Metric sections.

Health Score: 79.5/100
Total Modules: 25
Violations: 10
Layers: inferred from path names (ui, domain, infra) — set `layers` in .noupling/settings.json to take over, or `infer_layers: false` to turn inference off

Issues (20): 2 critical, 10 high, 6 medium, 2 low
Points lost: 20.5 (Coupling Violation 16.0, Cycle 4.5)

  [CRITICAL] Cycle: src/ring/alpha -> src/ring/beta -> src/ring/alpha
      Weakest link: src/ring/alpha -> src/ring/beta (1 import)
      Reason: … 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

Every card says why (reason, with this instance's numbers) and what to do (recommendation). Score impact is the points the Issue costs; only Coupling Violations and Cycles score, and their impacts sum to the points lost. The nine kinds are defined on the Findings page.

First clean-up

Start with the Points lost line: it tells you which kind is costing the score. Then work the cards top to bottom — they are already ordered by severity band. The briefing report turns the same list into a sprint plan ranked by score impact with an effort estimate per item:

noupling report . --format briefing
open .noupling/briefing.md

CI: fail when the score drops

The simplest gate. Scan, audit, and exit non-zero below a threshold.

# .github/workflows/noupling.yml
name: Architecture
on: [push, pull_request]
jobs:
  audit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - 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/
      - run: noupling scan .
      - run: noupling audit . --fail-below 80
Pick the threshold from your current score. Run noupling audit . locally, subtract a couple of points of headroom, and raise the bar as you clean up. A threshold above the current score fails every build on day one.

CI: fail only on Issues not in the baseline

Two options, and they compose. Diff mode narrows the audit to files changed against a base branch; baseline fails only on Issues the team has not accepted (see below). Diff mode needs full git history.

      - uses: actions/checkout@v4
        with:
          fetch-depth: 0                        # diff-base needs the base branch
      - run: noupling scan . --diff-base origin/${{ github.base_ref }}
      - run: noupling audit .                   # only Issues touching changed files
      - run: noupling scan .
      - run: noupling audit . --baseline        # exit 1 only on Issues not in .noupling/baseline.json

With --baseline the accepted Issues stay in the output marked (baselined), and the summary reads Not in baseline: 0 / Baselined: N, so the report is still the whole picture.

CI: comment on the pull request

The pr format is a short Markdown summary built for a comment: score with delta, per-kind counts, and the top five Issues with their recommendations. The repository ships a complete workflow you can copy: .github/workflows/noupling-pr.yml. The core of it:

      - run: noupling scan . --diff-base origin/${{ github.base_ref }}
      - run: noupling report . --format pr
      - uses: marocchino/sticky-pull-request-comment@v2
        with:
          path: .noupling/pr.md

SonarQube / SonarCloud

Export every Issue as a Sonar generic issue (one rule per kind, noupling:cycle, noupling:layer_violation, …) and point Sonar at the file.

noupling scan . && noupling report . --format sonar
# sonar-project.properties
sonar.externalIssuesReportPaths=.noupling/noupling-sonar.json

Pre-commit hook

Block commits that introduce Issues, locally, before CI sees them.

noupling hook install .      # writes .git/hooks/pre-commit
git commit --no-verify       # bypass once when you must
noupling hook uninstall .

Baseline: accept what's there today

Adopting noupling on an existing codebase usually starts with hundreds of Issues nobody will fix this quarter. Record them as accepted so the gate only fires on what changes from here on.

noupling scan .
noupling baseline save .            # writes .noupling/baseline.json: every current Issue, all nine kinds
git add .noupling/baseline.json
git commit -m "chore: accept current architecture Issues as the baseline"
noupling audit . --baseline          # exit 1 only on Issues not in the baseline
noupling report . --format html --baseline   # any report can mark accepted Issues

Baselined Issues are identified by kind and identity (the directory pair for Coupling Violations and Red Flags, the ring for Cycles, the subject otherwise), so adding another import between two directories that are already coupled does not count against the gate. When the team fixes an accepted Issue it simply disappears; re-run baseline save whenever you want the accepted set to shrink.

Upgrading from 0.8.x? Older baseline files covered only coupling violations and load as “nothing baselined” with a one-line warning. Run noupling baseline save . once after upgrading.

Review what the baseline holds

The file is plain JSON: one fingerprint per accepted Issue. Diff it in code review like any other config.

jq '.fingerprints[]' .noupling/baseline.json | sort
jq '.fingerprints | length' .noupling/baseline.json
jq -r '.fingerprints[] | select(startswith("cycle:"))' .noupling/baseline.json   # just the accepted Cycles

Keep history across runs

Every scan adds a snapshot to .noupling/history.db and records the score and per-kind Issue counts, so trends need nothing but repeated scans. In CI the database does not survive between jobs unless you keep it; cache it or commit it to a branch.

      - name: Restore noupling history
        uses: actions/cache@v4
        with:
          path: .noupling/history.db
          key: noupling-history-${{ github.ref_name }}-${{ github.run_id }}
          restore-keys: noupling-history-${{ github.ref_name }}-
      - run: noupling scan .
      - run: noupling audit . --baseline

Scans with --diff-base still record the whole project's trend point (the diff filter only narrows what audit prints), so a PR-only pipeline keeps a usable history too.

Trend over time

Two views of the same history: a table in the terminal, or the strategy report with the score line and one line per Issue kind.

noupling trend . --last 20            # score, modules, violations per snapshot with deltas
noupling trend . --by-module          # per top-level directory
noupling report . --format strategy --last 12
open .noupling/strategy.html

Snapshots taken before 0.9.0 have no per-kind counts and show as gaps, not zeros.

Declare your layers

Layers turn “sibling coupling” into “allowed downward” and “forbidden upward”. Order is top to bottom; a lower layer importing a higher one is a Layer Violation. Once you declare layers, inference stops.

{
  "layers": [
    { "name": "presentation", "pattern": "**/ui/**" },
    { "name": "domain",       "pattern": "**/domain/**", "allow_sibling": true },
    { "name": "data",         "pattern": "**/data/**" },
    { "name": "infra",        "pattern": "**/{infra,platform}/**" }
  ]
}

The Explorer's auto-layers banner offers a ready-made snippet from what it inferred — paste it and adjust. allow_sibling reduces the weight of coupling inside a layer where lateral dependencies are expected.

Turn layer inference off

For a flat codebase, or one whose directory names happen to match the keywords, audit as-is in strict mode:

{ "infer_layers": false }

Forbid a specific import

Dependency rules are glob-to-glob, with a message that becomes the Issue's reason.

{
  "dependency_rules": [
    {
      "from": "**/plugins/**",
      "to": "**/legacy/**",
      "allow": false,
      "message": "plugins must not reach into legacy; go through domain."
    }
  ]
}

Suppress one import

A suppression hides an edge at scan time (it is not a baseline). Put the comment on the import line:

use crate::legacy::compat; // noupling:ignore

The audit prints Suppressed: N imports via noupling:ignore so they stay visible. Set "allow_inline_suppression": false to disable the mechanism in CI.

Monorepo: audit each module on its own

Declare modules and, optionally, which ones may depend on which. Each gets its own score; cross-module imports outside depends_on are reported.

{
  "modules": [
    { "name": "app",     "path": "apps/app",       "depends_on": ["shared"] },
    { "name": "billing", "path": "services/billing", "depends_on": ["shared"] },
    { "name": "shared",  "path": "libs/shared" }
  ]
}
noupling audit .                       # per-module table + cross-module violations
noupling audit . --module billing      # one module's full report
noupling report . --format json --module billing

Explore the architecture

The Explorer is a single self-contained HTML file: a layered structure map, an Issues tab with every card, focus mode, and click-to-source links for your editor.

noupling report . --format explorer --editor vscode
open .noupling/explorer.html

Add --baseline to dim accepted Issues, --no-history to shrink the file, --title to name it. It works from file://, so it can be attached to a ticket or hosted as a static page.

Script against the JSON report

One issues array carries every Issue as an Issue card; filter by kind. The full shape is on the Report Formats page.

noupling report . --format json

jq '.issues | group_by(.kind) | map({kind: .[0].kind, n: length})' .noupling/report.json
jq -r '.issues[] | select(.kind == "cycle") | .subject.members | join(" -> ")' .noupling/report.json
jq -r '.issues[] | select(.severity == "critical" and .baselined == false) | "\(.kind_name): \(.recommendation)"' .noupling/report.json
jq '[.issues[].score_impact] | add' .noupling/report.json        # equals 100 - .score

Plan a sprint

briefing ranks the top ten Issues by score impact with an effort estimate and the core recommendation; dashboard is the single-page overview for a leadership review.

noupling report . --format briefing && open .noupling/briefing.md
noupling report . --format dashboard && open .noupling/dashboard.html

Draw the dependency graph

Graph formats accent every edge-shaped Issue — Coupling, Rule, Layer and Stability Violations and each hop of a Cycle — with one style per kind and a legend.

noupling report . --format mermaid    # paste .noupling/report.mermaid into a Markdown file
noupling report . --format dot && dot -Tsvg .noupling/report.dot -o architecture.svg
noupling report . --format bundle && open .noupling/bundle.html   # zoomable sunburst
Everything at once: noupling report . --format all writes every format into .noupling/ in one command.