Documentation
CLICommands

ox index

Build searchable indexes from code, GitHub PRs, issues, and other project data. ox index creates CodeDB -- a local database of commits, symbols, diffs, PRs, and issues that your AI coworker can query during sessions.

Usage

terminal
$

Run from any initialized repository. With no subcommand, ox index indexes all available sources; use a subcommand to index one source.

terminal
# Index every available source
$
FlagDescription
--fullWipe all indexes and rebuild from scratch
-d, --daysMax days of GitHub history to fetch
--prs-onlyIndex only pull requests (GitHub)
--issues-onlyIndex only issues (GitHub)
--no-pushExtract to the Ledger without pushing

What gets indexed

SourceContentCommand
Git historyCommits, diffs, file changesox index code
Code symbolsFunctions, types, classesox index code
GitHub PRsTitles, descriptions, comments, review threadsox index github
GitHub issuesTitles, descriptions, labels, commentsox index github

Subcommands

ox index code

Index git history and code symbols from your repository.

terminal
$
FlagDescription
--fullWipe the index and rebuild from scratch

Without --full, indexing is incremental -- only new commits since the last index are processed.

terminal
# Index the current repository
$
terminal
# Index a specific repository by URL
$
terminal
# Force a full re-index
$

ox index github

Fetch recent PRs and issues from GitHub and make them searchable. The data is extracted to the project Ledger and indexed into CodeDB, where ox code search type:pr and ox code search type:issue find it.

terminal
$

Requires a GitHub token (GITHUB_TOKEN, GH_TOKEN, or gh CLI config). The github_sync, github_sync_prs, and github_sync_issues settings in .sageox/config.json control it; all are enabled by default.

FlagDescription
--fullClear sync state and re-fetch everything
-d, --daysMax days of history to fetch
--prs-onlyIndex only pull requests
--issues-onlyIndex only issues
--no-pushExtract to the Ledger without pushing
terminal
# Index all GitHub activity
$
terminal
# Index only PRs
$

ox index status

Show index status. This is an alias for ox code status; add --json for JSON output.

terminal
$

Where the index lives

CodeDB stores its index locally, and your AI coworker queries it locally during sessions. ox index github also extracts PRs and issues to the project Ledger and pushes them; pass --no-push to extract without pushing.

CodeDB is local-only by design. Your code and git history stay on your machine. SageOx servers never see your source code.

Incremental vs full re-index

By default, ox index runs incrementally:

  • Code: Indexes only commits since the last run
  • GitHub: Fetches only PRs and issues updated since the last run

Use --full when:

  • The index seems stale or incomplete
  • You've changed indexing configuration
  • You want to rebuild from scratch after a major refactor

Full re-indexing takes longer but ensures the index matches your current repository state.

Searching the index

Once indexed, use ox code search to query CodeDB.

terminal
$
FlagDescription
--limitMaximum number of results
--full-jsonFull uncompacted JSON output (~4x more context tokens)

Example searches

terminal
# Find functions related to user auth
$
terminal
# Search for recent changes to the API
$
terminal
# Get JSON output for scripting
$

The ox code command group provides shortcuts for common indexing operations.

CommandEquivalentDescription
ox code index [url]ox index code [url]Alias for indexing code
ox code search <query>--Search the CodeDB index
ox code statusox index statusShow index status and stats
terminal
# Check index status
$

How AI coworkers use CodeDB

During a coding session, your AI coworker queries CodeDB with ox code. This enables:

  • Structured search -- a query DSL over symbols, code, diffs, commits, and comments, with filters that grep cannot match
  • History queries -- "when did this behavior change?" answered from git history
  • Cross-reference navigation -- resolved callers and callees show how modules connect across the codebase
  • PR/issue context -- reference decisions from code review threads

Without CodeDB, AI coworkers rely on grep and file reads. With it, they navigate your codebase with precision.

Troubleshooting

"Repository not initialized" -- Run ox init first to connect your repository to SageOx.

"No commits to index" -- The repository needs at least one commit. If you're starting fresh, make an initial commit first.

"GitHub rate limited" -- GitHub API has rate limits. Wait and retry, or use --prs-only, --issues-only, or --days to reduce API calls.

Stale search results -- Run ox index code to pick up recent commits. Use --full if incremental indexing isn't catching changes.

What's next