Communitygithub.com

YepAPI/skills

工具使用模式、多步驟推理、代理編排與結構化輸出。

skills 是什麼?

此技能定義了一套建構 AI 代理的嚴謹模式,專注於工具使用、多步驟推理與結構化輸出。它提供清晰的規則,例如將工具定義為附有描述的型別化函數,並透過 Zod 強制執行結構化輸出(`generateObject`),確保模型回傳的資料形狀符合預期。此外,它詳細說明了代理迴圈的實作方式:發送訊息 → 模型回應工具呼叫 → 執行工具 → 將結果回饋給模型,並重複此流程,直到任務完成,同時透過 `maxSteps` 參數防止無限迴圈。對於進階場景,技能提倡代理編排,將複雜任務拆分為專注於特定工具集的子代理,並由協調代理負責委派工作,避免單一代理擁有過多工具導致維護困難。它還強調了容錯機制,如對暫時性失敗進行指數退避重試,以及在使用工具結果前務必進行驗證與清理。支援的平臺包括 Vercel AI SDK 等基於模型與工具的開發框架。

相容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/YepAPI/skills/tree/HEAD/skills/ai-agents

在你喜歡的 AI 中提問

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

說明文件

AI 代理

規則

  • 將工具定義為附有描述的型別化函數 — 模型會自行選擇要呼叫哪個工具
  • 工具結構:{ name, description, parameters: zodSchema, execute: async (args) => result }
  • 多步驟迴圈:發送訊息 → 模型回傳工具呼叫 → 執行工具 → 將結果回饋 → 重複直到完成
  • 使用 maxSteps 限制以防止無限迴圈 — 根據複雜度,預設為 5-10 步
  • 使用 Zod 進行結構化輸出:generateObject({ schema: z.object({...}) }) 保證資料形狀
  • 重試邏輯:將工具執行包裝在 try/catch 中,對暫時性失敗進行 2-3 次重試,並使用指數退避
  • 代理編排:將複雜任務拆分為具有專注工具集的子代理,由協調代理負責委派
  • 在將工具結果回饋給模型前,務必進行驗證 — 清理不可信的資料
  • 使用 streamText 搭配 onToolCall 以即時觀察代理的推理過程

模式

// 工具定義
const tools = {
  searchDatabase: tool({
    description: "搜尋產品資料庫",
    parameters: z.object({ query: z.string(), limit: z.number().default(10) }),
    execute: async ({ query, limit }) => db.products.search(query, limit),
  }),
};

// 代理迴圈
const result = await generateText({
  model,
  tools,
  maxSteps: 10,
  messages,
});

避免事項

  • 給予代理無限制的工具存取權限 — 應將工具範圍限定在任務範圍內
  • 遺漏 maxSteps — 代理可能會無限迴圈
  • 未經驗證就信任工具輸出 — 在根據結果採取行動前務必檢查
  • 使用單一龐大代理 — 寧可使用專注的子代理,也不要一個代理擁有 20 個以上的工具

Individual skills in this repo

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

YepAPI/skills

WCAG 2.1 AA — semantic HTML, keyboard navigation, screen readers.

YepAPI/skills

Experiment setup, variant splitting, statistical significance, and feature flag integration.

YepAPI/skills

CRUD generators, data tables, user management, role-based access, and bulk operations.

YepAPI/skills

Monitor what ChatGPT and Gemini say about your brand using YepAPI.

YepAPI/skills

Queue workers with BullMQ/Inngest/Trigger.dev, job retries, dead letter queues, concurrency.

YepAPI/skills

Commander.js, interactive prompts with Clack, spinners, colors, config files, exit codes, and npm publishing.

YepAPI/skills

cmdk integration, Cmd+K trigger, fuzzy search, grouped actions, keyboard navigation, and dynamic action registration.

YepAPI/skills

Content planning with trend and sentiment data from YepAPI.

YepAPI/skills

Content calendar, keyword-driven planning, and content briefs.

YepAPI/skills

Theme switching with CSS variables, system preference detection, next-themes, and persistence.

YepAPI/skills

Threaded comments, @mentions, reactions, moderation queue, optimistic UI, and cursor pagination.

YepAPI/skills

Competitive analysis between domains using YepAPI.

YepAPI/skills

Layout grids, KPI cards, data tables with sorting/filtering, sidebar navigation, and responsive breakpoints.

YepAPI/skills

Data encryption — TLS everywhere, AES-256-GCM for PII, bcrypt passwords, encrypted backups.

YepAPI/skills

Chart patterns with Recharts/Nivo/D3, responsive containers, color scales, and accessibility.

YepAPI/skills

Drizzle schema definition, push vs migrate, type-safe queries, relations, transactions, and prepared statements.

YepAPI/skills

Upload handling, resize/compress, CDN delivery, blur placeholders, and next/image patterns.

YepAPI/skills

Local business and Google Maps research using YepAPI.

YepAPI/skills

Cursor-based pagination, IntersectionObserver, virtualized lists with @tanstack/react-virtual, and scroll position restoration.

YepAPI/skills

Chat UI components, streaming responses with AI SDK, context window management, and RAG patterns.

相關技能