Skip to main content

smelt

A linter for Python architecture boundaries and code smells.

If the same feedback keeps coming up in code review, make it a rule. Smelt puts those decisions in smelt.yml, where coding agents can read them, check their changes and fix findings before opening a PR. Commit hooks and CI enforce the same policy.

Keep database imports out of application code. Keep package internals behind their public API. Catch truthiness fallbacks that discard valid values, or tests that wait without a timeout. Choose the checks that match your project from the rule catalog, or add a rule for a recurring pattern.

Get started

Requires Python 3.12+. Install smelt-cli from PyPI:

uv tool install smelt-cli
smelt init --maintainability

Upgrading to 0.13.0? Follow the upgrade checklist for configuration keys, rule names and hook pins.

Review the generated smelt.yml: it proposes a starting policy from your layout and selects source and test checks. You decide which conventions to adopt. Small libraries can use individual rules without declaring layers or features.

Turn review feedback into policy

For a project with src/app/ and tests/, this policy encodes two recurring review comments: application code must not depend on infrastructure, and optional defaults should distinguish None from valid falsy values.

# smelt.yml
version: 1

project:
  root_packages: [app]
  source_roots: [src]
  test_roots: [tests]

architecture:
  layers:
    domain: {path: domain, may_depend_on: []}
    application: {path: application, may_depend_on: [domain]}
    infrastructure: {path: infrastructure, may_depend_on: [domain, application]}

rules:
  visibility/internal-public-member: warning
  visibility/internal-public-module-symbol: warning
  visibility/internal-public-attribute: warning
  visibility/test-only-public-function: warning
  visibility/test-only-public-attribute: warning
  typing/implicit-optional-default: warning
  tests/unbounded-wait: warning

Smelt catches an import that crosses the declared boundary:

# src/app/application/orders.py
from app.infrastructure.database import SqlOrderRepository  # SMT101

Application code should depend on an interface in an allowed layer; wire the concrete repository in your composition root. Smelt also flags this fallback:

def page_size(limit: int | None = None) -> int:
    return limit or 100  # SMT321: also replaces an explicit 0

If only None means "not supplied", use limit if limit is not None else 100. If treating zero as missing is deliberate, keep it with a reasoned exception.

smelt check --show-hints --fail-on warning
smelt explain SMT101  # why it fired and how to fix it

The same configuration can describe feature boundaries and third-party dependencies, package APIs and source conventions, and test conventions. Most checks require explicit selection or an applicable policy; see rule activation.

Use the visibility rules to review unnecessarily public definitions and APIs whose only observed users are tests.

Enable individual rules in YAML by their family/finding names or SMT codes. on uses the named rule's catalog severity. Families and ALL can disable or cap already-active rules in YAML. Use smelt check --select modeling to explore a family and smelt rules --unconfigured to discover rules to review.

In a uv workspace, project: {workspace: uv} in the root smelt.yml checks every member as one project. A member can add its own smelt.yml with rule and convention exceptions for its files; see uv workspaces.

Catch it at commit time

Smelt uses the pre-commit hook format. With prek, add this to .pre-commit-config.yml:

repos:
  - repo: local
    hooks:
      - id: smelt-staged
        name: smelt
        entry: smelt check --staged --fail-on warning
        language: python
        additional_dependencies: [smelt-cli==0.13.0]
        pass_filenames: false
        always_run: true
        require_serial: true
prek install

The hook installs a pinned wheel in its own environment and checks the Git index, including partial staging, deletions and policy changes. New warnings and errors block the commit. The agent gets a finding, fixes it, stages the change and retries. Existing pre-commit setups can use the same configuration.

Use smelt check --fail-on warning in CI for the full project check. See integrations for GitHub Actions, source hooks and other installation options. prek run --all-files runs the hook too, but the staged hook still checks the index; use smelt check to review the working tree.

Give agents a short feedback loop

Install the official Smelt skill in your project:

smelt skill install

Each smelt-cli release bundles the skill with its complete offline rule, configuration and command reference. It installs in .agents/skills/smelt; use --destination <skill-directory> for another location. After upgrading Smelt, run smelt skill install --force to replace the previous skill and remove obsolete references. Replacement includes local edits, so keep project-specific instructions in AGENTS.md or CLAUDE.md. Installation works before smelt init and leaves project policy unchanged. See CLI and reports.

Add this to your AGENTS.md or CLAUDE.md:

Before editing, run `smelt context <feature-or-path>` to read the applicable policy.
After editing, run `smelt check --changed --format concise` and address new findings.
Use `smelt explain <code>` for the rule's intent and repair advice.
Run focused tests, stage your changes, then run `prek run --all-files`.
Inspect and stage any hook fixes, and rerun until the checks pass.
Do not disable rules or record debt just to pass a check.

Findings include locations, evidence and repair advice. Changed checks compare with HEAD by default; use --changed --base origin/main to review a branch. For an existing codebase, debt baselines let you adopt a policy without requiring every old finding to be fixed in the first PR.

Fast enough to run between edits

Local checks reuse a worker and cache analysis by content. Staged checks read Git objects directly, including partially staged files, and reuse unchanged results. An edit still checks its effects on other modules.

One documented benchmark used 250 modules with 12 methods each on Windows 11 / Python 3.14. Warm medians, including process startup:

