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 files from stdin      
git diff --name-only | 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-alpha.7
    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.0a7.tar.gz (64.0 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.0a7-py3-none-win_amd64.whl (1.3 MB view details)

Uploaded Python 3Windows x86-64

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

Uploaded Python 3musllinux: musl 1.2+ x86-64

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

Uploaded Python 3musllinux: musl 1.2+ ARM64

loq-0.1.0a7-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.0a7-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (1.3 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

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

File metadata

  • Download URL: loq-0.1.0a7.tar.gz
  • Upload date:
  • Size: 64.0 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

Hashes for loq-0.1.0a7.tar.gz
Algorithm Hash digest
SHA256 576f70f45d466accf6a4c1020e430f0fc008047eeae1889952bd981f9da12bf0
MD5 6ab226ac1ed22d77e5573d69007a17b5
BLAKE2b-256 d89f27aacd5b1566ebbec1531ead263fa1f60899b8a7cd6aa1a710c34b05a5b8

See more details on using hashes here.

File details

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

File metadata

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

Hashes for loq-0.1.0a7-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 a5d0f98e9613ffab868aacc1e1277ca3f7d39158c55aa3d0e534865591592da7
MD5 89cc0202a4583ff2d10779bab72854eb
BLAKE2b-256 6b4811ed2d491b353cb7c159398a3017a64a5c424c85979a2eb805ded6763739

See more details on using hashes here.

File details

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

File metadata

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

Hashes for loq-0.1.0a7-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 a21ab864964823678b8478fef83f42c2634662f736cf8b552de09736f52ca91f
MD5 411cddeda16f6f10f5fdfbe9913cd9ad
BLAKE2b-256 57b2ae6bae30259715db7d97c7c7f929d5a210dd2a59b2564a020899fba8a7e5

See more details on using hashes here.

File details

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

File metadata

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

Hashes for loq-0.1.0a7-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 e54a96e61c9aafebfa873e5a897132e611b457892f149809380625d4fa9c1147
MD5 604264a5e374b31048842d59f09fce31
BLAKE2b-256 298b74e6e39ac302ff722acd2c154f5f6b3c28f750f914e859158b1333b2330e

See more details on using hashes here.

File details

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

File metadata

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

Hashes for loq-0.1.0a7-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9ed89b64ab1de6be9936d274b95f946a1b6f052493e1a1f1db3aac70852b3e0c
MD5 220bd2c9a03700e28eccc0b94fb83159
BLAKE2b-256 9048be790e0542fa660ec84f863e0440570442e167fc5c65d8ad36bd93e5f315

See more details on using hashes here.

File details

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

File metadata

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

Hashes for loq-0.1.0a7-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f9527526e4cffb12c84207cd2a92ccfa90968e137908b4329d9f6e07ba0cb575
MD5 09e4f4180717e636e09d44350cd11fe1
BLAKE2b-256 8428e9730ef5cf29baef96a015a514752d7142f48287ac7efc8bdd09794d2b28

See more details on using hashes here.

File details

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

File metadata

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

Hashes for loq-0.1.0a7-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 178393fa15968082aafb54c24d2015eef7090b0668ca6715e3e3c390bdeeea46
MD5 78201ce343f52d7111b8c7fbf4d56e94
BLAKE2b-256 0ab9519e83707c3819349e4497a4b30e9a814d155eb1317a25425cac73cb8045

See more details on using hashes here.

File details

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

File metadata

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

Hashes for loq-0.1.0a7-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 47d40a9792397f8f100e7c2984d56227bd05c7f3d6817e8e26a7af88cbff0b26
MD5 1d9727dbe8fa3840f0a7449f64c9fa8f
BLAKE2b-256 fce5b55110b86951b184019bfe7290ee73115b932b3bb0d4428bbe20c68d2f31

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