Skip to content
avidianityPublic

About

See Software entropy grow before it compounds. Measures duplication, verbosity, erosion, and import cycles as separate Metrics, and gates CI on them.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

17 stars

Watchers

1 watching

Forks

Latest commit

 

History

240 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

codeint: see Software entropy grow before it compounds

CI status GitHub Release npm version pub.dev version crates.io version License: MIT

Why codeint · How it works · Quick start · Guide · Reference · Programmatic API · Plugins · llms.txt

Note

Early development: codeint is still pre-1.0 and evolving quickly. CLI flags, configuration keys, report shapes, and the WebAssembly Plugin contract may change rapidly before 1.0.

Why codeint

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, unused dependencies, 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 your source code so you see it grow before it compounds, and reports Hazards next to Software entropy (ADR 0016). It ships with eight built-in Language plugins covering TypeScript/JavaScript (with built-in react, vue2, vue3, svelte, nextjs, nuxt, sveltekit, angular, and nestjs Framework profiles plus framework-blind .vue and .svelte <script> lowering), Rust, PHP, Dart, Python, Go, SQL, and Shell (.sh, .bash, .zsh), plus sandboxed WebAssembly Plugins for other languages and custom Metrics.

How it works

Independent Metrics, never one blended score

codeint reports every Metric side by side and never collapses them into one grade or index (ADR 0003). A single score hides regressions when one Metric improves while another worsens.

Five core Metrics are calibrated against stratified panels of current public repositories (ADR 0035):

  • Erosion: share of Function mass (cyclomatic_complexity * sqrt(source_lines)) in functions with cyclomatic complexity over 10, reported with function names.
  • Cognitive complexity: share of total nesting-weighted cognitive complexity held by functions scoring over 15.
  • Duplication: share of source lines in per-language exact Clone groups (at least 75 normalized tokens and 14 distinct normalized tokens, catching renamed copy-paste while ignoring import lists and data tables), grouped into Clone families across three or more locations, with opt-in anchor-checked near-clone detection (ADR 0037).
  • Verbosity: share of source lines in Flagged lines matching narrow redundant-construct rules (independent of Duplication, ADR 0024). The 2026-12-02 agent-reviewed audit (commit 9e3f53053618) recorded 10 false positives in 88 reviewed Flagged lines (of 100 sampled).
  • Import cycles: share of modules in at least one runtime Import cycle.

Additional independent Metrics and structural checks run in the same pass:

  • Test gap: share of total Production Function mass not executed by tests, read from user-named LCOV or Cobertura XML Coverage reports without running your test suite, listing the heaviest untested functions first (Test gap guide, ADR 0017). Set new_file_budgets.production.test_gap to enforce the ratio on newly added Production files in codeint diff.
  • Orphan files: Production files unreachable from manifest-declared, program-start, and configured entry_points, classified as unreferenced or test-only.
  • File size (opt-in): the share of Production source lines beyond the File size limit set in file_size.max_source_lines, with one Oversized file Finding per file over the limit.
  • Dependency hygiene: three independent Metrics (unused_dependencies, unlisted_dependencies, and dev_in_production_dependencies) comparing package.json, Cargo.toml, pyproject.toml, composer.json, pubspec.yaml, and go.mod against imported external packages while excluding standard-library built-ins.
  • Architectural import boundaries: named zones, built-in layered and hexagonal presets, public_files encapsulation, directional internal allow/deny rules, external-package allow_external/deny_external glob rules, and pre-edit codeint guard <path> checks before a file even exists on disk (Import boundaries guide).
  • Hazards: share of source lines matching AST-only Hazard line rules for patterns likely to cause wrong results, slow execution, or a security exposure, reported next to Software entropy with strict non-leakage (path, line, and rule name only, never source text), 32 built-in SQL rules including 5 schema-backed rules, and 10 built-in Shell rules (Hazards guide, SQL guide, Shell guide, ADR 0016).

Every file belongs to one Source set (production, test, generated, or vendored), so fixtures and generated code never distort Production ratios. Budgets cap absolute ratios, .codeint/ratchet.json (Ratchet, managed with codeint ratchet update) locks in whole-repository ceilings with Metric version tracking, and codeint diff <base> checks every pull request against its Git merge-base (ADR 0026). .codeint/baseline.json (Baseline, managed with codeint baseline update) freezes existing Findings with hashed surrounding-line context anchors, so codeint check hides them, holds new Findings to every Budget, and shrinks the Baseline as legacy Findings are fixed (ADR 0030, ADR 0032).

