Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Heuristic:AMAP ML SkillClaw Lazy Skill Catalog Loading

From Leeroopedia
Knowledge Sources
Domains Optimization, LLMs
Last Updated 2026-10-22 00:00 GMT

Overview

Lazy-loading skill catalog that injects only skill names and descriptions as an XML catalog, instructing the model to `read` at most one `SKILL.md` file on demand rather than loading all skill contents upfront.

Description

SkillClaw does not inject full skill contents into the system prompt. Instead, it builds an `<available_skills>` XML catalog listing each skill's `name`, `description`, and `location`. The model is instructed: "If exactly one skill clearly applies: read its SKILL.md at `<location>` with `read`, then follow it." This means the model loads skill content only when relevant — a single `read` tool call. If the catalog is too large for the full format (with descriptions), it falls back to a compact format (name + location only, omitting descriptions) to fit within `max_skills_prompt_chars` (default 30,000 chars). The constraint "never read more than one skill up front; only read after selecting" prevents the model from loading multiple skills and wasting context.

Usage

Use this heuristic when managing many skills — injecting all full skill contents would blow the context window. Applied automatically by `SkillManager.build_injection_prompt` and `SkillClawAPIServer._inject_skills`.

The Insight (Rule of Thumb)

  • Action: Inject skill catalog (names + descriptions) as XML; instruct model to read at most one `SKILL.md` on demand.
  • Value: `max_skills_prompt_chars` = 30,000 (default). Full format includes `<description>`; compact format omits it if catalog exceeds the limit.
  • Trade-off: One extra `read` tool call per relevant skill (slight latency), but saves massive context window space vs. injecting all skill contents.
  • Compatibility: Matches OpenClaw's `formatSkillsForPrompt` / `buildSkillsSection` behavior.

Reasoning

With dozens of skills, injecting all full contents could consume tens of thousands of tokens — leaving little room for the actual conversation. The lazy approach costs only the catalog size (names + short descriptions) in the system prompt, and one `read` call when a skill is actually needed. The "at most one skill" constraint is critical: it prevents the model from loading multiple skills and confusing their instructions. The compact fallback format (names only) ensures even very large skill libraries fit within the prompt budget.

Code Evidence

Injection instruction from `skillclaw/skill_manager.py:648-676`:

@staticmethod
def build_skills_section(skills_prompt, read_tool_name="read"):
    return "\n".join([
        "## Skills (mandatory)",
        "Before replying: scan <available_skills> <description> entries.",
        f"- If exactly one skill clearly applies: read its SKILL.md at "
        f"<location> with `{read_tool_name}`, then follow it.",
        "- If multiple could apply: choose the most specific one, then read/follow it.",
        "- If none clearly apply: do not read any SKILL.md.",
        "Constraints: never read more than one skill up front; only read after selecting.",
        trimmed,
        "",
    ])

Compact format fallback from `skillclaw/skill_manager.py:678-697`:

def build_injection_prompt(self, max_chars=30_000, read_tool_name="read"):
    skills = self.get_all_skills()
    if not skills:
        return ""
    full_prompt = self.format_skills_for_prompt(skills)
    if len(full_prompt) <= max_chars:
        catalog = full_prompt
    else:
        catalog = self.format_skills_compact(skills)
    return self.build_skills_section(catalog, read_tool_name)

Lazy loading description from `skillclaw/api_server.py:3187-3188`:

# The model is instructed to `read` at most one SKILL.md when
# relevant (lazy loading), matching OpenClaw's injection behaviour.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment