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.0.tar.gz (1.7 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.0-py3-none-win_arm64.whl (11.1 MB view details)

Uploaded Python 3Windows ARM64

mehen-1.8.0-py3-none-win_amd64.whl (12.5 MB view details)

Uploaded Python 3Windows x86-64

mehen-1.8.0-py3-none-manylinux_2_28_x86_64.whl (11.9 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ x86-64

mehen-1.8.0-py3-none-manylinux_2_28_aarch64.whl (11.0 MB view details)

Uploaded Python 3manylinux: glibc 2.28+ ARM64

mehen-1.8.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (11.0 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

mehen-1.8.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl (12.0 MB view details)

Uploaded Python 3manylinux: glibc 2.5+ x86-64

mehen-1.8.0-py3-none-macosx_11_0_arm64.whl (10.9 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

mehen-1.8.0-py3-none-macosx_10_12_x86_64.whl (11.8 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

  • Download URL: mehen-1.8.0.tar.gz
  • Upload date:
  • Size: 1.7 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.0.tar.gz
Algorithm Hash digest
SHA256 2777d4c0d83b38882e1e900352f396b6b2980ab599d67b09f7f25569dd3f5e89
MD5 b2f9db6d99ab0e087437e3d479016339
BLAKE2b-256 a0dbacebd6a498b8ae8124126ea266e001a9ed669d1023b95c758a33067e20e2

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mehen-1.8.0-py3-none-win_arm64.whl
  • Upload date:
  • Size: 11.1 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.0-py3-none-win_arm64.whl
Algorithm Hash digest
SHA256 c4cf83549f192433fcc63f5acaa31ce83dd714fbf99979efc009501ae9bebdc4
MD5 9abed009c48129bb5e0ac59a9fdb7c86
BLAKE2b-256 6b8ff00c674f0f6b3cae0f7cb20ed63eccd66f10bb68a711b000d124581b052b

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mehen-1.8.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 12.5 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.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 ca76dc0d1eb6946874d7b02c46954b598e671857ed49c4c749c6b343d21414e4
MD5 b4720da4b6eb3d6bbc249d2c4c2f92b2
BLAKE2b-256 e67ec8e4f996280486d91172b1c61776c2af5f9e345516ed336dc99457087819

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-1.8.0-py3-none-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 0cf97e0889c5b9a6baf0c80f487e9d7bc40f51d4ae8e7a14fc266f255b8333a7
MD5 ddd959f08d36e34f176e97ef17d3ab29
BLAKE2b-256 98d642a536e08ba568500abf15f2a0e9d22245a1a9960a5e1708563f94cf2960

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-1.8.0-py3-none-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 eea2a191ba4686e40e2c4fecfba44b6f5f86236f7b43ccf1cf30d774b333f967
MD5 5be961019996f6cf38a22468703c1af5
BLAKE2b-256 5aa9edfcdc7c325ca43389e78562bac8acd5b9e636b114a5165a150ecb846043

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-1.8.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ce3e72f57c3dfe1f106451512fa7003d24a7fd17af33002faf1990b1c1bc6fb5
MD5 fe9014b68f5c54a6f2b74f7487431280
BLAKE2b-256 d2e6527c8a9363eeabd8481b8bde0443bbcb829520cc2c178d81c0ded622f039

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-1.8.0-py3-none-manylinux_2_5_x86_64.manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 d33292e62d17adc5bc0f6b10f6ea5ba9ad91952e4cb52db7033ee9c4a3a35d3a
MD5 1b3a85ee94f1c0df8e8fb2d6803257fb
BLAKE2b-256 ccba5c85c55c1497d32a33b96f8f04e56762337c0a330cecf921b9cfe0218b87

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: mehen-1.8.0-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 10.9 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.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2dc842be0cdee7dfbe87ccbab5dff584a71a029a8b4ed5524bf257fb45f3239c
MD5 776dc6fac293f09abf0879a723bd35e3
BLAKE2b-256 a04f85100649f38c01c1355a149031fa232f2ba196829d27e50de10c990a3175

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for mehen-1.8.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 db9b9e5ac9f2026ba372de2ca2e4ff81b29dfa1d6d0fb0722b31f415d20f8d0b
MD5 978f214f29e596f558aefb362fb2e0f0
BLAKE2b-256 e8b25cefd317a71d85d5c8fd6337083e26902dd4032c80bf1212a21068faf962

See more details on using hashes here.

Provenance

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

This release

1.8.0 This release

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