> For the complete documentation index, see [llms.txt](https://www.openclawbook.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.openclawbook.xyz/en/ch29-skill-system/29.5-source-deep-dive-progressive-disclosure.md). Agents can also search and read this documentation through its [MCP server](https://www.openclawbook.xyz/~gitbook/mcp).

# 29.5 Source Deep Dive: Progressive Disclosure and Three-Tier Loading

> **Generated by**: Claude Opus 5 (claude-opus-5\[1m]) **Token usage**: Input \~240,000 tokens, Output \~9,000 tokens (this section) **Source baseline**: `v2026.3.9` (`v2026.3.8-170-g665f67726`); line numbers refer to this commit

***

Fifty-two bundled skills. Injecting all of them into the system prompt in full would cost hundreds of thousands of tokens — larger than most models' context windows.

How does OpenClaw solve it? Two mechanisms: **progressive disclosure** (see the index first, read only what you pick) and **environment pre-filtering** (skills that can't run never appear at all).

## 29.5.1 Positioning First: Skills Are Prompt-Layer, Not Code-Layer

A skill is a directory containing a `SKILL.md`, with minimal frontmatter:

```markdown
---
name: weather
description: "Get current weather and forecasts via wttr.in or Open-Meteo. Use when: ..."
metadata: { "openclaw": { "emoji": "🌤️", "requires": { "bins": ["curl"] } } }
---
```

The relationship to tools and plugins fits in one sentence:

> **Plugins register "what can be called" (tools/channels/CLI — the code layer); skills teach "how and when to use it" (the prompt layer).**

**A skill adds no tools of its own.** It assumes `exec`, `browser`, and friends already exist, and uses documentation to teach the model how to orchestrate `curl`, CLIs, and APIs.

That division is clean: adding a skill doesn't change the system's capability boundary, only the model's knowledge. Which is why skills can come from untrusted sources without expanding the attack surface — **though they do expand the prompt-injection surface** (§29.5.5).

## 29.5.2 Three-Tier Loading and Priority

```
<workspace>/skills          highest priority (project-specific)
       ↓
~/.openclaw/skills          shared across agents
       ↓
bundled skills/             lowest
```

Higher tiers override lower ones on a name collision (`docs/tools/skills.md:15-22`). Plugins may ship their own skills directory participating in the same rules.

This is **exactly isomorphic** to hooks' discovery rules (§30.3), with the same four origins: `openclaw-bundled` / `openclaw-managed` / `openclaw-workspace` / `openclaw-plugin`.

**The isomorphism is deliberate** — learn one set of discovery/override rules and you understand both skills and hooks.

## 29.5.3 Environment Pre-Filtering: Spend Prompt Budget Only on Executable Capabilities

At load time, skills are filtered by `requires`:

| Dimension | Example                         |
| --------- | ------------------------------- |
| `bins`    | Needs `curl` / `gh` / `ffmpeg`  |
| `env`     | Needs some environment variable |
| `config`  | Needs some config key           |
| `os`      | macOS only / Linux only         |

**A skill requiring `curl` on a machine without `curl` never enters the prompt at all.**

> The value of this design: **the model will never recommend an approach that can't run.** On a machine without `gh`, the model won't say "I'll create the issue with the gh CLI" and then fail.
>
> **Prompt budget is spent only on executable capabilities** — saving tokens and eliminating an entire class of "the model suggested something impossible" failures.

### Skills carry their own installation plans

`metadata.openclaw.install` can declare installation plans for missing dependencies, with `kind` covering five channels (`src/agents/skills/types.ts:3-17`'s `SkillInstallSpec`):

```
brew | node | go | uv | download
```

The macOS app's Skills panel renders **one-click install buttons** from this.

**A skill isn't just documentation — it carries the metadata to get itself running.**

`skills.entries.<name>.env` can also inject environment variables and API keys for a single skill (applied within the agent turn via `src/agents/skills/env-overrides.ts`).

## 29.5.4 Progressive Disclosure: See the Index, Read Only What You Pick

The system prompt contains **only one line of description per skill**, plus selection discipline:

```ts
// src/agents/system-prompt.ts:26-31
"Before replying: scan <available_skills> <description> entries.",
`- If exactly one skill clearly applies: read its SKILL.md at <location> with \`${params.readToolName}\`, 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.",
```

Four rules covering every case:

| Situation                   | Action                                                           |
| --------------------------- | ---------------------------------------------------------------- |
| Exactly one clearly applies | Read its `SKILL.md`, follow it                                   |
| Several might apply         | **Pick the most specific**, then read                            |
| None clearly apply          | **Don't read any `SKILL.md`**                                    |
| Constraint                  | **Never read more than one up front; only read after selecting** |

That last constraint is the crux. Without it the model reads three or four possibly-relevant skills "just to be safe" — several thousand tokens each, spending the savings right back.

**Cost comparison**:

```
Full injection:        52 skills × several thousand tokens each = hundreds of thousands
Progressive disclosure: 52 one-line descriptions + one selected skill ≈ a few thousand
```

> This is a general pattern: **when you have N large documents for the model to choose among, give it an index plus a read tool rather than stuffing them all into context.** The cost is one extra tool-call round trip; the benefit is context cost dropping from O(N) to O(1).

### One `SKILL.md`, two consumption paths

A skill can also become a **user slash command** via `user-invocable`, or even **dispatch directly to a tool bypassing the model** via `command-dispatch: tool` (`src/agents/skills/types.ts:40-48`).

**The same `SKILL.md` serves both autonomous model invocation and explicit user invocation.**

That's §44.3's "declarative single source + multi-end projection" theme applied to the skill system — one declaration, two consumers.

## 29.5.5 Ecosystem and Trust Boundary

The ecosystem side is served by ClawHub (clawhub.com) as a registry, with `clawhub install/update/sync` installing into the workspace.

**But the docs warn explicitly**:

> Third-party skills are **untrusted code**. Keys injected via `skills.entries.*.env` go into the **host process, not a sandbox**.

That risk deserves spelling out. A skill "being just a Markdown document" sounds safe, but:

1. `SKILL.md`'s content **goes straight into the model's prompt** — the classic prompt-injection entry point;
2. The commands it suggests **are executed by the `exec` tool** — subject to tool policy (§22.5.1), but a permissive configuration effectively lets the skill author execute commands indirectly;
3. API keys injected for a skill live **in the host process environment**, unprotected by any sandbox.

> **Risk note** (§45.2): for skills installed from ClawHub there is **no automated auditing mechanism beyond reading the source.** Read that Markdown before installing a third-party skill — it isn't long, and it's currently the only line of defense.

### Independent skill snapshots for cron sessions

`src/cron/isolated-agent/skills-snapshot.ts`: scheduled jobs can run with **only an allowlisted set of skills**.

That shrinks the automation turn's attack surface — an hourly job processing external email shouldn't be carrying all 52 skills.

***

## Section Summary

1. **Skills are prompt-layer, not code-layer**: plugins register "what can be called," skills teach "how and when to use it"; a skill adds no tools of its own.
2. **Three-tier loading**: `<workspace>/skills` > `~/.openclaw/skills` > bundled, **exactly isomorphic to hooks' discovery rules** (learn one set, use it twice).
3. **Pre-filtering by `requires` (bins/env/config/os)** — a skill needing `curl` never enters the prompt on a machine without it; **the model will never recommend an approach that can't run**.
4. **`metadata.openclaw.install` carries installation plans** (brew/node/go/uv/download), rendered as one-click buttons by the macOS app — skills carry the metadata to get themselves running.
5. **Progressive disclosure's four rules**, with the final constraint being the key: **never read more than one skill up front** — without it the model reads several "to be safe" and spends the savings back. Context cost drops from O(N) to O(1).
6. **One `SKILL.md`, two consumers**: autonomous model invocation plus user slash commands (`user-invocable` / `command-dispatch: tool`) — a single source projected to multiple ends.
7. **Understand the trust boundary**: `SKILL.md` goes straight into the prompt (an injection entry point), its suggested commands are executed by `exec`, and injected keys live in the host process rather than a sandbox; **the only current defense is reading the Markdown yourself**. Cron sessions can shrink the attack surface with an allowlisted skills snapshot.
