# heki

> Experimental static checker for Python that tracks side effects and mutations across function calls.


## Docs

- [Overview](https://heki.koxudaxi.dev/): 🧱 heki (壁, Japanese for "wall") is a static checker for Python, written in Rust
- [Scope and Limitations](https://heki.koxudaxi.dev/scope/): This page says what heki checks, what it leaves to other tools, where its knowledge comes from, and what it does when it cannot tell
- [Installation](https://heki.koxudaxi.dev/installation/): heki is a single executable: its Python package ships only that executable and installs no Python dependencies into your environment
- [Getting Started](https://heki.koxudaxi.dev/getting-started/): This page runs heki on a project, reads a diagnostic, applies a fix, and picks the rules
- [Rules](https://heki.koxudaxi.dev/rules/): heki has 53 rules in four families
- [Rule Precision](https://heki.koxudaxi.dev/precision/): A rule is exact once it is certified (below), and heuristic until then
- [Experimental Features](https://heki.koxudaxi.dev/experimental/): Experimental features can still change in behavior or precision, or be removed, in any release, and each change is listed in the release notes
- [Development](https://heki.koxudaxi.dev/development/): This page covers building and testing heki, its checks against CPython, the memory budget, the documentation, releases, and the crates

## Usage

- [Configuration](https://heki.koxudaxi.dev/configuration/): heki reads [tool.heki] from pyproject.toml, or a heki.toml / .heki.toml file with the same keys without the tool.heki prefix
- [Fixes and Safety](https://heki.koxudaxi.dev/fixes/): heki check --fix rewrites an OPT finding only when heki proves that the rewrite keeps what the program does
- [Adopting heki in a Code Base](https://heki.koxudaxi.dev/adoption/): An existing code base usually has findings you cannot fix at once
- [Configuration Advice](https://heki.koxudaxi.dev/recommend/): heki recommend analyzes a project as heki check does and prints advice on its configuration, with counts from the project and the keys to add to [tool.heki]
- [CLI Reference](https://heki.koxudaxi.dev/cli-reference/): Exit codes: 0 no diagnostic that fails the run (warnings and heuristic reports are reported without failing it), 1 an exact error diagnostic, or any diagnostic with --fail-on warning (lint.fail-on), among the Ratchet regressions when a baseline is used (or a refused --update-baseline, or pending --diff changes), 2 configuration / I/O / syntax errors

## Integrations

- [Editors (LSP)](https://heki.koxudaxi.dev/lsp/): heki server (alias heki lsp) is a Language Server Protocol server on stdin / stdout: it shows heki's diagnostics and fixes while you edit, with the results heki check reports
- [Coding Agents](https://heki.koxudaxi.dev/coding-agents/): heki gives coding agents (Claude Code, Codex, Cursor, and similar) the checks it gives people: every diagnostic says what was proven, where the evidence is, and what blocks a fix. heki inspect says what one function does, so an agent does not read its callees to find out

## Rules

- [async-blocking-call (EFF101)](https://heki.koxudaxi.dev/rules/async-blocking-call/): Family: Execution Effects (EFF) · Exact · Enabled by default · Severity error (a bug) · No automatic fix
- [async-blocking-fs (EFF105)](https://heki.koxudaxi.dev/rules/async-blocking-fs/): Family: Execution Effects (EFF) · Heuristic · Opt-in · Severity warning (slower code) · No automatic fix
- [async-def-as-sync-callback (EFF115)](https://heki.koxudaxi.dev/rules/async-def-as-sync-callback/): Family: Execution Effects (EFF) · Heuristic · Opt-in · Experimental · Severity error (a bug) · No automatic fix
- [cached-property-stale-mutation (MUT101)](https://heki.koxudaxi.dev/rules/cached-property-stale-mutation/): Family: Mutation & State (MUT) · Exact · Opt-in · Experimental · Severity error (a bug) · No automatic fix
- [cached-property-stale-read (MUT111)](https://heki.koxudaxi.dev/rules/cached-property-stale-read/): Family: Mutation & State (MUT) · Exact · Opt-in · Experimental · Severity error (a bug) · No automatic fix
- [cached-result-mutation (MUT114)](https://heki.koxudaxi.dev/rules/cached-result-mutation/): Family: Mutation & State (MUT) · Exact · Enabled by default · Severity error (a bug) · No automatic fix
- [call-owner-violation (MUT204)](https://heki.koxudaxi.dev/rules/call-owner-violation/): Family: Mutation & State (MUT) · Heuristic · Runs when its contract is declared · Severity error (a bug) · No automatic fix
- [change-lost-on-new-object (MUT119)](https://heki.koxudaxi.dev/rules/change-lost-on-new-object/): Family: Mutation & State (MUT) · Exact · Enabled by default · Severity error (a bug) · No automatic fix
- [circular-import-failure (IMP102)](https://heki.koxudaxi.dev/rules/circular-import-failure/): Family: Imports (IMP) · Heuristic · Opt-in · Experimental · Severity error (a bug) · No automatic fix
- [conditional-ownership-mutation (MUT112)](https://heki.koxudaxi.dev/rules/conditional-ownership-mutation/): Family: Mutation & State (MUT) · Heuristic · Opt-in · Experimental · Severity error (a bug) · No automatic fix
- [development-code-import (IMP104)](https://heki.koxudaxi.dev/rules/development-code-import/): Family: Imports (IMP) · Heuristic · Opt-in · Experimental · Severity error (a bug) · No automatic fix
- [development-dependency-at-import-time (IMP301)](https://heki.koxudaxi.dev/rules/development-dependency-at-import-time/): Family: Imports (IMP) · Heuristic · Opt-in · Experimental · Severity error (a bug) · No automatic fix
- [effect-boundary-violation (EFF201)](https://heki.koxudaxi.dev/rules/effect-boundary-violation/): Family: Execution Effects (EFF) · Heuristic · Runs when its contract is declared · Severity error (a bug) · No automatic fix
- [exclusive-object-fanout (EFF110)](https://heki.koxudaxi.dev/rules/exclusive-object-fanout/): Family: Execution Effects (EFF) · Heuristic · Opt-in · Experimental · Severity error (a bug) · No automatic fix
- [generator-never-iterated (EFF116)](https://heki.koxudaxi.dev/rules/generator-never-iterated/): Family: Execution Effects (EFF) · Heuristic · Opt-in · Experimental · Severity error (a bug) · No automatic fix
- [hash-attr-mutation (MUT107)](https://heki.koxudaxi.dev/rules/hash-attr-mutation/): Family: Mutation & State (MUT) · Heuristic · Opt-in · Severity error (a bug) · No automatic fix
- [immutable-quadratic-concat (OPT103)](https://heki.koxudaxi.dev/rules/immutable-quadratic-concat/): Family: Complexity Rewrites (OPT) · Exact · Opt-in · Severity warning (slower code) · No automatic fix
- [import-boundary-violation (IMP201)](https://heki.koxudaxi.dev/rules/import-boundary-violation/): Family: Imports (IMP) · Heuristic · Runs when its contract is declared · Experimental · Severity error (a bug) · No automatic fix
- [import-cycle (IMP101)](https://heki.koxudaxi.dev/rules/import-cycle/): Family: Imports (IMP) · Heuristic · Opt-in · Experimental · Severity warning (a bug that is rarely harmful) · No automatic fix
- [iterated-container-mutation (MUT113)](https://heki.koxudaxi.dev/rules/iterated-container-mutation/): Family: Mutation & State (MUT) · Heuristic · Opt-in · Experimental · Severity error (a bug) · No automatic fix
- [iterator-double-consumption (MUT106)](https://heki.koxudaxi.dev/rules/iterator-double-consumption/): Family: Mutation & State (MUT) · Heuristic · Opt-in · Severity error (a bug) · No automatic fix
- [list-front-insert (OPT121)](https://heki.koxudaxi.dev/rules/list-front-insert/): Family: Complexity Rewrites (OPT) · Exact · Opt-in · Severity warning (slower code) · Proven-safe suggestion (--fix --include-size-dependent)
- [list-front-pop (OPT120)](https://heki.koxudaxi.dev/rules/list-front-pop/): Family: Complexity Rewrites (OPT) · Exact · Opt-in · Severity warning (slower code) · Proven-safe suggestion (--fix --include-size-dependent)
- [list-quadratic-concat (OPT101)](https://heki.koxudaxi.dev/rules/list-quadratic-concat/): Family: Complexity Rewrites (OPT) · Exact · Enabled by default · Severity warning (slower code) · Safe fix (--fix)
- [lock-or-tx-held-across-io (EFF106)](https://heki.koxudaxi.dev/rules/lock-or-tx-held-across-io/): Family: Execution Effects (EFF) · Heuristic · Opt-in · Severity error (a bug) · No automatic fix
- [lock-reacquired-while-held (EFF109)](https://heki.koxudaxi.dev/rules/lock-reacquired-while-held/): Family: Execution Effects (EFF) · Heuristic · Opt-in · Experimental · Severity error (a bug) · No automatic fix
- [loop-carried-concat (DATA101)](https://heki.koxudaxi.dev/rules/loop-carried-concat/): Family: Data Pipelines (DATA) · Exact · Enabled by default · Severity warning (slower code) · No automatic fix
- [loop-db-query (EFF103)](https://heki.koxudaxi.dev/rules/loop-db-query/): Family: Execution Effects (EFF) · Exact · Enabled by default · Severity warning (slower code) · No automatic fix
- [loop-invariant-container-rebuild (OPT130)](https://heki.koxudaxi.dev/rules/loop-invariant-container-rebuild/): Family: Complexity Rewrites (OPT) · Exact · Opt-in · Severity warning (slower code) · Proven-safe suggestion (--fix --include-size-dependent)
- [loop-linear-dedup (OPT111)](https://heki.koxudaxi.dev/rules/loop-linear-dedup/): Family: Complexity Rewrites (OPT) · Exact · Opt-in · Severity warning (slower code) · Proven-safe suggestion (--fix --include-size-dependent)
- [loop-linear-list-lookup (OPT112)](https://heki.koxudaxi.dev/rules/loop-linear-list-lookup/): Family: Complexity Rewrites (OPT) · Heuristic · Off by default · Severity warning (slower code) · No automatic fix
- [loop-linear-membership (OPT110)](https://heki.koxudaxi.dev/rules/loop-linear-membership/): Family: Complexity Rewrites (OPT) · Exact · Opt-in · Severity warning (slower code) · Proven-safe suggestion (--fix --include-size-dependent)
- [loop-unpooled-client (EFF102)](https://heki.koxudaxi.dev/rules/loop-unpooled-client/): Family: Execution Effects (EFF) · Heuristic · Off by default · Severity warning (slower code) · No automatic fix
- [nested-loop-equijoin (OPT113)](https://heki.koxudaxi.dev/rules/nested-loop-equijoin/): Family: Complexity Rewrites (OPT) · Exact · Enabled by default · Severity warning (slower code) · No automatic fix
- [optional-dependency-at-import-time (IMP302)](https://heki.koxudaxi.dev/rules/optional-dependency-at-import-time/): Family: Imports (IMP) · Heuristic · Opt-in · Experimental · Severity error (a bug) · No automatic fix
- [read-owner-violation (MUT203)](https://heki.koxudaxi.dev/rules/read-owner-violation/): Family: Mutation & State (MUT) · Heuristic · Runs when its contract is declared · Severity error (a bug) · No automatic fix
- [readonly-param-mutation (MUT110)](https://heki.koxudaxi.dev/rules/readonly-param-mutation/): Family: Mutation & State (MUT) · Exact · Enabled by default · Severity warning (a bug that is rarely harmful) · No automatic fix
- [readonly-return-mutation (MUT202)](https://heki.koxudaxi.dev/rules/readonly-return-mutation/): Family: Mutation & State (MUT) · Heuristic · Runs when its contract is declared · Severity error (a bug) · No automatic fix
- [readonly-type-mutation (MUT108)](https://heki.koxudaxi.dev/rules/readonly-type-mutation/): Family: Mutation & State (MUT) · Heuristic · Opt-in · Severity error (a bug) · No automatic fix
- [readonly-view-mutation (MUT120)](https://heki.koxudaxi.dev/rules/readonly-view-mutation/): Family: Mutation & State (MUT) · Heuristic · Opt-in · Experimental · Severity error (a bug) · No automatic fix
- [recursion-error-as-value (EFF114)](https://heki.koxudaxi.dev/rules/recursion-error-as-value/): Family: Execution Effects (EFF) · Heuristic · Opt-in · Experimental · Severity error (a bug) · No automatic fix
- [sentinel-lost-in-deepcopy (MUT118)](https://heki.koxudaxi.dev/rules/sentinel-lost-in-deepcopy/): Family: Mutation & State (MUT) · Heuristic · Off by default · Severity error (a bug) · No automatic fix
- [set-dict-quadratic-merge (OPT102)](https://heki.koxudaxi.dev/rules/set-dict-quadratic-merge/): Family: Complexity Rewrites (OPT) · Exact · Enabled by default · Severity warning (slower code) · Safe fix (--fix)
- [set-order-output (EFF112)](https://heki.koxudaxi.dev/rules/set-order-output/): Family: Execution Effects (EFF) · Heuristic · Opt-in · Experimental · Severity error (a bug) · No automatic fix
- [shallow-copy-nested-mutation (MUT115)](https://heki.koxudaxi.dev/rules/shallow-copy-nested-mutation/): Family: Mutation & State (MUT) · Heuristic · Opt-in · Severity error (a bug) · No automatic fix
- [summary-effect-regression (MUT103)](https://heki.koxudaxi.dev/rules/summary-effect-regression/): Family: Mutation & State (MUT) · Heuristic · Opt-in · Severity error (a bug) · No automatic fix
- [unresolved-guarded-call (MUT207)](https://heki.koxudaxi.dev/rules/unresolved-guarded-call/): Family: Mutation & State (MUT) · Heuristic · Runs when its contract is declared · Severity error (a bug) · No automatic fix
- [unresolved-guarded-import (IMP202)](https://heki.koxudaxi.dev/rules/unresolved-guarded-import/): Family: Imports (IMP) · Heuristic · Runs when its contract is declared · Experimental · Severity error (a bug) · No automatic fix
- [unresolved-guarded-read (MUT206)](https://heki.koxudaxi.dev/rules/unresolved-guarded-read/): Family: Mutation & State (MUT) · Heuristic · Runs when its contract is declared · Severity error (a bug) · No automatic fix
- [unresolved-guarded-write (MUT205)](https://heki.koxudaxi.dev/rules/unresolved-guarded-write/): Family: Mutation & State (MUT) · Heuristic · Runs when its contract is declared · Severity error (a bug) · No automatic fix
- [unretained-async-task (EFF107)](https://heki.koxudaxi.dev/rules/unretained-async-task/): Family: Execution Effects (EFF) · Heuristic · Opt-in · Severity error (a bug) · No automatic fix
- [write-owner-violation (MUT201)](https://heki.koxudaxi.dev/rules/write-owner-violation/): Family: Mutation & State (MUT) · Heuristic · Runs when its contract is declared · Severity error (a bug) · No automatic fix
- [write-without-invalidation (MUT208)](https://heki.koxudaxi.dev/rules/write-without-invalidation/): Family: Mutation & State (MUT) · Heuristic · Runs when its contract is declared · Severity error (a bug) · No automatic fix
