跳到正文
Skillpedia
测试48k · #4354

debugging-code

它能做什么

帮助你找出编程代码中的错误。你可以让程序暂停、查看变量的值,并逐行执行,从而理解程序的运行过程。

适用场景

  • ✓程序崩溃或抛出错误时。
  • ✓程序的输出结果不正确时。
  • ✓你需要弄清楚代码是如何执行到某个位置的时候。

技能链接

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

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

使用方法

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

可直接粘贴的消息

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

可以这样问 AI

“帮我调试这段 Python 代码:`my_script.py`”

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

工作原理

这个工具会在你指定的位置暂停代码的执行。之后你可以查看当前状态,例如变量的值,并且一步一步地控制程序的执行。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Interactive Debugger

When to Use

Use this skill when you need interactively debug source code — set breakpoints, step through execution line by line, inspect live variable state, evaluate expressions against the running program, and navigate the call stack to trace root causes. Use when a program crashes, raises unexpected exceptions, produces...

Use when a program crashes, produces wrong output, or you need to understand exactly how execution reached a particular state — and running it again with more print statements won't give you the answer fast enough.

You can pause a running program at any point, read live variable values and the call stack at that exact moment, step forward line by line or jump to the next breakpoint, and evaluate arbitrary expressions against the live process — all without restarting.

Setup

This skill uses dap, a CLI tool that background daemon to interact with the debugger via the DAP Protocol, maintain the debugger state, so you can simply interact with it with multiple calls.

If dap isn't installed (check: command -v dap), install it NOW. Ask/notify the user before proceeding to install it.

From Homebrew (macOS)

brew install AlmogBaku/tap/dap

Installer script:

bash scripts/install-dap.sh

Install from sources:

go install github.com/AlmogBaku/debug-skill/cmd/dap@latest

This tool is open-sourced and available on GitHub, maintained and follows best practices.

Supports natively Python, Go, Node.js/TypeScript, Rust, C/C++, and any other language that supports DAP.

If a debugger backend is missing or fails to start, see references/installing-debuggers.md

For all commands and flags: dap --help or dap <cmd> --help.

Starting a Session

dap debug <file> launches the program under the debugger. Backend is auto-detected from the file extension.

Choose your starting strategy based on what you know:

  • Have a hypothesis — set a breakpoint where you expect the bug: dap debug script.py --break script.py:42
  • Conditional breakpoint — only stop when a condition is met: dap debug script.py --break "script.py:42:x > 5" ( always quote specs with conditions)
  • Multi-file app — breakpoints across modules: --break src/api/routes.py:55 --break src/models/user.py:30
  • No hypothesis, small program — walk from entry: dap debug script.py --stop-on-entry (avoid for large projects — startup code is noisy; bisect with breakpoints instead)
  • Exception, location unknown — dap debug script.py --break-on-exception raised (Python) / all (Go/JS)
  • Remote process — dap debug --attach host:port --backend <name>
  • Process already running (stuck server, live issue) — attach without restarting: dap debug --pid <PID> --backend <name>

    macOS + Go gotcha: dlv --pid requires SIP disabled (csrutil disable). Prefer starting the program under the debugger instead or attaching to a remote debugger!

Session isolation: --session <name> keeps concurrent agents from interfering. Tip: You might want to use your session id(${CLAUDE_SESSION_ID}) if available.

Run dap debug --help for all flags, backends, and examples.

The Debugging Mindset

Reach for a debugger when reading source alone can't validate the root cause. A debugger lets you observe what does happen: actual values, actual path, actual state. When that diverges from what should happen, you've found your bug.

Two strikes, rethink. If two hypotheses fail at the same location, your mental model is wrong. Re-read the code, form a completely different theory with different breakpoints.

Escalate gradually. Start with dap eval to test a quick hypothesis. Use conditional breakpoints to filter noise. Fall back to full breakpoints + stepping only when you need interactive control.

Mimic the user journey. If you're debugging a user flow, set breakpoints along the path you expect the code to take. If you expected compute() to be called, but it never is, then the bug is in the caller — not compute(), but whatever was supposed to call it.

Set breakpoints instead of prints. When you feel the urge to print something, set a breakpoint instead.

Know Your State

Every dap execution command returns full context automatically: current location, source, locals, call stack, and output. At each stop, ask:

  • Do the local variables have the values I expected?

…

常见问题

这个工具要怎么安装?

你可以在 macOS 上通过 Homebrew 安装(`brew install AlmogBaku/tap/dap`),也可以运行安装脚本(`bash scripts/install-dap.sh`),或者从源代码编译(`go install github.com/AlmogBaku/debug-skill/cmd/dap@latest`)。

支持哪些编程语言?

支持 Python、Go、Node.js/TypeScript、Rust、C/C++,以及其他使用 DAP 协议的语言。

什么是 ‘断点’?

‘断点’是你在代码中设置的一个位置,程序运行到这里时会暂时停下,方便你检查程序的状态。

详情

作者的原始描述

Interactively debug source code — set breakpoints, step through execution line by line, inspect live variable state, evaluate expressions against the running program, and navigate the call stack to trace root causes.

repo: sickn33/agentic-awesome-skills

热度

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

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能