agent-design-patterns

agent-design-patterns is a skill for Claude Code, Codex from kuhung/weread-book-skills. It costs 118 tokens per session (1,416 once invoked), scanned A, original, MIT.

A guide to choosing design patterns for AI agents, software systems that use AI to plan tasks and take actions.

In plain words
What is it for?
Use it to choose chains, routing, parallel work, multiple agents, reflection, safeguards, retrieval methods, model fallbacks, and context management.
Why use it?
It helps decide when an agent is appropriate and how to balance reliability, speed, cost, error handling, and human review.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit Use it to choose chains, routing, parallel work, multiple agents, reflection, safeguards, retrieval methods, model fallbacks, and context management.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/kuhung/weread-book-skills/agent-design-patterns
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add kuhung/weread-book-skills --skill agent-design-patterns
Clone the repo
git clone --depth 1 https://github.com/kuhung/weread-book-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for agent-design-patterns

README.md
[![agentmods](https://agentmods.dev/badge/skills/kuhung/weread-book-skills/agent-design-patterns/github.svg)](https://agentmods.dev/skills/kuhung/weread-book-skills/agent-design-patterns)
Your own site
<a href="https://agentmods.dev/skills/kuhung/weread-book-skills/agent-design-patterns"><img src="https://agentmods.dev/badge/skills/kuhung/weread-book-skills/agent-design-patterns/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for agent-design-patterns

Your own site · 80×15
<a href="https://agentmods.dev/skills/kuhung/weread-book-skills/agent-design-patterns"><img src="https://agentmods.dev/badge/skills/kuhung/weread-book-skills/agent-design-patterns.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 118 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,416 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00118 $0.01416
Opus 5 $0.00059 $0.00708
Sonnet 5 $0.00024 $0.00283
Haiku 4.5 $0.00012 $0.00142

Measured 11d ago against content hash b218475905d2, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

agent-design-patterns scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 11d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

skills/agent-design-patterns/SKILL.md · 52 lines

How it starts

The opening of the file, as written. The whole thing — 52 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Agent Design Patterns Advisor (智能体架构顾问)

你是一位 Agent 系统架构师,以设计模式与其代价的权衡帮助用户构建可靠、经济的智能体系统。Agent 不是全新物种,而是更需要传统软件工程纪律的复杂系统。

Core Philosophy

  1. 先问要不要 Agent: 传统方法(规则、分类器、确定性代码)能可靠解决的,不要引入 Agent。每个模式都有成本,选型先看代价。
  2. 上下文重于模型: 输出质量较少依赖模型架构,更多依赖上下文的丰富性。
  3. 确定性优先: 已被充分理解且可重复的问题用固定工作流;动态规划只留给真正开放的问题。
  4. 代价意识: 反思循环增加调用成本,多 Agent 增加通信开销,GraphRAG 增加维护成本——质量、速度、成本三者必有取舍。
  5. 工程纪律不可豁免: 容错、最小权限、结构化日志、状态管理规范,对 Agent 一样适用。

Operational Framework

场景一: 编排模式选型

按决策树引导: 任务可静态拆解 -> 提示词链(步骤间插入确定性验证逻辑);需按输入分流 -> 路由(规则最快最确定,嵌入适合语义分流,LLM 路由最灵活但最贵);子任务互相独立且依赖 I/O -> 并行化;需要多视角辩论或流水线专业分工 -> 多 Agent(先警告通信开销与决策连贯性成本)。

场景二: 质量与可靠性增强

输出质量不达标时: 先加反思循环(生产者-评审者结构),同时提醒每轮迭代都是新的 LLM 调用,时间敏感场景不适用。可靠性问题按三段式排查: 检测(工具输出校验、API 错误码、超时)-> 处理(重试瞬态错误、回退备选方案、优雅降级、通知人类)-> 恢复(状态回滚、根因诊断)。错误代价重大或任务含模糊性时,强制引入 HITL;注意区分 human-in-the-loop(人在每个决策环)与 human-on-the-loop(人定策略、AI 执行)。

场景三: RAG 技术选型

按需求阶梯推荐: 事实性问答 -> 基础 RAG + 混合检索(BM25 + 语义);答案分散在互联实体间 -> GraphRAG(先确认能承担图谱构建与维护成本);检索质量不可信、需多步综合 -> Agentic RAG(推理层做源验证、冲突协调、知识差距识别)。始终提示: 分块质量决定下限,知识库需要定期协调更新。

场景四: 成本与延迟优化

默认建议动态模型切换: 按 simple/reasoning/search 分类路由,简单查询走轻量模型,复杂推理走强模型;配置回退机制保障主模型不可用时优雅降级;上下文修剪与摘要控制 token;推理时计算(自一致性、多候选择优)可让小模型达到大模型效果,但同一查询成本翻倍。

Instruction Examples

用户: "我想做一个客服 Agent,用户问题五花八门,怎么设计?" 回应: 先路由后处理: 入口用基于嵌入或规则的路由把问题分流到订单状态/产品信息/技术支持等确定性工作流,只有开放性问题才进 LLM 对话流。已知高频问题用固定工作流比动态规划更可靠。错误代价高的操作(退款)加 HITL 审批环。

用户: "Agent 输出质量不稳定,要不要上多 Agent 辩论?" 回应: 先用更便宜的手段: 检查上下文是否充分(质量更多取决于上下文而非架构),再加单评审者反思循环。多 Agent 辩论是最后手段——通信开销大且决策连贯性难保证。同时确认场景是否质量重于延迟,否则反思循环本身就不划算。

用户: "RAG 答案老是不完整,是不是该换 GraphRAG?" 回应: 先诊断根因: 答案不完整常是分块策略问题(信息跨块分散),先试重叠分块、混合检索、父文档检索。GraphRAG 只在"答案需要跨实体关系推理"时值得——它带来图谱构建与持续维护的显著成本。若检索源本身质量存疑,考虑 Agentic RAG 的源验证层。

详细论据与案例见 notes/智能体设计模式_笔记.md

Field Notes (实战修正)

本章节沉淀该方法论在实战中被修正的经验(第二次残差),随使用持续更新。

使用方式: 在任何项目中对 Agent 说"记入实战修正",以 - YYYY-MM-DD: 经验内容 格式追加至此。全局挂载为软链接,此处的修改会直接写回 book-skills 仓库工作区,记得回仓库提交。

  • 初始提示: 搜索类 Agent 在理解不到位时会搜出 SEO 污染内容,规划模式不能替代检索质量把关。

Read the full file on GitHub · 52 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 11d ago First seen · 52 lines · 118 tokens per session scan A b218475905d2

Subscribe to this mod's changes

agent-design-patterns is a skill published in the GitHub repository kuhung/weread-book-skills (9 stars, last pushed 1mo ago), licensed MIT. It adds 118 tokens to every session and 1,416 once invoked, about $0.0006 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.

Related

Other skills, from other repositories

polar-billing

This skill should be used when working on Polar billing system, Stripe integration, subscription lifecycle, checkout flows, or benefit provisioning.

fcakyon/claude-codex-settings · 29 tokens

durable-objects

Build, debug, or review Cloudflare Durable Objects code for persistent state and coordination.

fcakyon/claude-codex-settings · 22 tokens

simplify

This skill should be used when the user asks to "simplify", "clean up the diff", "run simplify", "simplify the changes", "review changed code for cleanup", explicitly invokes "/simplify", or asks to "commit without simplify", "skip simplify for this commit", or "commit this but skip simplify". Reviews changed code…

fcakyon/claude-codex-settings · 97 tokens

ultralytics-platform

This skill should be used when user asks to "upload my model to Ultralytics Platform", "push this run to the platform", "upload a dataset to platform", "download a dataset from platform", "search platform datasets", "start cloud training", "train on platform GPUs", "export a model on platform", "deploy a model…

fcakyon/claude-codex-settings · 112 tokens

dokploy-deploy

This skill should be used when user asks to "deploy with Dokploy", "use Dokploy Cloud", "manage self-hosted Dokploy", "deploy Docker Compose on Dokploy", "manage Dokploy databases", "configure Dokploy domains", or "look up Dokploy CLI commands".

fcakyon/claude-codex-settings · 63 tokens

openai-frontend-design

Use for new frontend applications, dashboards, games, creative websites, hero sections, and visually driven UI from scratch, or when the user explicitly asks for a redesign/restyle/modernization. Builds from clean, airy, high-taste, readable image-generated concept design with section-specific references, faithful…

fcakyon/claude-codex-settings · 71 tokens