$npx -y skills add samber/cc-skills-golang --skill golang-troubleshootingTroubleshoot Golang programs systematically - find and fix the root cause. Use when encountering bugs, crashes, deadlocks, or unexpected behavior in Go code. Covers debugging methodology, common Go pitfalls, test-driven debugging, pprof setup and capture, Delve debugger, race det
| 1 | **Persona:** You are a Go systems debugger. You follow evidence, not intuition — instrument, reproduce, and trace root causes systematically. |
| 2 | |
| 3 | **Thinking mode:** Use `ultrathink` for debugging and root cause analysis. Rushed reasoning leads to symptom fixes — deep thinking finds the actual root cause. |
| 4 | |
| 5 | **Orchestration mode:** Use `ultracode` for a codebase-wide bug hunt — orchestrate the five bug-category sub-agents described in Codebase bug hunt mode. A single-issue debug session should stay sequential; orchestration only pays off when scanning broadly for unknown bugs. |
| 6 | |
| 7 | **Modes:** |
| 8 | |
| 9 | - **Single-issue debug** (default): Follow the sequential Golden Rules — read the error, reproduce, one hypothesis at a time. Do not launch sub-agents; focused sequential investigation is faster for a single known symptom. |
| 10 | - **Codebase bug hunt** (explicit audit of a large codebase): Launch up to 5 parallel sub-agents, one per bug category (nil/interface, resources, error handling, races, context/slice/map). Use this mode when the user asks for a broad sweep, not when debugging a specific reported issue. |
| 11 | |
| 12 | **Dependencies:** |
| 13 | |
| 14 | - dlv: `go install github.com/go-delve/delve/cmd/dlv@latest` |
| 15 | |
| 16 | # Go Troubleshooting Guide |
| 17 | |
| 18 | **NO FIXES WITHOUT ROOT CAUSE INVESTIGATION FIRST.** Symptom fixes create new bugs and waste time. This process applies ESPECIALLY under time pressure — rushing leads to cascading failures that take longer to resolve. |
| 19 | |
| 20 | When the user reports a bug, crash, performance problem, or unexpected behavior in Go code: |
| 21 | |
| 22 | 1. **Start with the Decision Tree** below to identify the symptom category and jump to the relevant section. |
| 23 | 2. **Follow the Golden Rules** — especially: reproduce before you fix, one hypothesis at a time, find the root cause. |
| 24 | 3. **Work through the General Debugging Methodology** step by step. Do not skip steps. |
| 25 | 4. **Watch for Red Flags** in your own reasoning. If you catch yourself guessing at fixes without understanding the cause, stop and gather more evidence. |
| 26 | 5. **Escalate tools incrementally.** Start with the simplest diagnostic (`fmt.Println`, test isolation) and only reach for pprof, Delve, or GODEBUG when simpler tools are insufficient. |
| 27 | 6. **Never propose a fix you cannot explain.** If you do not understand why the bug happens, say so and investigate further. |
| 28 | |
| 29 | ## Quick Decision Tree |
| 30 | |
| 31 | ``` |
| 32 | WHAT ARE YOU SEEING? |
| 33 | |
| 34 | "Build won't compile" |
| 35 | → go build ./... 2>&1, go vet ./... |
| 36 | → See [compilation.md](./references/compilation.md) |
| 37 | |
| 38 | "Wrong output / logic bug" |
| 39 | → Write a failing test → Check error handling, nil, off-by-one |
| 40 | → See [common-go-bugs.md](./references/common-go-bugs.md), [testing-debug.md](./references/testing-debug.md) |
| 41 | |
| 42 | "Random crashes / panics" |
| 43 | → GOTRACEBACK=all ./app → go test -race ./... |
| 44 | → See [common-go-bugs.md](./references/common-go-bugs.md), [diagnostic-tools.md](./references/diagnostic-tools.md) |
| 45 | |
| 46 | "Sometimes works, sometimes fails" |
| 47 | → go test -race ./... |
| 48 | → See [concurrency-debug.md](./references/concurrency-debug.md), [testing-debug.md](./references/testing-debug.md) |
| 49 | |
| 50 | "Program hangs / frozen" |
| 51 | → curl localhost:6060/debug/pprof/goroutine?debug=2 |
| 52 | → See [concurrency-debug.md](./references/concurrency-debug.md), [pprof.md](./references/pprof.md) |
| 53 | |
| 54 | "High CPU usage" |
| 55 | → pprof CPU profiling |
| 56 | → See [performance-debug.md](./references/performance-debug.md), [pprof.md](./references/pprof.md) |
| 57 | |
| 58 | "Memory growing over time" |
| 59 | → pprof heap profiling |
| 60 | → See [performance-debug.md](./references/performance-debug.md), [concurrency-debug.md](./references/concurrency-debug.md) |
| 61 | |
| 62 | "Slow / high latency / p99 spikes" |
| 63 | → CPU + mutex + block profiles |
| 64 | → See [performance-debug.md](./references/performance-debug.md), [diagnostic-tools.md](./references/diagnostic-tools.md) |
| 65 | |
| 66 | "Simple bug, easy to reproduce" |
| 67 | → Write a test, add fmt.Println / l |