Skip to main content

Leesh

A leash for LLM-written Python.

Why?

Python written by LLMs sucks.

Leesh is the remedy for that. It's based on a handful of good ideas:

  • Functional Core, Imperative Shell.

  • Parse, don't validate.

  • The Zen of Python: "There should be one, and preferably only one, obvious way to do it."

  • Separate business logic from code that talks to the outside world (data you don't control).

  • Isolate side effects.

  • Build on pure functions and values.

  • Don't rely on global state.

  • Inject your dependencies; it makes testing easier.

  • Parse outside data with Pydantic, convert it to dataclasses, then run the business logic.

  • Model domain data as well-structured dataclasses.

  • Prefer functions to methods.

  • You rarely need subclassing.

  • Raise exceptions only in specific places.

  • No default arguments or default values. Be explicit: you're not the one writing the code, the LLM is.

How it works

Every file belongs to a layer, decided by its path: core, port, shell, adapter, router, boundary, transaction, test. Each layer has rules about what it may import and which effects it may perform. Imports are followed across packages, re-exports and __init__.py files, so a dependency can't be laundered through a re-export.

Install

Install Leesh from PyPI. The CLI runs a bundled Rust executable; clients do not need Cargo or a Rust toolchain.

uv tool install leesh
leesh check

Run it without installing a persistent tool:

uvx leesh check

For a project's development dependencies, use uv add --dev leesh and uv run leesh check. To pin the Git source instead:

uv add --dev 'leesh @ git+https://github.com/denismaciel/lint-it.git@v0.20.2'

Or run it with pre-commit:

repos:
  - repo: https://github.com/denismaciel/lint-it
    rev: v0.20.2
    hooks:
      - id: leesh

Git and source-distribution installs download the matching executable from that release and verify its pinned SHA-256. Installed packages run offline. Prebuilt wheels are also attached to the release. Supported platforms: Linux x86-64 and ARM64 (including musl), macOS Intel (10.13+) and Apple Silicon (11+), and Windows x86-64. Python 3.12+ remains required.

The lint-it command remains an alias. Existing lint-it.toml files, the lint_it Python import, Git repository URLs, and native release asset names stay compatible.

Use

leesh init --layout domains   # write a starter lint-it.toml
leesh check                   # check the whole workspace
leesh check src/app/orders    # report findings under these paths only
leesh report                  # rank findings by rule, layer edge, target and area
leesh baseline                # record current findings so only new ones fail
leesh classify src            # show each file's layer and the pattern that matched
leesh explain LIT101          # show a rule's documentation
leesh rules                   # list every rule

check finds the workspace root from the nearest lint-it.toml (or pyproject.toml if there is none), discovers every package with a pyproject.toml below it, and always analyzes the whole workspace so that imports are followed across files and packages. Output formats are text, json ({"findings": [...], "summary": {...}}) and github (workflow annotations). Exit status is 0 when clean, 1 when there are findings, and 2 for usage errors or a manifest that cannot be loaded. Files are analyzed with native worker threads; --jobs 1 uses one worker.

Adopting Leesh on an existing codebase

Describe the code you have instead of moving it first: a custom layout maps today's directories to layers, and custom layers name the roles that don't fit the built-in ones (a Temporal workflow is a deterministic router). Then:

  1. leesh report shows which rules, layer edges and imported modules produce the findings, so you can tell policy questions from real debt.
  2. Settle policy in the manifest: [[allowed_dependencies]] for modules that act as ports, [[ignore]] for a rule you are not adopting yet in a given place, [conventions] for your framework bases. Each needs a reason.
  3. Set workspace.baseline and run leesh baseline. check now fails only on new findings, and on baseline entries that no longer match until you run leesh baseline --prune, so the baseline can only shrink.

Layers

Layer Holds May import (default)
core decisions, values, policies core, port
port interfaces the core needs core, port
shell orchestration of core and ports core, port, shell
adapter implementations of ports core, port, adapter
router HTTP handlers shell, boundary, router, transaction
boundary entry points, configuration, schemas anything
transaction units of work, migrations anything
test tests and fixtures anything
marker __init__.py files anything (followed, never a target)

A package's layout maps paths to layers. The built-in layouts are domains (src/<pkg>/domains/<domain>/{core,model,policy,ports,service}.py, app/, db/, integrations/), hexagonal (domain/, application/, adapters/, web/), flat (everything is shell, except model.py, core.py, policy.py, ports.py, adapters/ and cli.py), boundary, and test-support. A conventional module may grow into a package of the same name: the files of domains/orders/core/ are core like domains/orders/core.py. A package's kind (server, client or library) controls whether other packages may depend on it. Custom layers ([layers.<name>]) follow a built-in layer's rules with their own dependency policy.

See docs/rules.md for every rule and docs/configuration.md for the manifest.

Rust implementation

The installed CLI uses Rust. The original Python implementation remains in the package for compatibility and differential testing. To build Rust locally:

cargo build --locked --release --manifest-path rust/Cargo.toml
rust/target/release/lint-it-rust check

It reuses Ruff's parser, parallelizes analysis, and preserves Leesh's rules and CLI commands. See build and verification instructions and the Python/Rust performance comparison.

Development

cargo build --locked --release --manifest-path rust/Cargo.toml
export LINT_IT_NATIVE_BINARY="$PWD/rust/target/release/lint-it-rust"
make dev check test
make build release-check
uv run leesh rules --format markdown > docs/rules.md  # after changing a rule docstring

Python packaging uses uv and uv_build with a small native-artifact adapter. See release instructions for preparation and tagged releases.

A rule is a class with a code, a name, a docstring (its documentation) and check(file: SourceFile). Register it in src/lint_it/rules/registry.py.

License

MIT. See LICENSE.

Metadata

Release files for leesh 0.20.2

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

Source distribution (sdist)

Source distribution for leesh 0.20.2
File Size Uploaded Provenance Actions
leesh-0.20.2.tar.gz 461.2 kB With provenance Details for leesh-0.20.2.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for leesh 0.20.2
File Actions
leesh-0.20.2-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for leesh-0.20.2-py3-none-win_amd64.whl
leesh-0.20.2-py3-none-manylinux_2_28_x86_64.musllinux_1_2_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64, Linux musl 1.2+ x86-64 Details for leesh-0.20.2-py3-none-manylinux_2_28_x86_64.musllinux_1_2_x86_64.whl
leesh-0.20.2-py3-none-manylinux_2_28_aarch64.musllinux_1_2_aarch64.whl Python 3 none Linux musl 1.2+ ARM64, Linux glibc 2.28+ ARM64 Details for leesh-0.20.2-py3-none-manylinux_2_28_aarch64.musllinux_1_2_aarch64.whl
leesh-0.20.2-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for leesh-0.20.2-py3-none-macosx_11_0_arm64.whl
leesh-0.20.2-py3-none-macosx_10_13_x86_64.whl Python 3 none macOS 10.13+ x86-64 Details for leesh-0.20.2-py3-none-macosx_10_13_x86_64.whl

Total release size: 13.0 MB

Release files / leesh-0.20.2.tar.gz

Download URL leesh-0.20.2.tar.gz
Size 461.2 kB
Tags Source
SHA-256 checksum
How to use checksums
e0fab1e8ae62e55a4ed692fec02682d134f5ffb424189b2fa7243f61c260c62d
BLAKE2b-256 checksum
How to use checksums
630745283e40fae549698466d2f42ef2c07fe94c83263063cde1228cf1d39a47
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 16, 2026.

Transparency log

Release files / leesh-0.20.2-py3-none-win_amd64.whl

Download URL leesh-0.20.2-py3-none-win_amd64.whl
Size 2.4 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
ec8a6befe7185fc8e529934651dbd72344316d27526de3fccf9c069897656064
BLAKE2b-256 checksum
How to use checksums
08d3b9f31fe2479a0fdddf67e87c1376aa4246d95aa8fe90bc5f93bfe27acfc8
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 16, 2026.

Transparency log

Release files / leesh-0.20.2-py3-none-manylinux_2_28_x86_64.musllinux_1_2_x86_64.whl

Download URL leesh-0.20.2-py3-none-manylinux_2_28_x86_64.musllinux_1_2_x86_64.whl
Size 2.7 MB
Tags Linux glibc 2.28+ x86-64 Linux musl 1.2+ x86-64 Python 3
SHA-256 checksum
How to use checksums
2f3cdf24a982c6e534e893bbd2140a9e00cf4d76bed9fd9f8ffd9e050c893866
BLAKE2b-256 checksum
How to use checksums
01ed873e623e076a37ce72ee9f36a53e8a3b4b82abc0f106506ee1abcd9cb574
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 16, 2026.

Transparency log

Release files / leesh-0.20.2-py3-none-manylinux_2_28_aarch64.musllinux_1_2_aarch64.whl

Download URL leesh-0.20.2-py3-none-manylinux_2_28_aarch64.musllinux_1_2_aarch64.whl
Size 2.6 MB
Tags Linux glibc 2.28+ ARM64 Linux musl 1.2+ ARM64 Python 3
SHA-256 checksum
How to use checksums
008abebb6f1adc0724c25774b1b0b3ceae25ade4070d90452409f2c2142900b7
BLAKE2b-256 checksum
How to use checksums
08a87a98d0c792ffbaa693caedd8969bf1a10de9a088e6e40658617d6b886d58
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 16, 2026.

Transparency log

Release files / leesh-0.20.2-py3-none-macosx_11_0_arm64.whl

Download URL leesh-0.20.2-py3-none-macosx_11_0_arm64.whl
Size 2.4 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
44e18ba7250f7964dabd53dbc090decc60cea2f44e576664baa8f51c196cd6b5
BLAKE2b-256 checksum
How to use checksums
d3719ed98cfde35ad2c9904921b93be17f71ab93417d662104bc4c2c65297250
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 16, 2026.

Transparency log

Release files / leesh-0.20.2-py3-none-macosx_10_13_x86_64.whl

Download URL leesh-0.20.2-py3-none-macosx_10_13_x86_64.whl
Size 2.5 MB
Tags Python 3 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
11cd06f9347d996c6c7f5aefcd7ed99bf9b8348c8aec869714b15e5e5738e3e6
BLAKE2b-256 checksum
How to use checksums
5083f04c076ce10ea940bb3b188106fae64fb0c37f8349aa949e05439a390ae3
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 16, 2026.

Transparency log

Security for leesh 0.20.2

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 6 files in this release have been uploaded with provenance metadata.

Select from 6 files

Attestation for leesh-0.20.2.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 16, 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