跳到正文
Skillpedia
通用编程48k · #5438

phase-gated-debugging

它能做什么

这个 AI 助手能以有条理的方式帮你修复代码中的 bug。它会确保在做任何修改之前先找到真正的问题,并遵循 5 步流程,避免仓促修复。

适用场景

  • ✓当 bug 看似修好了,却反复出现时。
  • ✓当你需要一套循序渐进的流程来找出错误原因时。
  • ✓当错误偶尔才出现、很难追踪时。

技能链接

https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/phase-gated-debugging/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/phase-gated-debugging/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我的代码里出现了一个 bug,我找不出原因。你能用一套有条理的流程帮我排查吗?”

每周 5 个新技能,1 分钟读完。

工作原理

AI 会先尝试复现错误,然后添加注释来理解问题出现在哪里,接着分析根本原因,最后才应用修复。最后,它会检查错误是否真的解决了。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Phase-Gated Debugging

Overview

AI coding agents see an error and immediately edit code. They guess at fixes, get it wrong, and spiral. This skill enforces a strict 5-phase protocol where you CANNOT edit source code until the root cause is identified and confirmed.

Based on claude-debug (full plugin with PreToolUse hook enforcement).

When to Use

Use this skill when:

  • a bug keeps getting "fixed" without resolving the underlying issue
  • you need to slow an agent down and force disciplined debugging before code edits
  • the failure is intermittent, a regression, performance-related, or otherwise hard to isolate
  • you want an explicit user confirmation checkpoint before any fix is applied

The Protocol

Phase 1: REPRODUCE

Run the failing command/test. Capture the exact error. Run 2-3 times for consistency.

  • Do NOT read source code
  • Do NOT hypothesize
  • Do NOT edit any files

Phase 2: ISOLATE

Read code. Add diagnostic logging marked // DEBUG. Re-run with diagnostics. Binary search to narrow down.

  • Only // DEBUG marked logging is allowed
  • Do NOT fix the bug even if you see it

Phase 3: ROOT CAUSE

Analyze WHY at the isolated location. Use "5 Whys" technique. Remove debug logging.

State: "This is my root cause analysis: [explanation]. Do you agree, or should I investigate further?"

WAIT for user confirmation. Do NOT proceed without it.

Phase 4: FIX

Remove all // DEBUG lines. Apply minimal change addressing confirmed root cause.

  • Only edit files related to root cause
  • Do NOT refactor unrelated code

Phase 5: VERIFY

Run original failing test — must pass. Run related tests. For intermittent bugs, run 5+ times. If verification fails: root cause was wrong, go back to Phase 2.

Bug-Type Strategies

Type Technique
Crash/Panic Stack trace backward — trace the bad value to its source
Wrong Output Binary search — log midpoint, halve search space each iteration
Intermittent Compare passing vs failing run logs — find ordering divergence
Regression git bisect — find the offending commit
Performance Timing at stage boundaries — find the bottleneck

Key Rules

  1. NEVER edit source code in phases 1-3 (except // DEBUG in phase 2)
  2. NEVER proceed past phase 3 without user confirmation
  3. ALWAYS reproduce before investigating
  4. ALWAYS verify after fixing

Example

User request:

a bug keeps getting "fixed" without resolving the underlying issue; diagnose it and return the concrete next action.

Limitations

  • Use this skill only when the task clearly matches the scope described above.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.
常见问题

为什么不能直接修改代码?

如果不先弄清根本原因就修改代码,可能会让问题变得更糟,或者引入新的 bug。这个流程可以确保修复针对问题的源头。

这 5 个阶段分别是什么?

依次为:1. 复现错误,2. 通过注释隔离问题,3. 找出根本原因,4. 应用修复,5. 验证错误已解决。

如果修复没有生效怎么办?

如果在验证阶段发现错误仍未解决,AI 会回到隔离阶段,重新排查。

详情

作者的原始描述

Use when debugging any bug. Enforces a 5-phase protocol where code edits are blocked until root cause is confirmed. Prevents premature fix attempts.

repo: sickn33/agentic-awesome-skills

热度

GitHub 星标
48k
排名
#5438
许可证
MIT
更新时间
2026/10/15

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能