create-atomic-tool
ما الذي تفعله
تشرح المهارة كيفية كتابة أداة ذات مدخلات ومخرجات محددة الأنواع يستطيع وكيل الذكاء الاصطناعي استدعاءها، مع دعم اختياري للعمليات غير المتزامنة وأسرار من متغيرات البيئة. وهي موجهة للمطوّرين الذين يضيفون قدرات إلى وكلائهم.
متى تستخدمها
- ✓عندما يريد المطوّر أن يستدعي الوكيل واجهة برمجية خارجية عبر أداة محددة الأنواع.
- ✓عندما يريد المطوّر آلة حاسبة بسيطة أو أداة بحث للوكيل.
- ✓عندما يحتاج المطوّر إلى أن تُبلغ الأداة بأخطاء واضحة مثل حدود الاستخدام أو غياب البيانات.
رابط المهارة
https://github.com/Eigenwise/atomic-agents/blob/main/claude-plugin/atomic-agents/skills/create-atomic-tool/SKILL.mdانسخه والصقه في الذكاء الاصطناعي الذي تستخدمه (Claude أو ChatGPT أو Cursor) واطلب منه اتباع التعليمات.
طريقة الاستخدام
أسهل طريقة: انسخ الرسالة والصقها في الذكاء الاصطناعي الذي تستخدمه. سيقرأ المهارة وينفّذ تعليماتها.
رسالة جاهزة للصق
لـ Claude Code أو Codex أو Cursor: شغّله داخل مجلد مشروعك وستُثبَّت المهارة.
نزّل ملف SKILL.md وضعه في مجلد مهارات وكيلك.
مثال على ما تطلبه من الذكاء الاصطناعي
“أنشئ أداة تبحث عن حالة الطقس في مدينة وتعيد درجة الحرارة والأحوال الجوية.”
5 مهارات جديدة كل أسبوع. قراءة في دقيقة واحدة.
كيف تعمل
تسأل المهارة عما تفعله الأداة وعلى ماذا تعتمد، ثم تكتب مخططات المدخلات والمخرجات وصنف الإعداد ودالة التشغيل، مع قراءة الأسرار من متغيرات البيئة.
المحتوى التقني (ملف SKILL.md الأصلي)
النص الأصلي من المؤلف، مباشرة من GitHub.
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]):
"""
الأسئلة الشائعة
أين توضع مفاتيح API؟
تقول المهارة إن الأسرار تُقرأ من متغيرات البيئة، ولا تُكتب داخل الكود.
هل تحتاج إلى دعم غير متزامن؟
فقط إذا كان المشروع غير متزامن أو كان الاستدعاء ينتظر عمليات إدخال وإخراج. يمكن للمهارة إضافة نسخة غير متزامنة.
كيف تُعاد الأخطاء؟
تصف المهارة مخرجات فشل محددة النوع حتى يحصل الوكيل على نتيجة واضحة عند الأخطاء.
التفاصيل
الوصف الأصلي من المؤلف
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
الشعبية
- نجوم GitHub
- 6.3k
- الترتيب
- #14240
- الترخيص
- MIT
- آخر تحديث
- 29/10/2026
التعليقات
- …
المزيد من المهارات من هذا المستودع
create-atomic-agent
6.3kيساعد وكيلك على بناء وكيل جديد في Atomic Agents بمدخلات ومخرجات مُحددة الأنواع، وموجّه نظام، ومزوّد ذكاء اصطناعي مختار.
create-atomic-context-provider
6.3kيساعد وكيلك على إضافة مزوّد سياق إلى وكيل Atomic Agents، حتى تظهر تفاصيل حديثة مثل الوقت أو المستندات المسترجعة في موجّهه.
create-atomic-schema
6.3kيساعد وكيلك على تصميم مخططات مدخلات ومخرجات مُحددة الأنواع لوكلاء وأدوات Atomic Agents، مع أوصاف واضحة للحقول.
framework
6.3kيساعد وكيلك على العمل بشكل صحيح مع إطار Atomic Agents لبايثون، ويغطي المخططات والوكلاء والأدوات والموجهات وإعداد المزوّد.
مهارات مشابهة
api-connector-builder
280kيبني وكيلك اتصالات API جديدة على النمط الموجود، ويفيد عندما تحتاج إلى تكامل إضافي دون ابتكار طريقة جديدة للعمل.
api-design
280kيساعد وكيلك على تصميم واجهات REST API وفق أفضل الممارسات، ويوضح كيف تتواصل وكيف تُعرض الأخطاء وكيف تُنظَّم البيانات.
backend-patterns
280kيساعد وكيلك على أنماط بنية الخادم وتحسين قاعدة البيانات، ويفيد في بناء الشيفرة التي تعمل على الخادم أو مراجعتها.