create-atomic-tool
Skill này làm gì
Skill giải thích cách viết công cụ có đầu vào và đầu ra có kiểu mà agent AI có thể gọi, gồm hỗ trợ async tùy chọn và bí mật lấy từ biến môi trường. Dành cho lập trình viên bổ sung năng lực cho agent của họ.
Khi nào nên dùng
- ✓Khi lập trình viên muốn một agent gọi một API bên ngoài thông qua công cụ có kiểu.
- ✓Khi lập trình viên muốn một công cụ máy tính hoặc tra cứu đơn giản cho agent.
- ✓Khi lập trình viên cần một công cụ báo lỗi rõ ràng, như giới hạn tốc độ hoặc thiếu dữ liệu.
Liên kết skill
https://github.com/Eigenwise/atomic-agents/blob/main/claude-plugin/atomic-agents/skills/create-atomic-tool/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Tạo một công cụ tra cứu thời tiết cho một thành phố và trả về nhiệt độ cùng tình trạng thời tiết.”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
Skill hỏi công cụ làm gì và phụ thuộc vào những gì, rồi viết schema đầu vào và đầu ra, một lớp cấu hình và phương thức run, với bí mật được đọc từ biến môi trường.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Create an Atomic Agents Tool
A tool is a deterministic capability an agent can invoke. In Atomic Agents, every tool is a BaseTool[InSchema, OutSchema] subclass with a typed run() (and optional run_async()). The input/output schemas double as the tool's signature for the LLM and as Pydantic validation at runtime.
For deep material (MCP interop, distributing as a standalone package, advanced error patterns), the authority is ../framework/references/tools.md. This skill is the action-oriented path: clarify → write → verify.
When this fires vs the umbrella framework skill
- This skill: the user is creating a specific tool — wrapping an API, building a calculator, scraping a page, querying a DB.
frameworkskill: questions about Atomic Agents in general, or the user is doing something other than authoring a tool.
Phase 1 — Clarify
Bundle into one message:
- What does the tool do? One sentence. This becomes the class docstring and feeds the LLM's tool description.
- Inputs and outputs. Names, types, units. If unclear, propose a schema pair and confirm.
- External dependencies. HTTP API? DB? Local computation only? If HTTP, what auth (API key env var, OAuth, none)?
- Sync, async, or both? If the rest of the project is async or the call is I/O bound, plan a
run_async()alongsiderun(). - Failure modes. Rate limits, not-found, network errors — how should the agent see them? Default: typed failure output, not raised exceptions.
Skip any question already answered in context.
Phase 2 — Plan
Confirm the location and shape in one short block, then proceed:
- File:
<project>/tools/<tool_name>_tool.py(in-project tool — see../framework/references/project-structure.md). - Schemas:
<ToolName>Input,<ToolName>Output, optionally a typed failure shape. - Config:
<ToolName>Config(BaseToolConfig)if the tool needs API keys, base URLs, timeouts, retries. - Sync vs async: pick one or both.
- Error pattern: typed failure output (preferred) vs raise (only for programmer error).
Phase 3 — Implement
Skeleton — local computation, no config
from pydantic import Field
from atomic_agents import BaseIOSchema, BaseTool
class CalculatorInput(BaseIOSchema):
"""Arithmetic expression to evaluate."""
expression: str = Field(..., description="Python-style arithmetic, e.g. '2 + 2 * 3'.")
class CalculatorOutput(BaseIOSchema):
"""Result of evaluating the expression."""
result: float = Field(..., description="Numeric result.")
class CalculatorTool(BaseTool[CalculatorInput, CalculatorOutput]):
"""Evaluate simple arithmetic expressions safely."""
def run(self, params: CalculatorInput) -> CalculatorOutput:
import ast, operator as op
ops = {ast.Add: op.add, ast.Sub: op.sub, ast.Mult: op.mul, ast.Div: op.truediv}
def ev(n):
if isinstance(n, ast.Constant): return n.value
if isinstance(n, ast.BinOp): return ops[type(n.op)](ev(n.left), ev(n.right))
raise ValueError("unsupported")
return CalculatorOutput(result=ev(ast.parse(params.expression, mode="eval").body))
Skeleton — HTTP-backed, with config and typed failure
import os
import httpx
from typing import Literal, Optional
from pydantic import Field
from atomic_agents import BaseIOSchema, BaseTool, BaseToolConfig
class WeatherConfig(BaseToolConfig):
api_key: str = Field(
default_factory=lambda: os.environ.get("WEATHER_API_KEY", ""),
description="API key for the weather service.",
)
base_url: str = Field(
default="https://api.weather.example/v1",
description="Base URL for the weather API.",
)
timeout: float = Field(default=15.0, ge=1.0, le=120.0, description="Request timeout (s).")
class WeatherInput(BaseIOSchema):
"""A request for current weather conditions."""
city: str = Field(..., description="City name, e.g. 'Brussels'.")
class WeatherOutput(BaseIOSchema):
"""Current weather conditions, or a typed failure."""
status: Literal["ok", "error"] = Field(..., description="Outcome code.")
temperature_c: Optional[float] = Field(default=None, description="Temperature in Celsius.")
summary: Optional[str] = Field(default=None, description="Human-readable summary.")
error: Optional[str] = Field(default=None, description="Failure message when status='error'.")
class WeatherTool(BaseTool[WeatherInput, WeatherOutput]):
"""
Câu hỏi thường gặp
API key để ở đâu?
Skill nói bí mật được đọc từ biến môi trường, không được viết thẳng vào mã.
Có cần hỗ trợ async không?
Chỉ khi dự án là async hoặc lệnh gọi phải chờ I/O. Skill có thể thêm phiên bản async.
Lỗi được trả về thế nào?
Skill mô tả các đầu ra thất bại có kiểu để agent nhận kết quả rõ ràng khi có lỗi.
Chi tiết
Mô tả gốc của tác giả
Build a `BaseTool[InSchema, OutSchema]` subclass — input/output schemas, `BaseToolConfig`, `run()` (and optional `run_async()`), env-driven secrets, typed failure outputs. Use when the user asks to "add a tool", "create a tool", "wrap an API as a tool", "build a `BaseTool`", "make a calculator/search/weather tool", or runs `/atomic-agents:create-atomic-tool`.
repo: Eigenwise/atomic-agents
Độ phổ biến
- Sao GitHub
- 6.3k
- Vị trí xếp hạng
- #14240
- Giấy phép
- MIT
- Cập nhật
- 29/10/2026
Bình luận
- …
Thêm skill từ kho mã này
create-atomic-agent
6.3kGiúp agent của bạn xây dựng một Atomic Agents agent mới với đầu vào và đầu ra có kiểu, system prompt và nhà cung cấp AI đã chọn.
create-atomic-context-provider
6.3kGiúp agent của bạn thêm một context provider vào Atomic Agents agent, để các thông tin mới như thời gian hoặc tài liệu truy xuất xuất hiện trong prompt.
create-atomic-schema
6.3kGiúp agent của bạn thiết kế schema đầu vào và đầu ra có kiểu cho Atomic Agents agent và công cụ, với mô tả trường rõ ràng.
framework
6.3kGiúp agent của bạn làm việc đúng với framework Python Atomic Agents, gồm schema, agent, công cụ, prompt và thiết lập nhà cung cấp.
Skill tương tự
api-connector-builder
280kGiúp agent của bạn xây dựng kết nối API mới theo đúng mẫu đã có, dùng khi bạn cần thêm một tích hợp mà không tạo cách làm mới.
api-design
280kGiúp agent của bạn thiết kế REST API theo các thực hành tốt nhất, hữu ích để định nghĩa cách API giao tiếp, hiển thị lỗi và tổ chức dữ liệu.
backend-patterns
280kGiúp agent của bạn với các mẫu kiến trúc phía máy chủ và tối ưu cơ sở dữ liệu, hữu ích khi xây dựng hoặc rà soát code chạy trên máy chủ.