安全安装
- 作者仓库星标 0
- 作者更新于 实时读取
- 作者仓库 skills-registry
- 领域
- 工程开发
- 兼容 Agent
-
- Claude Code
- Cursor
- Cline
- Codex
- Windsurf
- Gemini CLI
- +20
- 信任分
- 88 / 100 · 社区维护
- 作者 / 版本 / 许可
- @tomevault-io · 未声明 license
- Token 消耗评级
- 低消耗
- 接入复杂程度
- 需简单配置
- 是否需要外部 API Key
- 不需要
- 兼容的系统
- 未声明(默认跨平台)
- 底层运行要求
- 无特殊要求
- 文件与系统权限
-
- 只读
- 允许写入 / 修改
- Shell 执行
- 读取环境变量
- 网络行为
- 允许外网请求
- 安装命令数
- 26 条
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
---
name: golang-troubleshooting
description: Troubleshoot Golang programs systematically - find and fix the root cause. Use when encountering…
category: 工程开发
runtime: 无特殊运行时
---
# golang-troubleshooting 输出预览
## PART A: 任务判断
- 适用问题:代码实现、重构、调试或代码审查。
- 输入要求:目标材料、限制条件、期望输出和验收方式。
- 证据边界:围绕“Quick Decision Tree / The Golden Rules / 1. Read the Error Message First”读取原文规则,不把推断写成作者承诺。
## PART B: 执行结果
- **01** 任务判断:确认你的需求是否属于代码实现、重构、调试或代码审查,并标出输入、限制和预期结果。
- **02** 执行计划:优先按“Quick Decision Tree / The Golden Rules / 1. Read the Error Message First”拆成步骤,说明每一步会读取什么、修改什么、产出什么。
- **03** 交付结果:给出可复制的命令、文件改动、检查清单或内容草稿,并说明如何继续迭代。
- **04** 风险边界:结合 读取文件、写入/修改文件、执行终端命令、读取环境变量、会按任务需要访问外部网络、通常不需要额外 API Key 给出执行前确认项。
## Running Rules
- 读取文件、写入/修改文件、执行终端命令、读取环境变量;会按任务需要访问外部网络;通常不需要额外 API Key。
- 先小样例验证,再放大到真实任务。
- 交付时同时给结果、检查口径和下一步迭代建议。 原文没有稳定的斜杠命令要求。安装验证后通常全局生效,直接在对话里点名这个 Skill 并描述任务即可。
告诉 Agent 目标文件或材料、期望结果、不可改范围、是否允许联网或执行命令。本 Skill 的权限画像是:读取文件、写入/修改文件、执行终端命令、读取环境变量。
先用一个小任务确认它会围绕“Quick Decision Tree / The Golden Rules / 1. Read the Error Message First”工作;涉及文件或命令时,先看 diff、日志、预览或测试结果。
检查最终产物是否包含明确结果、必要证据和下一步动作;如果输出泛泛而谈,就补充输入、边界和验收标准后重跑。
---
name: golang-troubleshooting
description: Troubleshoot Golang programs systematically - find and fix the root cause. Use when encountering…
category: 工程开发
source: tomevault-io/skills-registry
---
# golang-troubleshooting
## 什么时候使用
- 用于组织测试、定位失败并形成修复闭环 适合处理工程开发场景下的代码实现、调试、重构、测试或代码审查,核心价值是把输入、判断、执行、验证和交付边界固定下来,避免 Agent 泛泛回答。 把任务拆成可执行、可检查、可继续迭代的步骤;通常不需…
- 面向代码实现、重构、调试或代码审查,优先处理能明确输入、步骤和验收标准的工作。
## 需要提供什么
- 目标材料、目录范围、期望结果和不可改动内容。
- 是否允许联网、执行命令、读写文件或调用外部服务。
## 执行规则
- 围绕「Quick Decision Tree / The Golden Rules / 1. Read the Error Message First」组织步骤,不把推断写成作者事实。
- 读取文件、写入/修改文件、执行终端命令、读取环境变量;会按任务需要访问外部网络;通常不需要额外 API Key。
- 先跑小样例,确认结果可检查后再扩大任务范围。
## 输出要求
- 给出最终产物、关键证据、验证方式和下一步动作。
- 信息不足时标记 unknown,不编造命令、平台或依赖。 作者原文负责流程事实;仓库文件负责来源和命令;流狐只补充适用场景、限制和质量判断。
skill "golang-troubleshooting" {
输入层 -> 用户目标 + 目标文件 + 禁止范围 + 验收标准
上下文层 -> Quick Decision Tree / The Golden Rules / 1. Read the Error Message First
规则层 -> SKILL.md 触发条件 / 执行顺序 / 输出格式
运行层 -> 无特殊运行时 | 读取文件、写入/修改文件、执行终端命令、读取环境变量 | 会按任务需要访问外部网络
安全层 -> 通常不需要额外 API Key + 小任务验证 + diff / 日志复核
输出层 -> 可复制结果 + 检查清单 + 下一步迭代
} Persona: You are a Go systems debugger. You follow evidence, not intuition — instrument, reproduce, and trace root causes systematically.
Thinking mode: Use ultrathink for debugging and root cause analysis. Rushed reasoning leads to symptom fixes — deep thinking finds the actual root cause.
Modes:
- 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.
- 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.
Go Troubleshooting Guide
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.
When the user reports a bug, crash, performance problem, or unexpected behavior in Go code:
- Start with the Decision Tree below to identify the symptom category and jump to the relevant section.
- Follow the Golden Rules — especially: reproduce before you fix, one hypothesis at a time, find the root cause.
- Work through the General Debugging Methodology step by step. Do not skip steps.
- Watch for Red Flags in your own reasoning. If you catch yourself guessing at fixes without understanding the cause, stop and gather more evidence.
- 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. - Never propose a fix you cannot explain. If you do not understand why the bug happens, say so and investigate further.
Quick Decision Tree
WHAT ARE YOU SEEING?
"Build won't compile"
→ go build ./... 2>&1, go vet ./...
→ See [compilation.md](./references/compilation.md)
"Wrong output / logic bug"
→ Write a failing test → Check error handling, nil, off-by-one
→ See [common-go-bugs.md](./references/common-go-bugs.md), [testing-debug.md](./references/testing-debug.md)
"Random crashes / panics"
→ GOTRACEBACK=all ./app → go test -race ./...
→ See [common-go-bugs.md](./references/common-go-bugs.md), [diagnostic-tools.md](./references/diagnostic-tools.md)
"Sometimes works, sometimes fails"
→ go test -race ./...
→ See [concurrency-debug.md](./references/concurrency-debug.md), [testing-debug.md](./references/testing-debug.md)
"Program hangs / frozen"
→ curl localhost:6060/debug/pprof/goroutine?debug=2
→ See [concurrency-debug.md](./references/concurrency-debug.md), [pprof.md](./references/pprof.md)
"High CPU usage"
→ pprof CPU profiling
→ See [performance-debug.md](./references/performance-debug.md), [pprof.md](./references/pprof.md)
"Memory growing over time"
→ pprof heap profiling
→ See [performance-debug.md](./references/performance-debug.md), [concurrency-debug.md](./references/concurrency-debug.md)
"Slow / high latency / p99 spikes"
→ CPU + mutex + block profiles
→ See [performance-debug.md](./references/performance-debug.md), [diagnostic-tools.md](./references/diagnostic-tools.md)
"Simple bug, easy to reproduce"
→ Write a test, add fmt.Println / log.Debug
→ See [testing-debug.md](./references/testing-debug.md)
Remember: Read the Error → Reproduce → Measure One Thing → Fix → Verify
Most Go bugs are: missing error checks, nil pointers, forgotten context cancel, unclosed resources, race conditions, or silent error swallowing.
The Golden Rules
1. Read the Error Message First
Go error messages are precise. Read them fully before doing anything else:
- File and line number → go directly there
- Type mismatch → check function signatures, interface satisfaction
- "undefined" → check imports, exported names, build tags
- "cannot use X as Y" → check concrete types vs interfaces
2. Reproduce Before You Fix
NEVER debug by guessing — reproduce first. Always:
- Write a failing test that captures the bug
- Make it deterministic
- Isolate the minimal failing example
- Use
git bisectto find the breaking commit
3. If You Don't Measure It, You're Guessing
Never rely on intuition for performance or concurrency bugs:
- pprof over intuition
- race detector over reasoning
- benchmarks over assumptions
4. One Hypothesis at a Time
Change one thing, measure, confirm. If you change three things at once, you learn nothing.
5. Find the Root Cause — No Workarounds
A band-aid fix that masks the symptom IS NOT ACCEPTABLE. You MUST understand why the bug happens before writing a fix.
When you don't understand the issue:
- Trace the data flow backwards from the symptom to its origin.
- Question your assumptions. The code you trust might be wrong.
- Ask "why" five times. Keep going until you reach the actual root cause.
- Perform more troubleshooting checks. More fmt.Println, more output inspection...
6. Research the Codebase, Not Just the Diff
Before flagging a bug or proposing a fix, trace the data flow and check for upstream handling. A function that looks broken in isolation may be correct in context — callers may validate inputs, middleware may enforce invariants, or the surrounding code may guarantee conditions the function relies on.
- Trace callers — who calls this function and with what values? Use Grep/Agent to find all call sites.
- Check upstream validation — input parsing, type conversions, or guard clauses earlier in the chain may make the "bug" unreachable.
- Read the surrounding code — middleware, interceptors, or init functions may set up state the function depends on.
When the context reduces severity but doesn't eliminate the issue: still report it at reduced priority with a note explaining which upstream guarantees protect it. Add a brief inline comment (e.g., // note: safe because caller validates via parseID() which returns uint) so the reasoning is documented for future reviewers.
7. Start Simple
Sometimes fmt.Println IS the right tool for local debugging. Escalate tools only when simpler approaches fail. NEVER use fmt.Println for production debugging — use slog.
Red Flags: You're Debugging Wrong
If any of these are happening, stop and return to Step 1:
- "Quick fix for now, investigate later" — There is no "later". Find the root cause.
- Multiple simultaneous changes — One hypothesis at a time.
- Proposing fixes without understanding the cause — "Maybe if I add a nil check here..." is guessing, not debugging.
- Each fix reveals a new problem — You're treating symptoms. The real bug is elsewhere.
- 3+ fix attempts on the same issue — You have the wrong mental model. Re-read the code, trace the data flow from scratch.
- "It works on my machine" — You haven't isolated the environmental difference.
- Blaming the framework/stdlib/compiler — It's almost never a Go bug. Verify your code first.
Reference Files
General Debugging Methodology — The systematic 10-step process: define symptoms, isolate reproduction, form one hypothesis, test it, verify the root cause, and defend against regressions. Escalation guide: when to escalate from
fmt.Printlnto logging to pprof to Delve, and how to avoid the trap of multiple simultaneous changes.Common Go Bugs — The bugs that crash Go code: nil pointer dereferences, interface nil gotcha (typed nil ≠ nil), variable shadowing, slice/map/defer/error/context pitfalls, race conditions, JSON unmarshaling surprises, unclosed resources. Each with reproduction patterns and fixes.
Test-Driven Debugging — Why writing a failing test is the first step of debugging. Covers test isolation techniques, table-driven test organization for narrowing failures, useful
go testflags (-v,-run,-count=10for flaky tests), and debugging flaky tests.Concurrency Debugging — Race conditions, deadlocks, goroutine leaks. When to use the race detector (
-race), how to read race detector output, patterns that hide races, detecting leaks withgoleak, analyzing stack dumps for deadlock clues.Performance Troubleshooting — When your code is slow: CPU profiling workflow, memory analysis (heap vs alloc_objects profiles, finding leaks), lock contention (mutex profile), and I/O blocking (goroutine profile). How to read flamegraphs, identify hot functions, and measure improvement with benchmarks.
pprof Reference — Complete pprof manual. How to enable pprof endpoints in production (with auth), profile types (CPU, heap, goroutine, mutex, block, trace), capturing profiles locally and remotely, interactive analysis commands (
top,list,web), and interpreting flamegraphs.Diagnostic Tools — Auxiliary tools for specific symptoms. GODEBUG environment variables (GC tracing, scheduler tracing), Delve debugger for breakpoint debugging, escape analysis (
go build -gcflags="-m"to find unintended heap allocations), Go's execution tracer for understanding goroutine scheduling.Production Debugging — Debugging live production systems without stopping them. Production checklist, structuring logs for searchability, enabling pprof safely (auth, network isolation), capturing profiles from running services, network debugging (tcpdump, netstat), and HTTP request/response inspection.
Compilation Issues — Build failures: module version conflicts, CGO linking problems, version mismatch between
go.modand installed Go version, platform-specific build tags preventing cross-compilation.Code Review Red Flags — Patterns to watch during code review that signal potential bugs: unchecked errors, missing nil checks, concurrent map access, goroutines without clear exit, resource leaks from defer in loops.
Cross-References
- → See
samber/cc-skills-golang@golang-performanceskill for optimization patterns after identifying bottlenecks - → See
samber/cc-skills-golang@golang-observabilityskill for metrics, alerting, and Grafana dashboards for Go runtime monitoring - → See
samber/cc-skills@promql-cliskill for querying Prometheus metrics during production incident investigation - → See
samber/cc-skills-golang@golang-concurrency,samber/cc-skills-golang@golang-safety,samber/cc-skills-golang@golang-error-handlingskills
Source: aaawrong/cc-skills-golang — distributed by TomeVault.
先判断是否适合
作者设计意图
作者的方法与取舍
边界和复核