Skip to content
Progressive Skill Loading: 40+ Agent Skills, No Bloat — ContentBuffer guide

Progressive Skill Loading: 40+ Agent Skills, No Bloat

K
Kodetra Technologies··9 min read Intermediate

Summary

Build a skill-manifest registry so an AI agent wields dozens of skills without context bloat.

On June 23, 2026, a developer's side project hit #1 on Hacker News: a Google Workspace CLI that exposed 40+ structured \"skills\" an AI agent could call to drive Gmail, Drive, and Calendar. He was fired within days, and two days later Google announced an official Workspace CLI. The internet argued about the firing. Engineers noticed something else: how do you hand an agent 40 skills without drowning it?

The naive answer fails. If you paste 40 tool definitions into every request, you pay for ~12,000 tokens of schema on every single turn, and accuracy drops as the model picks the wrong tool from a wall of options. The trick that makes large skill sets work is progressive disclosure: show the agent a tiny catalog, and load a skill's full spec only when it actually needs it.

This guide builds that pattern from scratch in plain Python and wires it into Claude's tool-use loop. By the end you will have a skill registry, a three-tool \"manifest\" interface (find_skills, load_skill, run_skill), and a working agent that books a meeting and posts to Slack while only ever seeing three tool definitions.

What you'll build

  • A SkillRegistry that stores many skills but exposes a cheap one-line manifest.
  • Three meta-tools that let an agent discover, load, and execute any skill on demand.
  • A real Claude tool-use loop with argument validation and a loop guard.
  • A runnable offline demo so you can see the exact tool trace without an API key.

Prerequisites

  • Python 3.10 or newer.
  • pip install anthropic jsonschema.
  • An ANTHROPIC_API_KEY for the live version (the demo runs without one).
  • Comfort with JSON Schema and basic function calling.

The core idea: a manifest, not a menu

Think of tool definitions as standing overhead. A single skill definition (name, description, JSON schema, examples) is often 200-400 tokens. Forty of them is a fixed tax on every request, whether the task needs one skill or none. Worse, large flat tool lists hurt selection accuracy because the model has to disambiguate dozens of similar options at once.

Progressive disclosure flips this. The agent permanently holds only three small tools. It calls find_skills to get a short list of names and summaries, load_skill to pull the full instructions and schema for the one it picked, then run_skill to execute. The expensive detail enters context only for the handful of skills a task actually touches. This is the same principle behind Anthropic's Agent Skills (a SKILL.md whose body loads only when relevant) and the API's tool_search server tool.

Step 1: Define a skill and a registry

A skill is data plus a handler. The key design move is splitting summary (cheap, always visible) from instructions and input_schema (loaded on demand).

from dataclasses import dataclass
from typing import Callable, Any
import zlib

@dataclass
class Skill:
    name: str            # unique id the agent calls
    summary: str         # ONE line, shown in the manifest (cheap)
    instructions: str    # full how-to, loaded on demand (expensive)
    input_schema: dict   # JSON schema for the skill's arguments
    handler: Callable[..., Any]   # the function that does the work

class SkillRegistry:
    def __init__(self):
        self._skills: dict[str, Skill] = {}

    def register(self, skill: Skill):
        self._skills[skill.name] = skill

    def manifest(self, query: str = "") -> list:
        """Cheap catalog: name + summary only. Optional keyword filter."""
        q = query.lower().strip()
        out = []
        for s in self._skills.values():
            hay = (s.name + " " + s.summary).lower()
            if not q or any(w in hay for w in q.split()):
                out.append({"name": s.name, "summary": s.summary})
        return out

    def spec(self, name: str) -> dict:
        """Full spec for ONE skill, returned only when the agent asks."""
        s = self._skills[name]
        return {"name": s.name, "instructions": s.instructions,
                "input_schema": s.input_schema}

    def run(self, name: str, args: dict):
        return self._skills[name].handler(**args)

The registry holds everything, but manifest() returns only names and summaries. That is the catalog the agent browses. spec() is the on-demand detail, and run() dispatches to the real function.

Step 2: Register your skills

Each skill is a few lines. In a real app you'd register dozens; here are two concrete ones with deterministic handlers so the output is reproducible.

def cid(*parts):  # deterministic id (crc32 is stable across runs)
    return abs(zlib.crc32("".join(map(str, parts)).encode())) % 100000

registry = SkillRegistry()

registry.register(Skill(
    name="create_calendar_event",
    summary="Create a calendar event with a title, start time, and duration.",
    instructions=("Book meetings. Times must be ISO 8601 in the user's timezone. "
                  "Returns a shareable event URL. Do not invent attendees."),
    input_schema={"type": "object", "properties": {
        "title": {"type": "string"},
        "start": {"type": "string", "description": "ISO 8601 datetime"},
        "minutes": {"type": "integer", "default": 30}},
        "required": ["title", "start"]},
    handler=lambda title, start, minutes=30: {
        "url": f"https://cal.example.com/e/{cid(title, start)}",
        "title": title, "start": start, "minutes": minutes},
))

registry.register(Skill(
    name="post_slack_message",
    summary="Post a message to a Slack channel.",
    instructions=("Notify a channel. 'channel' must include the leading #. "
                  "Keep messages under 300 characters. Returns the permalink."),
    input_schema={"type": "object", "properties": {
        "channel": {"type": "string"}, "text": {"type": "string"}},
        "required": ["channel", "text"]},
    handler=lambda channel, text: {
        "permalink": f"https://slack.example.com/{channel.strip('#')}/p{cid(text)}",
        "channel": channel},
))

# ...imagine 38 more skills registered exactly the same way.

Step 3: Expose three meta-tools to the model

These three definitions are the entire surface the model sees, no matter how many skills you register. That's the whole point: standing overhead stays flat as your catalog grows.

# These three tiny tool definitions are the ONLY tools the model ever sees.
META_TOOLS = [
    {"name": "find_skills",
     "description": ("Search the skill catalog. Returns matching skill names and "
                     "one-line summaries. Call this first to discover what you can do."),
     "input_schema": {"type": "object",
        "properties": {"query": {"type": "string"}}, "required": ["query"]}},
    {"name": "load_skill",
     "description": ("Load the full instructions and argument schema for ONE skill "
                     "by name. Call before run_skill so you know the exact arguments."),
     "input_schema": {"type": "object",
        "properties": {"name": {"type": "string"}}, "required": ["name"]}},
    {"name": "run_skill",
     "description": "Execute a loaded skill with its arguments.",
     "input_schema": {"type": "object",
        "properties": {"name": {"type": "string"}, "args": {"type": "object"}},
        "required": ["name", "args"]}},
]

Step 4: Dispatch and validate

Never trust model-supplied arguments. Validate them against the skill's own JSON schema before executing, and return the schema back on failure so the model can self-correct on the next turn.

import json
from jsonschema import validate, ValidationError

def dispatch(registry, tool_name, tool_input):
    if tool_name == "find_skills":
        return registry.manifest(tool_input.get("query", ""))
    if tool_name == "load_skill":
        try:
            return registry.spec(tool_input["name"])
        except KeyError:
            return {"error": f"No skill named {tool_input['name']!r}"}
    if tool_name == "run_skill":
        name = tool_input["name"]
        args = tool_input.get("args", {})
        try:
            schema = registry.spec(name)["input_schema"]
        except KeyError:
            return {"error": f"No skill named {name!r}"}
        try:
            validate(instance=args, schema=schema)   # reject hallucinated args
        except ValidationError as e:
            return {"error": f"Invalid args: {e.message}", "schema": schema}
        return registry.run(name, args)
    return {"error": f"Unknown tool {tool_name!r}"}

Step 5: The agent loop

This is the standard Claude tool-use loop: call the Messages API, and while stop_reason is tool_use, run each requested tool and feed a tool_result back keyed by tool_use_id. The max_turns guard stops a runaway find/load/run cycle.

import anthropic

client = anthropic.Anthropic()      # reads ANTHROPIC_API_KEY
MODEL = "claude-sonnet-4-6"

def run_agent(user_msg, registry, max_turns=8):
    messages = [{"role": "user", "content": user_msg}]
    for _ in range(max_turns):              # loop guard: never run forever
        resp = client.messages.create(
            model=MODEL, max_tokens=1024,
            tools=META_TOOLS,               # always just 3 tool defs
            messages=messages,
        )
        messages.append({"role": "assistant", "content": resp.content})
        if resp.stop_reason != "tool_use":
            return "".join(b.text for b in resp.content if b.type == "text")

        results = []
        for block in resp.content:
            if block.type == "tool_use":
                out = dispatch(registry, block.name, block.input)
                print(f"[tool] {block.name}({json.dumps(block.input)})")
                results.append({"type": "tool_result",
                                "tool_use_id": block.id,
                                "content": json.dumps(out)})
        messages.append({"role": "user", "content": results})
    return "Stopped: hit max_turns."

print(run_agent(
    "Schedule a 30-min incident retro tomorrow 3pm and post it to #eng.",
    registry))

Worked example: book a retro, ping the channel

Ask the agent to schedule an incident retro and notify #eng. It discovers the two relevant skills out of a 40-skill catalog, loads each spec, and runs them. Here is the actual trace from the demo (deterministic IDs via crc32):

[tool] find_skills({"query": "calendar slack"})
[tool] load_skill({"name": "create_calendar_event"})
[tool] run_skill({"name": "create_calendar_event", "args":
        {"title": "Incident retro", "start": "2026-06-25T15:00:00", "minutes": 30}})
   -> {"url": "https://cal.example.com/e/58643", ...}
[tool] load_skill({"name": "post_slack_message"})
[tool] run_skill({"name": "post_slack_message", "args":
        {"channel": "#eng", "text": "Incident retro booked for 2026-06-25 15:00."}})
   -> {"permalink": "https://slack.example.com/eng/p66194", "channel": "#eng"}

Booked the retro for 2026-06-25 15:00 and posted it to #eng.

Notice the shape: one find_skills call surfaces candidates, then a load_skill + run_skill pair per skill used. Two skills touched, two specs loaded, 38 skills never entered context.

Run it offline first

You don't need an API key to see the loop work. Drop in a tiny stand-in client that replays the tool calls a model would make, assign it to client, and call run_agent. The full demo file (registry + meta-tools + dispatch + a FakeClient) runs as-is and prints the trace above. Swap FakeClient() for anthropic.Anthropic() to go live.

Why this beats a flat tool list

The numbers below are rough token estimates for a 40-skill catalog where a task uses two skills. Your exact counts depend on schema size, but the ratio is the point: standing overhead drops by an order of magnitude and stays flat as you add skills.

AspectFlat list (all 40 inline)Skill manifest (progressive)
Standing tool tokens / request~12,000 (all 40 schemas)~250 (3 meta-tools)
Detail loaded for a 2-skill taskAll 40, every turn2 specs, once
Selection accuracy at scaleDegrades with list sizeModel picks from short summaries
Adding a 41st skillBigger prompt for every callNo change to standing cost
CachingRe-sent each requestStatic meta-tools cache cleanly

Common pitfalls

Vague summaries. The summary is a routing key, not marketing. \"Handles communications\" is useless; \"Post a message to a Slack channel\" tells the model exactly when to pick it. Write summaries so two skills are never confusable from the one line alone.

Skipping validation. run_skill is a generic dispatcher into arbitrary functions. Always validate arguments against the schema and allowlist which skills a given agent may call. Returning the schema on a validation error lets the model fix its own arguments without a human.

No loop guard. A confused agent can ping-pong between find_skills and load_skill forever. Cap turns, and consider a per-task budget on how many skills it may load.

The model forgets it loaded a skill. In long conversations the loaded spec scrolls out of the model's effective attention. When run_skill fails validation, include the schema in the error so the correct shape re-enters context right when it's needed.

Returning the whole catalog from find_skills. If find_skills with an empty query dumps all 40 summaries, you've reinvented the flat list. Return a bounded top-k, and require a real query.

Forgetting prompt caching. The three meta-tool definitions are static. Mark them for caching so you stop paying to re-send them on every turn.

Quick reference

PieceRoleCost profile
manifest() / find_skillsDiscovery: names + summariesCheap, every task
spec() / load_skillFull instructions + schemaPer skill, on demand
run() / run_skillExecute the handlerOnce per action
META_TOOLSThe only tools the model seesFlat, cacheable
max_turnsLoop guardFree safety net

Next steps

  • Swap keyword matching in find_skills for embedding search when summaries get numerous or fuzzy.
  • Add prompt caching to META_TOOLS and the system prompt to cut standing cost to near zero.
  • Move skills into SKILL.md-style files with frontmatter so non-engineers can author them.
  • Explore the Messages API tool_search server tool, which implements this disclosure pattern natively.
  • Write an eval that checks the agent loads only the skills a task needs, no more.

The viral Workspace CLI wasn't impressive because it had 40 skills. It was impressive because the agent stayed sharp while holding all of them. Progressive disclosure is how you get there: a small, stable interface over a large, growing catalog.

Comments

Subscribe to join the conversation...

Be the first to comment

Found this useful?

Get new AI guides for builders by email. Free.

Join 3,604 newsletter subscribers.

Also get