本文へスキップ
Skillpedia
APIとサーバー(バックエンド)12k · #11575

python-debugpy

できること

このスキルは、Pythonの組み込みデバッガーとリモートデバッガーを使って、Pythonプログラムのバグを見つける方法をエージェントに教えます。print文では分からない問題で行き詰まっている開発者向けです。

使う場面

  • ✓Pythonプログラムが誤った結果を返し、原因が隠れているとき。
  • ✓Pythonのテストが、説明できない形で失敗するとき。
  • ✓Pythonのサービスが別のマシンで動く、または混乱した順序で起動し、デバッガーを付ける必要があるとき。

スキルのリンク

https://github.com/EKKOLearnAI/ekko-studio/blob/main/packages/ekko-agent/skills/python-debugpy/SKILL.md

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

使い方

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

貼り付け用メッセージ

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

AIへの頼み方の例

“私のPythonスクリプトが誤った合計を出します。一歩ずつ追って、どの値が誤っているかを見る手伝いをしてもらえますか。”

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

仕組み

エージェントは、その作業に最も簡単なデバッガーを選び、変数を確認できるように、プログラムを正しい行で一時停止させます。実行中のプログラムには、ローカルのポートでリモートデバッガーを接続します。

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

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

Python Debugging

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

Choose the smallest debugger that reaches the bad frame:

  • breakpoint(): local code where source edits are acceptable.
  • python3 -m pdb: launch from the beginning without editing source.
  • python3 -m pdb -c continue: stop at an unhandled exception.
  • debugpy: remote/headless processes, DAP clients, an existing PID, or startup races.

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>

Source-edit attach:

import debugpy

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

Post-mortem inspection:

import pdb
import sys

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

pdb commands

  • Flow: n, s, r, c, q.
  • Stack and 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>.
  • Evaluate or mutate: !statement; full REPL: interact.

Rules

  • Reproduce with the smallest command or test first.
  • Disable parallel test workers for pdb; worker pools usually break interactive stdin.
  • Keep debugpy in the active environment. Do not add it as a project dependency unless the project needs it.
  • Bind debug servers to 127.0.0.1; expose them only on an isolated network or through a secure tunnel.
  • Treat PID attach as process injection. Avoid security-sensitive or production targets unless explicitly approved.
  • On Linux, check ptrace and container privileges before changing a target when PID attach fails.
  • Before committing, run rg -n 'breakpoint\\(|pdb\\.set_trace|debugpy\\.' --type py and remove accidental breakpoints.
  • Rerun the normal project test gate without the debugger.
よくある質問

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

いつもではありません。このスキルは、コードを編集せずにデバッガーでプログラムを起動できますが、ローカルの作業ではソースのブレークポイントの行を使うこともあります。

すでに動いているプログラムをデバッグできますか?

はい。デバッガーは、プロセスのIDで既存のプロセスに接続できます。

ポストモーテムデバッグとは何ですか?

プログラムがクラッシュした瞬間にデバッガーを開き、その時点の状態を調べられるようにすることです。

詳細

作者による元の説明

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

repo: EKKOLearnAI/ekko-studio

人気

GitHubのスター
12k
ランキング
#11575
ライセンス
—
更新日
2026/11/2

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

0

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

コメント

  • …

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

似ているスキル