pylint-clean-architecture
A powerful, highly-opinionated Pylint plugin for enforcing Clean Architecture (The Onion Architecture) principles in Python projects.
This linter acts as a "GPS" for your codebase, preventing technical debt by strictly enforcing architectural boundaries, dependency rules, and design patterns.
Features
- Layer Boundary Enforcement: Prevents inner layers (Domain, UseCase) from importing outer layers (Infrastructure, Interface).
- Dependency Injection Checks: Forbids direct instantiation of infrastructure classes in UseCases.
- Design Pattern Enforcement: Detects "naked returns" from repositories, delegation anti-patterns, and more.
- Law of Demeter: Enforces loose coupling by flagging deep method chains.
- Contract Integrity: Ensures Infrastructure classes correctly implement Domain Protocols.
- Anti-Bypass Guard: Prevents "lazy" disabling of linter rules without justification.
Installation
pip install pylint-clean-architecture
Usage
Add the plugin to your pyproject.toml or Pylint configuration:
[tool.pylint.main]
load-plugins = ["clean_architecture_linter"]
Run Pylint as usual:
pylint src/
AI Coding Assistant Support
The clean-arch-init command generates architectural instructions for AI agents (like Cursor or GitHub Copilot) to prevent "Split Brain" issues by teaching the AI your project's rules before it writes code.
Usage:
clean-arch-init
Outcome: This creates a customized .agent/instructions.md file based on the layer names defined in the project's pyproject.toml.
Configuration
The linter is configured via [tool.clean-arch] in pyproject.toml.
[tool.clean-arch]
# 1. Project Type Presets (generic, cli_app, fastapi_sqlalchemy)
project_type = "generic"
# 2. Strict Visibility Enforcement
visibility_enforcement = true
# 3. Custom Layer Mapping (Map directory regex patterns to layers)
[tool.clean-arch.layer_map]
"services" = "UseCase"
"infrastructure/clients" = "Infrastructure"
"domain/models" = "Domain"
Rules
See RULES.md for a complete catalog of enforced rules and "Clean Fix" examples.
Contributing
- Fork the repo.
- Install dependencies:
make install. - Run tests:
make test. - Submit a PR.
Metadata
Release files for clean-architecture-linter-plugin 1.2.2
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 |
|---|---|---|---|---|
| clean_architecture_linter_plugin-1.2.2.tar.gz | 27.8 kB | With provenance | Details for clean_architecture_linter_plugin-1.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| clean_architecture_linter_plugin-1.2.2-py3-none-any.whl | Python 3 | none | any | Details for clean_architecture_linter_plugin-1.2.2-py3-none-any.whl |
Total release size: 59.7 kB
Release files / clean_architecture_linter_plugin-1.2.2.tar.gz
| Download URL | clean_architecture_linter_plugin-1.2.2.tar.gz |
|---|---|
| Size | 27.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b5254b28b280ff8d93d2d199e32f07246eb3616f44a8e279e434c976af6d9058
|
|
BLAKE2b-256 checksum How to use checksums |
0dc5e8467be4b146adc430ccd92956cc65016ec0c05a9a632bac51dade41b6ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Jan 12, 2026.
Transparency logRelease files / clean_architecture_linter_plugin-1.2.2-py3-none-any.whl
| Download URL | clean_architecture_linter_plugin-1.2.2-py3-none-any.whl |
|---|---|
| Size | 31.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1f17b7811b266c53280d85c1de139915d1143fedfc366808dd7275625b7a7e01
|
|
BLAKE2b-256 checksum How to use checksums |
52b689246dec1248300abdad504b7d0d25d9d865e2a34d8ee9f93574c9c282a0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.7
|
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 Jan 12, 2026.
Transparency logSecurity for clean-architecture-linter-plugin 1.2.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
Both files in this release have been uploaded with provenance metadata.
Attestation for clean_architecture_linter_plugin-1.2.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 Jan 12, 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.