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.
Why loq?
- 🔒 Hard limits to prevent oversized files and context rot
- 📏 One metric: line counts (
wc -lstyle) - 🧩 Works everywhere - no language-specific setup
- 🤖 Designed specifically with coding agents in mind
- 🦀 Lightning fast Rust core
Getting Started
Installation
# With uv (recommended)
uv tool install loq
# With pip
pip install loq
# With cargo
cargo install loq
Usage
# Check current directory (500 line default)
loq check
# Check specific paths
loq check src/ lib/
# Check files from stdin
git diff --name-only | loq check -
Output
Token-efficient default output:
✖ 892 > 500 src/utils/helpers.py
✖ 1_427 > 500 src/components/Dashboard.tsx
2 violations
Use loq -v for more context:
✖ 1_427 > 500 src/components/Dashboard.tsx
└─ rule: max-lines=500 (match: **/*.tsx)
Use --output-format json for machine-readable output:
loq check --output-format json
{
"version": "0.1.0",
"violations": [
{
"path": "src/main.rs",
"lines": 1427,
"max_lines": 500,
"rule": "default"
}
],
"skip_warnings": [],
"walk_errors": [],
"summary": {
"files_checked": 42,
"skipped": 0,
"passed": 41,
"violations": 1,
"walk_errors": 0
}
}
Configuration
loq works zero-config. Run loq init to create a loq.toml file to customize:
# default, for files not matching any rule
default_max_lines = 500
# skip .gitignore'd files
respect_gitignore = true
# ignore files or paths
exclude = [".git/**", "**/generated/**", "*.lock"]
# Add fix_guidance 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/"
# last match wins, ** matches any path
[[rules]]
path = "**/*.tsx"
max_lines = 300
Managing legacy files
Existing large files? Baseline them and ratchet down over time:
# Create loq.toml first
loq init
# Add rules for files over the limit
loq baseline
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? Relax creates or updates exact-path rules for the files currently failing checks:
# Use default buffer of 100 lines
loq relax
# Only update for one file
loq relax src/legacy.rs
# Add 50 lines above current size
loq relax --buffer 50
Add as a Pre-commit Hook
repos:
- repo: https://github.com/jakekaplan/loq
rev: v0.1.0-alpha.6
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.0a6.tar.gz.
File metadata
- Download URL: loq-0.1.0a6.tar.gz
- Upload date:
- Size: 61.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","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 |
1c37d864a52972eb8d1f7189a4feae2e01a6860c040861f0c0c4b86995822c6b
|
|
| MD5 |
9b6df58d71ce450fb6b8c6f02f03ca9e
|
|
| BLAKE2b-256 |
d23546a80e6cfa66f7631462abc17bd29c7a9778e5aaf0d84ea6c189d6e55762
|
File details
Details for the file loq-0.1.0a6-py3-none-win_amd64.whl.
File metadata
- Download URL: loq-0.1.0a6-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.26 {"installer":{"name":"uv","version":"0.9.26","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 |
641abd7645343b8b51031265f495b2d8868a27a8d20de2f592c2db00299839dc
|
|
| MD5 |
55ba3672829302544f888695569eb39b
|
|
| BLAKE2b-256 |
48b58fc0d61c04e690585192bace9232a7a8ddf001d2895a441258566b7e6f71
|
File details
Details for the file loq-0.1.0a6-py3-none-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: loq-0.1.0a6-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.26 {"installer":{"name":"uv","version":"0.9.26","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 |
9828d3da2c950c883faa434d7c5b7ee51da3fedeb5372e0f998b13a28d287acf
|
|
| MD5 |
534aa900cf18ec26bae5b869bd216561
|
|
| BLAKE2b-256 |
3e34d19f43ae998b5a32d68da2e3d169690d64d213c46f8e77a2207741b26f7f
|
File details
Details for the file loq-0.1.0a6-py3-none-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: loq-0.1.0a6-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.26 {"installer":{"name":"uv","version":"0.9.26","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 |
adb55a119a86e931f628a0c100b4b0992da5564409838b27c4f8a57a5a12dfa4
|
|
| MD5 |
095de0a8d1581be2bca93614a588a8fa
|
|
| BLAKE2b-256 |
9cd608451ece6d4a93ccadf0e33f82b5b97bd43be499de30c0eaf8b4fd231876
|
File details
Details for the file loq-0.1.0a6-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: loq-0.1.0a6-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 1.4 MB
- Tags: Python 3, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","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 |
025c0369797327d49a0830cdf4ea0f9e29bd8c8d13965dd5064158ac88d5d073
|
|
| MD5 |
39f6201863502af71dcb9f594bbb5041
|
|
| BLAKE2b-256 |
593232f546280b0af2071ba2690d31363114ed524184dde75276f66b2f2d57e7
|
File details
Details for the file loq-0.1.0a6-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: loq-0.1.0a6-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 1.3 MB
- Tags: Python 3, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: uv/0.9.26 {"installer":{"name":"uv","version":"0.9.26","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 |
255c0b331bb8832b7601f15b2e5e6336c04b844e3ff6c4f0aa9475d2a69097c0
|
|
| MD5 |
647d1cb27b6e266de7310fbd654c5e08
|
|
| BLAKE2b-256 |
40000e744f4843c01b9fc9a609fabf9ea0ecb3b27cddebddc1cdad5e69e874ae
|
File details
Details for the file loq-0.1.0a6-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: loq-0.1.0a6-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.26 {"installer":{"name":"uv","version":"0.9.26","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 |
79260d6b1227bc7e6d2aad1a3a8569eaa273eab82a335b2e577b45f56b149291
|
|
| MD5 |
8b563ff30efa79c93a883ee484a7b3fc
|
|
| BLAKE2b-256 |
7314c7befa473a2de39c17e89314e04fbe0df011ebd258e84e20dbf328921c6e
|
File details
Details for the file loq-0.1.0a6-py3-none-macosx_10_12_x86_64.whl.
File metadata
- Download URL: loq-0.1.0a6-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.26 {"installer":{"name":"uv","version":"0.9.26","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 |
db1a52ee0f183e1df6baedd8262ee36cd17be60c790b402994c25ae02fcc5f5f
|
|
| MD5 |
08817db0f343da70b060a149d39b0a88
|
|
| BLAKE2b-256 |
5c77ba6a542bcf618ee1ef2a075f02d83feebf6cc267be5afd6ab2d55b79dded
|