.pi/agent/skills/go-debug/SKILL.md
Reference guide for interactive Go debugging with Delve (dlv) — breakpoints, stepping, variable inspection, goroutine debugging, race conditions, deadlocks. Skip for simple bugs.
npx skillsauth add popoffvg/dotfiles go-debugInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Use Delve (dlv) to debug Go applications interactively. Set breakpoints, inspect variables, and step through Go code execution.
Use when:
Skip when:
t.Logf() and re-run test insteadgo install github.com/go-delve/delve/cmd/dlv@latest# Debug specific test
dlv test -- -test.run TestName
# Debug test with timeout
dlv test -- -test.run TestName -test.timeout 30s
# Debug with environment variables
ENV_VAR=true dlv test -- -test.run TestName
Inside dlv:
break file.go:123 - Set breakpoint at linebreak TestFunctionName - Break at function startcontinue or c - Run until breakpointnext or n - Step overstep or s - Step intoprint varName or p varName - Print variablelocals - Show local variablesargs - Show function argumentsgoroutines - List all goroutinesgoroutine <id> - Switch to goroutinestack or bt - Show stack tracelist - Show current code locationrestart or r - Restart programquit or q - Exit debugger# Debug binary
dlv exec ./myapp -- --config config.yaml
# Debug with compilation
dlv debug ./cmd/myapp -- --log-level debug
# Attach to running process
dlv attach <pid>
# Remote debugging (headless mode)
dlv debug --headless --listen=:2345 --api-version=2 --log ./cmd/myapp
# Create breakpoint file
cat > /tmp/breakpoints.txt <<EOF
break main.go:42
break controllers/runner/process.go:156
condition 2 jobID == "test-123"
continue
EOF
# Start with breakpoints
dlv test -- -test.run TestName < /tmp/breakpoints.txt
If the project has .vscode/launch.json, use its launch configurations for debugging. Common patterns:
# Find test function line number
grep -n "^func.*TestName" file_test.go
# Check if process is running
ps aux | grep dlv
# Kill hung dlv session
pkill -9 dlv
# Debug with core dump
dlv core ./binary ./core.dump
go test -racegoroutines to see all running goroutinesgoroutine <id> to inspect eachkill -QUIT <pid> (prints goroutine stacks)dlv attach <pid>goroutines to see all goroutinesbreak suite_test.go:234dlv test -- -test.run TestNamep actualValue, p expectedValuelocals, argsnext to understand flownext (over) or step (into)p varNamelist to see current locationfinish to run until function returns-gcflags="all=-N -l" to disable optimizations for better debuggingcondition <bp-num> <expression>clear <bp-num> or clearalltoggle <bp-num>print doesn't have persistent watches, re-run as needed-test.timeout 5m.claude/rules/ for test-specific patterns if they exist"could not launch process: decoding dwarf section info"
go clean -cache && go testBreakpoint not hit
listbreak FunctionNameVariables optimized away
go test -gcflags="all=-N -l"Can't attach to process
sudo or CAP_SYS_PTRACE capabilityWhen tests fail in CI:
Eval checklist:
Test inputs:
Can change: breakpoint strategy, stepping workflow, goroutine inspection steps, when-to-use criteria Cannot change: Delve as the debugging tool, skip-when criteria for simple bugs Min sessions before eval: 5 Runs per experiment: 3
tools
Improve a whole CLAUDE.local.md — the private, per-project rules captured from user corrections. Wraps each conditional rule in a <task-relevant> block so it only surfaces for matching work, merges duplicates, generalizes one-off facts, drops stale entries, and routes raw project facts to engram. Use when the user says "improve claude.local", "clean up the local rules", "claude.local is bloated", or after the Stop hook has appended many rules.
testing
WM pipeline and conventions shared across all phases. Agents must read this before spec, impl, or verify work.
development
One entry point for spec writing, implementation, and bug fixing. Default is new (write spec → grill loop → produce notes → author TODO bodies). Other subcommands: verify (audit), revise (sync to shipped), prototype (settle a decision), code-map (diagram), impl (execute one TODO), fix (analyze cause, correct thoughts, fix behavior), help (this page). Invoke as /code <subcommand>.
development
Red-Green-Refactor cycle for bug fixes. Before fixing a bug, first write a failing test that reproduces it (Red), then make the minimal change to pass (Green), then clean up the code (Refactor). Use on any bug fix, error correction, failing test repair, or when user says "fix this bug".