Communitygithub.com

エージェント内省デバッグ

エージェントの障害に対して、キャプチャ、診断、限定復旧、内省レポートを用いた構造化された自己デバッグワークフローです。エージェント実行が失敗し、単なる再試行ではなく再現可能な診断が必要な場合に使用します。

エージェント内省デバッグ とは?

このスキルは、AIエージェントの実行が繰り返し失敗する、トークンを消費するだけで進捗がない、同じツールをループする、または本来のタスクから逸脱する場合に使用する構造化された自己デバッグワークフローです。単なる再試行では解決できない問題に対して、障害状態の正確な記録、根本原因の診断、最小限の回復アクション、そして人間または後続のエージェントが理解できるデバッグレポートの作成を4フェーズで行います。Claude Code、Cursor、CodexなどのAIエージェントプラットフォームで利用でき、トークン消費の削減、デバッグ効率の向上、再現可能な問題解決を実現します。このスキルは隠れたランタイムではなくワークフローを提供するもので、エージェントが人間にエスカレーションする前に系統的に自己デバッグすることを教えます。

対応~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/everything-claude-code/tree/main/skills/agent-introspection-debugging

お気に入りのAIに質問する

このエージェントスキルを事前に読み込んだ状態で新しいチャットを開きます。

ドキュメント

エージェント内省デバッグ は何をしますか?

このスキルは、エージェントの実行が繰り返し失敗する、トークンを消費するだけで進捗がない、同じツールをループする、または本来のタスクから逸脱する場合に使用します。

これはワークフロースキルであり、隠れたランタイムではありません。エージェントが人間にエスカレーションする前に、系統的に自己デバッグする方法を教えます。

アクティブ化のタイミング

  • 最大ツール呼び出し / ループ制限エラー
  • 進捗がないまま繰り返される再試行
  • 出力品質を低下させ始めるコンテキストの肥大化またはプロンプトドリフト
  • 期待と現実のファイルシステムまたは環境状態の不一致
  • 診断と小さな修正アクションで回復可能なツール障害

スコープ境界

このスキルは以下のためにアクティブ化します:

  • 盲目的な再試行の前に障害状態をキャプチャする
  • 一般的なエージェント固有の障害パターンを診断する
  • 限定された回復アクションを適用する
  • 構造化された人間が読めるデバッグレポートを作成する

このスキルを以下の主な情報源として使用しないでください:

  • コード変更後の機能検証(verification-loop を使用)
  • より狭いECCスキルがすでに存在する場合のフレームワーク固有のデバッグ
  • 現在のハーネスが自動的に強制できないランタイムの約束

4フェーズループ

フェーズ1: 障害キャプチャ

回復を試みる前に、障害を正確に記録します。

キャプチャするもの:

  • エラータイプ、メッセージ、スタックトレース(利用可能な場合)
  • 最後の意味のあるツール呼び出しシーケンス
  • エージェントが実行しようとしていた処理
  • 現在のコンテキスト圧力:繰り返されるプロンプト、サイズオーバーの貼り付けログ、重複した計画、暴走したメモ
  • 現在の環境の前提:cwd、ブランチ、関連するサービスの状態、期待されるファイル

最小キャプチャテンプレート:

## 障害キャプチャ
- セッション / タスク:
- 進行中の目標:
- エラー:
- 最後の成功ステップ:
- 最後に失敗したツール / コマンド:
- 確認された繰り返しパターン:
- 検証する環境の前提:

フェーズ2: 根本原因診断

何かを変更する前に、障害を既知のパターンにマッチングします。

パターン考えられる原因確認内容
最大ツール呼び出し / 同じコマンドの繰り返しループまたは出口のないオブザーバーパス最後のN回のツール呼び出しを繰り返しについて検査
コンテキストオーバーフロー / 推論能力の低下無制限のメモ、繰り返される計画、サイズオーバーのログ最近のコンテキストを重複と低シグナルの塊について検査
ECONNREFUSED / タイムアウトサービスが利用不可、またはポートが間違っているサービスの健全性、URL、ポートの前提を検証
429 / クォータ枯渇再試行ストームまたはバックオフ不足繰り返し呼び出しをカウントし、再試行間隔を検査
書き込み後にファイルが見つからない / 古い差分競合、間違ったcwd、またはブランチドリフトパス、cwd、gitステータス、実際のファイル存在を再確認
「修正」後もテストが失敗する間違った仮説正確に失敗しているテストを特定し、バグを再導出

診断の質問:

  • これはロジック障害、状態障害、環境障害、それともポリシー障害ですか?
  • エージェントは本当の目的を見失い、間違ったサブタスクの最適化を始めていませんか?
  • 障害は決定的ですか、それとも一時的ですか?
  • 診断を検証する最小の可逆アクションは何ですか?

フェーズ3: 限定回復

診断結果の表面を変える最小のアクションで回復します。

安全な回復アクション:

  • 繰り返される再試行を停止し、仮説を言い直す
  • 低シグナルのコンテキストをトリミングし、アクティブな目標、ブロッカー、証拠のみを保持する
  • 実際のファイルシステム / ブランチ / プロセス状態を再確認する
  • タスクを1つの失敗コマンド、1つのファイル、または1つのテストに絞り込む
  • 推測による推論から直接観察に切り替える
  • 障害が高リスクまたは外部でブロックされている場合は人間にエスカレーションする

「エージェント状態をリセット」や「ハーネス設定を更新」といった、サポートされていない自動修復アクションを主張しないでください。現在の環境で実際のツールを通じてそれらを実行している場合を除きます。

限定回復チェックリスト:

## 回復アクション
- 選択した診断:
- 実行した最小アクション:
- これが安全な理由:
- 修正が機能したことを証明する証拠:

フェーズ4: 内省レポート

回復を次のエージェントまたは人間が理解できるようにするレポートで終了します。

## エージェント自己デバッグレポート
- セッション / タスク:
- 障害:
- 根本原因:
- 回復アクション:
- 結果:成功 | 部分的 | ブロック
- トークン / 時間消費リスク:
- 必要なフォローアップ:
- 後でエンコードする予防的変更:

回復ヒューリスティック

以下の介入をこの順序で優先します:

  1. 本当の目標を1文で言い直す。
  2. メモリを信頼する代わりに世界の状態を確認する。
  3. 失敗しているスコープを縮小する。
  4. 1つの識別チェックを実行する。
  5. その後にのみ再試行する。

悪いパターン:

  • 同じアクションをわずかに異なる表現で3回再試行する

良いパターン:

  • 障害をキャプチャする
  • パターンを分類する
  • 1つの直接チェックを実行する
  • チェックがサポートする場合にのみ計画を変更する

ECCとの統合

  • コードが変更された場合は、回復後に verification-loop を使用します。
  • 障害パターンが後でインスティンクトまたはスキルに値する場合は、continuous-learning-v2 を使用します。
  • 問題が技術的障害ではなく意思決定の曖昧さである場合は、council を使用します。
  • 競合するローカル状態またはリポジトリドリフトが原因で障害が発生した場合は、workspace-surface-audit を使用します。

出力標準

このスキルがアクティブな場合、「修正しました」だけで終了しないでください。

常に以下を提供します:

  • 障害パターン
  • 根本原因の仮説
  • 回復アクション
  • 状況が改善されたか、まだブロックされているかの証拠

Individual skills in this repo

This repo contains 20 individual skills — each has its own dedicated page.

accessibility

Design, implement, and audit inclusive digital products using WCAG 2.2 Level AA. Use when building or auditing UI that must meet WCAG 2.2 Level AA, or when reviewing a change for keyboard, contrast, or screen-reader support.

affaan-m/claude-api

Anthropic Claude API patterns for Python and TypeScript. Covers Messages API, streaming, tool use, vision, extended thinking, batches, prompt caching, and Claude Agent SDK. Use when building applications with the Claude API or Anthropic SDKs.

affaan-m/everything-claude-code

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/everything-claude-code

End-to-end marketing campaign planning and execution. Covers audience research, positioning, campaign angle definition, landing page copy, email sequences, social posts, ad copy, short-form video scripts, and content calendars. Use as the orchestration layer for multi-channel product launches. Use when planning or executing a multi-channel product launch, or producing landing page, email, social, or ad copy.

affaan-m/everything-claude-code-conventions

Development conventions and patterns for everything-claude-code. JavaScript project with conventional commits.

affaan-m/frontend-design

Create distinctive, production-grade frontend interfaces with high design quality. Use when the user asks to build web components, pages, or applications and the visual direction matters as much as the code quality.

affaan-m/gget

gget CLI and Python workflow for quick genomic database queries, sequence lookup, BLAST-style searches, enrichment checks, and reproducible bioinformatics evidence logs.

affaan-m/literature-review

Systematic literature-review workflow for academic, biomedical, technical, and scientific topics, including search planning, source screening, synthesis, citation checks, and evidence logging.

affaan-m/motion-ui

Production-ready UI motion system for React/Next.js. Use when implementing animations, transitions, or motion patterns.

affaan-m/project-guidelines-example

Example project-specific skill template based on a real production application.

affaan-m/pubmed-database

Direct PubMed and NCBI E-utilities search workflows for biomedical literature, MeSH queries, PMID lookup, citation retrieval, and API-backed literature monitoring.

affaan-m/scholar-evaluation

Structured scholarly-work evaluation for papers, proposals, literature reviews, methods sections, evidence quality, citation support, and research-writing feedback.

affaan-m/uspto-database

USPTO patent and trademark data workflow for official record lookup, PatentSearch queries, TSDR checks, assignment data, and reproducible IP research logs.

agent-architecture-audit

Full-stack diagnostic for agent and LLM applications. Audits the 12-layer agent stack for wrapper regression, memory pollution, tool discipline failures, hidden repair loops, and rendering corruption. Produces severity-ranked findings with code-first fixes. Essential for developers building agent applications, autonomous loops, or any LLM-powered feature. Use when an agent or LLM feature misbehaves and the failing layer is unknown, or before shipping an agent stack.

agent-eval

Head-to-head comparison of coding agents (Claude Code, Aider, Codex, etc.) on custom tasks with pass rate, cost, time, and consistency metrics. Use when choosing between coding agents, or when a change to an agent setup needs measured pass rate, cost, and time rather than an impression.

agent-harness-construction

Design and optimize AI agent action spaces, tool definitions, and observation formatting for higher completion rates. Use when defining or revising an agent

agentic-engineering

Operate as an agentic engineer using eval-first execution, decomposition, and cost-aware model routing. Use when planning or executing engineering work that agents will carry out end to end.

agentic-os

Build persistent multi-agent operating systems on Claude Code. Covers kernel architecture, specialist agents, slash commands, file-based memory, scheduled automation, and state management without external databases. Use when building a persistent multi-agent system on Claude Code with its own memory, commands, and scheduling.

agent-payment-x402

Add x402 payment execution to AI agents with per-task budgets, spending controls, and non-custodial wallets. Supports Base through agentwallet-sdk and X Layer through OKX Payments / OKX Agent Payments Protocol. Use when an agent must pay for something itself and needs per-task budgets, spending controls, and a non-custodial wallet.

agent-self-evaluation

Use after completing any non-trivial task. The agent self-rates its output on 5 axes — accuracy, completeness, clarity, actionability, conciseness — with concrete evidence per criterion. Produces a structured 1-5 scorecard with specific improvement suggestions.

関連スキル