Skip to main content

heki

The heki banner, a snake in front of a brick wall

heki (壁, Japanese for "wall") is a static checker for Python, written in Rust. It follows calls across files to find shared state changed in place, database queries in loops, and blocking calls in async code, and it enforces the boundaries your project declares. It runs alongside Ruff and your type checker (mypy, Pyright, Pyrefly, or ty), and never runs your code.

📚 Documentation · 🚀 Getting started · 📏 Rules · 📜 Contracts · 🤖 Coding agents

PyPI Python versions CI License: MIT

Highlights

  • With no configuration, heki reports cached results changed in place, database queries and new clients in loops, blocking calls in async code, and locks taken again while held (Rules).
  • The default rules report only what they prove. Every report on 378 packages and a holdout of 100 more was checked by hand, and none was false (Rule precision).
  • heki check --fix applies a rewrite only when it proves that the program behaves the same under CPython's semantics (Fixes and safety).
  • heki is a single binary with no Python dependencies, and it checks a 100,000-line project in a few seconds.
  • It runs in CI, in editors through its LSP server, and for coding agents as JSON. In our agent runs, it found an N+1 query that had passed the tests, Ruff, and strict mypy (the measurements).
  • Optional contracts in heki.toml say who may change, read, or call what, where I/O may happen, and which imports are allowed (Contracts).

Quick start

$ uvx heki check     # check the project in its root, with no install and no configuration
$ uvx heki init      # write heki.toml and a Ratchet baseline, and set up coding agents if you ask

The baseline holds today's reports, so only new ones fail. Getting started reads a diagnostic and applies a fix.

Example

# app/config.py
from functools import lru_cache


@lru_cache(maxsize=64)
def base_headers(region: str) -> dict[str, str]:
    return {"Accept": "application/json", "X-Region": region}
# app/api.py
from app.config import base_headers


def request_headers(region: str, token: str) -> dict[str, str]:
    headers = base_headers(region)
    headers["Authorization"] = f"Bearer {token}"
    return headers

Each file looks fine on its own, and the types are right. But lru_cache hands the same dict to every call with the same region, and request_headers writes a token into it, so a later caller of base_headers for that region sends the token of whoever called request_headers last.

Both files pass Ruff and strict type checking (mypy, Pyright, Pyrefly, and ty). heki check reports MUT114.

heki check in a terminal reports MUT114, with no configuration, for a dict that an lru_cache function returned and another file changes in place

Contracts (optional)

Contracts are rules only your project knows, and heki enforces them through helpers and aliases. This one lets only the functions in app.store change Order.items.

[[write-owners]]
name = "order-store"
targets = ["app.models.Order.items"]
allowed-writers = ["app.store.*"]
message = "change Order.items through app.store"
fail = true

A write through a helper in another file is then reported as MUT201 (the whole example). Contracts describes all eight contract tables.

Installation and CI

Install heki with uv tool install heki, pipx install heki, or pip install heki. The prebuilt wheels for Linux, macOS, and Windows need no Rust toolchain (Installation). heki is pre-release, so pin the version in CI with uvx heki==0.14.0 check and in the pre-commit hook.

# .pre-commit-config.yaml
repos:
  - repo: https://github.com/koxudaxi/heki-pre-commit
    rev: v0.14.0
    hooks:
      - id: heki

The release notes list every change. Adopting heki covers baselines and CI, and says what stays stable until 1.0.

Works alongside

Tool Checks heki adds
Ruff syntax and style what a call does across files
mypy, Pyright, Pyrefly, ty declared types in-place changes to read-only values through helpers
tach, import-linter import layers who changes, reads, or calls what, and where I/O happens

Documentation

The documentation is at heki.koxudaxi.dev, with an index for language models at llms.txt. Design philosophy says why heki works the way it does and where its name comes from, and the Changelog lists every release.

heki is licensed under the MIT license.

Metadata

