A powerful CLI tool that ingests your codebase and allows you to ask questions about it using Retrieval-Augmented Generation (RAG).
Installation • Quick Start • Commands • Configuration • Examples
- Features
- Installation
- Quick Start
- Commands
- Configuration
- Examples
- How It Works
- Architecture
- Troubleshooting
- FAQ
- Contributing
- License
- 🔒 Privacy-First: All data processing happens locally by default
- ⚡ Fast & Efficient: Local embeddings and optimized vector search
- 🤖 Multiple LLM Support: Works with Groq (cloud)
- 💾 Local Storage: SQLite database for embeddings and context
- 🎯 Smart Chunking: Intelligent code splitting with configurable overlap
- 📊 Streaming Output: Real-time response streaming for better UX
- 🎨 Multiple File Types: Supports TypeScript, JavaScript, Python, Go, Rust, Java, and more
- 🧠 Smart Configuration: Automatically detects project languages and optimizes config
- 🛡️ Intelligent Filtering: Automatically excludes binaries, large files, and build artifacts
- ⚙️ Highly Configurable: Fine-tune chunking, retrieval, and model parameters
- 🚀 Zero Setup: Works out of the box with sensible defaults
⚠️ Codebase Size Limitation: Codexa is optimized for small to medium-sized codebases. It currently supports projects with up to 200 files and 20,000 chunks. For larger codebases, consider using more restrictiveincludeGlobspatterns to focus on specific directories or file types.
Before installing Codexa, ensure you have the following:
-
Node.js: v20.0.0 or higher
node --version # Should be v20.0.0 or higher -
For Cloud LLM (Groq): A Groq API key from console.groq.com
Choose the installation method that works best for your system:
Install Codexa globally using npm:
npm install -g codexaVerify installation:
codexaInstall codexa using Homebrew on macOS:
First, add the tap:
brew tap sahitya-chandra/codexaThen install:
brew install codexaTo update codexa to the latest version:
If installed via npm:
npm install -g codexa@latestIf installed via Homebrew:
brew upgrade codexaCheck your current version:
codexa --versionCheck for updates:
- Visit the npm package page to see the latest version
- Or check the GitHub releases
💡 Tip: It's recommended to keep Codexa updated to get the latest features, bug fixes, and security updates.
Codexa requires an LLM to generate answers. You can use Groq (cloud).
Groq provides fast cloud-based LLMs with a generous free tier.
Step 1: Get a Groq API Key
- Visit console.groq.com
- Sign up or log in
- Navigate to API Keys section
- Create a new API key
- Copy your API key (starts with
gsk_)
Step 2: Set GROQ API Key
Run the following command to securely save your API key:
codexa config set GROQ_API_KEY "gsk_your_api_key_here"This will save the key to your local configuration file (.codexarc.json).
Step 3: Verify API Key is Set
codexa config get GROQ_API_KEYStep 4: Configure Codexa
Codexa defaults to using Groq when you run codexa init. If you need to manually configure, edit .codexarc.json:
{
"modelProvider": "groq",
"model": "openai/gpt-oss-120b",
"embeddingProvider": "local",
"embeddingModel": "Xenova/all-MiniLM-L6-v2"
}Models you can use:
openai/gpt-oss-120b(recommended, default)llama-3.1-70b-versatile
For Groq:
# 1. Get API key from console.groq.com
# 2. Run codexa init (defaults to Groq)
codexa init
# 3. Set GROQ API key
codexa config set GROQ_API_KEY "gsk_your_key"
# 4. Proceed to igestionOnce Codexa is installed and your LLM is configured, you're ready to use it:
-
Navigate to your project directory:
cd /path/to/your/project -
Initialize Codexa:
codexa init
This creates a
.codexarc.jsonconfiguration file with sensible defaults. -
Set GROQ API Key
codexa config set GROQ_API_KEY "gsk_your_key"
This will save the key to your local configuration file (
.codexarc.json). -
Ingest your codebase:
codexa ingest
This indexes your codebase and creates embeddings. First run may take a few minutes.
-
Ask questions:
codexa ask "How does the authentication flow work?" codexa ask "What is the main entry point of this application?" codexa ask "Show me how error handling is implemented"
Creates a .codexarc.json configuration file optimized for your codebase.
codexa initWhat it does:
- Analyzes your codebase to detect languages, package managers, and frameworks
- Creates optimized config with language-specific include/exclude patterns
- Generates
.codexarc.jsonin the project root with tailored settings - Can be safely run multiple times (won't overwrite existing config)
Detection Capabilities:
- Languages: TypeScript, JavaScript, Python, Go, Rust, Java, Kotlin, Scala, C/C++, Ruby, PHP, Swift, Dart, and more
- Package Managers: npm, yarn, pnpm, pip, poetry, go, cargo, maven, gradle, sbt, bundler, composer, and more
- Frameworks: Next.js, React, Django, Flask, Rails, Laravel, Spring, Flutter, and more
Example Output:
Analyzing codebase...
✓ Detected: typescript, javascript (npm, yarn)
✓ Created .codexarc.json with optimized settings for your codebase!
┌ 🚀 Setup Complete ──────────────────────────────────────────┐
│ │
│ Next Steps: │
│ │
│ 1. Review .codexarc.json - Update provider keys if needed |
│ 2. Set your GROQ API Key: codexa config set GROQ_API_KEY |
│ 3. Run: codexa ingest - Start indexing your codebase │
│ 4. Run: codexa ask "your question" - Ask questions │
│ │
└─────────────────────────────────────────────────────────────┘
Indexes the codebase and generates embeddings for semantic search.
codexa ingest [options]Options:
-f, --force- Clear existing index and rebuild from scratch
Examples:
# Standard ingestion
codexa ingest
# Force rebuild (useful if you've updated code significantly)
codexa ingest --forceWhat it does:
- Scans your repository based on
includeGlobsandexcludeGlobspatterns - Filters files - Automatically excludes binaries, large files (>5MB), and build artifacts
- Chunks files into manageable segments
- Generates vector embeddings for each chunk
- Stores everything in
.codexa/index.db(SQLite database)
Smart Filtering:
- Automatically skips binary files (executables, images, archives, etc.)
- Excludes files larger than the configured size limit (default: 5MB)
- Filters based on file content analysis (not just extensions)
Note: First ingestion may take a few minutes depending on your codebase size. Subsequent ingestions are faster as they only process changed files.
Manage configuration values, including API keys.
codexa config <action> [key] [value]Actions:
set <key> <value>- Set a configuration valueget <key>- Get a configuration valuelist- List all configuration values
Examples:
# Set Groq API Key
codexa config set GROQ_API_KEY "gsk_..."
# Check current key
codexa config get GROQ_API_KEYAsk natural language questions about your codebase.
codexa ask <question...> [options]Arguments:
<question...>- Your question (can be multiple words)
Options:
--stream- Enable streaming output
Examples:
# Basic question
codexa ask "How does user authentication work?"
# Question with multiple words
codexa ask "What is the main entry point of this application?"
# Enable streaming
codexa ask "Summarize the codebase structure" --streamHow it works:
- Converts your question to a vector embedding
- Searches the codebase for relevant chunks using vector similarity
- Retrieves the top-K most relevant code sections
- Sends question + context to the LLM
- Returns a contextual answer about your codebase
Codexa uses a .codexarc.json file in your project root for configuration. This file is automatically created when you run codexa init.
Location: .codexarc.json (project root)
Format: JSON
When you run codexa init, Codexa automatically:
-
Analyzes your codebase structure to detect:
- Languages present (by file extensions)
- Package managers used (by config files)
- Frameworks detected (by dependencies and config files)
-
Generates optimized patterns:
- Include patterns: Only file extensions relevant to detected languages
- Exclude patterns: Language-specific build artifacts, dependency directories, and cache folders
- Smart defaults: Based on your project type
-
Applies best practices:
- Excludes common build outputs (
dist/,build/,target/, etc.) - Excludes dependency directories (
node_modules/,vendor/,.venv/, etc.) - Includes important config files and documentation
- Filters binaries and large files automatically
- Excludes common build outputs (
This means your config is tailored to your project from the start, ensuring optimal indexing performance!
Some settings can be configured via environment variables:
| Variable | Description | Required For |
|---|---|---|
GROQ_API_KEY |
Groq API key for cloud LLM | Groq provider |
Example:
# Using config command (Recommended)
codexa config set GROQ_API_KEY "gsk_your_key_here"
# Or using environment variables
export GROQ_API_KEY="gsk_your_key_here" # macOS/LinuxType: "groq"
Default: "groq"
The LLM provider to use for generating answers.
"groq"- Uses Groq's cloud API (requiresGROQ_API_KEY)
Type: string
Type: string
Default: "openai/gpt-oss-120b"
The model identifier to use.
Type: "local"
Default: "local"
The embedding provider for vector search.
"local"- Uses@xenova/transformers(runs entirely locally)
Type: string
Default: "Xenova/all-MiniLM-L6-v2"
The embedding model for generating vector representations. This model is downloaded automatically on first use.
Type: number
Default: 200
Maximum number of lines per code chunk. Larger values = more context per chunk but fewer chunks.
Type: number
Default: 20
Number of lines to overlap between consecutive chunks. Helps maintain context at chunk boundaries.
Type: string[]
Default: ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx", "**/*.py", "**/*.go", "**/*.rs", "**/*.java", "**/*.md", "**/*.json"]
File patterns to include in indexing. Supports glob patterns.
Examples:
{
"includeGlobs": [
"**/*.ts",
"**/*.tsx",
"src/**/*.js",
"lib/**/*.py"
]
}Type: string[]
Default: ["node_modules/**", ".git/**", "dist/**", "build/**", ".codexa/**", "package-lock.json"]
File patterns to exclude from indexing.
Examples:
{
"excludeGlobs": [
"node_modules/**",
".git/**",
"dist/**",
"**/*.test.ts",
"coverage/**"
]
}Type: string
Default: ".codexa/sessions"
Directory to store conversation history for session management.
Type: string
Default: ".codexa/index.db"
Path to the SQLite database storing code chunks and embeddings.
Type: number
Default: 0.2
Controls randomness in LLM responses (0.0 = deterministic, 1.0 = creative).
- Lower values (0.0-0.3): More focused, deterministic answers
- Higher values (0.7-1.0): More creative, varied responses
Type: number
Default: 4
Number of code chunks to retrieve and use as context for each question. Higher values provide more context but may include less relevant information.
Type: number
Default: 5242880 (5MB)
Maximum file size in bytes. Files larger than this will be excluded from indexing. Helps avoid processing large binary files or generated artifacts.
Example:
{
"maxFileSize": 10485760
}Type: boolean
Default: true
Whether to automatically skip binary files during indexing. Binary detection uses both file extension and content analysis.
Example:
{
"skipBinaryFiles": true
}Type: boolean
Default: true
Whether to skip files exceeding maxFileSize during indexing. Set to false if you want to include all files regardless of size.
Example:
{
"skipLargeFiles": true,
"maxFileSize": 10485760
}{
"modelProvider": "groq",
"model": "openai/gpt-oss-120b",
"embeddingProvider": "local",
"embeddingModel": "Xenova/all-MiniLM-L6-v2",
"maxChunkSize": 300,
"chunkOverlap": 20,
"temperature": 0.2,
"topK": 4
}Remember: Set GROQ_API_KEY:
codexa config set GROQ_API_KEY "your-api-key"{
"modelProvider": "groq",
"model": "openai/gpt-oss-120b",
"maxChunkSize": 150,
"chunkOverlap": 15,
"topK": 6,
"temperature": 0.1,
"includeGlobs": [
"src/**/*.ts",
"src/**/*.tsx",
"lib/**/*.ts"
],
"excludeGlobs": [
"node_modules/**",
"dist/**",
"**/*.test.ts",
"**/*.spec.ts",
"coverage/**"
]
}# 1. Initialize in your project
cd my-project
codexa init
# 2. Set Groq Api Key
codexa config set GROQ_API_KEY <your-groq-key>
# 3. Index your codebase
codexa ingest
# 4. Ask questions
codexa ask "What is the main purpose of this codebase?"
codexa ask "How does the user authentication work?"
codexa ask "Where is the API routing configured?"# After significant code changes
codexa ingest --forceUpdate .codexarc.json to focus on specific languages:
{
"includeGlobs": [
"**/*.ts",
"**/*.tsx"
],
"excludeGlobs": [
"node_modules/**",
"**/*.test.ts",
"**/*.spec.ts"
]
}Codexa uses Retrieval-Augmented Generation (RAG) to answer questions about your codebase:
When you run codexa ingest:
- File Discovery: Scans your repository using glob patterns (
includeGlobs/excludeGlobs) - Code Chunking: Splits files into manageable chunks with configurable overlap
- Embedding Generation: Creates vector embeddings for each chunk using local transformers
- Storage: Stores chunks and embeddings in a SQLite database (
.codexa/index.db)
When you run codexa ask:
- Question Embedding: Converts your question into a vector embedding
- Vector Search: Finds the most similar code chunks using cosine similarity
- Context Retrieval: Selects top-K most relevant chunks as context
- LLM Generation: Sends question + context to your configured LLM
- Response: Returns an answer grounded in your actual codebase
- Privacy: All processing happens locally by default
- Speed: Local embeddings and vector search are very fast
- Accuracy: Answers are based on your actual code, not generic responses
- Context-Aware: Understands relationships across your codebase
┌─────────────────┐
│ User Query │
└────────┬────────┘
│
▼
┌─────────────────┐ ┌──────────────┐
│ Embedding │────▶│ Vector │
│ Generation │ │ Search │
└─────────────────┘ └──────┬───────┘
│
▼
┌──────────────┐
│ Context │
│ Retrieval │
└──────┬───────┘
│
▼
┌─────────────────┐ ┌──────────────┐
│ SQLite DB │◀────│ LLM │
│ (Chunks + │ │ (Groq) │
│ Embeddings) │ │ │
└─────────────────┘ └──────┬───────┘
│
▼
┌──────────────┐
│ Answer │
└──────────────┘
Key Components:
- Chunker: Splits code files into semantic chunks
- Embedder: Generates vector embeddings (local transformers)
- Retriever: Finds relevant chunks using vector similarity
- LLM Client: Generates answers (Groq cloud)
- Database: SQLite for storing chunks and embeddings
Problem: Using Groq provider but API key is missing.
Solutions:
- Set the API key using the config command (Recommended):
codexa config set GROQ_API_KEY "your-api-key"
- Or set the environment variable:
export GROQ_API_KEY="your-api-key" # macOS/Linux
- Verify it's set:
codexa config get GROQ_API_KEY
Problem: First ingestion takes too long.
Solutions:
- The dynamic config should already optimize patterns - check your
.codexarc.jsonwas generated correctly - Reduce
maxFileSizeto exclude more large files - Reduce
maxChunkSizeto create more, smaller chunks - Add more patterns to
excludeGlobsto skip unnecessary files - Be more specific with
includeGlobsto focus on important files - Use
--forceonly when necessary (incremental updates are faster) - Ensure
skipBinaryFilesandskipLargeFilesare enabled (default)
Problem: Answers are not relevant or accurate.
Solutions:
-
Increase
topKto retrieve more context:{ "topK": 6 } -
Adjust
temperaturefor more focused answers:{ "temperature": 0.1 } -
Re-index after significant code changes:
codexa ingest --force
-
Ask more specific questions
Problem: SQLite database is locked (multiple processes accessing it).
Solutions:
- Ensure only one
codexaprocess runs at a time - If using concurrent processes, each should use a different
dbPath
Problem: Some files aren't being indexed.
Solutions:
- Check
includeGlobspatterns in.codexarc.json - Verify files aren't excluded by
excludeGlobs - Run with
--forceto rebuild:codexa ingest --force
- Check file permissions (ensure Codexa can read the files)
Q: Can I use Codexa with private/confidential code?
A: Yes! Codexa processes everything locally by default. Your code never leaves your machine unless you explicitly use cloud providers like Groq.
Q: How much disk space does Codexa use?
A: Typically 10-50MB per 1000 files, depending on file sizes. The SQLite database stores chunks and embeddings.
Q: Can I use Codexa in CI/CD?
A: Yes, but you'll need to ensure your LLM provider is accessible. For CI/CD, consider using Groq (cloud).
Q: Does Codexa work with monorepos?
A: Yes! Adjust includeGlobs and excludeGlobs to target specific packages or workspaces.
Q: Can I use multiple LLM providers?
A: You can switch providers by updating modelProvider in .codexarc.json. Each repository can have its own configuration.
Q: How often should I re-index?
A: Codexa only processes changed files on subsequent runs, so you can run ingest frequently. Use --force only when you need a complete rebuild.
Q: Is there a way to query the database directly?
A: The SQLite database (.codexa/index.db) can be queried directly, but the schema is internal. Use Codexa's commands for all operations.
Q: Can I customize the prompt sent to the LLM?
A: Currently, the prompt is fixed, but this may be configurable in future versions.
Contributions are welcome! Please see our Contributing Guide for details.
Quick start:
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
For major changes, please open an issue first to discuss what you would like to change.
See CONTRIBUTING.md for detailed guidelines.
This project is licensed under the MIT License - see the LICENSE file for details.
Made with ❤️ by the Codexa team