Skip to content
bits
Give your model tools · Lesson 2 of 10

Describing a tool

Tutor:

Claude never sees your function's code. It only sees a description of it, and that description has three parts.

name is what Claude calls it by, like get_weather. Letters, digits, underscores and dashes, up to 128 characters. description is plain English: what the tool does and when to use it. input_schema says what arguments it takes, written in JSON Schema, a standard way to describe the shape of a JSON object.

import type Anthropic from "@anthropic-ai/sdk";
export const tools: Anthropic.Tool[] = [
{
name: "get_weather",
description:
"Get the current weather for one city. Use it whenever the user asks " +
"about weather, temperature or what to wear outdoors right now. " +
"It returns current conditions only, not forecasts.",
input_schema: {
type: "object",
properties: {
city: {
type: "string",
description: "City name, with country if it's ambiguous, e.g. Paris, France",
},
unit: {
type: "string",
enum: ["celsius", "fahrenheit"],
description: "Temperature unit. Defaults to celsius.",
},
},
required: ["city"],
},
},
];
TypeScriptUTF-8● lines 5–24: one tool, described
Tutor:

Read the schema from the top. The input is an object. It has two properties: city, a string, and unit, which can only be "celsius" or "fahrenheit" because it has an enum. Only city is required, so Claude can leave unit out.

Each property gets its own description too. “City name, with country if it's ambiguous” is what stops Claude sending "Paris" when the user meant Paris, Texas.

quick check+20 neurons
Tutor:

Claude has to decide whether a question needs get_weather. What does it go on?

    Type your answer or tap an option · Enter checks

    Tutor:

    You send the list of tools with every request, in a tools field next to your messages. That has a cost: the definitions are input tokens, and turning tools on adds a small hidden system prompt that teaches Claude how to call them (286 tokens on Claude Haiku 5.5, as of October 2026). A handful of tools is cheap. Hundreds of them crowd the context, which is one reason to keep your list short.

    quick check+20 neurons
    Tutor:

    Your tool takes a size that must be small, medium or large. What's the best way to say so?

      Type your answer or tap an option · Enter checks

      Tutor:

      Your turn. Ask Claude to write the input schema for a tool that looks up a flight's status: a required flight number, and an optional date. Ask for JSON only, so the answer stays short.

      Your turn

      Run your prompt and the replies land here.

        • Asks for a JSON Schema, not yet
        • Names the inputs, not yet
        • Says what's required, not yet
        • Asks for JSON only, not yet
        • Ran at 1.0, not yet
        run at
        ~0 tokens

        Turn on JavaScript to run prompts.