Enforce file size constraints
Project description
loq
Enforce file size constraints.
loq is a fast, minimal tool that keeps codebases LLM-context-friendly and human-maintainable by enforcing hard per-file line limits. The name visually resembles "loc" (lines of code).
LLMs happily generate big files. Big files burn context, slow reviews, and become dumping grounds. loq provides a hard constraint that stops files from growing too large.
Install
pip install loq
# Or with uv
uv tool install loq
# Or with cargo
cargo install loq
Quick start
# zero-config: uses built-in defaults
loq
# explicit check
loq check src/
# stdin list
git diff --cached --name-only | loq check -
Output
Violations show the file, line count, and how far over the limit:
✖ src/utils.py
512 lines (+12 over limit)
Summary:
Found 2 violations in 150 checked files.
✖ 2 Errors
⚠ 0 Warnings
✔ 148 Passed
Time: 12ms
Config
Create a config with defaults:
loq init
Baseline a legacy repo (exempts current errors, blocks new ones):
loq init --baseline
Config discovery walks upward from each file’s directory and uses the nearest loq.toml. Patterns are matched against paths relative to the config directory.
respect_gitignore defaults to true and applies the root .gitignore when scanning. The built-in defaults do not add any exclude patterns.
Development
Install Rust (once):
rustup default stable
Common tasks:
# build
cargo build
# run the CLI locally
cargo run -p loq -- check .
# install locally
cargo install --path crates/loq_cli
# quick checks (fmt + clippy)
just check
# benchmark against a public repo
just bench https://github.com/astral-sh/ruff
Enable git hooks in this repo:
git config core.hooksPath .githooks
Default loq.toml
default_max_lines = 500
respect_gitignore = true
exclude = []
exempt = []
# Last match wins. Put general rules first and overrides later.
[[rules]]
path = "**/*.tsx"
max_lines = 300
severity = "warning"
[[rules]]
path = "tests/**/*"
max_lines = 500
License
MIT.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file loq-0.1.0a1-py3-none-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: loq-0.1.0a1-py3-none-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: Python 3, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
504f4ec08ab3ea06f4d77b9c8be93fef301d20983b644a3e0a898901062f6b3d
|
|
| MD5 |
60c8dfa0bc2f33f2c505e818cc549604
|
|
| BLAKE2b-256 |
5faa08195244fbfe00de90623f6b68898bf4db93f7d771509bed50064252914e
|
File details
Details for the file loq-0.1.0a1-py3-none-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: loq-0.1.0a1-py3-none-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 1.2 MB
- Tags: Python 3, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a82a1bccccb3219124c71d4be8e11936032394f824323e487ff95b5e481b91e0
|
|
| MD5 |
94ba467a069b71ab967acdb2c8f59036
|
|
| BLAKE2b-256 |
6097d9ca93f00dfb5c57fa526addb0854ca577280db017af185e9bda69ef3a12
|
File details
Details for the file loq-0.1.0a1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: loq-0.1.0a1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 1.1 MB
- Tags: Python 3, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.24 {"installer":{"name":"uv","version":"0.9.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c6cc3450560a523fd7c5f04bbdcc8f41ea357f997f0be11ee975952432442a5b
|
|
| MD5 |
28c8601e664a84943ca898057f6bbdd4
|
|
| BLAKE2b-256 |
9f3e6293b6df1f22b34739211a515f2cdb48de9fa7745b995a8d459265559646
|