Release files for heki 0.14.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for heki 0.14.0
File Size Uploaded Provenance Actions
heki-0.14.0.tar.gz 5.0 MB With provenance Details for heki-0.14.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for heki 0.14.0
File Actions
heki-0.14.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for heki-0.14.0-py3-none-win_amd64.whl
heki-0.14.0-py3-none-musllinux_1_2_x86_64.whl Python 3 none Linux musl 1.2+ x86-64 Details for heki-0.14.0-py3-none-musllinux_1_2_x86_64.whl
heki-0.14.0-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details for heki-0.14.0-py3-none-manylinux_2_28_x86_64.whl
heki-0.14.0-py3-none-manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64 Details for heki-0.14.0-py3-none-manylinux_2_28_aarch64.whl
heki-0.14.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for heki-0.14.0-py3-none-macosx_11_0_arm64.whl
heki-0.14.0-py3-none-macosx_10_12_x86_64.whl Python 3 none macOS 10.12+ x86-64 Details for heki-0.14.0-py3-none-macosx_10_12_x86_64.whl

Total release size: 101.3 MB

Release files / heki-0.14.0.tar.gz

Download URL heki-0.14.0.tar.gz
Size 5.0 MB
Tags Source
SHA-256 checksum
How to use checksums
225e2e51975ff80f97669432069dc984bc6f69d8269f9524e40ba4f94fb8f74c
BLAKE2b-256 checksum
How to use checksums
fcdadbbb4fc9b1344d42c12f900ff6f1086c29b6d7d1154ef27114afd64ca95d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / heki-0.14.0-py3-none-win_amd64.whl

Download URL heki-0.14.0-py3-none-win_amd64.whl
Size 15.3 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
08269647a28bfb521b4d76a414fcb4979e17e72b67ac7f1545e32555066dbc23
BLAKE2b-256 checksum
How to use checksums
c891e8152873de2acba49eea620142c2b3f7812fb30210618e79cf82fa516be9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / heki-0.14.0-py3-none-musllinux_1_2_x86_64.whl

Download URL heki-0.14.0-py3-none-musllinux_1_2_x86_64.whl
Size 17.1 MB
Tags Linux musl 1.2+ x86-64 Python 3
SHA-256 checksum
How to use checksums
2932c3f8db65c9f844f8859faac9f4ad95c38a01aebfb806788a9ead30a882a1
BLAKE2b-256 checksum
How to use checksums
f65692116577de0a46c71753a0a6226c979b7d3d46ada3934554d89a02e05cfa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / heki-0.14.0-py3-none-manylinux_2_28_x86_64.whl

Download URL heki-0.14.0-py3-none-manylinux_2_28_x86_64.whl
Size 16.5 MB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
4b176cd4425cc23cd80596bed8efe8e77f2d7e1fa57414c22899187aff9ab2ef
BLAKE2b-256 checksum
How to use checksums
ed59ee5c195973bff4950d2393934818a250432646da60851de6c90ec66b1030
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / heki-0.14.0-py3-none-manylinux_2_28_aarch64.whl

Download URL heki-0.14.0-py3-none-manylinux_2_28_aarch64.whl
Size 16.1 MB
Tags Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
fc572cfe8111b27c1b39eac26f8eb8d318e48e0438b193a3bd21343a3072aeab
BLAKE2b-256 checksum
How to use checksums
d3a22c1b5a68611e625e1599382653c0ef886285d5d4c0653a4f8d2aa94b344f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / heki-0.14.0-py3-none-macosx_11_0_arm64.whl

Download URL heki-0.14.0-py3-none-macosx_11_0_arm64.whl
Size 15.3 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
ba06752a64b97de209446ca0623f1b71c32c5f93b39d316a8d9881193d41497f
BLAKE2b-256 checksum
How to use checksums
4570549bb586ee55f7db546222500f0ace621a83ad77c54c51b3c758ee763474
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Release files / heki-0.14.0-py3-none-macosx_10_12_x86_64.whl

Download URL heki-0.14.0-py3-none-macosx_10_12_x86_64.whl
Size 16.1 MB
Tags Python 3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
45c365cf99fc8c5bce20a36f17d702e06a8a3910cd58cffd600ed4e39c3a557f
BLAKE2b-256 checksum
How to use checksums
89e3c355e50c4822185747bfaa6049fd976c5bbbe8fa38790108a6626f1b6801
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

Security for heki 0.14.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 7 files in this release have been uploaded with provenance metadata.

Select from 7 files

Attestation for heki-0.14.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 30, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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