new-tool

new-tool is a command for Claude Code from davepoon/buildwithclaude. It costs 20 tokens per session (771 once invoked), scanned A, original, MIT.

A command for creating a function that lets an AG2 agent interact with an outside system, perform an operation, or calculate a result. AG2, formerly AutoGen, is a framework for building agents that use tools.

In plain words
What is it for?
Use it when adding an API call, file operation, or computation to an AG2 agent.
Why use it?
It gives the function a consistent structure with typed inputs, clear documentation, JSON results, and handling for invalid input or other errors.

Command for Claude Code

Written for Claude Code: argument-hint in frontmatter.

Part of the ag2-agent-builder plugin — 7 commands, 3 agents shipped together

About the project

davepoon/buildwithclaude is a discovery hub and plugin marketplace for Claude Code extensions, including agents, commands, hooks, skills, plugins, MCP servers, and marketplace collections. Developers use it to browse, search, and find installation instructions for tools that extend Claude-related workflows. Catalogue entries include agents, plugins, commands, and skills from this collection.

davepoon/buildwithclaude · 3,419 stars · on GitHub · buildwithclaude.com

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.

agentmods
npx agentmods add commands/davepoon/buildwithclaude/new-tool
Clone the repo
git clone --depth 1 https://github.com/davepoon/buildwithclaude

Made for: Claude Code.

Or install ag2-agent-builder, the plugin that ships this one along with the rest of its 7 commands, 3 agents.

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

README.md
[![agentmods](https://agentmods.dev/badge/commands/davepoon/buildwithclaude/new-tool.svg)](https://agentmods.dev/commands/davepoon/buildwithclaude/new-tool)
Your own site
<a href="https://agentmods.dev/commands/davepoon/buildwithclaude/new-tool"><img src="https://agentmods.dev/badge/commands/davepoon/buildwithclaude/new-tool.svg" alt="Measured on agentmods" height="20"></a>
Per session 20 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 771 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
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.00020 $0.00771
Opus 5 $0.00010 $0.00385
Sonnet 5 $0.00004 $0.00154
Haiku 4.5 $0.00002 $0.00077

Measured 6d ago against content hash 0057585dedea, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-06, from the pricing page.

Security

Grade A, and why

new-tool scanned grade A with 0 findings 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 6d 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.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/ag2-agent-builder/commands/new-tool.md · 110 lines

How it starts

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

You are creating tool functions for AG2 agents. Tools are how agents interact with external systems.

Instructions

  1. Ask the user for:

    • What the tool does (API call, file operation, computation, etc.)
    • Input parameters and their types
    • Expected output structure
    • Error scenarios to handle
  2. Generate the tool following this exact contract:

Tool Function Pattern

import json
from autogen.tools import tool


@tool()
def tool_name(required_param: str, optional_param: int = 10) -> str:
    """Clear, specific description of what this tool does.

    The docstring becomes the function description in the LLM's tool schema.
    Be specific about what the tool returns and when to use it.

    Args:
        required_param: What this parameter is for
        optional_param: What this controls (default: 10)
    """
    try:
        # Implementation here
        result = {
            "items": [],
            "total_count": 0,
            "metadata": {},
        }
        return json.dumps({"success": True, "data": result})
    except ValueError as e:
        return json.dumps({"success": False, "error": f"Invalid input: {e}"})
    except Exception as e:
        return json.dumps({"success": False, "error": str(e)})

Tool Contract Rules

Return format: Always a JSON string with this structure:

{"success": true, "data": { ... }}
{"success": false, "error": "Human-readable error message"}

Type annotations: All parameters MUST have type annotations. The LLM uses these to construct calls.

Docstrings: MUST include:

  • One-line summary of what the tool does
  • Args: section describing each parameter
  • Be specific -- vague descriptions lead to misuse by the LLM

Parameter design:

  • Use simple types: str, int, float, bool
  • Use str for complex inputs (JSON strings) -- avoid nested objects
  • Provide sensible defaults for optional parameters
  • Limit to 5 parameters max -- split into multiple tools if more needed

Read the full file on GitHub · 110 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. 6d ago First seen · 110 lines · 20 tokens per session scan A 0057585dedea

Subscribe to this mod's changes

new-tool is a command published in the GitHub repository davepoon/buildwithclaude (3,419 stars, last pushed yesterday), licensed MIT. It adds 20 tokens to every session and 771 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.