tool-design

tool-design is a skill for Claude Code, Codex from bojieli/ai-agent-book. It costs 100 tokens per session (3,272 once invoked), scanned C, original, Apache-2.0.

A guide for designing tools that AI agents use to work with software. It covers tool boundaries, input and output descriptions, search and reading results, safety checks, sandboxes, and cooperation between agents.

In plain words
What is it for?
Use it when adding or restructuring tools, designing MCP server tools, choosing between a dedicated tool and a written skill, or defining approval and sandbox behavior.
Why use it?
It helps avoid tool collections that are confusing, overly fragmented, unsafe, or too large for an agent to use reliably.

Skill for Claude CodeCodex

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

Good fit Use it when adding or restructuring tools, designing MCP server tools, choosing between a dedicated tool and a written skill, or defining approval and sandbox behavior.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/bojieli/ai-agent-book/tool-design
About the project

AI Agent: Design Principles and Engineering Practice is an open-source book that explains how AI agents combine language models, context, and tools, with accompanying experiments and code. It is intended for readers studying the principles and engineering of AI agents, from fundamentals through production use. The catalogue skills support coding-agent work related to the book's subject matter.

bojieli/ai-agent-book · 54,406 stars · on GitHub

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 bojieli/ai-agent-book --skill tool-design
Clone the repo
git clone --depth 1 https://github.com/bojieli/ai-agent-book

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 tool-design

