Syntax
Description
Indexes a repository and stores the knowledge graph in.gitnexus/. This is the main command for building GitNexus’s code intelligence.
The analyze command performs a multi-phase indexing pipeline:
- Scanning files — Walks the file tree and maps folder/file relationships
- Building structure — Extracts the repository structure
- Parsing code — Extracts functions, classes, methods, and interfaces using Tree-sitter ASTs
- Resolving imports — Resolves import statements across files with language-aware logic
- Tracing calls — Maps function calls and call chains
- Extracting inheritance — Identifies class hierarchies and interface implementations
- Detecting communities — Groups related symbols into functional clusters
- Detecting processes — Traces execution flows from entry points through call chains
- Creating search indexes — Builds full-text search indexes for fast retrieval
- Generating embeddings — Creates semantic embeddings for hybrid search (optional)
.gitnexus/ with full-text search and optional semantic embeddings.
Options
Path to the repository to index. Defaults to the current directory’s git root.
Force full re-index even if the index is up to date with the current commit.
Enable embedding generation for semantic search. Disabled by default.Embeddings are automatically skipped for repositories with more than 50,000 nodes to avoid long indexing times.
Usage Examples
Index current repository
Index a specific repository
Force full re-index
Enable semantic embeddings
Output Example
Automatic Setup
The analyze command automatically:- Registers the repository in the global registry (
~/.gitnexus/registry.json) - Adds
.gitnexus/to.gitignoreso indexes are never committed - Generates AI context files (
AGENTS.md,CLAUDE.md) with codebase overview - Installs agent skills to
.claude/skills/for Claude Code integration - Registers Claude Code hooks for automatic context enrichment
Index Staleness
The analyze command compares the current git commit with the last indexed commit. If they match and--force is not used, the command exits early with “Already up to date”.
To check if your index is stale:
Performance
The command automatically allocates 8GB heap for large repositories (e.g., Linux kernel). If the process is below this limit, it re-spawns itself with--max-old-space-size=8192.
Embedding Cache
When re-indexing with--embeddings, the command caches existing embeddings and only generates embeddings for new or modified symbols. This significantly speeds up incremental re-indexing.
Related Commands
gitnexus status— Check index status and stalenessgitnexus clean— Delete the indexgitnexus list— List all indexed repositories