{"slug": "show-hn-codeint-measure-duplication-and-complexity-drift-in-ai-written-code", "title": "Show HN: Codeint – Measure duplication and complexity drift in AI-written code", "summary": "A developer released codeint, an open-source Rust tool that measures \"software entropy\" in AI-written code by reporting four separate metrics — Erosion, Duplication, Verbosity and Import cycles — rather than a single combined score. codeint ships built-in language plugins for TypeScript/JavaScript, Rust, PHP, Dart and Python plus sandboxed WebAssembly plugins, and scans laravel/framework (132k production lines) in 0.47s and flutter/packages (434k production lines) in 3.68s on Apple Silicon. Each built-in language is calibrated against 20 public repositories pinned before 2023-01-01, and the tool offers `codeint check` budgets and `codeint diff <base>` ratcheting against a pull request's Git merge-base.", "body_md": "[Why codeint](#why-codeint) ·\n  [How it works](#how-it-works) ·\n  [Quick start](#quick-start) ·\n  [Guide](https://github.com/avidianity/codeint/blob/main/docs/guide/README.md) ·\n  [Reference](https://github.com/avidianity/codeint/blob/main/docs/reference.md) ·\n  [Programmatic API](https://github.com/avidianity/codeint/blob/main/docs/programmatic.md) ·\n  [Plugins](https://github.com/avidianity/codeint/blob/main/docs/plugins.md) ·\n  [llms.txt](https://github.com/avidianity/codeint/blob/main/llms.txt)\n\nCoding 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.\n\ncodeint measures **Software entropy** directly from the shape of source code so you see it grow before it compounds.\nIt ships with built-in Language plugins for TypeScript/JavaScript, Rust, PHP, Dart, and Python, plus sandboxed WebAssembly Plugins for other languages and custom Metrics.\n\ncodeint 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)).\nA single score hides regressions when one Metric improves while another worsens.\n\n- **Erosion** : share of Function mass (`cyclomatic_complexity * sqrt(source_lines)` ) in functions with cyclomatic complexity over 10.\n- **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).\n- **Verbosity** : share of source lines in zero-false-positive Flagged lines or Clone groups.\n- **Import cycles** : share of modules in at least one runtime Import cycle.\n\n- **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.\n- **Strict Source-set separation** : every file belongs to`production` ,`test` ,`generated` , or`vendored` , so fixtures and generated code never distort Production ratios.\n- **Budgets and Regressions** : Budgets cap absolute entropy in`codeint check` , while`codeint diff <base>` ratchets every pull request against its Git merge-base.\n- **Version-free parsing** : built-in Language plugins parse the modern superset of each language family, with no language-version pins needed in`codeint.json` .\n\ncodeint 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.\nIt 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.\nThird-party WebAssembly Plugins run with mandatory SHA-256 verification, zero host capabilities, and configurable memory and time caps.\n\nRead [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.\n\n10th 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)):\n\n| Language | Erosion | Duplication | Verbosity | Import cycles | \n|---|---|---|---|---|\n| TypeScript / JavaScript | 35.2% to 60.0% | 1.7% to 34.6% | 1.8% to 34.7% | 0.0% to 30.8% | \n| Rust | 38.0% to 64.2% | 5.0% to 32.5% | 6.0% to 32.9% | 2.1% to 50.6% | \n| PHP | 5.5% to 67.7% | 4.1% to 29.0% | 4.2% to 29.2% | 0.0% to 10.7% | \n| Dart | 4.7% to 41.9% | 7.3% to 25.6% | 8.0% to 25.9% | 7.3% to 52.4% | \n| Python | 14.4% to 62.4% | 1.2% to 20.1% | 1.4% to 20.4% | 0.0% to 32.1% | \n\nSee [docs/guide/languages.md](https://github.com/avidianity/codeint/blob/main/docs/guide/languages.md) for per-language rules and sample repository timings.\n\nInstall the standalone binary on macOS or Linux, on Windows, or run directly with `npx`:\n\n```\ncurl -fsSL https://github.com/avidianity/codeint/releases/latest/download/install.sh | bash\nirm https://github.com/avidianity/codeint/releases/latest/download/install.ps1 | iex\nnpx codeint check\n```\n\nRun codeint inside any Git repository:\n\n```\ncodeint init\ncodeint check\ncodeint diff main\ncodeint trend\n```\n\n- `codeint init` writes a starter`codeint.json` with a versioned`$schema` .\n- `codeint check` measures the working tree and prints each Metric with its Findings.\n- `codeint diff main` compares the working tree against the merge-base of`main` and fails on a Regression.\n- `codeint trend` prints each Metric across the latest main-line commits.\n\nOr call codeint programmatically from JavaScript/TypeScript (`npm install codeint`) or Rust (` codeint-cli`):\n\n``` js\nimport { check, diff } from \"codeint\";\n\nconst report = await check();\nconst prDiff = await diff({ base: \"main\" });\n```\n\n- [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) .\n- [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.\n- [Programmatic API](https://github.com/avidianity/codeint/blob/main/docs/programmatic.md) : JavaScript/TypeScript SDK and Rust library API.\n- [Plugins](https://github.com/avidianity/codeint/blob/main/docs/plugins.md) : build, hash, declare, and test external WebAssembly Language and Metric plugins.\n- [Glossary](https://github.com/avidianity/codeint/blob/main/GLOSSARY.md) : canonical definitions of every domain term on this page.\n- [llms.txt](https://github.com/avidianity/codeint/blob/main/llms.txt) : compact documentation index for coding agents and LLM tools.\n\nYou 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`.\n\n```\nnpm ci\nnpx lefthook install\ncargo test --workspace --locked\n```\n\nAgents and people follow the same rules: start with [.rules](https://github.com/avidianity/codeint/blob/main/.rules).\nThe repository checks are listed in [docs/checks/README.md](https://github.com/avidianity/codeint/blob/main/docs/checks/README.md).", "url": "https://wpnews.pro/news/show-hn-codeint-measure-duplication-and-complexity-drift-in-ai-written-code", "canonical_source": "https://github.com/avidianity/codeint", "published_at": "2026-11-22 11:58:04+00:00", "updated_at": "2026-11-22 12:42:27.112902+00:00", "lang": "en", "topics": ["ai-tools", "developer-tools", "ai-agents", "ai-research"], "entities": ["codeint", "Rust", "TypeScript", "JavaScript", "PHP", "Dart", "Python", "laravel/framework"], "also_reported_by": [], "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.", "recommendation": null, "alternates": {"html": "https://wpnews.pro/news/show-hn-codeint-measure-duplication-and-complexity-drift-in-ai-written-code", "markdown": "https://wpnews.pro/news/show-hn-codeint-measure-duplication-and-complexity-drift-in-ai-written-code.md", "text": "https://wpnews.pro/news/show-hn-codeint-measure-duplication-and-complexity-drift-in-ai-written-code.txt", "jsonld": "https://wpnews.pro/news/show-hn-codeint-measure-duplication-and-complexity-drift-in-ai-written-code.jsonld"}}