npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

file-path-header

v1.0.1

Published

Prepends a comment with the file's relative path at the top of supported source files.

Readme

File Path Header

A lightweight Node.js CLI tool that automatically adds file path comments to your source code files. Perfect for AI coding, documentation, and keeping track of file locations in large projects.

npm version License: MIT

✨ Why Use This?

  • 🤖 AI-Friendly: Makes it easier for AI tools (ChatGPT, Claude, etc.) to understand your project structure
  • 🔄 Auto-Updates: Automatically updates path comments when files are moved
  • 🎯 Smart Filtering: Respects .gitignore rules and skips irrelevant files
  • Zero Config: Works out of the box with sensible defaults
  • 🪝 Git Integration: Perfect for git hooks to keep paths synchronized

🚀 Quick Start

Installation

npm install -g file-path-header

Usage

Simply run in your project directory:

file-path-header

That's it! The tool will automatically find all supported source files and add path comments.

Before & After

Before:

import React from 'react';

function Header() {
  return <h1>Hello World</h1>;
}

After: (assuming that the file is located in: src/components/Header.js)

// src/components/Header.js
import React from 'react';

function Header() {
  return <h1>Hello World</h1>;
}

🎯 Perfect Combo with ASCII Tree Generator

For the ultimate project documentation setup, pair this with ascii-tree-generator:

# First, generate your project tree structure
npx ascii-tree-generator

# Then, add path headers to all source files
npx file-path-header

This combination gives AI tools (and developers) complete context about your project structure and individual file locations.

🛠 Supported Languages

| Comment Style | File Extensions | |---------------|-----------------| | // | .js, .ts, .jsx, .tsx, .java, .c, .cpp, .cs, .go, .rs, .php, .swift, .kt, .m, .scala| | # | .py, .sh, .rb, .pl |

🚫 Smart File Filtering

The tool automatically respects your .gitignore files and also ignores common build/temporary directories:

  • node_modules/, .git/
  • dist/, build/
  • .vscode/, .idea/
  • System files (.DS_Store, Thumbs.db)
  • Temporary files (*.tmp, *.cache, *.log)

🔄 How It Works

  1. Scans your project for supported source files
  2. Respects .gitignore rules and common ignore patterns
  3. Detects existing path comments and updates them if files have moved
  4. Adds clean, consistent path comments at the top of each file

Smart Comment Handling

  • ✅ Adds new comment if none exists
  • ✅ Updates existing comment if file path changed
  • ✅ Skips files that already have the correct comment
  • ✅ Removes outdated path comments before adding new ones

Git Integration

Pre-commit Hook

Add to .git/hooks/pre-commit:

#!/bin/sh
# Change to the project root directory
cd "$(git rev-parse --show-toplevel)"

npx file-path-header
git add .

Package.json Script

{
  "scripts": {
    "paths": "file-path-header"
  }
}

Then run: npm run paths

📁 Example Output

After running the tool on a typical React project:

// src/App.js
import React from 'react';
// ... rest of your code

// src/components/Header.jsx  
import React from 'react';
// ... component code

// src/utils/helpers.js
export const formatDate = (date) => {
// ... utility functions

// src/hooks/useAuth.js
import { useState, useEffect } from 'react';
// ... custom hook

🚀 Use Cases

  • AI Coding: Help AI understand your project structure
  • Code Reviews: Quickly identify file locations in diffs
  • Large Projects: Never lose track of where files are located
  • Refactoring: Automatically update path comments when moving files
  • Documentation: Generate consistent file headers across your project

🤝 Works Great With

  • ascii-tree-generator - Generate visual project structure
  • AI coding tools - ChatGPT, Claude, GitHub Copilot, etc.
  • Git hooks - Keep file paths in sync automatically
  • Documentation workflows - Maintain consistent project documentation

🔧 Technical Details

  • Zero dependencies - Lightweight and fast
  • Hierarchical .gitignore support - Respects all .gitignore files in your project
  • Cross-platform - Works on Windows, macOS, and Linux

📄 License

MIT License - feel free to use in your projects!

🔗 Links


Made with ❤️ by Maciej Popenda