CLI: Index Command
Build a semantic index of your codebase patterns for AI-powered search and analysis.
Overview
The rigour index command scans your codebase and builds a searchable index of:
- Universal Polyglot Support: High-fidelity indexing for Python, Go, Rust, Java, C++, TypeScript and more.
- AI-Powered Semantic Search: Natural language pattern discovery using local vector embeddings.
- Functions & signatures: Classes, methods, and architectural patterns.
- Architecture: Dependencies, versioning, and code conventions.
This index powers the Pattern Index MCP tools (rigour_find_patterns, rigour_detect_staleness).
Usage
# Build the index with default settings
rigour index
# Build with semantic embeddings (slower, more powerful)
rigour index --semantic
# Specify output location
rigour index --output .rigour/pattern-index.json
Options
| Option | Description | Default |
|---|---|---|
--semantic | Enable semantic embeddings for natural language search | false |
--output | Custom output path for the index file | .rigour/pattern-index.json |
How It Works
- Discovery: Scans your project for code files (respects
.gitignore). - Parsing: Extracts functions, classes, and patterns using AST parsing.
- Indexing: Builds a searchable structure with metadata.
- Embeddings (optional): Generates vector embeddings for semantic search.
Index Structure
The generated index contains:
{
"version": "1.0.0",
"generatedAt": "2026-01-28T09:00:00Z",
"entries": [
{
"name": "AuthService.validateToken",
"type": "function",
"path": "src/services/auth.ts",
"signature": "(token: string) => Promise<User>",
"complexity": 5,
"embedding": [0.123, 0.456, ...]
}
]
}
Best Practices
- Run on CI: Regenerate the index on each merge to
main. - Commit the Index: Include
.rigour/pattern-index.jsonin version control. - Use Semantic Mode: Enable
--semanticfor codebases > 10k LOC.
Integration with MCP
Once indexed, AI agents can use:
rigour_find_patterns— Search patterns by keyword or semantically.rigour_detect_staleness— Find outdated or deprecated patterns.
# Build and use immediately
rigour index --semantic