Communitygithub.com

代理程式框架構建

設計並優化 AI 代理的行動空間、工具定義及觀察格式化,以提高任務完成率。適用於定義或修改代理程式時使用。

代理程式框架構建 是什麼?

此技能專注於提升 AI 代理在規劃、呼叫工具、錯誤恢復及任務收斂方面的整體品質。它提供了一個核心模型,強調行動空間品質、觀察品質、恢復品質及上下文預算品質對代理輸出結果的影響。使用者可以學習如何設計穩定且明確的行動空間,並根據操作風險選擇合適的工具粒度(微觀、中觀、巨觀),從而最佳化工具呼叫效率。此外,該技能詳細說明了觀察設計的原則,要求每個工具回應都包含狀態、摘要、下一步動作和產出物,以利於後續的決策與除錯。最後,它涵蓋了錯誤恢復合約、上下文預算管理、架構模式選擇(如 ReAct、Function-calling 或混合模式)以及關鍵效能指標的基準測試,同時列出常見的反模式以供避免。此技能支援多種 AI 代理平台,包括但不限於 Claude Code、Cursor 和 Codex。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/affaan-m/everything-claude-code/tree/main/skills/agent-harness-construction

在你喜歡的 AI 中提問

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

說明文件

代理程式框架構建 是做什麼的?

當您正在改善代理的規劃、工具呼叫、錯誤恢復及任務收斂時,請使用此技能。

核心模型

代理輸出品質受到以下因素限制:

  1. 行動空間品質
  2. 觀察品質
  3. 恢復品質
  4. 上下文預算品質

行動空間設計

  1. 使用穩定且明確的工具名稱。
  2. 保持輸入以結構定義優先,且範圍狹窄。
  3. 回傳確定性的輸出形狀。
  4. 除非無法隔離,否則避免使用萬用工具。

粒化規則

  • 對於高風險操作(部署、遷移、權限),使用微觀工具。
  • 對於常見的編輯/讀取/搜尋迴圈,使用中觀工具。
  • 僅在往返開銷為主要成本時,使用巨觀工具。

觀察設計

每個工具回應都應包含:

  • status: success|warning|error
  • summary: 一行摘要
  • next_actions: 可操作的後續步驟
  • artifacts: 檔案路徑 / ID

錯誤恢復合約

針對每個錯誤路徑,包含:

  • 根本原因提示
  • 安全重試指令
  • 明確停止條件

上下文預算管理

  1. 保持系統提示簡潔且不變。
  2. 將大量指導內容移至按需載入的技能中。
  3. 偏好引用檔案,而非內嵌長文件。
  4. 在階段邊界進行壓縮,而非依據任意 token 門檻。

架構模式指引

  • ReAct:最適合路徑不確定的探索性任務。
  • Function-calling:最適合結構化的確定性流程。
  • 混合模式(推薦):ReAct 規劃 + 型別化工具執行。

基準測試

追蹤:

  • 完成率
  • 每任務重試次數
  • pass@1 和 pass@3
  • 每成功任務成本

反模式

  • 過多語意重疊的工具。
  • 不透明的工具輸出,無恢復提示。
  • 僅輸出錯誤而無下一步驟。
  • 使用不相關的參考資訊造成上下文負載過重。

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.

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-introspection-debugging

Structured self-debugging workflow for AI agent failures using capture, diagnosis, contained recovery, and introspection reports. Use when an agent run fails and you need a reproducible diagnosis instead of a retry.

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.

相關技能