Chuyển đến nội dung
Skillpedia
Kiểm thử48k · #4354

debugging-code

Skill này làm gì

Giúp tìm lỗi trong mã lập trình. Bạn có thể tạm dừng chương trình, xem giá trị biến và chạy từng dòng để hiểu điều gì đang xảy ra.

Khi nào nên dùng

  • ✓Khi một chương trình bị sập hoặc báo lỗi.
  • ✓Khi kết quả đầu ra của chương trình không đúng.
  • ✓Khi bạn cần hiểu mã đã đi đến một điểm nhất định như thế nào.

Liên kết skill

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

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/sickn33/agentic-awesome-skills/blob/main/plugins/agentic-awesome-skills-claude/skills/debugging-code/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Giúp tôi gỡ lỗi mã Python này: `my_script.py`”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Công cụ tạm dừng việc thực thi mã của bạn tại những điểm cụ thể. Sau đó, bạn có thể kiểm tra trạng thái hiện tại, như giá trị biến, và điều khiển việc thực thi từng bước.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

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?

…

Câu hỏi thường gặp

Tôi cài công cụ này bằng cách nào?

Bạn có thể cài bằng Homebrew trên macOS (`brew install AlmogBaku/tap/dap`), bằng script cài đặt (`bash scripts/install-dap.sh`), hoặc biên dịch từ mã nguồn (`go install github.com/AlmogBaku/debug-skill/cmd/dap@latest`).

Công cụ hỗ trợ những ngôn ngữ lập trình nào?

Nó hỗ trợ Python, Go, Node.js/TypeScript, Rust, C/C++ và các ngôn ngữ khác dùng giao thức DAP.

Điểm dừng (breakpoint) là gì?

Đó là điểm bạn đặt trong mã để việc thực thi tạm dừng tại đó, cho phép bạn kiểm tra trạng thái của chương trình.

Chi tiết

Mô tả gốc của tác giả

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

Độ phổ biến

Sao GitHub
48k
Vị trí xếp hạng
#4354
Giấy phép
MIT
Cập nhật
15/10/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự