$npx -y skills add haoxiang-xu/PuPu --skill gitnexus-debuggingUse 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\"
| 1 | # Debugging with GitNexus |
| 2 | |
| 3 | ## When to Use |
| 4 | |
| 5 | - "Why is this function failing?" |
| 6 | - "Trace where this error comes from" |
| 7 | - "Who calls this method?" |
| 8 | - "This endpoint returns 500" |
| 9 | - Investigating bugs, errors, or unexpected behavior |
| 10 | |
| 11 | ## Workflow |
| 12 | |
| 13 | ``` |
| 14 | 1. query({search_query: "<error or symptom>"}) → Find related execution flows |
| 15 | 2. context({name: "<suspect>"}) → See callers/callees/processes |
| 16 | 3. READ gitnexus://repo/{name}/process/{name} → Trace execution flow |
| 17 | 4. cypher({statement: "MATCH path..."}) → Custom traces if needed |
| 18 | ``` |
| 19 | |
| 20 | > If "Index is stale" → run `node .gitnexus/run.cjs analyze` in terminal. |
| 21 | |
| 22 | ## Checklist |
| 23 | |
| 24 | ``` |
| 25 | - [ ] Understand the symptom (error message, unexpected behavior) |
| 26 | - [ ] query for error text or related code |
| 27 | - [ ] Identify the suspect function from returned processes |
| 28 | - [ ] context to see callers and callees |
| 29 | - [ ] Trace execution flow via process resource if applicable |
| 30 | - [ ] cypher for custom call chain traces if needed |
| 31 | - [ ] Read source files to confirm root cause |
| 32 | ``` |
| 33 | |
| 34 | ## Debugging Patterns |
| 35 | |
| 36 | | Symptom | GitNexus Approach | |
| 37 | | -------------------- | ---------------------------------------------------------- | |
| 38 | | Error message | `query` for error text → `context` on throw sites | |
| 39 | | Wrong return value | `context` on the function → trace callees for data flow | |
| 40 | | Intermittent failure | `context` → look for external calls, async deps | |
| 41 | | Performance issue | `context` → find symbols with many callers (hot paths) | |
| 42 | | Recent regression | `detect_changes` to see what your changes affect | |
| 43 | | "How does A reach B?" | `trace` between the two symbols — shortest call chain in one call | |
| 44 | |
| 45 | ## Tools |
| 46 | |
| 47 | **query** — find code related to error: |
| 48 | |
| 49 | ``` |
| 50 | query({search_query: "payment validation error"}) |
| 51 | → Processes: CheckoutFlow, ErrorHandling |
| 52 | → Symbols: validatePayment, handlePaymentError, PaymentException |
| 53 | ``` |
| 54 | |
| 55 | **context** — full context for a suspect: |
| 56 | |
| 57 | ``` |
| 58 | context({name: "validatePayment"}) |
| 59 | → Incoming calls: processCheckout, webhookHandler |
| 60 | → Outgoing calls: verifyCard, fetchRates (external API!) |
| 61 | → Processes: CheckoutFlow (step 3/7) |
| 62 | ``` |
| 63 | |
| 64 | **cypher** — custom call chain traces: |
| 65 | |
| 66 | ```cypher |
| 67 | MATCH path = (a)-[:CodeRelation {type: 'CALLS'}*1..2]->(b:Function {name: "validatePayment"}) |
| 68 | RETURN [n IN nodes(path) | n.name] AS chain |
| 69 | ``` |
| 70 | |
| 71 | **trace** — shortest call chain between two symbols ("how does A reach B?"), one call instead of chaining `context` hops: |
| 72 | |
| 73 | ``` |
| 74 | trace({ from: "processCheckout", to: "fetchRates" }) |
| 75 | → status: ok, hopCount: 3 |
| 76 | → hops: processCheckout → validatePayment → verifyCard → fetchRates |
| 77 | → edges: CALLS (1.0), CALLS (0.95), CALLS (1.0) |
| 78 | ``` |
| 79 | |
| 80 | When no path exists, `trace` reports the furthest reachable node — exactly where the chain breaks (dynamic dispatch, reflection, or an external boundary). |
| 81 | |
| 82 | ## Example: "Payment endpoint returns 500 intermittently" |
| 83 | |
| 84 | ``` |
| 85 | 1. query({search_query: "payment error handling"}) |
| 86 | → Processes: CheckoutFlow, ErrorHandling |
| 87 | → Symbols: validatePayment, handlePaymentError |
| 88 | |
| 89 | 2. context({name: "validatePayment"}) |
| 90 | → Outgoing calls: verifyCard, fetchRates (external API!) |
| 91 | |
| 92 | 3. READ gitnexus://repo/my-app/process/CheckoutFlow |
| 93 | → Step 3: validatePayment → calls fetchRates (external) |
| 94 | |
| 95 | 4. Root cause: fetchRates calls external API without proper timeout |
| 96 | ``` |