/code-index - Index Codebase for Semantic Search
Index your project's source code for semantic search, symbol lookup, and call graph analysis.
Prerequisites
Codanna must be installed:
# Install codanna
cargo install codanna
# Or from CODITECT fork
cargo install --git https://github.com/coditect-ai/codanna.git
Usage
# Index current project (default)
/code-index
# Index specific directory
/code-index src/
# Force full reindex
/code-index --force
# Show index status
/code-index --status
# Index with semantic embeddings
/code-index --with-embeddings
System Prompt
⚠️ EXECUTION DIRECTIVE:
When the user invokes /code-index, you MUST:
- IMMEDIATELY execute the indexing command
- Show progress during indexing
- Report statistics when complete (files, symbols, time)
You are executing codanna code indexer for CODITECT semantic code search.
Index Location: .coditect/.codanna/index/
Execution Flow:
- Check if codanna is installed
- Run
codanna indexwith appropriate options - Monitor progress
- Report final statistics
Commands:
# Basic indexing
codanna index .
# With watch mode (for MCP server)
codanna serve --watch
# Force reindex
codanna index . --force
# Get index info
codanna info
Default Exclusions: (via .codannaignore or .gitignore)
node_modules/target/dist/.git/*.min.jsvendor/
Options
| Option | Description |
|---|---|
[path] | Directory to index (default: current directory) |
--force | Force full reindex, ignore cache |
--status | Show current index status |
--with-embeddings | Generate semantic embeddings (slower, better search) |
--languages LANGS | Limit to specific languages (comma-separated) |
--exclude PATTERNS | Additional exclusion patterns |
Examples
Index Current Project
/code-index
Result: Indexes all supported files in current directory
Index Specific Directory
/code-index src/api/
Result: Indexes only the src/api/ directory
Force Full Reindex
/code-index --force
Result: Clears cache and reindexes everything
Check Index Status
/code-index --status
Result: Shows symbol count, file count, last indexed time
Index with Embeddings
/code-index --with-embeddings
Result: Generates semantic vectors for better natural language search
Output Format
🔍 Indexing project...
Configuration:
Path: /Users/dev/myproject
Languages: rust, python, typescript, javascript
Exclusions: node_modules, target, dist
Progress:
[████████████████████░░░░] 82% (1,247/1,520 files)
Parsing: src/api/handlers.rs
✅ Indexing complete!
Statistics:
Files indexed: 1,520
Symbols found: 24,891
Functions: 8,234
Structs/Classes: 1,456
Methods: 12,890
Constants: 2,311
Index size: 48.2 MB
Time elapsed: 12.4s
Parse speed: 75,234 symbols/sec
Index location: .coditect/.codanna/index/
Supported Languages
| Language | Extensions | Parser |
|---|---|---|
| Rust | .rs | tree-sitter-rust |
| Python | .py | tree-sitter-python |
| TypeScript | .ts, .tsx | tree-sitter-typescript |
| JavaScript | .js, .jsx | tree-sitter-javascript |
| Java | .java | tree-sitter-java |
| Kotlin | .kt, .kts | tree-sitter-kotlin |
| Go | .go | tree-sitter-go |
| PHP | .php | tree-sitter-php |
| C | .c, .h | tree-sitter-c |
| C++ | .cpp, .hpp, .cc | tree-sitter-cpp |
| C# | .cs | tree-sitter-c-sharp |
| Swift | .swift | tree-sitter-swift |
| GDScript | .gd | tree-sitter-gdscript |
Configuration
File: .coditect/config/codanna.json
{
"codanna": {
"enabled": true,
"auto_index": true,
"include_paths": ["src/", "lib/", "scripts/"],
"exclude_paths": ["node_modules/", "dist/", ".git/"],
"languages": ["rust", "python", "typescript", "javascript"],
"semantic_search": {
"enabled": true,
"embedding_model": "AllMiniLML6V2",
"threshold": 0.6
},
"index_location": ".coditect/.codanna/"
}
}
Integration
Works with:
/code-search- Search the indexed codebase/impact- Analyze change impact/callers- Find function callers/calls- Find function calls
Triggered by:
- Manual invocation
- First
/code-searchif no index exists - File watcher (when
codanna serve --watchis running)
Troubleshooting
| Issue | Solution |
|---|---|
| "codanna not found" | Run cargo install codanna |
| "Permission denied" | Check write access to .coditect/ |
| Slow indexing | Exclude large directories (node_modules, target) |
| Missing symbols | Verify file extensions are in supported languages |
| "Index corrupted" | Run /code-index --force |
When NOT to Use
Do NOT use when:
- Codanna is not installed
- Project has no source code (documentation-only)
- Disk space critically low
Principles
This command embodies:
- #1 Recycle, Extend, Re-Use - Leverages existing codanna tool
- #3 Complete Execution - Full indexing with progress
- #6 Self-Provisioning - Checks prerequisites, guides installation
Full Standard: CODITECT-STANDARD-AUTOMATION.md
Tool: codanna index Requires: codanna installed ADR: ADR-065 Version: 1.0.0 Last Updated: 2026-01-11