Intelligent Code Indexing and Search with AI-Powered Analysis
Centipede indexes your codebase at function and file levels, enabling fast search and AI-powered answers about your code. It uses multi-strategy search and Google Gemini for code comprehension and navigation.
- Go 1.25 or later
- Gemini API key from Google AI Studio
git clone https://github.com/elxgy/centipede.git
cd centipede
make build
cp .env.example .envEdit .env and set GEMINI_API_KEY=your_actual_api_key_here.
# Index your codebase
./build/centipede index .
# Search for code
./build/centipede search "authentication function"
./build/centipede search "error handling" --with-context
# Ask AI about your code
./build/centipede ask "How does the user login work?"./build/centipede tui
# or: make tuiThe TUI uses a mode-based command bar. Tab cycles between modes:
| Mode | Action |
|---|---|
| Search | Type query, Enter to search |
| Ask | Type question, Enter to ask AI |
| Help | Enter to open help overlay |
| Index | Enter to re-index project |
| Shortcut | Action |
|---|---|
| F6 | next pane |
| Ctrl+J | focus results |
| Ctrl+L | focus details |
| Ctrl+K | focus command |
| Ctrl+C | quit |
| Ctrl+H | help overlay |
| Ctrl+R | re-index |
| Command | Description |
|---|---|
index [path] |
Index a directory (default: current) |
search <query> |
Search indexed code |
search <query> --with-context |
Search with file context |
ask <question> |
Ask AI about code |
tui |
Interactive TUI |
version |
Print version |
Set GEMINI_API_KEY in .env. Optional config.yaml supports project paths, exclude patterns, indexing languages, and AI settings. See docs/SEARCH.md for advanced configuration.
| Language | Parser | Features |
|---|---|---|
| Go | Native AST | Functions, methods, signatures, doc comments |
| Python | Tree-sitter | Functions, methods, classes, docstrings |
| General | Full-file | JS, TS, Rust, Java, C/C++ and others as file context |
Add general to indexing.languages in config.yaml for broader coverage.
Centipede crawls your code, parses it into CodeChunks (functions) and ContextChunks (files), stores data in SQLite and full-text index in Bleve. Search uses phrase, term, fuzzy, and semantic strategies. The ask command gathers relevant context and sends it to Gemini for answers.
- AI API key required: Set
GEMINI_API_KEYin.envnext to the executable - No results: Run
./build/centipede index .first; check exclude patterns - Slow AI: Use
thinking_budget: 0in config; reducemax_tokens - Slow indexing: Increase
workers; addexclude_patterns; checkmax_file_size
Debug: CENTIPEDE_LOGGING_LEVEL=debug ./build/centipede index .
make deps
make build
make test
make tui- docs/SEARCH.md - Search configuration and tuning
API keys stay in local .env files. Indexed data is stored locally in SQLite. Only search context is sent to Gemini. Exclude sensitive paths via exclude_patterns.
In the future the AI used for code analysis will be switched to a small open-source model so everything runs completely local.
- google.golang.org/genai - Google AI SDK
- github.com/blevesearch/bleve - Full-text search
- github.com/spf13/cobra - CLI
- github.com/spf13/viper - Configuration
- github.com/smacker/go-tree-sitter - Python parsing
GPL v3 - see LICENSE.