Skip to main content

Overview

The detect_changes tool analyzes your uncommitted git changes (diff) and maps them to indexed symbols in the knowledge graph, then traces which execution flows are impacted. This is essential for pre-commit review and understanding the scope of your changes.
When to use: Before committing — to understand what your changes affect. Pre-commit review, PR preparation.Next step: Review affected processes. Use context() on high-risk symbols. READ gitnexus://repo/{name}/process/{name} for full traces.

Parameters

string
default:"unstaged"
What changes to analyze:
  • "unstaged" - Only unstaged changes (default)
  • "staged" - Only staged changes (what will be committed)
  • "all" - Both staged and unstaged changes
  • "compare" - Compare against a specific branch/commit (requires base_ref)
Use cases:
  • "staged" - Pre-commit check
  • "all" - Full working tree analysis
  • "compare" - PR impact analysis (e.g., comparing against main)
string
Branch or commit to compare against when using scope: "compare"Examples:
  • "main"
  • "develop"
  • "HEAD~3" (3 commits back)
  • "abc123def" (specific commit hash)
string
Repository name or path. Required when multiple repos are indexed. Omit if only one repo is available.

Response

array
required
Symbols modified by the git diff
array
required
Execution flows impacted by these changes
string
required
Overall risk assessment: LOW, MEDIUM, HIGH, or CRITICALBased on:
  • Number of changed symbols
  • Number of affected processes
  • Criticality of affected modules
object
required
High-level change summary

Example Usage

Check Unstaged Changes (Default)

Pre-Commit Check (Staged Only)

Full Working Tree Analysis

PR Impact Analysis

Multi-Repo Change Detection

Example Response

Risk Assessment

Real-World Examples

Example 1: Pre-Commit Check

Example 2: PR Preparation

Example 3: Debugging Recent Changes

Best Practices

Make detect_changes({scope: "staged"}) part of your pre-commit workflow to understand what you’re about to commit.
When preparing a pull request, use scope: "compare" with base_ref: "main" to see the full impact of your branch.
Don’t just look at changed symbols — review which execution flows are affected. Breaking “LoginFlow” is more critical than a utility function.
For high-risk changes, use context() on changed symbols to understand their full dependency graph.
If detect_changes shows MEDIUM/HIGH risk, run impact() on changed symbols to see the full blast radius.

Workflow Integration

Pre-Commit Hook

CI/CD Integration

Use Cases

  • Pre-commit review: Understand what you’re about to commit
  • PR preparation: Document the scope of changes
  • Debugging: “What did I just change that broke this?”
  • Code review: Reviewers can see execution flow impact
  • Risk assessment: Automated change risk evaluation
  • Test planning: Know which tests to focus on

Limitations

Index Freshness Requireddetect_changes maps git diffs to the knowledge graph. If your index is stale (outdated), it may miss recently added symbols or show incorrect mappings.Solution: If you see a staleness warning, run npx gitnexus analyze before using detect_changes.
  • impact - Deeper blast radius analysis for specific symbols
  • context - Understand changed symbols in detail
  • rename - Safe refactoring tool
  • gitnexus://repo/{name}/processes - Review affected execution flows
  • gitnexus://repo/{name}/context - Check if index is stale