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 and C#), 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.8.1.tar.gz (1.5 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.8.1-py3-none-win_arm64.whl (10.9 MB view details)

Uploaded Python 3Windows ARM64

mehen-1.8.1-py3-none-win_amd64.whl (12.3 MB view details)

Uploaded Python 3Windows x86-64

mehen-1.8.1-py3-none-manylinux_2_28_x86_64.whl (11.7 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

mehen-1.8.1-py3-none-manylinux_2_28_aarch64.whl (10.8 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

mehen-1.8.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (10.8 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

mehen-1.8.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (11.8 MB view details)

Uploaded Python 3manylinux: glibc 2.5+ x86-64

mehen-1.8.1-py3-none-macosx_11_0_arm64.whl (10.7 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

mehen-1.8.1-py3-none-macosx_10_12_x86_64.whl (11.6 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for mehen-1.8.1.tar.gz
Algorithm Hash digest
SHA256 4f2ac98665204ed553a16e4072a199d498991223bf029ff062348d3aff8b0f30
MD5 47b36b11898d746f4970b6e5204c8709
BLAKE2b-256 85e1a562447de835e7b0051a27c62727ce5b313441c29dc32811525488852009

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-1.8.1.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.8.1-py3-none-win_arm64.whl.

File metadata

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

File hashes

Hashes for mehen-1.8.1-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 672cd0b933ef8dd7341c88cc211868e052d13e53b99debcb0049b8d39ee52838
MD5 c2e9a1ad4df887c909466a67520651b2
BLAKE2b-256 380d71be97cab9726afe7d4adeceb2d9b28aa2de94432db34b8e743b5334d7a1

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-1.8.1-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.8.1-py3-none-win_amd64.whl.

File metadata

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

File hashes

Hashes for mehen-1.8.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 ed82fc5ea16c8f0789212ce014e1aec85bb6776942f7e9be0c8914e82d970d73
MD5 01a8779e7316bd1920dc1a16fa98df17
BLAKE2b-256 0a159f20d7fea3ab11b1db39276a2a6fd6571783a4ee1976d922ae26ad0b9a7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-1.8.1-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.8.1-py3-none-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for mehen-1.8.1-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 04016e105a72ef6641579882ea84823fb403cf2a55189397a339fde360e1a93b
MD5 9c357b0f1d48a669b24029f6c53945fa
BLAKE2b-256 112f38480c02d91c9e564902a250324649f96ae9d9179843efb3392febe0ec3e

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-1.8.1-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.8.1-py3-none-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for mehen-1.8.1-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 2388fa424f0328d1926b45e0225e19b77d30c2808578cd08ee2c9a0ec97b6fc7
MD5 5d1334f8a8fbcaf6982a9712419e0d99
BLAKE2b-256 064ae8f81709428d1f4f8a9762109e46fa72ddda7bc188aa6267aa79230d19b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-1.8.1-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.8.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for mehen-1.8.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 85bff2cf8c7a129ee40c5182052ce36ee6e01b33553e2bab19a2ed2261f3c374
MD5 b292b8c1580aab09ad6e73a38eec67a6
BLAKE2b-256 3174bf7e32b0c7a73c6672a5d4d7e204aeed7114333c4df7e9201a156a1132ff

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-1.8.1-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.8.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl.

File metadata

File hashes

Hashes for mehen-1.8.1-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 cef7c3df32a1a45f465a8a382bfce76f016e2749c8a5003ab4fe82f9bd179795
MD5 4368dfb7922a87fa3d99c3f31a1af3a4
BLAKE2b-256 53343f610156848af166e5a0bc2ee034fced3c720ba06cc6dee2a388d82f8640

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-1.8.1-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.8.1-py3-none-macosx_11_0_arm64.whl.

File metadata

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

File hashes

Hashes for mehen-1.8.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a78238c0a0f40f2087653de4a87b7adb76cbd7b6589789517ed9ca512d368bca
MD5 f1ab2fb0d65d3d52a9e9dc6542e7c1b8
BLAKE2b-256 e7f76a8046fa3fa6691b102fa12a093e4973d3fd398c9442f3cb13d9d16c6db0

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-1.8.1-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.8.1-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for mehen-1.8.1-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 d1860248296630d91b1f577dd99344b3aeca92f2a961079189ca2c92c603c1c4
MD5 fd12be2849c005cec870829082a77e8a
BLAKE2b-256 a1f95ae6c54fe030927c9c99ea00c1aa5b0ca848a1cf02b0ac157619d9b0e553

See more details on using hashes here.

Provenance

The following attestation bundles were made for mehen-1.8.1-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

This release

1.8.1 This release

9 files

1.8.0

9 files

1.7.0

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