Communitygithub.com

YepAPI/技能

工具使用模式、多步推理、智能体编排与结构化输出。

技能 是什么?

该技能为AI智能体(如Claude Code、Cursor、Codex等)提供了一套完整的工具使用、多步推理与智能体编排的最佳实践。它定义了类型安全工具的定义规范(名称、描述、参数模式与异步执行函数),并描述了经典的多步循环流程:发送消息→模型选择工具→执行工具→反馈结果→重复直到完成。技能强调了`maxSteps`限制以防止无限循环、使用Zod进行结构化输出保证、通过重试逻辑与指数退避处理瞬态故障,以及将复杂任务分解为具有聚焦工具集的子智能体进行协调编排。最后,它列出了常见陷阱,如授予不受限制的工具访问权限、缺少`maxSteps`、信任未经验证的输出以及构建臃肿的单体智能体,引导开发者构建更稳健、更高效的AI代理系统。

兼容平台~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.

相关技能