Skip to main content

A lightweight CLI to index a codebase and create a context-ready prompt file for LLM.

Project description

CodeIndexer

PyPI version

A lightweight CLI tool for indexing codebases to provide context for LLMs.

Why ?

Still doing some finger-hurting typing or copy-pasting just to update your LLM about code changes or set up context in new chats (the old way 😅, without copilots)?

I run this tool to generate a structured prompt with my project files, so all I have to do is copy, paste, and the model is ready to go! ⌛⏱️✨

Installation ℹ️

pip install codeindexer

# Basic usage
codeindexer --index ./my_repo --format md index_file.md

# Filter by file extensions (create a txt prompt file index_file.txt)
codeindexer --index ./my_repo --only .py,.js,.md --format txt index_file.txt

# Skip specific directories or files (create a json prompt file index_file.json)
codeindexer --index ./my_repo --skip node_modules/,venv/,*.log --format json index_file.json

# Explicitly include files/paths (even if ignored by .gitignore)
codeindexer --index ./my_repo --include important.log,temp/config.json --format md index_file.md

# Add a custom prompt at the end
codeindexer --index ./my_repo --prompt "Analyze and suggest improvements." --format md index_file.md

# Disable .gitignore parsing
codeindexer --index ./my_repo --no-gitignore --format md index_file.md

# Split the prompt into multiple parts e.g 1000 lines max (place prompt parts in the index_file/... folder)
codeindexer --index ./my_repo --format md index_file.md --split 1000

Example of indexed output file (index_file.md) 📋

# Repo: my_repo
# Folder structure:
my_repo/
├── src/
│   ├── main.py
│   ├── utils.py
├── tests/
│   ├── test_main.py
├── README.md
├── requirements.txt

# Files  
# my_repo/requirements.txt  
{contents of my_repo/requirements.txt}  

# my_repo/README.md  
{contents of my_repo/README.md}  

# my_repo/src/main.py  
{contents of my_repo/src/main.py}  

...  
________________________________________

Acknowledge the project's description and files, do no provide additional explanation, wait for instructions

Options 🔧

  • --index: Directory to index (required)
  • --only: Comma-separated list of file extensions to include (e.g., .py,.js,.md)
  • --skip: Comma-separated list of patterns to skip (e.g., node_modules/,venv/,*.log)
  • --include: Comma-separated list of patterns to explicitly include even if in .gitignore
  • --format: Output format (md, txt, json) - default is md
  • --prompt: Custom prompt to add at the end of the index
  • --no-skip-env: Include .env files (by default they are skipped)
  • --no-gitignore: Disable automatic parsing of .gitignore files (enabled by default)
  • --split: Split output into chunks with specified max lines per file (default: 1000)

Features ✨

  • ✅ Generate a single file with your repo’s structure and files
  • ✅ Automatically respects .gitignore rules 📋
  • ✅ Filters files by extension and skips binaries 🔍
  • ✅ Multiple output formats: Markdown, text, JSON 📝
  • ✅ Add a custom prompt for LLM context 🤖
  • ✅ Split output files into small parts

Contributing 🤝

Contributions are welcome! Please check out our Contributing Guide for details on how to get started.

License

MIT

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

codeindexer-0.1.2.tar.gz (13.8 kB view details)

Uploaded Source

Built Distribution

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

codeindexer-0.1.2-py3-none-any.whl (14.0 kB view details)

Uploaded Python 3

File details

Details for the file codeindexer-0.1.2.tar.gz.

File metadata

  • Download URL: codeindexer-0.1.2.tar.gz
  • Upload date:
  • Size: 13.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for codeindexer-0.1.2.tar.gz
Algorithm Hash digest
SHA256 36669cc665e52e1b85c687c989ac2137c107de3034b2c0a710673022ffd51c19
MD5 98a078af8d813b9a835154728803804b
BLAKE2b-256 3c982fd5d79cb05d84164e7806303a2840bf0b7bb741e15d91baa49ae43fd004

See more details on using hashes here.

File details

Details for the file codeindexer-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: codeindexer-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 14.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for codeindexer-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3f329e97695ce29b1d52b4b8faf80e1473746768cc54c21e5ca976e916044107
MD5 92ffa151bce72fbcf935b2903b00eec3
BLAKE2b-256 f01396357e58db5f48171c162d9b858666e0b419e7c9fdc6a593350431ee0132

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