Skip to main content

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
  • 📏 Line counts first, with optional approximate token budgets for prompts and agent-facing files
  • 🧩 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. They manage line limits and leave token-governed files alone, and they operate on the current directory (like check), writing to the nearest loq.toml found above it.

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

# Or default to an approximate token budget instead of lines.
# Set only one of default_max_lines / default_max_tokens.
# default_max_tokens = 8000

# skip .gitignore'd files
respect_gitignore = true

# ignore files or paths
exclude = ["**/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

# Agent-facing files can use approximate token budgets.
# Tokens are estimated as bytes / 4, rounded up.
[[rules]]
path = "prompts/**/*.md"
max_tokens = 8000

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.2.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.

Metadata

Release files for loq 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for loq 0.2.0
File Size Uploaded Provenance
loq-0.2.0.tar.gz 77.2 kB Without provenance Details

Built distributions (wheels)

Table of built distributions (wheels) for loq 0.2.0
File
loq-0.2.0-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
loq-0.2.0-py3-none-musllinux_1_2_x86_64.whl Python 3 none Linux musl 1.2+ x86-64 Details
loq-0.2.0-py3-none-musllinux_1_2_aarch64.whl Python 3 none Linux musl 1.2+ ARM64 Details
loq-0.2.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details
loq-0.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl Python 3 none Linux glibc 2.17+ ARM64 Details
loq-0.2.0-py3-none-macosx_11_0_arm64.whl Python 3 none macOS 11.0+ ARM64 Details
loq-0.2.0-py3-none-macosx_10_12_x86_64.whl Python 3 none macOS 10.12+ x86-64 Details

Total release size: 9.3 MB

Release files / loq-0.2.0.tar.gz

Download URL loq-0.2.0.tar.gz
Size 77.2 kB
Tags Source
SHA-256 checksum
How to use checksums
ee953ce910e4bb5add3a80d0f36640e3d9286de5b9640e62b795b27c42f908e3
BLAKE2b-256 checksum
How to use checksums
80a354405649a3beb599fc64790b3ac48da2570c80b8f8eca6ab971bd5549d31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","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}

Release files / loq-0.2.0-py3-none-win_amd64.whl

Download URL loq-0.2.0-py3-none-win_amd64.whl
Size 1.3 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
8a3e448f1eec1015fff8c6571c885f9e0f7363b0e5e51ed432b47ad8ff5ebab5
BLAKE2b-256 checksum
How to use checksums
c522cb252bf24b2894af7d6b82f747b8de8eee572935f2b6548b6f0e0129f8da
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","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}

Release files / loq-0.2.0-py3-none-musllinux_1_2_x86_64.whl

Download URL loq-0.2.0-py3-none-musllinux_1_2_x86_64.whl
Size 1.4 MB
Tags Linux musl 1.2+ x86-64 Python 3
SHA-256 checksum
How to use checksums
ab0b47010022bff5bad98f573b55b9b74aeb2db43c368264418016b1c1b7c3d1
BLAKE2b-256 checksum
How to use checksums
51bd3147365b59e1d158ec1f5e62bb9a56146727e5a8d432616c3c46151a7b77
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","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}

Release files / loq-0.2.0-py3-none-musllinux_1_2_aarch64.whl

Download URL loq-0.2.0-py3-none-musllinux_1_2_aarch64.whl
Size 1.3 MB
Tags Linux musl 1.2+ ARM64 Python 3
SHA-256 checksum
How to use checksums
884d751e34db6d835acf4b42a5e08b35b277133a96878e5df4f471b3c5ef014f
BLAKE2b-256 checksum
How to use checksums
bf9740e0a1274933def21e3b9fd48d8fa02d3d766abade227de3e19febac1210
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","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}

Release files / loq-0.2.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL loq-0.2.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 1.4 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
a58625d7d0948affa2c3d7e54c27f2650d5f2d19b2c1e0c78a84b28f72f4c044
BLAKE2b-256 checksum
How to use checksums
ea3b2c9c752b0590d7d55735502212345bf78c90390e619f7534fef46eda1463
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","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}

Release files / loq-0.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL loq-0.2.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 1.3 MB
Tags Linux glibc 2.17+ ARM64 Python 3
SHA-256 checksum
How to use checksums
1e5e7ba3f04a6918cadb5cef10229a5f95a9f5a78bf1612f63bd1368bc7e06a8
BLAKE2b-256 checksum
How to use checksums
2aea473ceafffbbd0b0906c40ffef231c9433f4efba6dfd7e0a64572adae762a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","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}

Release files / loq-0.2.0-py3-none-macosx_11_0_arm64.whl

Download URL loq-0.2.0-py3-none-macosx_11_0_arm64.whl
Size 1.2 MB
Tags Python 3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
433ef7781be480eadb9a27a18de7f5a47b30c0f14e13028a4665cff33a45ea22
BLAKE2b-256 checksum
How to use checksums
270dc13d11d617a7c14102099de6278bf1ab4df32aba468011c7f8b2fb3f7ce4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","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}

Release files / loq-0.2.0-py3-none-macosx_10_12_x86_64.whl

Download URL loq-0.2.0-py3-none-macosx_10_12_x86_64.whl
Size 1.3 MB
Tags Python 3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
8370ae3310827b42ab92ccb4fdb7c525d939ad8e6ccd7fdc50ffd8bd7d29dd89
BLAKE2b-256 checksum
How to use checksums
51d9c17515be994dd660b9819ed0abfa54e3131d2697ec3ea0a1d4c2eb9aeedd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","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}

Security for loq 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page