Skip to main content

mehen

mehen is a Rust-powered CLI for detecting heuristic source code metrics at scale: complexity, maintainability, lines of code, documentation health, and more.

It is designed for fast, deterministic analysis over large codebases, helping both human and AI engineers track how complexity evolves over time.

📚 Documentation: https://mehen.ophi.dev

What is Mehen?

In Ophidiarium projects, names matter. Mehen is a mythical ancient Egyptian serpent associated with guarding Ra. In the same spirit, mehen helps guard your codebase from slowly collapsing under complexity.

Why teams use mehen

  • Polyglot by design — per-file language detection across eleven source languages plus Markdown and SQL. Useful for monorepos.
  • Real language parsers — Ruff for Python, Oxc for TS/JS/JSX/TSX, Mago for PHP, Prism for Ruby, ra_ap_syntax for Rust, ANTLR (Kotlin spec grammar for Kotlin, grammars-v4 for Java), pulldown-cmark for Markdown, sqruff for SQL, tree-sitter for Go, C, PowerShell.
  • Code, documentation, and SQL in one tool — source-code complexity, Markdown documentation health, and a dedicated relational metric family for .sql files.
  • Deterministic, no network — pure static analysis. Same input → same output. Safe for air-gapped CI.
  • Pull-request native — built-in mehen diff plus a sticky comment GitHub Action.

Install

# npm
npm install -g mehen

# PyPI / uv
uv tool install mehen
# or: pip install mehen

# cargo binstall
cargo binstall --git https://github.com/ophi-dev/mehen mehen

Full installation guide: https://mehen.ophi.dev/installation.

Quick start

# Analyze a single file
mehen metrics src/main.py --pretty

# Rank the worst offenders in a tree
mehen top-offenders src --metric cognitive

# Diff metrics against main
mehen diff --from main --to HEAD --paths src --output-format markdown

Quickstart: https://mehen.ophi.dev/quickstart.

GitHub Action

Drop the action into a workflow to publish per-PR metric trends:

permissions:
  contents: read
  pull-requests: write
  issues: write

steps:
  - uses: actions/checkout@v6
    with:
      fetch-depth: 0
  - uses: ophi-dev/mehen@v1
    with:
      paths: src

Full reference: https://mehen.ophi.dev/guides/github-action.

Documentation

Everything else lives in the docs site:

  • Code metrics — cyclomatic, cognitive, Halstead, MI, ABC, LOC family, NOM, NPA, NPM, WMC.
  • Markdown metrics — DMI, MRPC, MCC, link debt, filler/lazy risk, English/Japanese prose layer.
  • SQL metrics — CTE graphs, join/subquery structure, object-touch risk, SQL Halstead, and composite scores via mehen-sql (sqruff-backed).
  • Commandsmehen metrics, mehen diff, mehen top-offenders.
  • Developers guide — build, test, contribute, add a language.

Contributing

Issues and pull requests welcome at https://github.com/ophi-dev/mehen/issues.

License

