Agent skill

langchain-tools

在 LangChain 中定义和使用工具 - 包括工具装饰器、自定义工具、内置工具和工具模式

majiayu000github.com/majiayu000GitHub ↗
claude-codeMIT
Install
npx skills add majiayu000/claude-skill-registry --skill langchain-tools-evanfang0054-cc-system-creator-sc --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 2
SKILL.md size: 10 KB
Bundled scripts: none
Path: skills/ai-llm/langchain-tools-evanfang0054-cc-system-creator-sc/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 534
Language: HTML

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# langchain-tools (JavaScript/TypeScript) ## 概述 工具是代理可以执行的函数,用于执行获取数据、运行代码或查询数据库等操作。工具具有描述其用途和参数的模式,帮助模型理解何时以及如何使用它们。 **核心概念:** - **tool()**:从函数创建工具的装饰器 - **模式**:定义工具参数的 Zod 模式 - **描述**:帮助模型理解何时使用工具 - **内置工具**:用于常见任务的预制工具 ## 何时定义自定义工具 | 场景 | 创建自定义工具? | 原因 | |----------|---------------------|------| | 特定领域的逻辑 | ✅ 是 | 对您的应用来说是独特的 | | 第三方 API 集成 | ✅ 是 | 需要自定义集成 | | 数据库查询 | ✅ 是 | 您的模式/数据 | | 通用工具(搜索、计算) | ⚠️ 可能 | 先检查现有工具 | | 文件操作 | ⚠️ 可能 | 存在内置文件系统工具 | ## 决策表 ### 工具定义方法 | 方法 | 使用时机 | 示例 | |--------|-------------|---------| | `tool()` 配合函数 | 简单工具 | 基本转换 | | `tool()` 配合模式 | 复杂参数 | 多个类型化字段 | | `StructuredTool` | 完全控制 | 自定义错误处理 | | 内置工具 | 常见操作 | 搜索、代码执行 | ## 代码示例 ### 基本工具定义 ```typescript import { tool } from "langchain"; import { z } from "zod"; // 简单工具 const calculator = tool( async ({ operation, a, b }: { operation: string; a: number; b: number }) => { if (operation === "add") return a + b; if (operation === "multiply") return a * b; throw new Error(`未知操作:${operation}`); }, { name: "calculator", description: "执行数学计算。当您需要计算数字时使用此工具。", schema: z.object({ operation: z.enum(["add", "subtract", "multiply", "divide"]).describe("数学运算"), a: z.number().describe("第一个数字"), b: z.number().describe("第

What's inside
Steps it walks through
  1. 概述
  2. 何时定义自定义工具
  3. 决策表
  4. 工具定义方法
  5. 代码示例
  6. 基本工具定义
  7. 带详细模式的工具
  8. 异步工具
  9. 带错误处理的工具
  10. 带副作用的工具
  11. 带外部依赖的工具
  12. 带复杂返回类型的工具
  13. 带运行时配置的工具
  14. 多个相关工具
Ships with 1 file
  • metadata.json
More from claude-skill-registry
All skills →
About this skill
What does the langchain-tools skill do?

在 LangChain 中定义和使用工具 - 包括工具装饰器、自定义工具、内置工具和工具模式

How do I install it?

Run `npx skills add majiayu000/claude-skill-registry --skill langchain-tools-evanfang0054-cc-system-creator-sc --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going