Skip to content

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 ​

FlagDefaultDescription
--checkfalseCI 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-historyfalseSkip git history collection. Produces an index without intent or anti-patterns, but runs faster
--max-history <N>20Limit the number of commits collected per file
--install-missingfalseBefore indexing, detect languages in the repo and install any missing plugins

Examples ​

shell
npx ctxo index
shell
# Fail the build if the committed index has drifted from source.
npx ctxo index --check
shell
# Skip git history. Useful on a fresh clone, or in hot-path benchmarks.
npx ctxo index --skip-history
shell
npx ctxo index --max-history 5
shell
# Install detected plugins, then index in one command.
npx ctxo index --install-missing
shell
# Invoked by the post-commit hook; runs in milliseconds.
npx ctxo index --file packages/cli/src/core/logger.ts

Staleness detection (--check) ​

--check iterates every git-tracked source file and compares it to the committed index:

  1. Fast path β€” if the file mtime is at or below lastModified in the index, the file is considered fresh.
  2. Slow path β€” if mtime has changed but the content hash matches the stored contentHash, the file is still considered fresh. This avoids false positives after git 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 ​

CodeMeaning
0Index 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.ignore and index.ignoreProjects globs are honored by ctxo index.

Released under the MIT License.