Skip to content

path-comment-hook

Add file path headers to your source code automatically.

Never lose track of where you are in large codebases. This pre-commit hook automatically adds file path comments to the top of your source files, making code navigation effortless.

  • Set up in 5 minutes


    Install with pip and integrate with pre-commit in minutes.

    Getting started

  • Better Code Navigation


    Know exactly where you are in large codebases.

    Why path headers?

  • Highly Configurable


    Customize comment styles, exclusions, and more.

    Configuration

  • Multi-Language Support


    Works with Python, JavaScript, TypeScript, C/C++, and more.

    Supported languages

Quick Example

def calculate_tax(amount, rate):
    """Calculate tax based on amount and rate."""
    return amount * rate

def format_currency(amount):
    """Format amount as currency string."""
    return f"${amount:.2f}"
# src/utils/tax_calculator.py

def calculate_tax(amount, rate):
    """Calculate tax based on amount and rate."""
    return amount * rate

def format_currency(amount):
    """Format amount as currency string."""
    return f"${amount:.2f}"

Installation

pip install path-comment-hook
pipx install path-comment-hook
poetry add --group dev path-comment-hook

Pre-commit Integration

Add to your .pre-commit-config.yaml:

repos:
  - repo: https://github.com/Shorzinator/path-comment-hook
    rev: v0.3.0  # Use the latest version
    hooks:
      - id: path-comment

Key Features

  • Fast: Parallel processing for large codebases
  • Configurable: Customize comment styles and exclusions
  • Multi-language: Support for 10+ programming languages
  • Zero dependencies: Lightweight and reliable
  • Reversible: Easy to add or remove headers
  • Smart detection: Handles shebangs and encoding automatically

Quick Start

  1. Install the hook:

    pip install path-comment-hook
    

  2. Add to pre-commit config:

    - repo: https://github.com/Shorzinator/path-comment-hook
      rev: v0.3.0
      hooks:
        - id: path-comment
    

  3. Run on your project:

    pre-commit run path-comment --all-files
    

That's it! Your files now have path headers for better navigation.

What's Next?

Community


path-comment-hook is open source and available under the MIT license.