mehen is released under the GNU Affero General Public License v3.0.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mehen-1.7.0.tar.gz (1.1 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

mehen-1.7.0-py3-none-win_arm64.whl (9.6 MB view details)

Uploaded Python 3Windows ARM64

mehen-1.7.0-py3-none-win_amd64.whl (10.7 MB view details)

Uploaded Python 3Windows x86-64

mehen-1.7.0-py3-none-manylinux_2_28_x86_64.whl (10.3 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

mehen-1.7.0-py3-none-manylinux_2_28_aarch64.whl (9.6 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

mehen-1.7.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (9.5 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

mehen-1.7.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (10.4 MB view details)

Uploaded Python 3manylinux: glibc 2.5+ x86-64

mehen-1.7.0-py3-none-macosx_11_0_arm64.whl (9.4 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

mehen-1.7.0-py3-none-macosx_10_12_x86_64.whl (10.1 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file mehen-1.7.0.tar.gz.

File metadata

  • Download URL: mehen-1.7.0.tar.gz
  • Upload date:
  • Size: 1.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for mehen-1.7.0.tar.gz
Algorithm Hash digest
SHA256 576ffaa066fd15f559f5cf9fdd4bb12194cce7c3b1dddb4a608081e58a695617
MD5 70f1c641e44cedcd2cdcb6eb47f44da0
BLAKE2b-256 a356f6d89b23cf5aecb49ab6c2fceea0afacf2df88995b7f6c6e1078acd254d0

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-1.7.0.tar.gz:

Publisher: release.yml on ophi-dev/mehen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mehen-1.7.0-py3-none-win_arm64.whl.

File metadata

  • Download URL: mehen-1.7.0-py3-none-win_arm64.whl
  • Upload date:
  • Size: 9.6 MB
  • Tags: Python 3, Windows ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for mehen-1.7.0-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 01e219d725ede3766f912ff2ad9d68259e47c61fde6ed704234320733602f195
MD5 c4c9c383ab43a4fbd2ce00737ba1a678
BLAKE2b-256 7800e1eee2d18b829f3fe74e7c178c28da0a267e8a42adc7baaccc25385f6085

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-1.7.0-py3-none-win_arm64.whl:

Publisher: release.yml on ophi-dev/mehen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mehen-1.7.0-py3-none-win_amd64.whl.

File metadata

  • Download URL: mehen-1.7.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 10.7 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for mehen-1.7.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 39dee37d8fc4035ee7dfad7b103c2470a912d07fd04395e281c0007cc3224cce
MD5 a6f9210c5dca75fcbf7b1cfe8ef343cb
BLAKE2b-256 f2cff6bef665ec376bc309c8a0d78d7ba1ffac2fca680fd2672f92ad6c08bf58

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-1.7.0-py3-none-win_amd64.whl:

Publisher: release.yml on ophi-dev/mehen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mehen-1.7.0-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mehen-1.7.0-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 c7ee4b5882e1c94ef0b67485f0f3e35601c2771af795a65f8cc15276d5497977
MD5 0ffd4098742a56c6530c4d569f0d3358
BLAKE2b-256 ed1f4fd4e96211c0411c862926702e073dc7c966e66a7972f11fb7606d013f79

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-1.7.0-py3-none-manylinux_2_28_x86_64.whl:

Publisher: release.yml on ophi-dev/mehen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mehen-1.7.0-py3-none-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for mehen-1.7.0-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 01eb01ed1f113e429fcb3485eb585132d51c3f225758c3271c07f872708105aa
MD5 3f4281470836adc11b73d9c293a2cc9c
BLAKE2b-256 d6060af2dfb026615cab6634dd4b54ad223f6a57681cc607f8213484c8a55237

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-1.7.0-py3-none-manylinux_2_28_aarch64.whl:

Publisher: release.yml on ophi-dev/mehen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mehen-1.7.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mehen-1.7.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 4d994e4c93b13f884c3358db95f812c96173f1cbafd9f0f80f701fc68e776f7f
MD5 9c93fa85aaaaa3fcd43e02ab283b49d0
BLAKE2b-256 ffe4154f0141c4acc112b718f1ea814011b5254ffd5c0373c8d25b6db59bd63c

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-1.7.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release.yml on ophi-dev/mehen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mehen-1.7.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for mehen-1.7.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 3b0305b2d320914361cbb39c93f4daaf18a5bbd636ee1af7dd036f8a57a8ed16
MD5 171c938ec182e4b48546281dd107e161
BLAKE2b-256 978cc4830f9acd719778e2ce93f50c1b29fb2018f28662fa97307163ce6299fa

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-1.7.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl:

Publisher: release.yml on ophi-dev/mehen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mehen-1.7.0-py3-none-macosx_11_0_arm64.whl.

File metadata

  • Download URL: mehen-1.7.0-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 9.4 MB
  • Tags: Python 3, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for mehen-1.7.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 6b8dae99372e332ffd715c993aaf6d0f4ee062417ea1ec4ca5d0c69569734c37
MD5 d37b0dd4a0d21d6668fdd8864e887a1e
BLAKE2b-256 a6a45d73de13e5437fbc16453f605a4f93b1f495e689e49034c958c64dc64d13

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-1.7.0-py3-none-macosx_11_0_arm64.whl:

Publisher: release.yml on ophi-dev/mehen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mehen-1.7.0-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for mehen-1.7.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 36bd93d218f50a260464b0619fe272c7cc3f9e7c4d8a6198ad1cc0a294524929
MD5 c427f04754fceca5a6f7fa89a0e48720
BLAKE2b-256 23640629d05a246a6e2d2804bc51aa9fb0daab6343806b40b7c5fc34ce158c15

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-1.7.0-py3-none-macosx_10_12_x86_64.whl:

Publisher: release.yml on ophi-dev/mehen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

1.10.0

9 files

1.9.0

9 files

1.8.1

9 files

1.8.0

9 files

This release

1.7.0 This release

9 files

1.6.0

9 files

1.5.1

9 files

1.4.1

9 files

1.4.0

9 files

1.3.0

9 files

1.2.0

9 files

1.1.0

9 files

1.0.2

9 files

0.7.0

7 files

0.5.0

8 files

0.4.3

7 files

0.4.1

8 files

0.4.0

8 files

0.2.0

8 files

0.1.0

7 files

0.0.6

8 files

0.0.5

8 files

0.0.4

7 files

0.0.3

8 files

0.0.2

8 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page