Skip to main content

AI-first Python code structure enforcer — 1 file, 1 function

Project description

big-brother

AI-first Python code structure enforcer — 1 file, 1 function.

Code is organized for agents that ls a directory and know what every file does by its name. Big brother sees everything but judges nothing — it reports violations, the gatekeeper decides which are acceptable cohesion and which are real debt.

Install

pip install py-big-brother

CLI Usage

# Scan a project
big-brother .

# Exit 1 on unvetted violations (for CI)
big-brother . --strict

# Skip patterns
big-brother . --ignore "test_*" --ignore "migrations/*"

# Show line ranges per function
big-brother . --lines

# Custom LOC limits
big-brother . --source-max 600 --test-max 400

# Extract a monolith into a 1-file-1-function package
big-brother --stub server.py --output server/

Module invocation also works:

python3 -m big_brother .

Python API

from big_brother import scan, print_report, print_laws

# scan() needs an args-like object with: ignore, source_max, test_max
import argparse
args = argparse.Namespace(ignore=[], source_max=800, test_max=500)

violations, vetted = scan("/path/to/project", args)
print_report(violations, vetted, lines=False)

The Laws

  1. One public function per .py file — filenames ARE the API
  2. __init__.py with re-exports must have __all__ — no opaque packages
  3. Entry files ≤3 non-main defs — routers route, they don't work
  4. Source files ≤800 LOC, test files ≤500 LOC — agents lose coherence past these limits

Vetting

Not every violation needs fixing. Cohesive small functions that are always modified together can stay in one file. To acknowledge a reviewed file:

Add # bb:vetted to the first 10 lines of the file (usually in the module docstring). Vetted files still appear in output but won't block --strict.

License

MIT

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

py_big_brother-0.2.0.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

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

py_big_brother-0.2.0-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file py_big_brother-0.2.0.tar.gz.

File metadata

  • Download URL: py_big_brother-0.2.0.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for py_big_brother-0.2.0.tar.gz
Algorithm Hash digest
SHA256 9d1a8152e7ee01a3d0c262b16c63a43c09aae30c849dbb37118a5fab2b3f8030
MD5 51a4c74d929c8fbe06f171b08649863c
BLAKE2b-256 8af5fb448381b3078bb7291ff18331a8f05825b2e56e0e213d2b18287aed8214

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_big_brother-0.2.0.tar.gz:

Publisher: publish.yml on ai-janitor/big-brother

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file py_big_brother-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: py_big_brother-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for py_big_brother-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 722ecd5a4858f144c2ede271b0fa71e0208e1f98b49d842bdac9e71f65bf2eee
MD5 e9186ef1cdf715ecef01879c2d2060aa
BLAKE2b-256 96058aaf853d37e4355ec47d7780b0a33cb7ecd1c00144d44d63bd1b33b6f303

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_big_brother-0.2.0-py3-none-any.whl:

Publisher: publish.yml on ai-janitor/big-brother

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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