/component-index
Rebuild or update the CODITECT component index database. Supports full rebuild, incremental updates, and FTS maintenance.
Syntax
/component-index [options]
Options
| Option | Description | Example |
|---|---|---|
--full | Full rebuild (delete and recreate) | --full |
--incremental | Only new/changed files (default) | --incremental |
--type <type> | Index only specific type | --type agent |
--rebuild-fts | Rebuild FTS index only | --rebuild-fts |
--vacuum | Vacuum database after indexing | --vacuum |
--verify | Verify index integrity | --verify |
--dry-run | Preview what would be indexed | --dry-run |
--verbose | Show detailed progress | --verbose |
--stats | Show statistics after indexing | --stats |
--project <id> | Scope indexing to project components (ADR-159) | --project PILOT |
Modes
Incremental (Default)
Only indexes new or modified files based on content hash:
/component-index
# Or explicitly:
/component-index --incremental
When to use: Regular updates, after adding new components
Full Rebuild
Deletes existing index and rebuilds from scratch:
/component-index --full
When to use: After schema changes, corruption, major updates
FTS Rebuild
Rebuilds only the full-text search index:
/component-index --rebuild-fts
When to use: Search returning wrong results, FTS integrity errors
Examples
Standard Operations
# Quick incremental update
/component-index
# Full rebuild with statistics
/component-index --full --stats
# Preview changes without applying
/component-index --dry-run --verbose
Targeted Indexing
# Re-index only agents
/component-index --type agent
# Re-index scripts after bulk update
/component-index --type script --verbose
Maintenance
# Verify index integrity
/component-index --verify
# Optimize database
/component-index --vacuum
# Full maintenance workflow
/component-index --full --vacuum --verify --stats
Output
Component Index Update
======================
Mode: incremental
Started: 2026-01-22 14:30:00
Scanning...
agents/ 152 files
commands/ 89 files
skills/ 221 files
scripts/ 339 files
hooks/ 62 files
workflows/ 45 files
documents/ 686 files
Processing...
New: 15
Updated: 3
Unchanged: 1576
Errors: 0
Statistics:
Total components: 3,027
Index size: 4.2 MB
FTS records: 3,027
Duration: 12.4s
Status: SUCCESS
Implementation
# Underlying script
python3 scripts/component-indexer.py [options]
# Python API
from scripts.component_indexer import ComponentIndexer
indexer = ComponentIndexer()
indexer.run(incremental=True)
Database Operations
Tables Modified
| Table | Operation |
|---|---|
components | INSERT/UPDATE component records |
capabilities | INSERT capabilities |
triggers | INSERT triggers |
component_relationships | INSERT relationships |
component_search | FTS5 index sync |
Index Integrity
The indexer maintains:
- Content hashes for change detection
- Timestamps for audit trail
- Referential integrity between tables
- FTS index synchronization
Scheduling
Automatic Indexing
Configure in ~/.coditect/config/config.json:
{
"component_index": {
"auto_index": true,
"schedule": "0 */6 * * *",
"mode": "incremental"
}
}
Git Hook Integration
Add to .git/hooks/post-commit:
#!/bin/bash
python3 ~/.coditect/scripts/component-indexer.py --incremental
Error Handling
Common Errors
| Error | Cause | Fix |
|---|---|---|
database is locked | Concurrent access | Wait and retry |
no such table | Missing schema | --full rebuild |
FTS integrity error | Corrupt FTS | --rebuild-fts |
UNIQUE constraint | Duplicate ID | Check for duplicates |
Recovery
# Backup first (ADR-118: platform.db is Tier 1 - component data)
cp ~/PROJECTS/.coditect-data/context-storage/platform.db platform.db.bak
# Full rebuild
/component-index --full
# If still failing, delete and recreate
rm ~/PROJECTS/.coditect-data/context-storage/platform.db
/component-index --full
Related Commands
| Command | Purpose |
|---|---|
/component-search | Search indexed components |
/component-stats | View index statistics |
/component-validate | Validate component files |
/component-activate | Activate component loading |
Script: scripts/component-indexer.py
Database (ADR-118): ~/PROJECTS/.coditect-data/context-storage/platform.db (Tier 1 - component data)