Codebase navigation, Git history, and ownership

Beyond static snapshots, codeint helps humans and coding agents understand how files connect and evolve:

  • codeint trace <from> <to>: find the shortest runtime import paths between two modules.
  • codeint impact <paths...> / --changed <base-ref>: compute the transitive reverse-dependency blast radius, separating Production and Test dependents and listing affected Workspace packages.
  • --package <path>: scope check, diff, impact, and trace to one Workspace package in a monorepo.
  • codeint churn: rank eroded and duplicated files alongside their Git commit churn independently per Metric.
  • codeint coupling: detect pairs of files that repeatedly change together in the same commits and flag whether they share a direct runtime import.
  • CODEOWNERS filtering (--owner <pattern>): filter check and diff Findings to a specific team or owner.

Built for CI and coding agents

  • JSON, JSONC, TOML, and YAML configuration with .codeint/ state: configure codeint in codeint.{json,jsonc,toml,yaml,yml} or .codeint/config.{json,jsonc,toml,yaml,yml} (codeint init writes codeint.jsonc by default, or pass --format json|toml|yaml), set an optional default output format (toon, text, json, sarif, or markdown) for analysis and report commands, lock in monotonic whole-repository ceilings in .codeint/ratchet.json via codeint ratchet update, and freeze existing Findings in .codeint/baseline.json via codeint baseline update.
  • Single-scan multi-format reporting and Checks API annotations: save codeint check --format json or codeint diff --format json once, then re-render losslessly into concise monochrome text, toon, json, sarif, or markdown or publish inline pull-request line annotations via the GitHub Checks API with codeint report (or check-run: true in the GitHub Action, with no code scanning required).
  • Introspection and diagnostics: inspect machine-readable CLI/MCP capabilities with codeint schema, see effective settings with default/file/cli provenance via codeint config --resolved, verify repository health offline with codeint doctor, and check an external Wasm Plugin against the Plugin contract with codeint plugin test.
  • First-class MCP integration: run codeint agent status and codeint agent install to register the local stdio MCP server (codeint mcp) for Claude Code, Cursor, and Codex, exposing check, diff, trend, guard, impact, trace, churn, and coupling with compact TOON output by default and optional format: "json".

Built for speed and safety

