thai-lint
The AI Linter - Catch the mistakes AI coding assistants keep making.
thailint detects anti-patterns that AI tools frequently introduce: duplicate code, excessive nesting, magic numbers, SRP violations, and more. It works across Python, TypeScript, JavaScript, and Rust with unified rules - filling gaps that existing linters miss.
Installation
pip install thailint
Or run instantly with uvx (no install required):
uvx thailint dry src/
Or with Docker:
docker run --rm -v $(pwd):/data washad/thailint:latest --help
Quick Start
# Generate a config file (optional)
thailint init-config
# Run any linter
thailint dry src/
That's it. See violations, fix them, ship better code.
Available Linters
| Linter | What It Catches | Command | Docs |
|---|---|---|---|
| DRY | Duplicate code across files | thailint dry src/ |
Guide |
| Nesting | Deeply nested if/for/while blocks | thailint nesting src/ |
Guide |
| Magic Numbers | Unnamed numeric literals | thailint magic-numbers src/ |
Guide |
| Performance | O(n²) patterns: string += in loops, regex in loops | thailint perf src/ |
Guide |
| SRP | Classes doing too much | thailint srp src/ |
Guide |
| File Header | Missing documentation headers | thailint file-header src/ |
Guide |
| Stateless Class | Classes that should be functions | thailint stateless-class src/ |
Guide |
| Collection Pipeline | Loops with embedded filtering | thailint pipeline src/ |
Guide |
| Method Property | Methods that should be @property | thailint method-property src/ |
Guide |
| File Placement | Files in wrong directories | thailint file-placement src/ |
Guide |
| Lazy Ignores | Unjustified linting suppressions | thailint lazy-ignores src/ |
Guide |
| Improper Logging | Print statements and conditional verbose patterns | thailint improper-logging src/ |
Guide |
| Stringly Typed | Strings that should be enums | thailint stringly-typed src/ |
Guide |
| LBYL | Look Before You Leap anti-patterns | thailint lbyl src/ |
Guide |
| Law of Demeter | Deep object chain access (reaching through objects) | thailint law-of-demeter src/ |
Guide |
| Version Freshness | EOL/outdated runtime versions in infra files | thailint version-freshness . |
Guide |
| Unwrap Abuse | .unwrap()/.expect() that panic at runtime (Rust) |
thailint unwrap-abuse src/ |
Guide |
| Clone Abuse | .clone() abuse: loops, chains, unnecessary (Rust) |
thailint clone-abuse src/ |
Guide |
| Blocking Async | Blocking std:: calls in async functions (Rust) | thailint blocking-async src/ |
Guide |
Configuration
Create .thailint.yaml in your project root:
dry:
enabled: true
min_duplicate_lines: 4
nesting:
enabled: true
max_nesting_depth: 3
magic-numbers:
enabled: true
allowed_numbers: [-1, 0, 1, 2, 10, 100]
Or add a [tool.thailint] section to your pyproject.toml:
[tool.thailint]
dry = {enabled = true, min_duplicate_lines = 4}
nesting = {enabled = true, max_nesting_depth = 3}
magic-numbers = {enabled = true, allowed_numbers = [-1, 0, 1, 2, 10, 100]}
Config precedence: .thailint.yaml > .thailint.json > pyproject.toml.
Or generate one automatically:
thailint init-config --preset lenient # or: strict, standard
See Configuration Reference for all options.
Output Formats
# Human-readable (default)
thailint dry src/
# JSON for CI/CD
thailint dry --format json src/
# SARIF for GitHub Code Scanning
thailint dry --format sarif src/ > results.sarif
Ignoring Violations
# Line-level
timeout = 3600 # thailint: ignore[magic-numbers]
# File-level
# thailint: ignore-file[dry]
Or in config:
dry:
ignore:
- "tests/"
- "**/generated/**"
See How to Ignore Violations for all 5 ignore levels.
CI/CD Integration
# GitHub Actions
- name: Run thailint
run: |
pip install thailint
thailint --parallel dry src/
thailint --parallel nesting src/
Use --parallel for faster linting on large codebases (2-4x speedup on multi-core systems).
Exit codes: 0 = success, 1 = violations found, 2 = error.
Documentation
- Quick Start Guide - Get running in 5 minutes
- Configuration Reference - All config options
- Troubleshooting - Common issues
- Full Documentation - Everything else
Contributing
Contributions welcome! See CONTRIBUTING.md for guidelines.
git clone https://github.com/be-wise-be-kind/thai-lint.git
cd thai-lint
poetry install
just test
License
MIT License - see LICENSE for details.
Support
Metadata
Release files for thailint 0.24.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 | |
|---|---|---|---|
| thailint-0.24.0.tar.gz | 346.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| thailint-0.24.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 842.5 kB
Release files / thailint-0.24.0.tar.gz
| Download URL | thailint-0.24.0.tar.gz |
|---|---|
| Size | 346.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
11e84b7f5b3fbe708bbcb887a269e62fe9355038444bd72f76c3b887fbb1e62a
|
|
BLAKE2b-256 checksum How to use checksums |
4293a3b3b058d233f72834afd077ca0fa67c8cff93b4b0ccd93c949828575564
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.12.3 Linux/6.18.7-76061807-generic
|
Release files / thailint-0.24.0-py3-none-any.whl
| Download URL | thailint-0.24.0-py3-none-any.whl |
|---|---|
| Size | 495.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
43fe99cc48593faee959e037be05c69b520acbb5a4ea643528449fa6b2b62bec
|
|
BLAKE2b-256 checksum How to use checksums |
557756ecd469a180160daf89300383b3125178e1f8dcc88f48a83fede3b18b17
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.4.1 CPython/3.12.3 Linux/6.18.7-76061807-generic
|