Overview
Thedetect_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
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 (requiresbase_ref)
"staged"- Pre-commit check"all"- Full working tree analysis"compare"- PR impact analysis (e.g., comparing againstmain)
Branch or commit to compare against when using
scope: "compare"Examples:"main""develop""HEAD~3"(3 commits back)"abc123def"(specific commit hash)
Repository name or path. Required when multiple repos are indexed. Omit if only one repo is available.
Response
Symbols modified by the git diff
Execution flows impacted by these changes
Overall risk assessment: LOW, MEDIUM, HIGH, or CRITICALBased on:
- Number of changed symbols
- Number of affected processes
- Criticality of affected modules
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
| Risk Level | Criteria | Action |
|---|---|---|
| LOW | Less than 3 symbols, 1-2 processes, single module | Standard testing |
| MEDIUM | 3-8 symbols, 2-5 processes, 1-2 modules | Careful review, test affected flows |
| HIGH | More than 8 symbols, more than 5 processes, multiple modules | Comprehensive testing, staged deployment |
| CRITICAL | Critical modules (auth, payments), wide impact | Extensive testing, careful monitoring |
Real-World Examples
Example 1: Pre-Commit Check
Example 2: PR Preparation
Example 3: Debugging Recent Changes
Best Practices
Run before every commit
Run before every commit
Make
detect_changes({scope: "staged"}) part of your pre-commit workflow to understand what you’re about to commit.Use 'compare' for PRs
Use 'compare' for PRs
When preparing a pull request, use
scope: "compare" with base_ref: "main" to see the full impact of your branch.Review affected processes
Review affected processes
Don’t just look at changed symbols — review which execution flows are affected. Breaking “LoginFlow” is more critical than a utility function.
Follow up with context()
Follow up with context()
For high-risk changes, use
context() on changed symbols to understand their full dependency graph.Compare risk with impact()
Compare risk with impact()
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
Related Tools
- impact - Deeper blast radius analysis for specific symbols
- context - Understand changed symbols in detail
- rename - Safe refactoring tool
Related Resources
gitnexus://repo/{name}/processes- Review affected execution flowsgitnexus://repo/{name}/context- Check if index is stale