Skip to main content

Enforce file size constraints

Project description

loq

CI codecov PyPI Crates.io License: MIT

An electric fence for LLMs (and humans too).

Why file size matters

Big files mean more tokens. More tokens mean:

  • Slower responses - LLMs take longer to process what they don't need
  • Higher costs - you pay per token
  • Context rot - large files become dumping grounds that overwhelm both LLMs and humans

loq stops the sprawl before it starts.

Why loq?

LLMs are great at generating code, but sometimes they go off the rails. You can tell an LLM what to do, but the only way to guarantee it listens is with feedback loops and hard constraints. loq provides that constraint: a fast, dead-simple way to enforce file size limits.

Linters like Ruff and ESLint check correctness. loq checks size. It does one thing: enforce line counts (wc -l style). No parsers, no plugins, language agnostic. One tool for your entire polyglot monorepo.

Getting started

Installation

# With uv (recommended)
uv tool install loq

# With pip
pip install loq

# With cargo
cargo install loq

Usage

loq                                        # Check current directory (zero-config, 500 line default)
loq check src/ lib/                        # Check specific paths
git diff --name-only | loq check -         # Check files from stdin

Pre-commit

# .pre-commit-config.yaml
repos:
  - repo: local
    hooks:
      - id: loq
        name: loq
        entry: loq
        language: system
        pass_filenames: false

LLM-friendly output

Output is designed to be token-efficient:

✖  1_427 > 500   src/components/Dashboard.tsx
✖    892 > 500   src/utils/helpers.py
2 violations (14ms)

Use loq -v for additional 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 = ["**/generated/**"] # additional patterns to skip

[[rules]]                     # last match wins
path = "**/*.tsx"
max_lines = 300

[[rules]]
path = "tests/**/*"
max_lines = 600

Baseline

Have a codebase with existing large files? Baseline them:

loq init       # Create loq.toml first
loq baseline   # Add rules for files over the limit

Run loq baseline periodically to ratchet down. It automatically:

  • Adds rules for new violations
  • Updates rules when files shrink (tightens the limit)
  • Removes rules when files drop below the threshold

Use --threshold to override the default limit:

loq baseline --threshold 300

Contributing

Contributions are welcome! See CONTRIBUTING.md for development setup and guidelines.

License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

loq-0.1.0a3.tar.gz (49.3 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

loq-0.1.0a3-py3-none-win_amd64.whl (1.3 MB view details)

Uploaded Python 3Windows x86-64

loq-0.1.0a3-py3-none-musllinux_1_2_x86_64.whl (1.4 MB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

loq-0.1.0a3-py3-none-musllinux_1_2_aarch64.whl (1.3 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

loq-0.1.0a3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.3 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

loq-0.1.0a3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.2 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

loq-0.1.0a3-py3-none-macosx_11_0_arm64.whl (1.2 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

loq-0.1.0a3-py3-none-macosx_10_12_x86_64.whl (1.3 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file loq-0.1.0a3.tar.gz.

File metadata

  • Download URL: loq-0.1.0a3.tar.gz
  • Upload date:
  • Size: 49.3 kB
  • Tags: Source
  • 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

Hashes for loq-0.1.0a3.tar.gz
Algorithm Hash digest
SHA256 8f34ed32eed79d3257fc6c6e2ffc4970795bae0fbd7dee95cdb027d351a87839
MD5 60396fabf388c5dddb71dd9556fd373d
BLAKE2b-256 872d911c0ca3175aa30358eb0b1dd4789e3695292db63dc50da34be0d8aa001a

See more details on using hashes here.

File details

Details for the file loq-0.1.0a3-py3-none-win_amd64.whl.

File metadata

  • Download URL: loq-0.1.0a3-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.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

Hashes for loq-0.1.0a3-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 51cd849b94f09d211bb842809cce4172ee0904092be2643bdb9629001745f3b9
MD5 32446d3f7e1c51371e339f773b5971ac
BLAKE2b-256 39682dbb5e29e0333f036b92b09f6b54bbd8e68b51b780051f01e15c307b6ab1

See more details on using hashes here.

File details

Details for the file loq-0.1.0a3-py3-none-musllinux_1_2_x86_64.whl.

File metadata

  • Download URL: loq-0.1.0a3-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.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

Hashes for loq-0.1.0a3-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 3e5501abcbab67d14e6c71a6c010609430a9495a888e10047d5542ffd46acd65
MD5 3bee0cf31ee7bf8df7d7e72c21e002f0
BLAKE2b-256 6577fda09acd73fc44f6a7cfa9851dd8d8fdab0829311b9c7fa1f1af30b3affa

See more details on using hashes here.

File details

Details for the file loq-0.1.0a3-py3-none-musllinux_1_2_aarch64.whl.

File metadata

  • Download URL: loq-0.1.0a3-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.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

Hashes for loq-0.1.0a3-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 afc46f65303b9ff64ae0e517f4834cf0e5b97cd5b375cbfd66dadf267f94f725
MD5 8f97170c16e0d87af75755a75bf51cef
BLAKE2b-256 980976677afb5f9d380a89cf59489f03cdb7c1c6318d1c81c6fc3073cce93893

See more details on using hashes here.

File details

Details for the file loq-0.1.0a3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

  • Download URL: loq-0.1.0a3-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.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

Hashes for loq-0.1.0a3-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 63a146821abc50f9166fdec83a92330ddec81d78fc02d0956cf00957fc02f4e6
MD5 d319bc1a031a42e99b94fbf51de71e4b
BLAKE2b-256 cc2710e195de9e4e843fed4a098f4a7b3e2b78a0218d317adb3ea83b341fa8e9

See more details on using hashes here.

File details

Details for the file loq-0.1.0a3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

  • Download URL: loq-0.1.0a3-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.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

Hashes for loq-0.1.0a3-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 efb606799326bdba9e0931ae6664076eb24ea9ce29f540ec62071f3da7d89753
MD5 2847e41b5ab5197c621500bb97908bc3
BLAKE2b-256 80d968f2418009771b764fc6fcbd379892464c7d96cf668ea570f8b3d6e93806

See more details on using hashes here.

File details

Details for the file loq-0.1.0a3-py3-none-macosx_11_0_arm64.whl.

File metadata

  • Download URL: loq-0.1.0a3-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.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

Hashes for loq-0.1.0a3-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 20afc0638df897312ea33f064cd8d05ee437c77ff6fca890ac33d41cc5fe9dbd
MD5 95658641d002a4149a3d30facb70df93
BLAKE2b-256 9149cfa207080940c9d447ca4633d7a25790d50e936de29d154dcc1941c45e54

See more details on using hashes here.

File details

Details for the file loq-0.1.0a3-py3-none-macosx_10_12_x86_64.whl.

File metadata

  • Download URL: loq-0.1.0a3-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.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

Hashes for loq-0.1.0a3-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 e65cb220446f1a2fad5c0e3e0c97715204652cb3896b35bb50967745d1f74ade
MD5 03e3309e318c22a20b7040b4c63ff4f1
BLAKE2b-256 6a7cd028a1041caef85844b7a68926138daedac6ab4aa720f6cb8c77a30dcb49

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page