本文へスキップ
Skillpedia
一般的なプログラミング394k · #76

python-debugpy

できること

このスキルは、pdbやdebugpyを含むPythonのデバッグツールを使い、コードを一時停止して状態を調べる手順を、AIエージェントに示します。Pythonのコードやサービスで厄介なバグを見つけたい開発者のためのものです。

使う場面

  • ✓Pythonのスクリプトが妙な動きをし、ある地点での値を確認する必要があるとき。
  • ✓Pythonのテストが失敗し、その中を段階的に追いたいとき。
  • ✓長く動いているPythonのサービスを、リモートでデバッガーに接続する必要があるとき。

スキルのリンク

https://github.com/openclaw/openclaw/blob/main/skills/python-debugpy/SKILL.md

コピーしてAI(Claude、ChatGPT、Cursor)に貼り付け、指示に従うよう頼んでください。

使い方

いちばん簡単な方法:メッセージをコピーしてAIに貼り付けるだけ。AIがスキルを読んで指示に従います。

貼り付け用メッセージ

このスキルを使って手伝ってください:https://github.com/openclaw/openclaw/blob/main/skills/python-debugpy/SKILL.md このリンクのSKILL.mdファイルを読んで、私の作業でその指示に従ってください。
こういうスキルを、AIが自分で見つけてくれたら?無料のSkillpedia MCPをインストール。1行で、作業の前に15,000+のスキルから探してくれます。1分でインストール →

AIへの頼み方の例

“私のPythonのスクリプトが誤った数字を出しています。正しい地点で一時停止して、変数の値を見せてください。”

毎週5つの新しいスキル。1分で読めます。

仕組み

このスキルは、問題に到達できる最も小さいデバッガーを選びます。pdbセッションや、コード内のブレークポイントなどです。そのうえでプログラムを段階的に進め、値を確認し、修正案を提案します。

技術的な内容(元のSKILL.md)

作者による元のテキスト(英語)をGitHubからそのまま表示しています。

Python Debugpy

Use when Python code needs interactive debugging: hidden locals, confusing state mutation, failing tests, subprocesses, long-running services, or remote/headless attach.

Pick the smallest debugger that reaches the bad frame.

Choose

  • breakpoint(): local code, source edits ok, fastest path.
  • python3 -m pdb: no source edit, launch from the beginning.
  • python3 -m pdb -c continue: stop at an unhandled exception.
  • debugpy: remote/headless process, DAP client, already-running PID, or service startup race.

Commands

python3 -m pdb path/to/script.py arg1
python3 -m pdb -c continue path/to/script.py
python3 -c "import debugpy" || python3 -m pip install debugpy
python3 -m debugpy --listen 127.0.0.1:5678 --wait-for-client path/to/script.py
python3 -m debugpy --listen 127.0.0.1:5678 --wait-for-client -m package.module
python3 -m debugpy --listen 127.0.0.1:5678 --pid <pid>

For source-edit attach:

import debugpy

debugpy.listen(("127.0.0.1", 5678))
debugpy.wait_for_client()
debugpy.breakpoint()

For post-mortem:

import pdb, sys

try:
    run()
except Exception:
    pdb.post_mortem(sys.exc_info()[2])
    raise

pdb

  • Flow: n, s, r, c, q.
  • Stack/source: w, u, d, a, l, ll.
  • Values: p expr, pp expr, display expr.
  • Breakpoints: b file.py:42, b func, b file.py:42, condition, cl <num>.
  • Mutate/evaluate: !statement; full REPL: interact.

Rules

  • Reproduce with the smallest command/test first.
  • Disable parallel test workers for pdb; interactive stdin usually breaks inside worker pools.
  • Keep debugpy in the active env; do not add it as a project dependency unless the project already wants it.
  • Bind debug servers to 127.0.0.1; do not expose 0.0.0.0 unless isolated or tunnelled.
  • Use unique ports for parallel sessions.
  • debugpy --pid injects into a running process; confirm the target pid before attaching.
  • If PID attach fails on Linux, check ptrace/container privileges before changing the target.
  • Cleanup before commit: rg -n 'breakpoint\\(|pdb\\.set_trace|debugpy\\.' --type py.
  • Rerun the normal project test/gate without the debugger.
  • PYTHONBREAKPOINT=0 disables breakpoint().
  • If a process is stuck after debugger detach, confirm it is not still paused at a breakpoint.
よくある質問

コードを変更する必要がありますか?

必ずしも必要ではありません。pdbセッションはソースを変更せずに始められますが、コード内のブレークポイントのほうが速い場合もあります。

実行中のサービスをデバッグできますか?

はい。debugpyは、実行中のプロセスや、起動中のサービスに接続できます。

デバッグポートを開くのは安全ですか?

スキルはデバッグポートにローカルのアドレス127.0.0.1を使うため、自分のマシンからしか接続できません。

詳細

作者による元の説明

Debug Python with pdb, breakpoint(), post-mortem inspection, and debugpy remote attach.

repo: openclaw/openclaw

人気

GitHubのスター
394k
ランキング
#76
ライセンス
MIT
更新日
2026/11/2

このスキルは役に立ちますか?

0

ログイン して投票しましょう。

コメント

  • …

このリポジトリの他のスキル

似ているスキル