heki
🧱 heki (壁, Japanese for "wall") is a static checker for Python, written in Rust. It tracks side effects and mutations across function calls, and checks a 100,000-line project in a few seconds.
Ruff checks syntax and style, and mypy, Pyright, Pyrefly, and ty check types. heki checks what your code does: which effects a call reaches and which state it changes, across functions and files.
It works on two levels. With no configuration, it catches bugs such as blocking calls in async
code, database queries in loops, and in-place changes to read-only parameters. On top of that, it
enforces the walls your project writes as
contracts: which functions may change a
field, call a function, or reach I/O.
📚 Documentation · 🚀 Getting started · 📏 Rules · 📜 Contracts
⚡ Try it in your project's root, without installing: uvx heki check. Then follow
Try it in 5 minutes.
A bug found with no configuration
Each file looks fine on its own: the bug is in the call chain.
# app/users.py
import requests
def fetch_name(user_id: int) -> str:
return requests.get(f"https://api.example.com/users/{user_id}", timeout=5).text
def load_user(user_id: int) -> dict[str, str]:
return {"id": str(user_id), "name": fetch_name(user_id)}
# app/api.py
from app.users import load_user
async def get_user(user_id: int) -> dict[str, str]:
return load_user(user_id)
A wall your project writes
Only the functions in app.store may change Order.items. Write that down once:
# heki.toml
[[write-owners]]
name = "order-store"
targets = ["app.models.Order.items"]
allowed-writers = ["app.store.*"]
message = "change Order.items through app.store"
fail = true # a report of this contract fails the run
# app/models.py
class Order:
def __init__(self) -> None:
self.items: list[str] = []
# app/store.py
from app.models import Order
def add_item(order: Order, item: str) -> None:
order.items.append(item)
app/checkout.py changes the list through a helper in another file:
# app/util.py
def append_to(items: list[str], item: str) -> None:
items.append(item)
# app/checkout.py
from app.models import Order
from app.util import append_to
def add_gift_wrap(order: Order) -> None:
append_to(order.items, "gift-wrap")
The image at the top is heki check on these examples: EFF101 with no configuration, and
MUT201 from the contract. The same code passes mypy, Pyright, Pyrefly, and ty in strict mode
(mypy --strict, Pyright's strict, Pyrefly's strict preset, every ty rule as an error), and
Ruff with every rule on asks only for docstrings and copyright lines.
How heki differs
| Tool | Models | heki adds |
|---|---|---|
| Ruff | syntax and style | the effects behind a call: a blocking call, a query, or a write, wherever it happens |
| mypy, Pyright, Pyrefly, ty | declared types | in-place changes, through aliases and helpers, to frozen, ReadOnly, and Final fields and to Sequence / Mapping / AbstractSet arguments |
| tach, import-linter | which modules may import which | which functions write or read a field, call a function, or reach I/O; import rules that know when each import runs (experimental); planned: reading these tools' contracts as heki contracts |
Use heki next to these tools; its configuration, suppression comments, and output formats follow Ruff's. Design Philosophy says why heki works this way and compares its checks with what Rust and Haskell enforce.
🧭 What heki can do
✅ Bug checks with no configuration
These rules run by default, and each report shows the chain of calls that leads to it. Every report they made on 378 packages (about 30.75 million lines) and on a frozen holdout of 100 more was checked by hand, with no false claim (Rule precision).
| What goes wrong | Rule |
|---|---|
A blocking call that a call in an async def always runs, several helpers below |
EFF101 |
| A database statement on every iteration of a loop over data | EFF103 |
| A lock that is not reentrant, taken again while it is held, so the thread or task waits for itself | EFF109 |
| A call of a generator function whose generator nothing iterates, so its body never runs | EFF116 |
A Sequence / Mapping / AbstractSet argument changed in place by a helper |
MUT110 |
A list, dict, or set that an lru_cache / cache function returned, changed in place |
MUT114 |
A change of a builtin container that is lost because the object is new and nothing holds it (list(xs).sort()) |
MUT119 |
| A DataFrame or array concatenated with itself on every loop iteration | DATA101 |
| A list rebuilt, or a dict or set merged, on every loop iteration, and a nested-loop join | OPT101, OPT102, OPT113 |
The size-dependent rewrites (OPT103, OPT110, OPT111, OPT120, OPT121, OPT130) are exact
too, but opt-in. The other rules are heuristic or opt-in (Rules).
heki check --fix applies an OPT rewrite only when it proves, under CPython's semantics, that
the program behaves the same (Fixes and safety). More by
problem: async and execution effects,
state ownership and mutation, and
imports and module boundaries.
📜 Walls you write: contracts and coding agents
Write the rules your project keeps by review today as contract tables in heki.toml or under
[tool.heki]. heki follows aliases, helpers, and subclasses, with nothing added at run time.
Contract reports are heuristic, so they are warnings until the table sets fail = true.
| What you want to keep | Contract | Main keys |
|---|---|---|
Only app.store changes Order.items |
write-owners |
targets = ["Order.items"], allowed-writers = ["app.store.*"] |
Only app.billing reads Order.card_token |
read-owners |
targets = ["Order.card_token"], allowed-readers = ["app.billing.*"] |
Only app.admin calls app.db.reset |
call-owners |
targets = ["app.db.reset"], allowed-callers = ["app.admin.*"] |
No caller changes the settings load_settings returns to everyone |
readonly-returns |
producers = ["app.config.load_settings"], deep = true |
Every change of Order.items is followed by order_changed() |
invalidation |
targets = ["Order.items"], invalidators = ["app.cache.order_changed"] |
Code in app.render makes no blocking call |
effect-boundaries |
scopes = ["app.render.*"], forbid = ["blocking"] |
app.domain imports nothing from app.web, even lazily or inside a function |
import-boundaries (experimental) |
importers = ["app.domain.*"], forbidden-imports = ["app.web", "app.web.*"] |
See Contracts for every key. A coding agent
can miss a rule written in its instructions, but not a contract that heki check enforces:
- List
heki.tomlandheki-baseline.tomlinCODEOWNERS: moving a wall takes a review. - A contract's
messagestarts the help line of its reports, so the agent reads it as the fix. - A Stop hook sends a failing check back before the agent ends its turn.
heki inspect(experimental) shows what one function reaches, changes, and returns.--output-format jsongives every check as JSON, and the Agent Skill (experimental) teaches the routine after an edit. Coding agents has the whole setup.
🚀 Try it in 5 minutes
-
In your project's root (the directory with
pyproject.toml), runuvx heki check. An exact error, likeEFF101above, fails the run (exit code 1). Warnings are printed but don't fail it unless you pass--fail-on warning. -
Ask what fits the project with
heki recommend(experimental). It writes no file and helps most when the first step finds nothing, as on heki's sample service:$ uvx heki check All checks passed (4 file(s)). ... $ uvx heki recommend ... Contract candidates write-owners app.models:Order.* high written by 1 function(s), all in app.store (add_item), changed in place; read in 2 other module(s)
Only
app.storewritesOrder.items, so heki proposes that wall with the keys to add. Getting started shows more of the report. -
Keep it running with the pre-commit hook and a CI step, and record today's findings in a Ratchet baseline so only new ones fail:
uvx heki==0.11.0 check --baseline heki-baseline.toml --update-baseline. The starter recipes have these setups ready to copy.
📦 Installation
$ uv tool install heki # or: pipx install heki / pip install heki
$ uvx heki check # run without installing
heki ships prebuilt wheels on PyPI for Linux (x86-64, AArch64, x86-64 musl), macOS (Apple silicon,
Intel), and Windows (x86-64). uvx heki, pip install heki, and the pre-commit hook need no Rust
toolchain and compile nothing. Building from source is for other platforms and for development:
see Installation.
⌨️ Usage
$ heki check # check the project
$ heki check --heuristic # also run the heuristic rules
$ heki check --diff # preview proven-safe fixes
$ heki check --fix # apply them
$ heki check --baseline heki-baseline.toml # fail only on new findings
$ heki rule EFF101 # explain a rule
$ heki server # LSP server for editors
$ heki inspect app.users.load_user # what one function does (experimental)
$ heki recommend # configuration advice (experimental)
🪜 pre-commit and CI
# .pre-commit-config.yaml
repos:
- repo: https://github.com/koxudaxi/heki-pre-commit
rev: v0.11.0
hooks:
- id: heki
# A step of a GitHub Actions job that has uv
- run: uvx heki==0.11.0 check
The hook runs heki check --touched on the staged files, so old findings in other files don't
block a commit. It still fails on a report in an unstaged file whose call chain passes through a
staged file, and, with a baseline, on every regression. Run the whole project in CI. In GitHub
Actions, the reports show up as annotations.
Adopting heki has the SARIF run for
code-scanning alerts, a local hook, and how to check only the files a pull request changes.
🛡️ Stability
On the way to 1.0, heki keeps these stable: the exit codes 0, 1, and 2, the exact rules that
run by default, the format of the Ratchet baseline, the contract tables write-owners,
read-owners, call-owners, readonly-returns, invalidation, and effect-boundaries with
fail = true and [lint] fail = [...], and the json, sarif, and github output formats. A
change to one of them is listed under "Breaking changes" in the release notes. The experimental
features can change in any release: heki recommend, heki inspect, heki skill,
--generate-prompt, and the rules marked experimental
(the list).
📚 Documentation
When heki isn't sure, it doesn't report. Scope and limitations says what it checks, where its knowledge comes from, and what it leaves to other tools.
- 🚀 Getting started - run heki on a project, read a diagnostic, apply a fix
- ⚙️ Configuration & Contracts - rule selection, contracts, the Python version
- 📏 Rules - every rule, with its tier
- 📐 Rule precision - exact and heuristic rules, and how they are measured
- 🔧 Fixes and safety - how rewrites are proven safe
- 🪜 Adopting heki - Ratchet baselines, pre-commit, CI
- 🖥️ Editors (LSP) - VS Code, Neovim, and any LSP client
- 🤖 Coding agents - JSON output and agent setup
- ⌨️ CLI reference - every command and option
- 🛠️ Development - building, testing, and the gates
- 📝 Changelog
📛 Name
heki is 壁, "wall", in its Sino-Japanese (on) reading, the one used in compounds such as 防火壁 (bōkaheki, "firewall"). On its own the character is usually read kabe.
📄 License
Metadata
Release files for heki 0.11.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| heki-0.11.0.tar.gz | 3.8 MB | With provenance | Details for heki-0.11.0.tar.gz |
Built distributions (wheels)
| File | Actions Reset | |||
|---|---|---|---|---|
| heki-0.11.0-py3-none-win_amd64.whl | Python 3 | none | Windows x86-64 | Details for heki-0.11.0-py3-none-win_amd64.whl |
| heki-0.11.0-py3-none-musllinux_1_2_x86_64.whl | Python 3 | none | Linux musl 1.2+ x86-64 | Details for heki-0.11.0-py3-none-musllinux_1_2_x86_64.whl |
| heki-0.11.0-py3-none-manylinux_2_28_x86_64.whl | Python 3 | none | Linux glibc 2.28+ x86-64 | Details for heki-0.11.0-py3-none-manylinux_2_28_x86_64.whl |
| heki-0.11.0-py3-none-manylinux_2_28_aarch64.whl | Python 3 | none | Linux glibc 2.28+ ARM64 | Details for heki-0.11.0-py3-none-manylinux_2_28_aarch64.whl |
| heki-0.11.0-py3-none-macosx_11_0_arm64.whl | Python 3 | none | macOS 11.0+ ARM64 | Details for heki-0.11.0-py3-none-macosx_11_0_arm64.whl |
| heki-0.11.0-py3-none-macosx_10_12_x86_64.whl | Python 3 | none | macOS 10.12+ x86-64 | Details for heki-0.11.0-py3-none-macosx_10_12_x86_64.whl |
Total release size: 83.3 MB
Release files / heki-0.11.0.tar.gz
| Download URL | heki-0.11.0.tar.gz |
|---|---|
| Size | 3.8 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dfa360f8015e6892729c69bedd957180a8201ae2523b385c05b8107e33c2619c
|
|
BLAKE2b-256 checksum How to use checksums |
e01d0aab48dd35de78d542950d56c3b792a88cc5d4c1980e21a85622d37e4545
|
| 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 27, 2026.
Transparency logRelease files / heki-0.11.0-py3-none-win_amd64.whl
| Download URL | heki-0.11.0-py3-none-win_amd64.whl |
|---|---|
| Size | 12.5 MB |
| Tags | Python 3 Windows x86-64 |
|
SHA-256 checksum How to use checksums |
0144d872fd33716b9d1b23e239c135a80338d8d3854f954d339ee109c490fd86
|
|
BLAKE2b-256 checksum How to use checksums |
3145efe841276e6612e8dd7021338a076668f8d24664b89fa24c4d9627d53a27
|
| 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 27, 2026.
Transparency logRelease files / heki-0.11.0-py3-none-musllinux_1_2_x86_64.whl
| Download URL | heki-0.11.0-py3-none-musllinux_1_2_x86_64.whl |
|---|---|
| Size | 14.2 MB |
| Tags | Linux musl 1.2+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
e5999c82488e046a31437637ca9e624480a7584388c1283f518613e49519cd24
|
|
BLAKE2b-256 checksum How to use checksums |
5ff5fdb2b81ae4ac6fb15c556160dc5f932fa812ba2b41a587461843c93ae67f
|
| 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 27, 2026.
Transparency logRelease files / heki-0.11.0-py3-none-manylinux_2_28_x86_64.whl
| Download URL | heki-0.11.0-py3-none-manylinux_2_28_x86_64.whl |
|---|---|
| Size | 13.6 MB |
| Tags | Linux glibc 2.28+ x86-64 Python 3 |
|
SHA-256 checksum How to use checksums |
a39cee939bcd99e38ce07198891f9b8e17b9c849264c9f012bae058c754f5a45
|
|
BLAKE2b-256 checksum How to use checksums |
43e6690056fb9e3413d8c597029176c2e0db3c716a0617317cf59655c1885b6a
|
| 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 27, 2026.
Transparency logRelease files / heki-0.11.0-py3-none-manylinux_2_28_aarch64.whl
| Download URL | heki-0.11.0-py3-none-manylinux_2_28_aarch64.whl |
|---|---|
| Size | 13.3 MB |
| Tags | Linux glibc 2.28+ ARM64 Python 3 |
|
SHA-256 checksum How to use checksums |
e3b60a85569514a797e47d2149dfd16b91553f074363bf9d61460298d4802afa
|
|
BLAKE2b-256 checksum How to use checksums |
273eb24975aea3aa94f82ef953dcce90b945eedbf4f046ce543194eee09a7bfb
|
| 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 27, 2026.
Transparency logRelease files / heki-0.11.0-py3-none-macosx_11_0_arm64.whl
| Download URL | heki-0.11.0-py3-none-macosx_11_0_arm64.whl |
|---|---|
| Size | 12.6 MB |
| Tags | Python 3 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
8c57c5ea3250bcec7854075f02c57ec1d8653e131ae2b1a2d076702207b9ad42
|
|
BLAKE2b-256 checksum How to use checksums |
f5612c5cc25c47ddab223748effee99d36cbdd2aa577a79e2c059495097b352e
|
| 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 27, 2026.
Transparency logRelease files / heki-0.11.0-py3-none-macosx_10_12_x86_64.whl
| Download URL | heki-0.11.0-py3-none-macosx_10_12_x86_64.whl |
|---|---|
| Size | 13.3 MB |
| Tags | Python 3 macOS 10.12+ x86-64 |
|
SHA-256 checksum How to use checksums |
a4566eb6ff15f3714a91932b3b78eb4b3661148764e5e4752e2f030cb35da19a
|
|
BLAKE2b-256 checksum How to use checksums |
7df21f4b342b65080eb701279871016116b841c59171df7d0afc8f51c48ca078
|
| 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 27, 2026.
Transparency logSecurity for heki 0.11.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.
Attestation for heki-0.11.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 27, 2026.
Transparency logA 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.