---
title: "mehen — code & documentation metrics"
description: "Rust-powered CLI for heuristic code and documentation metrics: complexity, maintainability, lines of code, and Markdown documentation health."
keywords: ["mehen", "code metrics", "documentation metrics", "complexity", "maintainability"]
---

**mehen** is a fast, deterministic CLI for code and documentation metrics. It analyzes eleven source
languages plus SQL and Markdown, runs in seconds even on large monorepos, and ships a GitHub Action
that publishes per-PR metric trends out of the box.

```bash
mehen metrics src/main.py --pretty
mehen top-offenders src --metric cognitive
mehen diff --from main --to HEAD --paths src
```

<Columns cols={2}>
  <Card title="Get started" icon="rocket" href="/quickstart">
    Run mehen against your project in under a minute.
  </Card>
  <Card title="GitHub Action" icon="github" href="/guides/github-action">
    Add the action and start posting metric trends on PRs.
  </Card>
  <Card title="Code metrics" icon="ruler" href="/metrics/code/overview">
    Cyclomatic, cognitive, Halstead, MI, ABC, LOC family, NOM, NPA, NPM, WMC.
  </Card>
  <Card title="SQL metrics" icon="database" href="/metrics/sql/overview">
    CTE graphs, join/subquery structure, object-touch risk, SQL Halstead, composite scores.
  </Card>
  <Card title="Markdown metrics" icon="book-open" href="/metrics/markdown/overview">
    DMI, MRPC, MCC, link debt, filler/lazy risk, English/Japanese prose layer.
  </Card>
  <Card title="History metrics" icon="clock-rotate-left" href="/metrics/history/overview">
    Churn, code age, ownership, hotspots, change coupling, bug risk — from git history.
  </Card>
</Columns>

## Why mehen?

<Columns cols={2}>
  <Card title="Real language parsers" icon="microchip">
    Ruff for Python, Oxc for TS/JS/JSX/TSX, Mago for PHP, Prism for Ruby, ra_ap_syntax for Rust,
    ANTLR for Kotlin, Java, and C#, sqruff for SQL, pulldown-cmark for Markdown, tree-sitter for Go, C,
    PowerShell.
  </Card>
  <Card title="Code, SQL, and documentation" icon="files">
    One tool covers source-code complexity, first-class SQL structure metrics, *and* Markdown
    documentation health.
  </Card>
  <Card title="Deterministic, no network" icon="lock">
    Pure static analysis. Same input → same output. Safe for air-gapped CI.
  </Card>
  <Card title="PR-native reporting" icon="git-pull-request">
    Built-in `mehen diff` with sticky GitHub comment via the official action.
  </Card>
</Columns>

## What mehen computes

For source code:

- [Cyclomatic complexity](/metrics/code/cyclomatic), [Cognitive complexity](/metrics/code/cognitive),
  [Halstead metrics](/metrics/code/halstead), [Maintainability Index](/metrics/code/mi),
  [ABC](/metrics/code/abc).
- [Function & class shape](/metrics/code/overview): [NOM](/metrics/code/nom), [NARGS](/metrics/code/nargs),
  [NEXITS](/metrics/code/nexits), [NPA](/metrics/code/npa), [NPM](/metrics/code/npm),
  [WMC](/metrics/code/wmc).
- The [LOC family](/metrics/code/loc): SLOC, PLOC, LLOC, CLOC, blanks.

For SQL:

- [Structural and cognitive complexity](/metrics/sql/overview) from CTE, join, subquery, `CASE`, and
  window structure; a [Review Burden Index](/metrics/sql/overview) and [Change Risk
  Score](/metrics/sql/overview); an [SQL Halstead](/metrics/sql/overview) and maintainability index.

For Markdown documentation:

- [Documentation Maintainability Index (DMI)](/metrics/markdown/dmi).
- [Markdown Reading Path Complexity (MRPC)](/metrics/markdown/mrpc),
  [Markdown Cognitive Complexity (MCC)](/metrics/markdown/mcc),
  [Markdown Halstead](/metrics/markdown/halstead).
- [Link Debt](/metrics/markdown/link-debt), [Table Burden](/metrics/markdown/table-burden),
  [Visual Scaffold](/metrics/markdown/visual-scaffold), [Artifact Debt](/metrics/markdown/artifact-debt).
- [Repository Grounding](/metrics/markdown/repository-grounding),
  [Evidence Coverage](/metrics/markdown/evidence-coverage),
  [Filler / Lazy Structure Risk](/metrics/markdown/filler-lazy-risk),
  [Review Criticality Index](/metrics/markdown/review-criticality-index).
- An opt-in [English readability ensemble](/metrics/markdown/prose/english-readability) and
  [Japanese prose layer](/metrics/markdown/prose/japanese-script-composition).

From git history:

- [Churn](/metrics/history/churn) (absolute and size-relative), [code age](/metrics/history/age),
  [commit frequency](/metrics/history/commit-frequency).
- [Ownership & authorship](/metrics/history/ownership): distinct authors, minor contributors,
  top-contributor share.
- [Hotspot](/metrics/history/hotspot) (cognitive complexity × commit frequency),
  [sum of coupling](/metrics/history/sum-of-coupling), and
  [bug risk](/metrics/history/bug-risk) (bug-fix count and Time-Weighted Risk).

## What is Mehen?

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