|
| 1 | +--- |
| 2 | +name: gitnexus-debugging |
| 3 | +description: "Use when the user is debugging a bug, tracing an error, or asking why something fails. Examples: \"Why is X failing?\", \"Where does this error come from?\", \"Trace this bug\"" |
| 4 | +metadata: |
| 5 | + pattern: pipeline |
| 6 | + steps: "4" |
| 7 | +--- |
| 8 | + |
| 9 | +# Debugging with GitNexus |
| 10 | + |
| 11 | +Execute the workflow steps in order. Do NOT skip steps or proceed to the next step until the current one is complete. |
| 12 | + |
| 13 | +## When to Use |
| 14 | + |
| 15 | +- "Why is this function failing?" |
| 16 | +- "Trace where this error comes from" |
| 17 | +- "Who calls this method?" |
| 18 | +- "This endpoint returns 500" |
| 19 | +- Investigating bugs, errors, or unexpected behavior |
| 20 | + |
| 21 | +## Workflow |
| 22 | + |
| 23 | +``` |
| 24 | +1. gitnexus_query({query: "<error or symptom>"}) → Find related execution flows |
| 25 | +2. gitnexus_context({name: "<suspect>"}) → See callers/callees/processes |
| 26 | +3. READ gitnexus://repo/{name}/process/{name} → Trace execution flow |
| 27 | +4. gitnexus_cypher({query: "MATCH path..."}) → Custom traces if needed |
| 28 | +``` |
| 29 | + |
| 30 | +> If "Index is stale" → run `npx gitnexus analyze` in terminal. |
| 31 | +
|
| 32 | +## Checklist |
| 33 | + |
| 34 | +``` |
| 35 | +- [ ] Understand the symptom (error message, unexpected behavior) |
| 36 | +- [ ] gitnexus_query for error text or related code |
| 37 | +- [ ] Identify the suspect function from returned processes |
| 38 | +- [ ] gitnexus_context to see callers and callees |
| 39 | +- [ ] Trace execution flow via process resource if applicable |
| 40 | +- [ ] gitnexus_cypher for custom call chain traces if needed |
| 41 | +- [ ] Read source files to confirm root cause |
| 42 | +``` |
| 43 | + |
| 44 | +## Debugging Patterns |
| 45 | + |
| 46 | +| Symptom | GitNexus Approach | |
| 47 | +| -------------------- | ---------------------------------------------------------- | |
| 48 | +| Error message | `gitnexus_query` for error text → `context` on throw sites | |
| 49 | +| Wrong return value | `context` on the function → trace callees for data flow | |
| 50 | +| Intermittent failure | `context` → look for external calls, async deps | |
| 51 | +| Performance issue | `context` → find symbols with many callers (hot paths) | |
| 52 | +| Recent regression | `detect_changes` to see what your changes affect | |
| 53 | + |
| 54 | +## Tools |
| 55 | + |
| 56 | +**gitnexus_query** — find code related to error: |
| 57 | + |
| 58 | +``` |
| 59 | +gitnexus_query({query: "payment validation error"}) |
| 60 | +→ Processes: CheckoutFlow, ErrorHandling |
| 61 | +→ Symbols: validatePayment, handlePaymentError, PaymentException |
| 62 | +``` |
| 63 | + |
| 64 | +**gitnexus_context** — full context for a suspect: |
| 65 | + |
| 66 | +``` |
| 67 | +gitnexus_context({name: "validatePayment"}) |
| 68 | +→ Incoming calls: processCheckout, webhookHandler |
| 69 | +→ Outgoing calls: verifyCard, fetchRates (external API!) |
| 70 | +→ Processes: CheckoutFlow (step 3/7) |
| 71 | +``` |
| 72 | + |
| 73 | +**gitnexus_cypher** — custom call chain traces: |
| 74 | + |
| 75 | +```cypher |
| 76 | +MATCH path = (a)-[:CodeRelation {type: 'CALLS'}*1..2]->(b:Function {name: "validatePayment"}) |
| 77 | +RETURN [n IN nodes(path) | n.name] AS chain |
| 78 | +``` |
| 79 | + |
| 80 | +## Example: "Payment endpoint returns 500 intermittently" |
| 81 | + |
| 82 | +``` |
| 83 | +1. gitnexus_query({query: "payment error handling"}) |
| 84 | + → Processes: CheckoutFlow, ErrorHandling |
| 85 | + → Symbols: validatePayment, handlePaymentError |
| 86 | +
|
| 87 | +2. gitnexus_context({name: "validatePayment"}) |
| 88 | + → Outgoing calls: verifyCard, fetchRates (external API!) |
| 89 | +
|
| 90 | +3. READ gitnexus://repo/my-app/process/CheckoutFlow |
| 91 | + → Step 3: validatePayment → calls fetchRates (external) |
| 92 | +
|
| 93 | +4. Root cause: fetchRates calls external API without proper timeout |
| 94 | +``` |
0 commit comments