RAG-based Q&A system for code repositories with verifiable citations
Project description
CodeRAG - Code Q&A with Verifiable Citations
RAG-based Q&A system for code repositories that provides grounded answers with verifiable citations.
๐ Quick Start
# Install
pip install code-rag-me
# Configure (get free API key from https://console.groq.com/keys)
coderag setup
# Start web interface
coderag serve
Open http://localhost:8000 to use the web interface.
Claude Desktop Integration (MCP)
# Auto-configure Claude Desktop
coderag mcp-install
# Restart Claude Desktop
Now you can use CodeRAG directly in Claude Desktop!
โจ Features
- Grounded Responses: Every answer includes citations to source code
[file:start-end] - Cloud or Local LLM: Use Groq (free), OpenAI, Anthropic, or run locally with GPU
- GitHub Integration: Index any public GitHub repository
- MCP Support: Integrate directly with Claude Desktop
- Semantic Chunking: Tree-sitter for Python, text fallback for other languages
- Web Interface: Gradio UI for easy interaction
- REST API: Programmatic access for integration
- CLI: Full command-line interface
๐ CLI Commands
coderag setup # Configure LLM provider and API key
coderag serve # Start web server
coderag mcp-install # Configure Claude Desktop for MCP
coderag mcp-run # Run MCP server (used by Claude Desktop)
coderag index <url> # Index a GitHub repository
coderag query <repo> "?" # Ask a question about code
coderag repos # List indexed repositories
coderag doctor # Diagnose setup issues
๐ง Installation
Linux
Arch Linux / Manjaro
Arch Linux uses PEP 668 to protect system Python. Use one of these methods:
Option A: pipx (Recommended for CLI tools)
sudo pacman -S python-pipx
pipx install code-rag-me
Option B: Virtual environment
python -m venv ~/.local/share/coderag-venv
source ~/.local/share/coderag-venv/bin/activate
pip install code-rag-me
To always have coderag available, add to your ~/.bashrc or ~/.zshrc:
alias coderag="~/.local/share/coderag-venv/bin/coderag"
Debian / Ubuntu
# Install Python and pip
sudo apt update
sudo apt install python3 python3-pip python3-venv
# Option A: pipx (Recommended)
sudo apt install pipx
pipx install code-rag-me
# Option B: Virtual environment
python3 -m venv ~/.local/share/coderag-venv
source ~/.local/share/coderag-venv/bin/activate
pip install code-rag-me
Fedora / RHEL / CentOS
# Install Python and pip
sudo dnf install python3 python3-pip
# Option A: pipx (Recommended)
sudo dnf install pipx
pipx install code-rag-me
# Option B: Virtual environment
python3 -m venv ~/.local/share/coderag-venv
source ~/.local/share/coderag-venv/bin/activate
pip install code-rag-me
Other Linux Distributions
# Create virtual environment
python3 -m venv ~/.local/share/coderag-venv
source ~/.local/share/coderag-venv/bin/activate
pip install code-rag-me
macOS
Option A: pipx (Recommended)
# Install pipx via Homebrew
brew install pipx
pipx ensurepath
pipx install code-rag-me
Option B: Virtual environment
python3 -m venv ~/.local/share/coderag-venv
source ~/.local/share/coderag-venv/bin/activate
pip install code-rag-me
Option C: Homebrew Python
brew install python@3.11
pip3 install code-rag-me
Windows
Option A: pipx (Recommended)
# Install pipx
pip install pipx
pipx ensurepath
# Install CodeRAG
pipx install code-rag-me
Option B: Virtual environment
# Create virtual environment
python -m venv %USERPROFILE%\coderag-venv
# Activate (Command Prompt)
%USERPROFILE%\coderag-venv\Scripts\activate.bat
# Activate (PowerShell)
& $env:USERPROFILE\coderag-venv\Scripts\Activate.ps1
# Install
pip install code-rag-me
Option C: Direct install (not recommended)
pip install code-rag-me
Note: On Windows, you may need to run PowerShell as Administrator or enable script execution with
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
From Source
git clone https://github.com/Sebastiangmz/CodeRAG.git
cd CodeRAG
pip install -e .
coderag setup
Docker
git clone https://github.com/Sebastiangmz/CodeRAG.git
cd CodeRAG
docker compose up
Post-Installation
After installing, configure your LLM provider:
coderag setup
This will prompt you to:
- Choose an LLM provider (Groq recommended - free tier available)
- Enter your API key (get one at https://console.groq.com/keys)
- Configure optional settings
๐ Usage Examples
Web Interface
- Run
coderag serve - Open http://localhost:8000
- Go to "Index Repository" โ Enter GitHub URL โ Click "Index"
- Go to "Ask Questions" โ Select repo โ Ask questions
Command Line
# Index a repository
coderag index https://github.com/owner/repo
# Ask questions
coderag query abc12345 "How does authentication work?"
# List repositories
coderag repos
REST API
# Index repository
curl -X POST http://localhost:8000/api/v1/repos/index \
-H "Content-Type: application/json" \
-d '{"url": "https://github.com/owner/repo"}'
# Query
curl -X POST http://localhost:8000/api/v1/query \
-H "Content-Type: application/json" \
-d '{"question": "How does X work?", "repo_id": "abc12345"}'
Claude Desktop (MCP)
After running coderag mcp-install and restarting Claude Desktop:
You: Use coderag to index https://github.com/owner/repo
Claude: I'll index that repository for you...
โ
Indexed! 150 files, 1,234 chunks.
You: How does the authentication system work?
Claude: Based on the code, authentication is handled in...
[src/auth/handler.py:45-78]
โ๏ธ Configuration
Environment Variables
# LLM Provider (groq, openai, anthropic, openrouter, together, local)
MODEL_LLM_PROVIDER=groq
MODEL_LLM_API_KEY=your-api-key
# Embeddings (runs locally on CPU by default)
MODEL_EMBEDDING_DEVICE=auto # auto, cuda, or cpu
# Server
SERVER_HOST=0.0.0.0
SERVER_PORT=8000
Config File
Configuration is stored in ~/.config/coderag/config.json after running coderag setup.
๐๏ธ Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ User Interface โ
โ (Gradio UI / REST API / MCP / CLI) โ
โโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Ingestion Pipeline โ
โ GitHub Clone โ File Filter โ Chunker (Tree-sitter/Text) โ
โโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Indexing & Storage โ
โ Embeddings (nomic-embed) โ ChromaDB (Cosine) โ
โโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโดโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Retrieval & Generation โ
โ Query โ Top-K Search โ LLM (Cloud/Local) โ Response โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
๐ Project Structure
src/coderag/
โโโ cli.py # Unified CLI
โโโ ingestion/ # Repository loading and chunking
โโโ indexing/ # Embeddings and vector storage
โโโ retrieval/ # Semantic search
โโโ generation/ # LLM inference and citations
โโโ mcp/ # Model Context Protocol server
โโโ ui/ # Gradio web interface
โโโ api/ # REST API endpoints
โโโ models/ # Data models
๐งช Development
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest tests/
# Format code
black src/ tests/
# Lint
ruff check src/ tests/
# Type check
mypy src/
๐ Performance
- Indexing: ~1000 files in < 5 minutes
- Query: Response in < 10 seconds
- Embeddings: Runs on CPU (~275MB model)
- LLM: Cloud (instant) or Local (requires 8GB+ VRAM)
๐ Citation Format
All responses include citations:
[file_path:start_line-end_line]
Example:
The authentication logic is in the login() function [src/auth.py:45-78].
๐ Troubleshooting
Run diagnostics:
coderag doctor
Common Issues
externally-managed-environment error (Linux)
error: externally-managed-environment
ร This environment is externally managed
This happens on modern Linux distributions (Arch, Fedora 38+, Ubuntu 23.04+) that implement PEP 668. Solution: use pipx or a virtual environment. See the Installation section for your distribution.
No API key configured
coderag setup # Run interactive setup
CUDA / GPU errors
If you don't have a GPU or encounter CUDA errors:
export MODEL_EMBEDDING_DEVICE=cpu
coderag serve
Or add to your .env file:
MODEL_EMBEDDING_DEVICE=cpu
Claude Desktop not detecting MCP
- Run
coderag mcp-install - Completely quit Claude Desktop (not just close the window)
- Restart Claude Desktop
- Check the MCP icon in Claude Desktop settings
Permission denied on Linux/macOS
# If using pipx
pipx ensurepath
source ~/.bashrc # or ~/.zshrc
# If using venv, make sure it's activated
source ~/.local/share/coderag-venv/bin/activate
PowerShell execution policy (Windows)
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
๐ License
MIT License - see LICENSE file
๐ค Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
๐ Acknowledgments
- Groq for fast, free LLM inference
- nomic-embed-text by Nomic AI
- ChromaDB for vector storage
- Tree-sitter for code parsing
- MCP by Anthropic
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file code_rag_me-0.1.1.tar.gz.
File metadata
- Download URL: code_rag_me-0.1.1.tar.gz
- Upload date:
- Size: 58.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ff6909d54bada4c80ef02f2110a2c0da2f83113dbbd78a62373eb06632b0838
|
|
| MD5 |
ac9f5067c3f821c4f461a72156bf1cdf
|
|
| BLAKE2b-256 |
efd8329d0b7b5b0d086486d05117b38a8dd882adc6da07fd039641f6c6166c27
|
Provenance
The following attestation bundles were made for code_rag_me-0.1.1.tar.gz:
Publisher:
publish.yml on Sebastiangmz/CodeRAG
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
code_rag_me-0.1.1.tar.gz -
Subject digest:
1ff6909d54bada4c80ef02f2110a2c0da2f83113dbbd78a62373eb06632b0838 - Sigstore transparency entry: 779591466
- Sigstore integration time:
-
Permalink:
Sebastiangmz/CodeRAG@b0dc0c3585e8dbe9c1d30a675c71a8993f9f3b0e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Sebastiangmz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b0dc0c3585e8dbe9c1d30a675c71a8993f9f3b0e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file code_rag_me-0.1.1-py3-none-any.whl.
File metadata
- Download URL: code_rag_me-0.1.1-py3-none-any.whl
- Upload date:
- Size: 57.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e76f6e04093739952244b8afad35e5472626795ca5332994251c77e8f257ebe3
|
|
| MD5 |
d6b60c73690c56ca526da76cae90b5e5
|
|
| BLAKE2b-256 |
3e2beb631b7f3f415d4f419d77227bb33b26b2bf475f0aa17a213612f9769d9c
|
Provenance
The following attestation bundles were made for code_rag_me-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on Sebastiangmz/CodeRAG
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
code_rag_me-0.1.1-py3-none-any.whl -
Subject digest:
e76f6e04093739952244b8afad35e5472626795ca5332994251c77e8f257ebe3 - Sigstore transparency entry: 779591467
- Sigstore integration time:
-
Permalink:
Sebastiangmz/CodeRAG@b0dc0c3585e8dbe9c1d30a675c71a8993f9f3b0e -
Branch / Tag:
refs/heads/main - Owner: https://github.com/Sebastiangmz
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b0dc0c3585e8dbe9c1d30a675c71a8993f9f3b0e -
Trigger Event:
workflow_dispatch
-
Statement type: