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). Written in Rust, loq enforces file line limits: fast, works out of the box, and language agnostic.

Why loq?

  • 🔒 Hard limits to prevent oversized files and context rot
  • 📏 One metric: line counts (wc -l style)
  • 🧩 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 for violations (default: 500 lines)
loq check           

# Check specific paths               
loq check src/ lib/     
     
# Check only staged files
loq check --staged

# Check files changed since a ref
loq check --diff HEAD
loq check --diff origin/main..HEAD

# Check files from stdin
git diff --name-only | loq check -

--staged and --diff are repo-wide modes. They cannot be combined with PATH args or stdin scope (loq check -).

Managing legacy files

# Creates, updates or removes exact-path rules
# to match the current state of your files.
loq baseline

# Creates or updates exact-path rules for current violations
loq relax
loq relax src/legacy.rs   # specific file
loq relax --extra 50      # custom buffer

# Ratchets down or removes existing exact-path rules
# as your file sizes become compliant over time
loq tighten

All three commands manage exact-path rules in loq.toml. baseline and relax can add new rules; tighten only updates or removes existing ones.

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
# * stays within a path segment
# ** matches across directories
[[rules]]
path = "**/*.tsx"
max_lines = 300

Output options

# Detailed output
loq check -v

# JSON format
loq check --output-format json

Add as a Pre-commit Hook

repos:
  - repo: https://github.com/jakekaplan/loq
    rev: v0.1.0
    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


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.0.tar.gz (73.4 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.0-py3-none-win_amd64.whl (1.4 MB view details)

Uploaded Python 3Windows x86-64

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

Uploaded Python 3musllinux: musl 1.2+ x86-64

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

Uploaded Python 3musllinux: musl 1.2+ ARM64

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

Uploaded Python 3manylinux: glibc 2.17+ x86-64

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

Uploaded Python 3manylinux: glibc 2.17+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

loq-0.1.0-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.0.tar.gz.

File metadata

  • Download URL: loq-0.1.0.tar.gz
  • Upload date:
  • Size: 73.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","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.0.tar.gz
Algorithm Hash digest
SHA256 2c0748bfbd0f36a7899d19bfa50af2609dbdd09351fc8951f7c4741ed4340c86
MD5 2aa7a648eacfe6baca12501a130e3801
BLAKE2b-256 9781a17733cc91f34192c7ebfa946df89e14385dc384952485fcacde759d0dc7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: loq-0.1.0-py3-none-win_amd64.whl
  • Upload date:
  • Size: 1.4 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","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.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 dcb0da5c60ba65d8978e91fd0e8116c920c79374dff78092cd1cc6a732fbaebf
MD5 fe0f8e3c79c770784b79556f0cc3906d
BLAKE2b-256 0e843477378f4a22c89f4b0268ffeb45738fc67d629067bbd6ad9a7de40e0ed0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: loq-0.1.0-py3-none-musllinux_1_2_x86_64.whl
  • Upload date:
  • Size: 1.5 MB
  • Tags: Python 3, musllinux: musl 1.2+ x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","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.0-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 97fbd077ed12627bc8a9897f863489cc0a535dee884a100c419c8039fd758b64
MD5 9e08309bcf4a73fa09bb2a884b11d979
BLAKE2b-256 a9bdeaea9d747ac43384c5e319886a23edb6b61007be6ca856f480110a57cb52

See more details on using hashes here.

File details

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

File metadata

  • Download URL: loq-0.1.0-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.10.10 {"installer":{"name":"uv","version":"0.10.10","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.0-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 2af38e4e503986b930d036ec867720648a8dff468d6a938b6f3579024deace9c
MD5 f7c6a995bd004cf8293634ef7ea6b761
BLAKE2b-256 c11e77fd1ac28d4bbb79a0006a7489aa527e6df00fef7668c47d7a69c46804e8

See more details on using hashes here.

File details

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

File metadata

  • Download URL: loq-0.1.0-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.10.10 {"installer":{"name":"uv","version":"0.10.10","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.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 5f37096eb4e7deb8c11928aad914a472b0b74485a5dbebd16f17f223ef973e22
MD5 20e05076631292a7bfa7c2df77de465a
BLAKE2b-256 1ca557f6a11fa86d3e75f16283dbdb7925796bd430ec298407d2824e23de2740

See more details on using hashes here.

File details

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

File metadata

  • Download URL: loq-0.1.0-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.10.10 {"installer":{"name":"uv","version":"0.10.10","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.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 98781f2da950c8a2f8ff1e136f7199abdfd1456b921253e97891eba1a6d8f7d7
MD5 8aca6cb453d6bb3ab9f89668a9f31aa2
BLAKE2b-256 5b7c9898a91f70ba757c07395bf4827953245ad1721b03f2a88750d4d789d342

See more details on using hashes here.

File details

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

File metadata

  • Download URL: loq-0.1.0-py3-none-macosx_11_0_arm64.whl
  • Upload date:
  • Size: 1.3 MB
  • Tags: Python 3, macOS 11.0+ ARM64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.10.10 {"installer":{"name":"uv","version":"0.10.10","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.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 06fbbb2d879bec68cbc3bf245ca9c0b3f1b34378520f088d43906ca4b005dcbc
MD5 7bb06982ddd9756921af0a2f3f5dbb42
BLAKE2b-256 ab51f0e99405c265dd700b6a325bd9c096a2fe6982ec251614470c10ff9ebd44

See more details on using hashes here.

File details

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

File metadata

  • Download URL: loq-0.1.0-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.10.10 {"installer":{"name":"uv","version":"0.10.10","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.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 3609a7cb924fe3a91f4e2783302f103c4800fb77d3aa44f25751d7e59671b8c4
MD5 2c386a182202f27a9b771e44bb36ef62
BLAKE2b-256 7a2466fb5fb05c1381d3f7006ed0f3ea02f44e18f8908f616bb4a9c4a052388d

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