# Show HN: Codeint – Measure duplication and complexity drift in AI-written code

> Source: <https://github.com/avidianity/codeint>
> Published: 2026-11-22 11:58:04+00:00

**Key takeaway:** codeint reports Erosion, Duplication, Verbosity and Import cycles as four separate metrics instead of one score, so a regression in one is not masked by improvement in another, and `codeint diff <base>` ratchets each pull request against its Git merge-base.

[Why codeint](#why-codeint) ·
  [How it works](#how-it-works) ·
  [Quick start](#quick-start) ·
  [Guide](https://github.com/avidianity/codeint/blob/main/docs/guide/README.md) ·
  [Reference](https://github.com/avidianity/codeint/blob/main/docs/reference.md) ·
  [Programmatic API](https://github.com/avidianity/codeint/blob/main/docs/programmatic.md) ·
  [Plugins](https://github.com/avidianity/codeint/blob/main/docs/plugins.md) ·
  [llms.txt](https://github.com/avidianity/codeint/blob/main/llms.txt)

Coding agents write locally valid code very quickly. Each pull request can pass tests and linters while quietly adding copied blocks, redundant branches, deeper functions, and tangled imports. Over dozens of changes, that structural drag compounds until both humans and agents slow down.

codeint measures **Software entropy** directly from the shape of source code so you see it grow before it compounds.
It ships with built-in Language plugins for TypeScript/JavaScript, Rust, PHP, Dart, and Python, plus sandboxed WebAssembly Plugins for other languages and custom Metrics.

codeint reports four Metrics side by side and never collapses them into one grade or index ([ADR 0003](https://github.com/avidianity/codeint/blob/main/docs/adr/0003-no-combined-score.md)).
A single score hides regressions when one Metric improves while another worsens.

- **Erosion** : share of Function mass (`cyclomatic_complexity * sqrt(source_lines)` ) in functions with cyclomatic complexity over 10.
- **Duplication** : share of source lines in Clone groups (at least 75 normalized tokens and 14 distinct normalized tokens, catching renamed copy-paste while ignoring import lists and data tables).
- **Verbosity** : share of source lines in zero-false-positive Flagged lines or Clone groups.
- **Import cycles** : share of modules in at least one runtime Import cycle.

- **Pre-2023 Reference ranges** : every built-in language is calibrated against 20 public repositories pinned before`2023-01-01` (10th to 90th percentile), so raw numbers have grounded context.
- **Strict Source-set separation** : every file belongs to`production` ,`test` ,`generated` , or`vendored` , so fixtures and generated code never distort Production ratios.
- **Budgets and Regressions** : Budgets cap absolute entropy in`codeint check` , while`codeint diff <base>` ratchets every pull request against its Git merge-base.
- **Version-free parsing** : built-in Language plugins parse the modern superset of each language family, with no language-version pins needed in`codeint.json` .

codeint is written in safe Rust (`#![forbid(unsafe_code)]`, [ADR 0004](https://github.com/avidianity/codeint/blob/main/docs/adr/0004-forbid-unsafe-code.md)) around two clean seams: Language plugins lower source files into a language-neutral Code model, and Metric plugins compute Metrics and Findings over that model.
It reads tracked files and commit history directly from Git objects without modifying your working tree, scanning `laravel/framework` (132k Production lines) in `0.47s` and `flutter/packages` (434k Production lines) in `3.68s` on Apple Silicon.
Third-party WebAssembly Plugins run with mandatory SHA-256 verification, zero host capabilities, and configurable memory and time caps.

Read [docs/guide/philosophy-and-architecture.md](https://github.com/avidianity/codeint/blob/main/docs/guide/philosophy-and-architecture.md) for the full architecture diagram and design rationale.

10th to 90th percentile across 20 pre-2023 open-source repositories per language ([ADR 0008](https://github.com/avidianity/codeint/blob/main/docs/adr/0008-typescript-reference-ranges.md), [ADR 0010](https://github.com/avidianity/codeint/blob/main/docs/adr/0010-rust-reference-ranges.md), [ADR 0011](https://github.com/avidianity/codeint/blob/main/docs/adr/0011-php-reference-ranges.md), [ADR 0012](https://github.com/avidianity/codeint/blob/main/docs/adr/0012-dart-reference-ranges.md), [ADR 0013](https://github.com/avidianity/codeint/blob/main/docs/adr/0013-python-reference-ranges.md)):

| Language | Erosion | Duplication | Verbosity | Import cycles | 
|---|---|---|---|---|
| TypeScript / JavaScript | 35.2% to 60.0% | 1.7% to 34.6% | 1.8% to 34.7% | 0.0% to 30.8% | 
| Rust | 38.0% to 64.2% | 5.0% to 32.5% | 6.0% to 32.9% | 2.1% to 50.6% | 
| PHP | 5.5% to 67.7% | 4.1% to 29.0% | 4.2% to 29.2% | 0.0% to 10.7% | 
| Dart | 4.7% to 41.9% | 7.3% to 25.6% | 8.0% to 25.9% | 7.3% to 52.4% | 
| Python | 14.4% to 62.4% | 1.2% to 20.1% | 1.4% to 20.4% | 0.0% to 32.1% | 

See [docs/guide/languages.md](https://github.com/avidianity/codeint/blob/main/docs/guide/languages.md) for per-language rules and sample repository timings.

Install the standalone binary on macOS or Linux, on Windows, or run directly with `npx`:

```
curl -fsSL https://github.com/avidianity/codeint/releases/latest/download/install.sh | bash
irm https://github.com/avidianity/codeint/releases/latest/download/install.ps1 | iex
npx codeint check
```

Run codeint inside any Git repository:

```
codeint init
codeint check
codeint diff main
codeint trend
```

- `codeint init` writes a starter`codeint.json` with a versioned`$schema` .
- `codeint check` measures the working tree and prints each Metric with its Findings.
- `codeint diff main` compares the working tree against the merge-base of`main` and fails on a Regression.
- `codeint trend` prints each Metric across the latest main-line commits.

Or call codeint programmatically from JavaScript/TypeScript (`npm install codeint`) or Rust (` codeint-cli`):

``` js
import { check, diff } from "codeint";

const report = await check();
const prDiff = await diff({ base: "main" });
```

- [Guide](https://github.com/avidianity/codeint/blob/main/docs/guide/README.md) : modular walkthroughs for[Philosophy and Architecture](https://github.com/avidianity/codeint/blob/main/docs/guide/philosophy-and-architecture.md) ,[Getting Started](https://github.com/avidianity/codeint/blob/main/docs/guide/getting-started.md) ,[Configuration (`codeint.json`)](https://github.com/avidianity/codeint/blob/main/docs/guide/configuration.md) ,[Built-in Languages](https://github.com/avidianity/codeint/blob/main/docs/guide/languages.md) , and[CI and GitHub Actions](https://github.com/avidianity/codeint/blob/main/docs/guide/ci-and-github-actions.md) .
- [Reference](https://github.com/avidianity/codeint/blob/main/docs/reference.md) : tested reference for every command, flag, exit code, report format (`toon` ,`json` ,`sarif` ,`markdown` ), and`codeint.json` key.
- [Programmatic API](https://github.com/avidianity/codeint/blob/main/docs/programmatic.md) : JavaScript/TypeScript SDK and Rust library API.
- [Plugins](https://github.com/avidianity/codeint/blob/main/docs/plugins.md) : build, hash, declare, and test external WebAssembly Language and Metric plugins.
- [Glossary](https://github.com/avidianity/codeint/blob/main/GLOSSARY.md) : canonical definitions of every domain term on this page.
- [llms.txt](https://github.com/avidianity/codeint/blob/main/llms.txt) : compact documentation index for coding agents and LLM tools.

You need Rust through rustup ([rust-toolchain.toml](https://github.com/avidianity/codeint/blob/main/rust-toolchain.toml)), Node.js 24 and npm ([package.json](https://github.com/avidianity/codeint/blob/main/package.json)), and `gitleaks` plus `lychee` on your `PATH`.

```
npm ci
npx lefthook install
cargo test --workspace --locked
```

Agents and people follow the same rules: start with [.rules](https://github.com/avidianity/codeint/blob/main/.rules).
The repository checks are listed in [docs/checks/README.md](https://github.com/avidianity/codeint/blob/main/docs/checks/README.md).
