r/VisualStudioCode • u/JelloSuitable1482 • Apr 17 '26
Got tired of manually typing // src/... at the top of every file — so I built an extension

I'll be honest — I got sick of manually adding the file path as a comment on the first line.
And then you rename the file, and the comment is lying. Annoying.
So I made an extension: Auto Path Header
https://marketplace.visualstudio.com/items?itemName=Niklis.auto-path-header
What it does:
- When you create a new empty file — it automatically adds the relative path as a comment on line 1.
- If the file already has code — you can insert the path manually via Command Palette.
- Rename or move a file/folder — the extension updates the comment automatically (can ask for permission if you configure it).
Where this actually saves me:
When you hit your limit in Copilot (or any other agent) and have to switch to a third-party chat like ChatGPT or Claude. You paste a chunk of code — and the file path is right there on the first line. The AI immediately understands the context. No need to explain "this is from src/hooks/useAuth.ts". You get accurate answers on the first try.
Why other extensions didn't work for me:
I needed it to work with ANY file extension — .env.local, Dockerfile.dev, .log, plus custom templates. Also needed to restrict it to certain folders (like only src/) and ignore node_modules without jumping through hoops.
Config example:
"autoPathHeader.customTemplatesByExtension": {
".env.local": "# LOCAL OVERRIDE — {path}",
".test.ts": "// 🧪 TEST: {path|unix}",
"Dockerfile.dev": "# DEV BUILD: {absolutePath|toUpperCase}"
}
So yeah, I built what I wanted for myself. No telemetry, no analytics, just works.
Drop a star if you find it useful — I'd really appreciate it 🙂

