Skip to main content

/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:

  1. IMMEDIATELY execute the indexing command
  2. Show progress during indexing
  3. 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:

  1. Check if codanna is installed
  2. Run codanna index with appropriate options
  3. Monitor progress
  4. 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.js
  • vendor/

Options

OptionDescription
[path]Directory to index (default: current directory)
--forceForce full reindex, ignore cache
--statusShow current index status
--with-embeddingsGenerate semantic embeddings (slower, better search)
--languages LANGSLimit to specific languages (comma-separated)
--exclude PATTERNSAdditional 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

LanguageExtensionsParser
Rust.rstree-sitter-rust
Python.pytree-sitter-python
TypeScript.ts, .tsxtree-sitter-typescript
JavaScript.js, .jsxtree-sitter-javascript
Java.javatree-sitter-java
Kotlin.kt, .ktstree-sitter-kotlin
Go.gotree-sitter-go
PHP.phptree-sitter-php
C.c, .htree-sitter-c
C++.cpp, .hpp, .cctree-sitter-cpp
C#.cstree-sitter-c-sharp
Swift.swifttree-sitter-swift
GDScript.gdtree-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-search if no index exists
  • File watcher (when codanna serve --watch is running)

Troubleshooting

IssueSolution
"codanna not found"Run cargo install codanna
"Permission denied"Check write access to .coditect/
Slow indexingExclude large directories (node_modules, target)
Missing symbolsVerify 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