Skip to main content
The analyze command processes a repository and builds a complete knowledge graph of its structure, dependencies, and execution flows.

Usage

Arguments

string
Path to the repository to index. Defaults to current directory’s git root.

Options

boolean
default:"false"
Force full re-index even if already up to date. Use when the index is corrupted or after upgrading GitNexus.Flag: -f, --force
boolean
default:"false"
Enable embedding generation for semantic search. Automatically skipped for repositories with more than 50,000 symbols.Flag: --embeddings

Examples

Basic Usage

Index the current repository:

Index Specific Path

Force Re-index

Output

The command displays a progress bar with real-time phase updates:

Successful Indexing

Already Up to Date

GitNexus tracks the current git commit hash. If you’re on the same commit as the last analysis, indexing is skipped unless you use --force.

Indexing Pipeline

The analyze command runs a multi-phase pipeline:

Phase 1: Code Analysis (0-60%)

  1. Scanning files — Walks the file tree
  2. Building structure — Maps folder hierarchy
  3. Parsing code — Extracts functions, classes, methods using Tree-sitter
  4. Resolving imports — Links imports to definitions
  5. Tracing calls — Builds function call graph
  6. Extracting inheritance — Maps class hierarchies
  7. Detecting communities — Groups related symbols into functional clusters
  8. Detecting processes — Traces execution flows from entry points

Phase 2: Graph Database (60-85%)

Loads the graph into KuzuDB for fast querying.

Phase 3: Search Indexes (85-90%)

Creates full-text search indexes for:
  • Files
  • Functions
  • Classes
  • Methods
  • Interfaces

Phase 4: Embeddings (90-98%, optional)

Generates semantic embeddings for hybrid search. Only runs when --embeddings is enabled and symbol count is under 50,000.

Phase 5: Finalization (98-100%)

  • Saves metadata to .gitnexus/meta.json
  • Registers repository in global registry
  • Adds .gitnexus/ to .gitignore
  • Generates AGENTS.md and CLAUDE.md context files
  • Installs agent skills (per-repo)
  • Registers Claude Code hooks (if applicable)

Generated Files

.gitnexus/ Directory

Context Files

AGENTS.md — Instructions for AI agents on how to use the knowledge graph CLAUDE.md — Claude Code-specific context (same as AGENTS.md, different filename for compatibility)

Skills Directory

.claude/skills/gitnexus/ — Agent skills for exploring, debugging, impact analysis, and refactoring (Claude Code only)

Performance

Typical Performance

Memory Management

GitNexus automatically allocates 8GB heap for large repositories. It re-spawns with increased memory if needed.
For repositories with 10,000+ files, ensure you have at least 10GB free RAM to avoid swapping.

Embeddings

Semantic search is disabled by default for performance reasons.

When to Enable Embeddings

  • You want semantic “find similar code” queries
  • Repository has fewer than 50,000 symbols
  • You have time for longer indexing

Automatic Skipping

Embeddings are automatically skipped when:

Caching

Embeddings are cached between re-indexes. Only new or changed symbols are re-embedded.

Troubleshooting

”Not inside a git repository”

GitNexus requires a git repository. Initialize one first:

Process Crashes / Out of Memory

Increase heap size:

Embeddings Segfault

This is a known issue with ONNX Runtime on some platforms. The process force-exits after completion to bypass the crash. Your index is safe.

Stale Index Warning

If commits have been made since last indexing:

See Also