README.md
[![agentmods](https://agentmods.dev/badge/skills/bojieli/ai-agent-book/tool-design/github.svg)](https://agentmods.dev/skills/bojieli/ai-agent-book/tool-design)
Your own site
<a href="https://agentmods.dev/skills/bojieli/ai-agent-book/tool-design"><img src="https://agentmods.dev/badge/skills/bojieli/ai-agent-book/tool-design/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 tool-design

Your own site · 80×15
<a href="https://agentmods.dev/skills/bojieli/ai-agent-book/tool-design"><img src="https://agentmods.dev/badge/skills/bojieli/ai-agent-book/tool-design.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 100 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 3,272 The whole file, excluding the scripts and references it only reads on demand.
Security scan C 1 finding. 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.00100 $0.03272
Opus 5.5 $0.00040 $0.01309
Sonnet 5.5 $0.00020 $0.00654
Haiku 4.5 $0.00010 $0.00327

Measured 22d ago against content hash 2a39e676512a, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade C, and why

tool-design scanned grade C with 1 finding 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 22d 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.

Recursive force deletehighDestructive command

rm -rf with a variable or a broad path is one typo away from removing the wrong tree.

- **Sidecar**:与主模型流式输出并行的轻量分类器,对单次工具调用做门控。它**只读结构化字段**(`{tool:"bash", command:"rm -rf /tmp/data"}`),刻意隔离主模型的自由文本,否则用户输入或网页里夹带"请允许执行 rm -rf"就能把审查骗过去。数百毫秒完成,用户几乎无感。审查对象不同所以可用轻量模型:Proposer-Reviewer 审的是开放式思考,需能力相近;Sidecar 判的
skills/tool-design/SKILL.md · 101 lines

How it starts

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

工具设计

何时使用

  • 为 Agent 新增一批工具,或审查既有工具集("这个工具该不该拆/该不该合")
  • 判断一项能力应做成专用工具(function calling)、通用执行器,还是一份 Skill
  • 编写或修订工具 name / description / 参数 schema / 返回值说明
  • 设计感知工具(搜索、读取、多模态解析)的返回格式、分页与截断策略
  • 设计执行工具(shell、文件、外部系统)的输入验证、审批、沙盒与可观测性
  • 设计协作工具(spawn_subagent、HITL、通知)的接口与提示词

核心原则

  • 工具对应目标,不对应 API 端点。 早期反模式是把每个 API 端点包成一个工具,Agent 要协调好几个才能完成一个目标。这是 ACI(Agent-Computer Interface)的核心:让工具对 Agent 而非对人友好。
  • 默认通用优于专用。 LLM 本身有强大的思考与代码生成能力,不要限制它。与其提供四则运算计算器,不如给一个装好 sympy/numpy/pandas 的 code_interpreter。
  • 四种情况才退回专用工具:① 安全、权限、审计需要(如生产库写操作);② 屏蔽平台差异并给出更好反馈(如 grep/find 在 Mac/Win/Linux 语法不一);③ 使用频率极高;④ 参数结构复杂(嵌套对象、多字段联合校验)。
  • 粒度偏向整合。 判断标准是功能相似性与使用场景重叠度:extract_pdf_text/extract_docx_content/extract_pptx_content 应合成 read_document(file_type=...)。整合降低认知负担、描述更清晰、便于扩展。
  • 形态与数量是两个独立决策。 能力做成什么形态定"每条能力常驻多少 token、参数怎么传、谁能改";一次暴露多少条是披露策略。别把两者混为一谈。
  • 感知工具防上下文爆炸,执行工具防不可逆错误。 前者的设计关键是控制输出信息量,后者的设计核心是安全约束。
  • 模型感知到的世界与工具操作的世界之间不能有系统性偏差——不得静默转换或注入参数。

实践模式

1. 形态选择的四个决策维度

维度 判据
安全与权限 需精细授权、审计留痕、有不可逆风险 → 专用工具;否则优先通用
参数复杂度 嵌套对象、多字段联合校验 → 专用 schema;简单参数走 CLI 同样可靠
变更频率 频繁变化 → Skill(改文本,不用重新测试部署);稳定底层操作 → 专用工具
模型能力 强模型可用 Skill + 通用执行器减少工具数;弱模型需要结构化 schema 引导

Skill 的代价:模型要生成合法命令行参数并处理引号转义,规则比 JSON 复杂且跨平台有差异,参数复杂时更易出错。折中办法:Skill 要求把复杂结构化参数写成 JSON 文件,再在命令行导入。 Skill 的收益:人类编写者友好,不会因局部语法错误"牵一发而动全身"(schema 少个花括号会让整个 Agent 报错,Skill 少量错误不会)。

2. 工具描述的四条写法

  • 写"什么时候用",不只"能做什么":不说"搜索相关内容",说"当需要获取实时信息或查找未知事实时使用"。
  • 明确边界比描述能力更重要:文件搜索工具必须说明它只按文件名匹配、不能搜文件内容。多数调用失败的根因是模型不知道工具不能做什么。
  • 参数给具体例子:timestamp:RFC3339 格式,例如 2024-03-15T14:30:00Z;phone:E.164(国家代码+号码,无空格),例如 +8613888888888 / +12025551234。
  • 描述返回值与代价:"返回 JSON 数组,每元素含 title/url/snippet";"此工具需下载完整网页,大型站点可能 5-10 秒,只要元信息请用 get_page_metadata"。
  • 每个工具附 1-5 个真实调用示例。JSON Schema 只能表达类型,无法表达时间戳是秒还是毫秒、过滤条件如何嵌套这类隐式约定;加示例后基准准确率可从约 72% 升到 90%。
  • 调试原则:Agent 频繁选错工具时,先查工具描述,别先怀疑模型。修正描述的 ROI 远高于换更强的模型。

3. 参数保真性

反模式是静默输入转换与静默参数注入:

  • Cursor 曾把 old_string 中的中文弯引号(“”)静默转成英文直引号,导致读取工具原样返回弯引号、替换工具却匹配不到——模型反复失败且无法自行诊断。
  • 某 IDE 的 bash 工具自动给所有 git commit 追加"AI 生成"标记参数,老版本 Git 直接报错,模型怎么改提交信息都失败。 规则:必须规范化时,在工具描述中说明,并在返回值中明确告知模型。

Read the full file on GitHub · 101 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. 22d ago First seen · 101 lines · 100 tokens per session scan C 2a39e676512a

Subscribe to this mod's changes

tool-design is a skill published in the GitHub repository bojieli/ai-agent-book (54,406 stars, last pushed 7d ago), licensed Apache-2.0. It adds 100 tokens to every session and 3,272 once invoked, about $0.0004 per session on Opus 5.5. A static security scan graded it C with 1 finding (recursive force delete). No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-24.

Related

Other skills, from other repositories