agentsclimarketplace

Systematic debugging strategies

Skill findscripter/everything-skills/02-engineering/systematic-debugging-strategies

类书式 AI Agent 技能大典 · 精选/中文化/互见成网的 500+ 开源技能,可作为 Claude Code 插件市场一键安装。A curated, cross-referenced encyclopedia of 500+ open-source agent skills.

Install
npx -y skills add findscripter/everything-skills --skill systematic-debugging-strategies

Assembled from the repository path, not quoted from the project. Check it against their README if it does not work.

2 things to look at

  • no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
  • 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.

What its author says it does

Copied from the file, not written here

当排查 elusive bug、性能劣化、生产事故、崩溃栈/dump、分布式系统异常时使用;做法是按「复现-取证-假设-实验-定位-验证」科学闭环,配合二分(git bisect)、定向日志/断点、差分对比与 profiling,产出可复现步骤、根因结论与已验证修复。不适用于无可复现症状、纯功能开发或拿不到日志/trace/运行信号的场景。触发词:调试、复现、栈追踪、性能、生产事故、内存泄漏

The file declares its own license as MIT. That is the author’s claim about this one file, and it is not the same thing as the license GitHub reports for the repository, which is listed with the other numbers below.

SKILL.md

5.9 KB, as published. Nobody here has run it

何时使用

适用:

  • 追查难缠的隐蔽 bug、偶现/flaky 问题。
  • 排查性能劣化(慢查询、卡顿、内存增长)。
  • 处理生产事故、分析崩溃 dump 或栈追踪。
  • 调试分布式系统中的异常行为。

不该用(负边界):

  • 没有可复现问题,也没有可观测症状时——先收集症状再来。
  • 任务是纯粹的新功能开发。
  • 拿不到日志、trace 或任何运行期信号时(先打通可观测性)。

核心心态:不要假设「不可能是 X」「我没改过 Y」「在我机器上是好的」——逐一核实。一次只改一处,保留笔记,必要时用「橡皮鸭法」把问题讲出来。

步骤

遵循科学方法闭环:观察 → 假设 → 实验 → 分析 → 重复,直到定位根因。

  1. 复现(Reproduce):确认能否稳定复现(总是/有时/随机)、需要哪些前置条件、他人能否复现。构造最小可复现样例,删掉无关代码,记录精确步骤与环境。
  2. 取证(Gather):收集完整栈追踪、错误码、日志;记录 OS / 运行时 / 依赖版本与环境变量;查 git 历史、部署时间线、配置变更;确认影响范围(全量 vs 特定用户/浏览器/环境)。
  3. 假设(Hypothesize):问「什么变了」「好坏两边有何不同」「可能在哪一层失败(输入校验/业务逻辑/数据层/外部服务)」。
  4. 实验定位(Test):二分缩小范围;加定向日志/断点追踪状态;隔离组件、mock 依赖;用差分表对比 working vs broken。
  5. 修复与验证(Verify):定位根因而非症状;改完后用第 1 步的复现路径验证确实修复;记录结论。

指令

  • 回归定位用 git bisect 二分提交:
git bisect start
git bisect bad                 # 当前是坏的
git bisect good v1.0.0         # v1.0.0 是好的
# 在自动切到的中间提交上测试,然后:
git bisect good   # 正常
git bisect bad    # 仍坏
# 重复直到锁定,结束后:
git bisect reset
  • Python 打断点与 post-mortem:
breakpoint()                   # Python 3.7+,优于 pdb.set_trace()
try:
    risky_operation()
except Exception:
    import pdb; pdb.post_mortem()   # 在异常现场调试
  • Python 性能 profiling:
import cProfile, pstats
cProfile.run('slow_function()', 'profile_stats')
stats = pstats.Stats('profile_stats')
stats.sort_stats('cumulative')
stats.print_stats(10)          # 最慢的前 10
  • JS/TS 控制台技巧与计时:console.table(arr)console.trace()console.assert(v>0,'must be positive')console.time('op')…console.timeEnd('op');条件断点用 if (cond) debugger;
  • Node 内存排查:当 process.memoryUsage().heapUsed 超阈值时 require('v8').writeHeapSnapshot(),对比前后两份 heap 快照定位泄漏。
  • Go:dlv debug main.go 调试;debug.PrintStack() 打栈;引入 net/http/pprof 访问 /debug/pprof/ 做内存/CPU profiling。

示例

差分调试——把可工作与故障两侧逐项列表对比,从差异推假设:

维度WorkingBroken
环境DevelopmentProduction
Node 版本18.16.018.15.0
数据量空库100 万条
用户Admin普通用户
浏览器ChromeSafari
时间白天午夜后

假设:与时间相关?优先检查时区处理。

偶现 bug:加密集日志(计时、状态迁移、外部交互),重点查竞态(共享状态并发访问、异步乱序、缺同步)与定时依赖(setTimeout、Promise 顺序),并做压力/变速复跑。

注意事项

  • 卡住时优先核对清单:拼写/变量名笔误、大小写敏感、null/undefined、数组越界 off-by-one、异步竞态、作用域(闭包/提升)、类型不匹配、缺依赖、环境变量、路径(绝对 vs 相对)、缓存与陈旧数据。
  • 性能问题先 profile 再优化,别盲改;常见元凶:N+1 查询、无谓重渲染、大数据处理、同步 I/O。
  • 生产环境只取证不乱改:靠 Sentry/Bugsnag、日志、监控收集证据;用脱敏生产数据本地复现;通过 feature flag 与 staging 验证修复。
  • 常见错误:一次改多处、不读完整栈、默认问题很复杂、把调试日志带上线、该用调试器却只 console.log、过早放弃、不验证修复。

互见

  • 源仓库 resources/implementation-playbook.md(详细模式、检查单与各语言代码示例)。
  • 可配合本大典中的性能分析、生产运维/可观测性相关条目联用。

采编自 sickn33/antigravity-awesome-skills(MIT License)。

Keep looking

Skills are one crate of 328,083. Ordering is by how many stacks a row turns up in, so the top of any crate is what has actually been picked rather than what has the most stars.