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
testing
Use when the user asks to create test sets, enumerate scenarios, generate edge cases, or draft a coverage matrix before implementation.
testing
Use when the user asks to review, audit, score, or validate test sets for missed cases before execution or merge.
tools
Test harness plugins in isolation using tmux panes. Runs MCP servers, unit tests, typecheck, and Claude plugin loading. Use when user says "test plugin", "check plugin", "run plugin tests", "validate plugin", or names a specific plugin to test.
development
Guide for designing integration and e2e tests using BDD (Behavior-Driven Development) methodology with Cucumber-style Given/When/Then scenarios. Use when writing or reviewing tests for any service, API, or component. Language-agnostic — covers scenario structure, step notation, assertion principles, async patterns, and common anti-patterns.