autoheader
The enterprise-grade standard for adding, refreshing, and managing repo-relative file headers.
autoheader automatically manages file headers containing repo-relative paths for source code projects. Whether you are working in a massive monorepo or a small microservice, it ensures every file is traceable, standardizing your codebase and improving developer navigation.
"Where is this file located?" — Never ask this again.
🚀 Quick Start
Prerequisites
- Python 3.8+
- Basic understanding of your project structure.
Installation
pip install "autoheader[precommit]"
Run
# Initialize and dry-run
autoheader --init && autoheader
Demo
# Copy-paste this into any file to see autoheader in action!
# src/main.py (autoheader will add this line)
import sys
print("Hello World")
✨ Features
Core
- 🌐 Polyglot Support: Manages headers for Python, JavaScript, Go, CSS, and any other language via a simple TOML configuration.
- ⚙️ Smart Setup: Get started in seconds with
autoheader --initto generate a battle-tested default configuration. - 🧩 LSP Support: Includes a Language Server (
autoheader --lsp) for real-time diagnostics directly in your IDE. - ⚡ Rich UX: Beautiful, modern output with emojis, progress bars, and visual diffs (powered by Rich).
- 🧠 Smart Copyright: Automatically updates year ranges (e.g., 2020-2025) in existing headers instead of overwriting them.
- 💻 Official SDK: Import
autoheaderin your own Python scripts (from autoheader import AutoHeader) for custom integrations. - 📂 Team Configuration: Centralize settings using
autoheader.tomlor a remote config URL (--config-url) to keep your team aligned. - 📜 Native SPDX Support: Easily use standard licenses (e.g., MIT, Apache-2.0) by setting
license_spdxin your config.
Performance
- 🚀 Parallel Execution: Supports passing specific files, parallel execution, and caching for blazing fast speed in CI pipelines.
- Smart Filtering:
.gitignoreaware, inline ignores (autoheader: ignore), and robust depth/exclusion controls.
Security
- 🛡️ Pre-commit Integration: Automatically enforce headers on every commit with
autoheader --checkor the built-in hook installer. - 🤖 GitHub Action: Use the official action
uses: dhruv13x/autoheader@v1to check headers in your CI/CD pipelines. - 🤖 Auto-Installer: Setup hooks instantly with
autoheader --install-precommitorautoheader --install-git-hook. - 🔍 SARIF Support: Output results in SARIF format (
--format sarif) for integration with GitHub Security and other scanning tools.
🛠️ Configuration
Environment Variables
| Variable | Description | Default | Required |
|---|---|---|---|
NO_COLOR |
Disable colored output if set. | None |
No |
AUTOHEADER_CONFIG |
Path to configuration file. | autoheader.toml |
No |
CLI Arguments
| Argument | Description | Default |
|---|---|---|
| Main Actions | ||
files |
Specific files to process (space separated). Scans root if empty. | (all) |
-d, --dry-run |
Preview changes without writing. | True |
-nd, --no-dry-run |
Apply changes to disk. | False |
--override |
Force rewrite of existing headers. | False |
--remove |
Remove all autoheader lines from files. | False |
| CI / Integration | ||
--check |
Exit 1 if changes needed. | False |
--check-hash |
Verify content integrity. | False |
--install-precommit |
Install pre-commit hook. |
False |
--install-git-hook |
Install native .git/hooks. |
False |
--init |
Generate default config. | False |
--lsp |
Start Language Server. | False |
| Configuration | ||
--config-url |
Remote config URL. | None |
--root |
Project root path. | cwd |
--workers |
Parallel workers. | 8 |
--timeout |
File processing timeout (s). | 60.0 |
--clear-cache |
Reset internal cache. | False |
| Filtering | ||
--depth |
Max directory scan depth. | None |
--exclude |
Glob patterns to skip. | [] |
--markers |
Project root markers. | ['.gitignore', ...] |
| Header Customization | ||
--blank-lines-after |
Blank lines after header. | 1 |
| Output | ||
--format |
default or sarif. |
default |
-v, --verbose |
Increase verbosity. | 0 |
-q, --quiet |
Suppress info output. | False |
--no-color |
Disable colors. | False |
--no-emoji |
Disable emojis. | False |
The autoheader.toml File
The primary way to configure autoheader is via the autoheader.toml file. Generate one with autoheader --init.
[general]
workers = 8
backup = false
exclude = ["tests/fixtures/*"]
[language.python]
file_globs = ["*.py"]
prefix = "# "
template = "# {path}\n#\n{license}"
license_spdx = "MIT"
Python SDK
You can use autoheader directly in your Python scripts.
from autoheader import AutoHeader
ah = AutoHeader(root=".")
# Apply headers to all files
results = ah.apply(dry_run=False)
# Check compliance
check_results = ah.check(["src/main.py"])
🏗️ Architecture
autoheader follows a strict Separation of Concerns.
src/autoheader/
├── cli.py # Entry Point: UI, args parsing, mode selection
├── api.py # The SDK: Official public API wrapper
├── core.py # Execution: File writing, diffing, safety checks
├── planner.py # The Brain: Pure business logic, decision making (PlanItem)
├── config.py # Config: TOML loading, merging, validation
├── walker.py # Discovery: File scanning, gitignore processing
├── headerlogic.py # Parsing: Header detection, SPDX handling
├── ui.py # The Face: Rich output, visual diffs
├── lsp.py # Language Server: Real-time IDE integration
└── hooks.py # Integration: Native git hook installer
Flow:
- Input: User runs CLI or SDK, providing target files and flags.
- Discovery:
walker.pyscans the file system, respecting.gitignoreandexcluderules. - Planning:
planner.pyevaluates each file in parallel against the configuration to determine the necessary action (Add, Override, Skip). - Execution:
core.pyapplies the plan, modifying files safely with optional backups. - Output:
ui.pyrenders the results to the console (or SARIF) with rich feedback.
🐞 Troubleshooting
| Issue | Solution |
|---|---|
| "Header not updating" | Check if file is excluded in .gitignore or via exclude in autoheader.toml. |
| "Permission denied" | Ensure you have write permissions to the files. Run with sudo only if necessary. |
| "LSP not working" | Ensure autoheader[lsp] is installed. Restart your IDE language server. |
| "Config not found" | Run autoheader --init to create autoheader.toml. |
| "Wrong path in header" | Check your root directory setting (--root). |
Debug Mode:
Run with autoheader -vv to see detailed debug logs, including file scanning decisions and configuration loading.
🤝 Contributing
Contributions are welcome!
Please refer to our contribution guidelines below (full CONTRIBUTING.md coming soon).
- Fork the repository.
- Clone your fork:
git clone ... - Install dev dependencies:
pip install -e ".[dev,precommit]" - Run tests:
pytest - Linting:
ruff check .
🗺️ Roadmap
We are actively building the future of code standardization.
- ✅ v9.0: Native LSP Support, Pre-commit auto-installer, Rich CLI, Official SDK, GitHub Action.
- ✅ v10.0 (Pre-release): Native Git Hook Installer, SARIF reporting, Remote Configuration.
Check ROADMAP.md for the full list of future goals like Semantic License Analysis.
License: MIT © dhruv13x
Metadata
Release files for autoheader 12.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| autoheader-12.0.0.tar.gz | 41.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| autoheader-12.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 82.6 kB
Release files / autoheader-12.0.0.tar.gz
| Download URL | autoheader-12.0.0.tar.gz |
|---|---|
| Size | 41.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e612976e17d0a9e33396e738d7a711e3e96f46369f45556180474987f7768355
|
|
BLAKE2b-256 checksum How to use checksums |
c37001f4d7e4534a579f4caa1619119904fde495f51a219e0fe47b23dd3eb544
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 18, 2026.
Transparency logRelease files / autoheader-12.0.0-py3-none-any.whl
| Download URL | autoheader-12.0.0-py3-none-any.whl |
|---|---|
| Size | 40.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6239663c9b4983474af9f64d3397b7254a966bd6cea30d48d80750837a4f1dee
|
|
BLAKE2b-256 checksum How to use checksums |
74ff79a470c213d1329fa26f5815a1022ca17c360853848d1535eac26d5eb982
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
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.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Jun 18, 2026.
Transparency log