Saltar al contenido
Skillpedia
APIs y servidores (backend)6,3 mil · #14240

create-atomic-tool

Qué hace

Explica cómo escribir una herramienta con entradas y salidas tipadas que un agente de IA puede invocar, incluido el soporte asíncrono opcional y los secretos tomados de variables de entorno. Va dirigida a desarrolladores que añaden capacidades a sus agentes.

Cuándo usarla

  • ✓Cuando un desarrollador quiere que un agente llame a una API externa mediante una herramienta tipada.
  • ✓Cuando un desarrollador quiere una calculadora o una herramienta de consulta sencilla para un agente.
  • ✓Cuando un desarrollador necesita que una herramienta informe errores claros, como límites de uso o datos que faltan.

Link de la skill

https://github.com/Eigenwise/atomic-agents/blob/main/claude-plugin/atomic-agents/skills/create-atomic-tool/SKILL.md

Cópialo y pégalo en tu IA (Claude, ChatGPT o Cursor) pidiéndole que siga las instrucciones.

Cómo usar

La forma más fácil: copia el mensaje y pégalo en tu IA. Ella lee la skill y sigue las instrucciones.

Mensaje listo para pegar

Usa esta skill para ayudarme: https://github.com/Eigenwise/atomic-agents/blob/main/claude-plugin/atomic-agents/skills/create-atomic-tool/SKILL.md Lee el archivo SKILL.md de ese link y sigue sus instrucciones en mi tarea.
¿Quieres que tu IA encuentre skills como esta por sí sola?Instala el MCP gratis de Skillpedia: una línea, y busca entre 15.000+ skills antes de cada tarea.Instalar en 1 minuto →

Ejemplo de qué pedirle a la IA

“Crea una herramienta que busque el tiempo de una ciudad y devuelva la temperatura y las condiciones.”

5 skills nuevas por semana. 1 minuto de lectura.

Cómo funciona

La skill pregunta qué hace la herramienta y de qué depende, y luego escribe los esquemas de entrada y salida, una clase de configuración y el método de ejecución, con los secretos leídos desde variables de entorno.

Contenido técnico (SKILL.md original)

Texto original del autor, en inglés, directo de 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.
  • framework skill: questions about Atomic Agents in general, or the user is doing something other than authoring a tool.

Phase 1 — Clarify

Bundle into one message:

  1. What does the tool do? One sentence. This becomes the class docstring and feeds the LLM's tool description.
  2. Inputs and outputs. Names, types, units. If unclear, propose a schema pair and confirm.
  3. External dependencies. HTTP API? DB? Local computation only? If HTTP, what auth (API key env var, OAuth, none)?
  4. Sync, async, or both? If the rest of the project is async or the call is I/O bound, plan a run_async() alongside run().
  5. 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]):
    """
Preguntas frecuentes

¿Dónde van las claves de API?

La skill dice que los secretos se leen desde variables de entorno y no se escriben en el código.

¿Necesita soporte asíncrono?

Solo si el proyecto es asíncrono o la llamada espera operaciones de entrada y salida. La skill puede añadir una versión asíncrona.

¿Cómo se devuelven los errores?

La skill describe salidas de fallo tipadas para que el agente reciba un resultado claro cuando hay errores.

Detalles

Descripción original del autor

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

Popularidad

Estrellas en GitHub
6,3 mil
Posición en el ranking
#14240
Licencia
MIT
Actualizada
29/10/2026

¿Te sirve esta skill?

0

Entra para votar.

Comentarios

  • …

Más skills de este repositorio

Skills parecidas