Skip to main content

Annotates source files with their relative paths for easier AI/debug context

Project description

Annotator CLI

Annotator is a simple CLI utility that prepends relative file paths as comments to your project files as the first line.
It’s designed to make AI debugging easier by automatically marking file paths for better context and easier copy-pasting.


✨ Features

  • 🚀 Automatically annotates files with their relative paths
  • 🔄 Reversible — clean annotations with --revert
  • 🎯 Template system — framework-specific presets (Next.js, Spring Boot, Python, React, Prisma)
  • ⚙️ Fully customizable via .annotator.jsonc configuration
  • 🚫 Smart filtering — respects .gitignore, excludes binaries, and skips nested paths
  • 🔍 Stateless revert — removes annotations using unique signature (~annotator~)
  • Lightweight and fast — minimal dependencies

📦 Installation

Via pipx (recommended):

pipx install annotator-cli

Via pip:

pip install annotator-cli

🚀 Quick Start

1. Initialize configuration

cd /path/to/your/project
annotator --init

This creates .annotator.jsonc with sensible defaults and helpful comments.

2. Annotate your project

annotator

3. Revert annotations (if needed)

annotator --revert

📝 Configuration

Annotator uses a layered configuration system:

Priority Chain:
.gitignore.annotator.jsonctemplates (cumulative)

Example .annotator.jsonc

{
  // List of templates to apply (keeping default is recommended)
  // pick additional: nextjs, react, springboot, python3, prisma ...
  "templates": ["default", "nextjs"],

  // Behavior settings
  "settings": {
    "max_recursive_depth": 10, // How deep to recurse into folders
    "max_num_of_files": 1000, // Maximum files to process
    "max_file_size_kb": 512, // Skip files larger than this
  },

  // Override comment styles for specific extensions
  // Example: ".kt": "//", ".scala": "//"
  "comment_styles": {},

  // Additional file extensions to exclude
  "exclude_extensions": [".log", ".cache"],

  // Additional directories to exclude (supports nested paths)
  // Example: ["temp", "src/generated/proto"]
  "exclude_dirs": ["node_modules", ".venv", "__pycache__"],

  // Additional specific file names to exclude
  "exclude_files": [".env", ".annotator.jsonc"],
}
📋 Configuration Details

Templates

Annotator includes built-in templates for common frameworks:

  • default - General-purpose config with 40+ languages, common excludes
  • nextjs - Next.js specific exclusions (.next, config files, etc.)
  • react - React/Vite/CRA exclusions
  • springboot - Spring Boot/Maven/Gradle exclusions
  • python3 - Python virtual envs, caches, Jupyter notebooks
  • prisma - Prisma schema and migration exclusions

Templates are applied cumulatively in order. See all templates at:
github.com/assignment-sets/annotator-cli/tree/main/annotator/templates

Comment Styles

Maps file extensions or exact filenames to comment syntax:

".js": "//",
".py": "#",
".html": "<!--",
".css": "/*"

Exclusion Rules

  • exclude_extensions: Skip files by extension (e.g., [".log", ".bin"])
  • exclude_dirs: Skip directories by name or nested path (e.g., ["node_modules", "src/generated"])
  • exclude_files: Skip specific filenames (e.g., [".env", "package-lock.json"])

Note: .gitignore patterns are always respected and have highest priority.

Extension Parsing

Extensions are parsed from the last . to the end:

  • file.js.js
  • component.test.tsx.tsx
  • archive.tar.gz.gz

🎯 CLI Commands

# Annotate current directory
annotator

# Annotate specific path
annotator /path/to/project

# Initialize configuration
annotator --init

# Remove all annotations
annotator --revert

# Show help
annotator --help

🔧 How It Works

  1. Loads configuration from .annotator.jsonc and merges with selected templates
  2. Respects .gitignore patterns (highest priority)
  3. Applies filters based on extensions, directories, files, and size limits
  4. Prepends comments with relative path and unique signature:
   # src/utils/helper.py ~annotator~
  1. Skips already annotated files (idempotent)
  2. Revert support removes only lines containing ~annotator~ signature

📚 Common Use Cases

Next.js Project

{
  "templates": ["default", "nextjs"],
}

Python Data Science Project

{
  "templates": ["default", "python3"],
  // customize more as you need for example
  "exclude_extensions": [".parquet"],
}

Spring Boot Microservice

{
  "templates": ["default", "springboot"],
}

Full-Stack React + Prisma

{
  "templates": ["default", "react", "prisma"],
}

🤝 Contributing

Want to add a template for your favorite framework? PRs welcome!

Repository: github.com/assignment-sets/annotator-cli


⚠️ Disclaimer

This software is provided as-is, without warranty of any kind.
Use at your own risk — the author is not responsible for data loss, crashes, or security issues.


📄 License

MIT License - see LICENSE file for details.


🙏 Acknowledgments

Built to make AI-assisted debugging easier by providing better file context.

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

annotator_cli-1.0.0.tar.gz (14.1 kB view details)

Uploaded Source

Built Distribution

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

annotator_cli-1.0.0-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file annotator_cli-1.0.0.tar.gz.

File metadata

  • Download URL: annotator_cli-1.0.0.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for annotator_cli-1.0.0.tar.gz
Algorithm Hash digest
SHA256 027f7f73ceaa62a93f7f09f74ca883748aa34d2a4dd2fb84162a3a940c95d11f
MD5 1a554a4fd6dbb815defe25b654ef9ba5
BLAKE2b-256 d3b48171ac585f59412340f7423f4cd2f27358a1ceef11c37e653fcddbec1c30

See more details on using hashes here.

File details

Details for the file annotator_cli-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: annotator_cli-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for annotator_cli-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e559ea0c756c65e977b0650ca02dde5009e0977be77c0c3125eabe99597b33c0
MD5 cd484a2816591d5ecb0a20a44b6c0e7d
BLAKE2b-256 bbc2d8b600139311f5c927ee3a3833a17e3e31da050eab2f92a1895a8d1be77c

See more details on using hashes here.

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