ctxo index β
Builds the full codebase index. For every source file tracked by git (and not filtered by index.ignore), ctxo extracts symbols and edges via the registered language plugins, aggregates git history for intent and anti-pattern detection, and writes:
.ctxo/index/<path>.jsonβ one JSON document per source file (committed)..ctxo/.cache/symbols.dbβ local SQLite cache (gitignored, rebuilt from JSON).
Supports monorepos: if package.json declares workspaces, each workspace is discovered and indexed.
Synopsis β
shell
npx ctxo index [options]Flags β
| Flag | Default | Description |
|---|---|---|
--check | false | CI gate. Does not write anything. Exits 1 if any file is stale, missing, or deleted |
--file <path> | Incremental re-index of a single file. Used by the post-commit hook | |
--skip-history | false | Skip git history collection. Produces an index without intent or anti-patterns, but runs faster |
--max-history <N> | 20 | Limit the number of commits collected per file |
--install-missing | false | Before indexing, detect languages in the repo and install any missing plugins |
Examples β
shell
npx ctxo indexshell
# Fail the build if the committed index has drifted from source.
npx ctxo index --checkshell
# Skip git history. Useful on a fresh clone, or in hot-path benchmarks.
npx ctxo index --skip-historyshell
npx ctxo index --max-history 5shell
# Install detected plugins, then index in one command.
npx ctxo index --install-missingshell
# Invoked by the post-commit hook; runs in milliseconds.
npx ctxo index --file packages/cli/src/core/logger.tsStaleness detection (--check) β
--check iterates every git-tracked source file and compares it to the committed index:
- Fast path β if the file mtime is at or below
lastModifiedin the index, the file is considered fresh. - Slow path β if mtime has changed but the content hash matches the stored
contentHash, the file is still considered fresh. This avoids false positives aftergit checkout,cp -p, and CI clone.
Any file missing from the index, present in the index but deleted from disk, or with a mismatched content hash is reported as stale.
Exit codes β
| Code | Meaning |
|---|---|
0 | Index written, or --check found no drift |
1 | --check found stale/missing files, or a flag validation error |
See also β
ctxo watchβ keep the index fresh during development.ctxo statusβ inspect the existing index.ctxo syncβ rebuild the SQLite cache without re-parsing sources.- .ctxo/config.yaml β
index.ignoreandindex.ignoreProjectsglobs are honored byctxo index.