Skip to main content

When to Use This Skill

Use the Debugging skill when you need to:
  • Trace where an error originates
  • Understand why a function is failing
  • Find who calls a problematic method
  • Investigate unexpected behavior
  • Debug 500 errors or crashes
  • Understand intermittent failures

Example Scenarios

Use gitnexus_context to see all callers and callees, then check for external dependencies or data flow issues.
Use gitnexus_query with the error message text to find throw sites, then trace backwards through the call chain.
Use gitnexus_context to get all incoming calls categorized by relationship type (CALLS, IMPORTS).
Query for the endpoint handler, use context to trace callees, look for external API calls or missing error handling.

Workflow

Follow these steps for effective debugging:

Step-by-Step Guide

1. Understand the Symptom Before querying the graph, clearly identify:
  • Error message (exact text)
  • Unexpected behavior description
  • Which endpoint/function exhibits the issue
  • When it happens (always? intermittent? specific conditions?)
2. Query for Related Code
Returns:
  • Processes involving this error (e.g., CheckoutFlow, ErrorHandling)
  • Symbols related to the error (validatePayment, handlePaymentError, PaymentException)
  • Prioritized by relevance
3. Get Full Context on Suspect
Returns:
  • Incoming calls: Who triggers this function
  • Outgoing calls: What this function depends on
  • Processes: Execution flows involving this symbol
Pay special attention to outgoing calls marked as external APIs—these are common failure points.
4. Trace Execution Flow
See exactly where the suspect function appears in the execution chain. 5. Custom Call Chain Traces (Advanced) If you need deeper analysis:
This finds all paths leading to the suspect function. 6. Confirm Root Cause Read the source files to verify your hypothesis.

Checklist

  • Understand the symptom (error message, unexpected behavior)
  • gitnexus_query for error text or related code
  • Identify the suspect function from returned processes
  • gitnexus_context to see callers and callees
  • Trace execution flow via process resource if applicable
  • gitnexus_cypher for custom call chain traces if needed
  • Read source files to confirm root cause

Debugging Patterns

GitNexus provides different approaches depending on the symptom:

Tools for Debugging

gitnexus_query

Find code related to an error:
Returns:
Best for:
  • Finding code related to error messages
  • Discovering error handling flows
  • Locating exception definitions

gitnexus_context

Get full context on a suspect:
Returns:
Best for:
  • Finding who calls the failing function
  • Discovering external dependencies
  • Understanding data flow

gitnexus_cypher

Custom call chain traces:
Returns:
Best for:
  • Complex call chain analysis
  • Finding all paths to a function
  • Debugging indirect dependencies
Always read gitnexus://repo/{name}/schema before writing Cypher queries to understand the graph structure.

Example: “Payment endpoint returns 500 intermittently”

Here’s a complete debugging walkthrough:

Step 1: Understand the Symptom

  • What: /api/checkout endpoint returns 500
  • When: Intermittent (not every request)
  • Error: “Payment validation failed”

Step 2: Query for Error Handling

Result:

Step 3: Get Context on validatePayment

Result:
Hypothesis: fetchRates is an external API call—might be timing out!

Step 4: Trace Execution Flow

Result:

Step 5: Read Source Code

Read src/payments/validator.ts:42:
Root cause confirmed: fetchRates calls an external API without a proper timeout. When the API is slow, the request hangs and eventually times out with 500. Fix: Add timeout to external API call.

Advanced Debugging Techniques

Finding All Error Throw Sites

Tracing Data Flow

  1. Use context to find where data is created (incoming refs)
  2. Follow outgoing calls to see transformations
  3. Check process trace to see the full pipeline

Debugging Async Issues

  1. context to find all async function calls
  2. Look for missing await or error handling
  3. Check for race conditions (multiple callers of same async function)

Best Practices

Look for External Calls

External APIs are common failure points—check context outgoing calls.

Trace Backwards

Start at the error, use context to find callers, repeat until you reach the entry point.

Check Processes

Process traces show the full execution chain—useful for understanding flow.

Use Cypher for Complex Traces

For multi-hop call chains, write custom Cypher queries.

Common Pitfalls

Missing Error Handling

If outgoing calls include external APIs but incoming calls don’t show try/catch wrappers, there might be missing error handling.

Circular Dependencies

This finds circular call chains that might cause stack overflows.

Hot Paths

If incoming calls show many callers, this might be a performance bottleneck.

Next Steps

Learn Impact Analysis

Once you’ve fixed the bug, use impact analysis to ensure your changes don’t break other code