codeint is written in safe Rust (#![forbid(unsafe_code)] on every host, core, CLI, and built-in Plugin crate, ADR 0004) 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. External WebAssembly Plugins implement the versioned codeint:plugin@0.6.0 WIT contract with mandatory SHA-256 verification, zero host capabilities, and configurable memory and time caps, using codeint-plugin-sdk for safe Rust builds on wasm32-wasip2 (no_std, zero extra tools) or wasm32-unknown-unknown (std plus wasm-tools component new) with zero WASI imports (ADR 0027).

Read docs/guide/philosophy-and-architecture.md for the full architecture diagram and design rationale.

Calibrated Reference ranges

10th to 90th percentile across stratified panels of up to 100 current public repositories per built-in language (77 for SQL under the 200+-star floor) and 50 current public repositories per calibrated Framework profile, sampled round-robin across three star bands (ADR 0035):

Language Erosion Cognitive complexity Duplication Verbosity Import cycles Docs
TypeScript / JavaScript 18.7% to 67.1% 12.1% to 53.2% 1.8% to 25.2% 0.0% to 0.2% 0.0% to 18.2% ADR 0035
React (.jsx / .tsx) 5.4% to 56.6% 3.8% to 39.9% 2.6% to 31.5% 0.0% to 0.1% 0.0% to 20.2% ADR 0035
Vue 2 (.vue) 2.5% to 47.9% 3.3% to 40.6% 2.3% to 26.7% 0.0% to 0.3% 0.0% to 12.8% ADR 0035
Vue 3 (.vue) 4.2% to 43.8% 2.2% to 29.7% 2.1% to 29.7% 0.0% to 0.2% 0.0% to 32.5% ADR 0035
Rust 24.5% to 70.4% 17.6% to 58.5% 4.7% to 37.7% 0.0% to 0.5% 0.0% to 61.1% ADR 0035
PHP 6.4% to 59.1% 4.4% to 54.2% 2.5% to 20.9% 0.0% to 0.4% 0.0% to 13.3% ADR 0035
Dart 3.9% to 49.5% 0.0% to 37.8% 2.7% to 25.7% 0.0% to 1.1% 6.1% to 60.0% ADR 0035
Python 23.9% to 71.7% 24.9% to 63.7% 1.1% to 22.0% 0.0% to 1.1% 0.0% to 49.2% ADR 0035
Go 30.4% to 74.6% 30.6% to 67.1% 3.4% to 24.3% 0.0% to 0.4% 0.0% to 0.0% ADR 0035
SQL 0.0% to 91.8% 0.0% to 90.2% 0.0% to 90.9% 0.0% to 0.0% N/A ADR 0035
Shell 36.4% to 93.0% 21.8% to 82.8% 0.3% to 71.3% 0.0% to 3.1% N/A ADR 0035

See the calibration provenance for the dataset and measured binary for each Metric.

See docs/guide/languages.md for per-language rules and sample repository timings. See docs/evaluation.md for the published calibration report (eval/panels.json: 927 panel entries across 918 unique repositories), native-parser recall, and agent-reviewed audit; corpus-eval CI validates the separate 40-repository eval/corpus.json manifest.

Quick start

Install the standalone binary on macOS or Linux, on Windows, via Cargo, or run directly with npx or dart run:

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
cargo install codeint
npx codeint check
dart pub add --dev codeint
dart run codeint check

Run codeint inside any Git repository:

codeint init
codeint init --adopt
codeint check
codeint diff main
codeint ratchet update
codeint baseline update
codeint guard src/domain/order.ts
codeint doctor
codeint plugin test plugins/my-plugin.wasm
codeint agent install
  • codeint init writes a starter codeint.jsonc with a versioned $schema (pass --format json, --format toml, or --format yaml for codeint.json, codeint.toml, or codeint.yaml).
  • codeint init --adopt onboards an existing codebase in one step: it writes the starter codeint.jsonc with per_file: true, zero Budgets for each recorded Metric, and commented new_file_budgets, writes .codeint/ratchet.json and .codeint/baseline.json from the current state, and prints a pull-request workflow, without replacing any existing file (adoption guide).
  • 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 any Budget, Ratchet, or Regression failure.
  • codeint ratchet update creates or monotonically tightens .codeint/ratchet.json ceilings for whole-repository runs.
  • codeint baseline update creates .codeint/baseline.json, or removes fixed Findings from it, so codeint check hides existing Findings and reports only new ones.
  • codeint guard src/domain/order.ts checks architectural boundary rules for an existing or planned file path.
  • codeint doctor runs offline diagnostics on Git status, config validity, detected languages, workspaces, and Plugins.
  • codeint plugin test plugins/my-plugin.wasm runs the Conformance runner against an external Wasm Plugin and prints each violated rule with a fix hint.
  • codeint agent install registers codeint mcp in detected local coding agents.

Or call codeint programmatically from JavaScript/TypeScript (npm install codeint), Rust (cargo add codeint), or Dart (codeint on pub.dev):

import { check, diff } from "codeint";

const checked = await check();
const prDiff = await diff("main");
use std::path::Path;
use codeint::{CheckOptions, DiffOptions, check, diff};

let checked = check(Path::new("."), &CheckOptions::default())?;
let pr_diff = diff(Path::new("."), "main", &DiffOptions::default())?;
import 'package:codeint/codeint.dart';

const client = CodeintClient(cwd: '.');
final checked = await client.check();
final prDiff = await client.diff('main');

Documentation

Development

You need Rust through rustup (rust-toolchain.toml), Node.js 24 and npm (package.json), gitleaks plus lychee on your PATH, and cargo-nextest 0.9.152 for cargo xtask affected-tests.

npm ci
npx lefthook install
cargo xtask affected-tests

Read CONTRIBUTING.md for the contributor workflow and local setup. Agents and people follow the same repository rules: start with .rules and docs/checks/README.md.

License

MIT

About

See Software entropy grow before it compounds. Measures duplication, verbosity, erosion, and import cycles as separate Metrics, and gates CI on them.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

17 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages