Communitygithub.com

代理自我反思除錯

針對 AI 代理失敗提供結構化的自我除錯工作流程,包含失敗捕獲、診斷、受控恢復及反思報告。當代理執行失敗且需要可重現的診斷而非單純重試時使用。

代理自我反思除錯 是什麼?

此技能建立一個系統化的四階段除錯循環,用於當 AI 代理(如 Claude Code 或 Cursor)陷入反覆失敗、資源消耗或任務偏離時,能進行自我診斷與恢復。其核心在於「先捕獲再診斷,最後才恢復」,避免盲目重試。支援在發生最大工具呼叫限制、上下文溢出、環境狀態不一致等情境時激活。技能提供明確的界限,如與 `verification-loop`、`continuous-learning-v2` 等其他技能的整合方式,以及安全的恢復操作清單。最終輸出包含完整的除錯報告,讓下一個代理或人類能清楚理解失敗原因、恢復行動與當前狀態,從而提升除錯效率與可重現性。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/ECC/tree/main/skills/agent-introspection-debugging

在你喜歡的 AI 中提問

開啟一個已預先載入此 Agent Skill 的新對話。

說明文件

代理自我反思除錯 是做什麼的?

當代理執行反覆失敗、消耗 tokens 卻無進展、在同一個工具上重複循環,或偏離原定任務時,請使用此技能。

這是一個工作流程技能,而非隱藏的運行時機制。它教導代理在升級給人類之前,先系統性地自我除錯。

何時激活

  • 達到最大工具呼叫 / 循環限制失敗
  • 反覆重試但無任何進展
  • 上下文增長或提示偏移導致輸出品質下降
  • 檔案系統或環境狀態與預期不符
  • 工具失敗但可能透過診斷和較小的修正行動復原

範圍界限

此技能用於:

  • 在盲目重試前捕獲失敗狀態
  • 診斷常見的代理特定失敗模式
  • 執行受控的復原行動
  • 產生結構化的人類可讀除錯報告

請勿將此技能作為以下情況的主要來源:

  • 程式碼變更後的功能驗證;請使用 verification-loop
  • 當存在更狹義的 ECC 技能時的特定框架除錯
  • 當前執行環境無法自動強制執行的運行時承諾

四階段循環

階段 1:失敗捕獲

在嘗試恢復之前,先精確記錄失敗資訊。

捕獲內容:

  • 錯誤類型、訊息及堆疊追蹤(如可用)
  • 最後一次有意義的工具呼叫序列
  • 代理當時嘗試要做的事
  • 當前上下文壓力:重複的提示、過大的貼上記錄、重複的計劃或失控的筆記
  • 當前環境假設:cwd、分支、相關服務狀態、預期檔案

最小捕獲範本:

## 失敗捕獲
- Session / 任務:
- 進行中的目標:
- 錯誤:
- 最後成功步驟:
- 最後失敗的工具 / 命令:
- 觀察到的重複模式:
- 需要驗證的環境假設:

階段 2:根本原因診斷

在改變任何事物之前,先將失敗匹配到已知模式。

模式可能原因檢查方式
達到最大工具呼叫 / 重複相同命令循環或無退出觀察者路徑檢查最近 N 次工具呼叫是否有重複
上下文溢出 / 推理品質下降無限制的筆記、重複的計劃、過大的記錄檢查近期上下文是否有重複和低訊號的大量內容
ECONNREFUSED / 超時服務不可用或連接埠錯誤驗證服務健康狀態、URL 和連接埠假設
429 / 配額耗盡重試風暴或缺少退避機制計算重複呼叫次數並檢查重試間隔
寫入後檔案遺失 / 差異過時競爭條件、錯誤的 cwd 或分支偏移重新檢查路徑、cwd、git 狀態和實際檔案是否存在
修正後測試仍然失敗錯誤的假設隔離確切失敗的測試並重新推導錯誤原因

診斷問題:

  • 這是邏輯失敗、狀態失敗、環境失敗還是策略失敗?
  • 代理是否遺失真正目標而開始最佳化錯誤的子任務?
  • 失敗是確定性的還是短暫性的?
  • 能驗證診斷的最小可逆行動是什麼?

階段 3:受控恢復

以改變診斷面貌的最小行動進行恢復。

安全的恢復行動:

  • 停止反覆重試,重新陳述假設
  • 修剪低訊號的上下文,僅保留活躍目標、阻礙因素和證據
  • 重新檢查實際的檔案系統 / 分支 / 進程狀態
  • 將任務縮小到一個失敗的命令、一個檔案或一個測試
  • 從推測性推理切換到直接觀察
  • 當失敗是高風險或受到外部阻礙時,升級給人類

除非你目前在當前環境中透過真實工具實際執行它們,否則不要聲稱不支援的自動修復行動,例如「重設代理狀態」或「更新執行環境設定」。

受控恢復檢查清單:

## 恢復行動
- 選擇的診斷:
- 採用的最小行動:
- 為何這項行動安全:
- 哪些證據可以證明修復有效:

階段 4:反思報告

以一份讓下一個代理或人類能清楚理解的報告結束。

## 代理自我除錯報告
- Session / 任務:
- 失敗:
- 根本原因:
- 恢復行動:
- 結果:成功 | 部分成功 | 受阻
- Token / 時間耗損風險:
- 後續需要處理的事項:
- 日後應編碼的預防性變更:

恢復啟發式規則

請依下列順序選擇干預方式:

  1. 用一句話重新陳述真正的目標。
  2. 驗證世界狀態,而非信任記憶。
  3. 縮小失敗範圍。
  4. 執行一個具辨別力的檢查。
  5. 然後才重試。

不良模式:

  • 以稍微不同的措辭重試相同動作三次

良好模式:

  • 捕獲失敗
  • 分類模式
  • 執行一個直接檢查
  • 僅在檢查支援時才改變計劃

與 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/content-engine

Create platform-native content systems for X, LinkedIn, TikTok, YouTube, newsletters, and repurposed multi-platform campaigns. Use when the user wants social posts, threads, scripts, content calendars, or one source asset adapted cleanly across platforms.

affaan-m/ECC

Multi-platform content distribution across X, LinkedIn, Threads, and Bluesky. Adapts content per platform using content-engine patterns. Never posts identical content cross-platform. Use when the user wants to distribute content across social platforms.

affaan-m/fal-ai-media

Unified media generation via fal.ai MCP — image, video, and audio. Covers text-to-image (Nano Banana), text/image-to-video (Seedance, Kling, Veo 3), text-to-speech (CSM-1B), and video-to-audio (ThinkSound). Use when the user wants to generate images, videos, or audio with AI.

affaan-m/manim-video

日本語翻訳:このファイルは manim-video 用の日本語翻訳が必要です

affaan-m/remotion-video-creation

Remotion のベストプラクティス - React で動画を作成する。3D、アニメーション、音声、字幕、チャート、トランジションなどをカバーするドメイン固有の29のルール。

affaan-m/video-editing

AI-assisted video editing workflows for cutting, structuring, and augmenting real footage. Covers the full pipeline from raw capture through FFmpeg, Remotion, ElevenLabs, fal.ai, and final polish in Descript or CapCut. Use when the user wants to edit video, cut footage, create vlogs, or build video content.

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.

agent-sort

Build an evidence-backed ECC install plan for a specific repo by sorting skills, commands, rules, hooks, and extras into DAILY vs LIBRARY buckets using parallel repo-aware review passes. Use when ECC should be trimmed to what a project actually needs instead of loading the full bundle.

ai-first-engineering

Engineering operating model for teams where AI agents generate a large share of implementation output. Use when setting team process, review gates, or ownership rules for a codebase largely written by agents.

ai-regression-testing

Regression testing strategies for AI-assisted development. Sandbox-mode API testing without database dependencies, automated bug-check workflows, and patterns to catch AI blind spots where the same model writes and reviews code. Use when adding regression coverage to AI-assisted code, or when the same model both wrote and reviewed a change.

android-clean-architecture

Clean Architecture patterns for Android and Kotlin Multiplatform projects — module structure, dependency rules, UseCases, Repositories, and data layer patterns. Use when structuring modules, layers, or data flow in an Android or KMP project.

angular-developer

Generates Angular code and provides architectural guidance. Trigger when creating projects, components, or services, or for best practices on reactivity (signals, linkedSignal, resource), forms, dependency injection, routing, SSR, accessibility (ARIA), animations, styling (component styles, Tailwind CSS), testing, or CLI tooling.

api-connector-builder

Build a new API connector or provider by matching the target repo

相關技能