Check Unchanged retry After a Python edit
Staged CLI, transitive imports + member checks 49 ms 380 ms
Complete prek hook, member checks 227 ms 612 ms

These are measured examples, not a latency guarantee. The first cache build took about 2.6–3.9 seconds in that run; installation and other hooks are excluded. See the setup, raw samples and reproduction commands for the exact policies and timings.

Learn more

Smelt analyzes Python source statically. Use it alongside tests, a type checker and Ruff; advisory findings still need review. See scope and limits. Run Smelt with a Python version that can parse your code. Release wheels include the native client; building from source requires Rust 1.88+ and a platform linker.

Metadata

Release files for smelt-cli 0.13.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 smelt-cli 0.13.0
File Size Uploaded Provenance Actions
smelt_cli-0.13.0.tar.gz 1.2 MB With provenance Details for smelt_cli-0.13.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for smelt-cli 0.13.0
File Actions
smelt_cli-0.13.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details for smelt_cli-0.13.0-py3-none-win_amd64.whl
smelt_cli-0.13.0-py3-none-manylinux_2_28_x86_64.whl Python 3 none Linux glibc 2.28+ x86-64 Details for smelt_cli-0.13.0-py3-none-manylinux_2_28_x86_64.whl
smelt_cli-0.13.0-py3-none-manylinux_2_28_aarch64.whl Python 3 none Linux glibc 2.28+ ARM64 Details for smelt_cli-0.13.0-py3-none-manylinux_2_28_aarch64.whl
smelt_cli-0.13.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details for smelt_cli-0.13.0-py3-none-macosx_11_0_arm64.whl
smelt_cli-0.13.0-py3-none-macosx_10_12_x86_64.whl Python 3 none macOS 10.12+ x86-64 Details for smelt_cli-0.13.0-py3-none-macosx_10_12_x86_64.whl

Total release size: 9.3 MB

Release files / smelt_cli-0.13.0.tar.gz

Download URL smelt_cli-0.13.0.tar.gz
Size 1.2 MB
Tags Source
SHA-256 checksum
How to use checksums
8dfd36d9a7ffe403e9f4e3fe00e0309e129fb2a541f07d2c2b40837d549855fd
BLAKE2b-256 checksum
How to use checksums
be37ddb3b3a3dbde3c5431a63a117c0efaf998f9e632def7499abcfe00b148be
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 18, 2026.

Transparency log

Release files / smelt_cli-0.13.0-py3-none-win_amd64.whl

Download URL smelt_cli-0.13.0-py3-none-win_amd64.whl
Size 1.6 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
7067ca65ae70ffe97e06e3b0dc50606d55083e9af3541ac0ca13775bc565e0ec
BLAKE2b-256 checksum
How to use checksums
7cd4bd63fda535c81ec4b41c1d197e2bc4f1fd43812451e5317465b43824bae3
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 18, 2026.

Transparency log

Release files / smelt_cli-0.13.0-py3-none-manylinux_2_28_x86_64.whl

Download URL smelt_cli-0.13.0-py3-none-manylinux_2_28_x86_64.whl
Size 1.7 MB
Tags Linux glibc 2.28+ x86-64 Python 3
SHA-256 checksum
How to use checksums
6fd4bed6a03e636754ec8a5a84a268332ad5e3f2eb0b669985562c58c1f55ba0
BLAKE2b-256 checksum
How to use checksums
a07d7f4853f0543374e6325f3ed216f6a9318765fce22c69bc5e64e1b7dfc97a
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 18, 2026.

Transparency log

Release files / smelt_cli-0.13.0-py3-none-manylinux_2_28_aarch64.whl

Download URL smelt_cli-0.13.0-py3-none-manylinux_2_28_aarch64.whl
Size 1.6 MB
Tags Linux glibc 2.28+ ARM64 Python 3
SHA-256 checksum
How to use checksums
8e2a10d0a115570bbbc543955b78cadaa0db9b1fa53b687905c3e976ad619921
BLAKE2b-256 checksum
How to use checksums
2e0b6e6108ef48ffbb75cd482ae57694b0dba62b88f00317cf1eca03f9ea5e89
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 18, 2026.

Transparency log

Release files / smelt_cli-0.13.0-py3-none-macosx_11_0_arm64.whl

Download URL smelt_cli-0.13.0-py3-none-macosx_11_0_arm64.whl
Size 1.6 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
5527d8904c74c09daabf5e3bb25c4658ea194f44524268b1f5740d1c29fc1a24
BLAKE2b-256 checksum
How to use checksums
952913d42d85ae49fc0c345b3faab6ed70d4200524b44b33fb36a836c3f81b91
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 18, 2026.

Transparency log

Release files / smelt_cli-0.13.0-py3-none-macosx_10_12_x86_64.whl

Download URL smelt_cli-0.13.0-py3-none-macosx_10_12_x86_64.whl
Size 1.6 MB
Tags Python 3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
19f15d463f5a5a4fed1718b88e514c9e74b4f90eea04417e1180e12adccfa45c
BLAKE2b-256 checksum
How to use checksums
7e6a90ace9322d70a50253b15b287302e2fc85c3d0cf35f5e81564f08d15fb09
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 18, 2026.

Transparency log

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

Select from 6 files

Attestation for smelt_cli-0.13.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 18, 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