Skip to main content

Enterprise-grade file header tool that injects repo-relative path headers into Python files

Project description

autoheader

autoheader is an enterprise-grade CLI tool for Python projects that automatically adds or refreshes file headers containing each file’s repo-relative path.
This helps developers quickly identify file origins, improves navigation in large codebases, and standardizes file structure across teams.

Example of what autoheader produces:

# src/utils/parser.py

from __future__ import annotations

Perfect for monorepos, multi-module architectures, enterprise Python codebases, and any project where file traceability matters.


---

 Features

Automatic repository root detection
Uses multiple project markers (pyproject.toml, README, .gitignore, etc.) to confirm safe execution.

Idempotent header insertion
Runs repeatedly with no duplicates. If the header already matches the files path, it simply skips.

Override mode (--override)
Rewrites outdated or incorrect headers when files are moved or refactored.

Dry-run by default
No accidental writes. Shows exactly what will change.

Backup support (--backup)
Creates .bak files for full rollback safety.

Depth guard (--depth)
Prevents accidental traversal of deep or unwanted paths in large repos.

Exclusion system (--exclude)
Automatically avoids dangerous directories like .git, .github, virtualenvs, build folders, etc.

Verbose reporting (--verbose)
See exactly which files were added, skipped, or overridden.

Installable via PyPI with zero configuration
Just pip install autoheader.



---

📦 Installation

Install from PyPI:

pip install autoheader

Or install from source:

pip install git+https://github.com/dhruv13x/autoheader


---

🚀 Quick Start

Run inside a Python project:

autoheader

This performs a safe dry-run and shows what would be changed.

Apply changes for real:

autoheader --no-dry-run

Override all headers (useful after moving files):

autoheader --override --no-dry-run

Create backups for safety:

autoheader --backup --no-dry-run


---

📘 Advanced Usage

 Specify max directory depth

autoheader --depth 3 --no-dry-run

Avoids walking deep directory trees.


---

 Exclude additional paths

autoheader --exclude tests --exclude build

Built-in exclusions include:

.git/

.github/

virtualenvs

build artifacts



---

 Force yes in CI environments

autoheader --yes --no-dry-run

Skips root detection prompts.


---

📂 Example Output

Dry-run:

DRY ADD:      src/utils/parser.py
DRY ADD:      src/models/user.py
DRY ADD:      api/routes/index.py

Summary: added=3, overridden=0, skipped_ok=14, skipped_excluded=5.
NOTE: this was a dry run. Use --no-dry-run to apply changes.

Real run:

ADD:          src/utils/parser.py
OVERRIDE:     src/core/config.py
SKIP (ok):    src/api/__init__.py

Summary: added=1, overridden=1, skipped_ok=22, skipped_excluded=5.


---

🛡 Safety & Guarantees

autoheader is built with enterprise safety in mind:

Never touches files without your permission

Never rewrites headers unless explicitly told

Never runs destructive operations

Clearly separates real execution from dry-run

Designed for CI/CD environments

OIDC-secure PyPI publishing



---

🔧 Development

Install in editable mode:

git clone https://github.com/dhruv13x/autoheader
cd autoheader
pip install -e .[dev]

Run tests:

pytest

Run linter & formatter:

ruff check .
black .


---

🤝 Contributing

Pull requests are welcome.
If proposing large changes, open an issue first to discuss design and approach.


---

🐛 Reporting Issues

Please open issues here:
https://github.com/dhruv13x/autoheader/issues

Include:

What command you ran

Error output

Your Python version

OS / environment information



---

📜 License

MIT © dhruv13x


---

 Support the Project

If this tool helped you, consider giving the repo a star:

https://github.com/dhruv13x/autoheader

Stars help visibility and future development!

---

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

autoheader-0.2.0.tar.gz (12.7 kB view details)

Uploaded Source

Built Distribution

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

autoheader-0.2.0-py3-none-any.whl (13.6 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for autoheader-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2d9a2c505e002768bd86ebfda52aff7fe4f8ebf727539a214d1db4d22deded2c
MD5 0c08f4144af774bdebcbd7ebcedcf78a
BLAKE2b-256 031baf5b76f3ab9a0bcef4d1cca0f9c31ee8cc1a0a3896fb69c98c7fcdf1ff7b

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on dhruv13x/autoheader

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

File details

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

File metadata

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

File hashes

Hashes for autoheader-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5d2cf86703fb7fae21295614f1e890e348bc019cb6929d126ef18777afbc6a22
MD5 f9115ea1be0bbad9daeebfc446adb438
BLAKE2b-256 83df44f6097de95aa3705b218c657677f3c78e39797daa16f9a595318dc5754a

See more details on using hashes here.

Provenance

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

Publisher: publish.yml on dhruv13x/autoheader

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