Enforce file size constraints
Project description
loq
An electric fence for LLMs (and humans too). Written in Rust,
loq enforces file line limits: fast, zero-config, and language agnostic.
Quickstart
# With uv (recommended)
uv tool install loq
# With pip
pip install loq
# With cargo
cargo install loq
loq # Check current directory (500 line default)
loq check src/ lib/ # Check specific paths
git diff --name-only | loq check - # Check files from stdin
Why loq?
- Hard limits on file size to prevent context rot
- One metric: line counts (
wc -lstyle) - No parsers, no plugins, no config required
- LLM-friendly minimal output and fast Rust core
LLM-friendly, token-efficient output:
✖ 1_427 > 500 src/components/Dashboard.tsx
✖ 892 > 500 src/utils/helpers.py
2 violations (14ms)
Use loq -v for more context:
✖ 1_427 > 500 src/components/Dashboard.tsx
└─ rule: max-lines=500 (match: **/*.tsx)
Configuration
loq works zero-config. Run loq init to customize:
default_max_lines = 500 # files not matching any rule
respect_gitignore = true # skip .gitignore'd files
exclude = [".git/**", "**/generated/**", "*.lock"]
[[rules]] # last match wins, ** matches any path
path = "**/*.tsx"
max_lines = 300
Add fix_guidance in loq.toml to include project-specific instructions with
each violation when piping output to an LLM:
fix_guidance = "Split large files: helpers → src/utils/, types → src/types/"
Managing legacy files
Existing large files? Baseline them and ratchet down over time:
loq init # Create loq.toml first
loq baseline # Add rules for files over the limit
Run periodically. It tightens limits as files shrink, removes rules once files
are under the threshold, and ignores files that grew. Files cannot be
rebaselined to a higher limit unless you pass --allow-growth. Use
--threshold 300 to set a custom limit.
Need to ship while files are still too big? Accept defeat creates or updates exact-path rules for the files currently failing checks:
loq accept-defeat # Use default buffer of 100 lines
loq accept-defeat src/legacy.rs # Only update for one file
loq accept-defeat --buffer 50 # Add 50 lines above current size
Add as a Pre-commit Hook
repos:
- repo: https://github.com/jakekaplan/loq
rev: v0.1.0-alpha.5
hooks:
- id: loq
Contributing
Contributions are welcome! See CONTRIBUTING.md for development setup and guidelines.
License
This project is licensed under the MIT License.
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 Distribution
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.0a5.tar.gz.
File metadata
- Download URL: loq-0.1.0a5.tar.gz
- Upload date:
- Size: 56.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","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 |
77245e6ce2c7ca135a5398a3dbada903ce6e99a365bbaaa329e976c1143c5e08
|
|
| MD5 |
971a159846ce93efa0cce1051bea8d53
|
|
| BLAKE2b-256 |
8bbc4a2d2ffd70be6cba1ea80bc20565dddd697eadec33cba89690a8c40bfb75
|
File details
Details for the file loq-0.1.0a5-py3-none-win_amd64.whl.
File metadata
- Download URL: loq-0.1.0a5-py3-none-win_amd64.whl
- Upload date:
- Size: 1.3 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","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 |
70bc02c86fae82736fe291916c99d7d4e95529014bac03aecb24accfb54a534d
|
|
| MD5 |
5b07abc5162004b0efd0c7e03f11ebb1
|
|
| BLAKE2b-256 |
67e0b5ce04ddf2a83250286e33484c72e002c742cef41a37a75e4c6b7d73afac
|
File details
Details for the file loq-0.1.0a5-py3-none-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: loq-0.1.0a5-py3-none-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 1.4 MB
- Tags: Python 3, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","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 |
8bcd87f88f4aee34abc1fbe7e037fd3c33588f2459b449b59b4161bbfc2cfdc8
|
|
| MD5 |
20abd3ab886b63daae1051fddcfed5be
|
|
| BLAKE2b-256 |
c6fa4d15341bb6e3cf3cd0b00d582fbc8742821d5da4359bc903d36ac93c7d3b
|
File details
Details for the file loq-0.1.0a5-py3-none-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: loq-0.1.0a5-py3-none-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 1.3 MB
- Tags: Python 3, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","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 |
8a541a9e53dab538b55b76db8c8ccf594673cfe05a0f1ff40023388b9c705447
|
|
| MD5 |
9da58a69fcab48fc98b617e8d2a9dccc
|
|
| BLAKE2b-256 |
a7ee34c760bf931251b46cf2288b0786d4f051cc29eb6b6c93c64d91cd48468c
|
File details
Details for the file loq-0.1.0a5-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: loq-0.1.0a5-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: Python 3, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","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 |
8fe0e40062d3adc4add46faa14ce7ae85078f71d9919d24e1ae801c0b10a8bd4
|
|
| MD5 |
2917e313d6b217d7a6eeecba2137d8bd
|
|
| BLAKE2b-256 |
66b8928caeb855bf22e9b356555be600f9f2cc514624943c0f51ba5da8185488
|
File details
Details for the file loq-0.1.0a5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: loq-0.1.0a5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 1.2 MB
- Tags: Python 3, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","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 |
20f61d77555cd916a32977d32cc35f341320795deebc93d6840b8c89c8bc0751
|
|
| MD5 |
3b9cb56f8ab55d4b54d2bb8ad355573d
|
|
| BLAKE2b-256 |
1618a6921c6a359b3480b22d128c8f268fc9cc745bb7445775c83cb281eed0b4
|
File details
Details for the file loq-0.1.0a5-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: loq-0.1.0a5-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 1.2 MB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","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 |
dcd009a627538522d082e18456d99bdffcb614bb1fac935c0494382c32ba1c41
|
|
| MD5 |
8131e03fae1ba41bd241f4e3dfbeaa96
|
|
| BLAKE2b-256 |
e0092c4ef7a23bf3d32bf08bdb4ede64941da8add2b32d7174bbf741a37e10e5
|
File details
Details for the file loq-0.1.0a5-py3-none-macosx_10_12_x86_64.whl.
File metadata
- Download URL: loq-0.1.0a5-py3-none-macosx_10_12_x86_64.whl
- Upload date:
- Size: 1.3 MB
- Tags: Python 3, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.25 {"installer":{"name":"uv","version":"0.9.25","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 |
732196ba285770b63a18dba219c73cda4c8ad9f1b76720a5227d06309e613d29
|
|
| MD5 |
e59c46767fac7a38cbe82db960ce4b4b
|
|
| BLAKE2b-256 |
5a982def32bc19544489cadc730659b022ba80522860a789a1da97f3e13c911c
|