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.1.0.tar.gz (10.7 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.1.0-py3-none-any.whl (14.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: py_big_brother-0.1.0.tar.gz
  • Upload date:
  • Size: 10.7 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.1.0.tar.gz
Algorithm Hash digest
SHA256 8f303122d43881f3a6458f4a3df316cdc9af95646afd68a5a9a2e74e0e37abbc
MD5 9fbfa4cb48b579222e65c566d7a87577
BLAKE2b-256 f3a7baf37b625a2d9ec81530c37adcfe5020fee6d52b5704854c9ba17a746df7

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_big_brother-0.1.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.1.0-py3-none-any.whl.

File metadata

  • Download URL: py_big_brother-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.3 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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ad4213a8e1f9b0b172855a4766a7bbaa39857a90122e8d47c99e5831f908528e
MD5 8e18c8313f46c10f5de0d83afdef88d8
BLAKE2b-256 693c5806f9e2dbd2ead08584a380c3e5b654f622f39388f4429a8f8a59c0aad4

See more details on using hashes here.

Provenance

The following attestation bundles were made for py_big_brother-0.1.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