> 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/ch06-skills-ecosystem/6.3-writing-a-custom-skill.md). Agents can also search and read this documentation through its [MCP server](https://www.openclawbook.xyz/~gitbook/mcp).

# 6.3 Writing a Custom Skill

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

***

## 6.3.1 The `SKILL.md` Format

A skill is one directory with one required file:

```
my-skill/
└── SKILL.md
```

### Frontmatter

```markdown
---
name: my-skill
description: "One line describing what this does. Use when: the specific situation."
metadata:
  {
    "openclaw": {
      "emoji": "🔧",
      "requires": {
        "bins": ["curl", "jq"],
        "env": ["MY_API_KEY"],
        "os": ["darwin", "linux"]
      },
      "install": [
        { "id": "brew", "kind": "brew", "package": "jq" }
      ]
    }
  }
---
```

| Field              | Notes                                                                  |
| ------------------ | ---------------------------------------------------------------------- |
| `name`             | Must match the directory name                                          |
| `description`      | **The most important line you write** — see below                      |
| `requires.bins`    | Binaries that must exist, or the skill doesn't load                    |
| `requires.anyBins` | At least one must exist                                                |
| `requires.env`     | Environment variables that must be set                                 |
| `requires.config`  | Config paths that must be truthy                                       |
| `requires.os`      | Platform restriction                                                   |
| `install`          | How to install missing dependencies (brew / node / go / uv / download) |

### Why `description` matters most

The system prompt contains **only your description** (§29.5.4). It's the entire basis on which the model decides whether to read your skill.

| Bad                   | Good                                                                                                                                 |
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------ |
| `"Weather skill"`     | `"Get current weather and forecasts via wttr.in. Use when: the user asks about weather, temperature, or forecast for any location."` |
| `"Deployment helper"` | `"Deploy the app to staging or production via the deploy.sh script. Use when: the user asks to deploy, ship, or release."`           |

**The "Use when:" convention is doing the work.** Describing capability isn't enough; the model needs the trigger condition.

### The body

Everything after the frontmatter is what the model reads once it selects your skill. Write it as instructions to a competent colleague:

````markdown
# My Skill

## Getting current data

Run this and parse the JSON:

```bash
curl -s "https://api.example.com/v1/data" -H "Authorization: Bearer $MY_API_KEY" | jq '.items'
````

The response shape is:

* `items[].id` — the record ID
* `items[].status` — one of `pending`, `active`, `closed`

## Common tasks

**Finding a record by name**: filter on `items[].name`, matching case-insensitively.

**Creating a record**: POST to `/v1/data` with `{"name": "...", "status": "pending"}`.

## Things to avoid

* Don't call `/v1/bulk-delete` — it has no confirmation and no undo.
* The API rate-limits at 60 requests/minute; batch where possible.

````

**Include the failure modes and the things not to do.** Those are what a skill can teach that the model can't infer.

## 6.3.2 Writing One from Scratch

A worked example — a skill for a project's release process.

```bash
mkdir -p ~/.openclaw/workspace/skills/release
````

`~/.openclaw/workspace/skills/release/SKILL.md`:

```markdown
---
name: release
description: "Run the project's release process: version bump, changelog, tag, publish. Use when: the user asks to release, cut a version, or publish a new version."
metadata:
  { "openclaw": { "emoji": "🚀", "requires": { "bins": ["git", "npm"] } } }
---

# Release Process

## Preconditions — check all of these first

1. On the `main` branch: `git branch --show-current`
2. Working tree clean: `git status --porcelain` must be empty
3. Tests pass: `npm test`

**If any precondition fails, stop and report. Do not proceed.**

## Steps

1. Determine the version bump from the changes since the last tag:
   `git log $(git describe --tags --abbrev=0)..HEAD --oneline`
   - Breaking changes → major
   - New features → minor
   - Fixes only → patch

2. Bump: `npm version <major|minor|patch> --no-git-tag-version`

3. Update `CHANGELOG.md`: add a section for the new version, grouping commits
   under Added / Changed / Fixed. Write for users, not developers —
   describe the effect, not the implementation.

4. Commit: `git add -A && git commit -m "chore(release): v<version>"`

5. Tag: `git tag v<version>`

6. **Stop here and ask for confirmation before pushing.**

7. After confirmation: `git push && git push --tags`

## Never

- Never force-push a release tag.
- Never release from a branch other than `main`.
- Never skip the test run, even if the user asks.
```

Notice what makes this useful:

* **Preconditions with an explicit stop instruction** — the model will otherwise happily proceed past a dirty working tree;
* **A confirmation point before the irreversible step**;
* **A "Never" section** — the constraints that matter most.

## 6.3.3 Testing, Debugging, and Publishing

### Testing

```bash
openclaw skills status | grep release      # did it load?
```

If it didn't load, `requires` isn't satisfied — the status output tells you which requirement failed.

Then test the selection behavior:

```
release version 1.2.0
```

Watch whether the model reads the skill. If it doesn't, **your `description` isn't matching the request** — that's almost always the problem. Rewrite it with a clearer "Use when:".

### Debugging

```
/context list
```

Confirms the skill's description is in the prompt at all.

If the model reads the skill but does the wrong thing, the body is ambiguous. Common fixes:

| Symptom                               | Fix                                             |
| ------------------------------------- | ----------------------------------------------- |
| Skips preconditions                   | Add an explicit "If any fails, stop and report" |
| Proceeds past a step needing approval | Add "Stop here and ask for confirmation"        |
| Uses the wrong command variant        | Give the exact command, not a description of it |
| Does extra unwanted things            | Add a "Never" section                           |

### Publishing

To share via ClawHub, follow their submission process. Before publishing:

* **Remove anything machine-specific** — absolute paths, your usernames, your hostnames;
* **Declare `requires` honestly** so it doesn't load where it can't work;
* **Include `install` specs** so missing dependencies are actionable;
* **Re-read it as a stranger would.** Remember that whatever you write goes directly into someone's model prompt (§6.1.4) — the same trust considerations you'd apply to a skill you install apply to one you publish.

***

## Section Summary

1. **A skill is one directory with one `SKILL.md`** — frontmatter declaring `requires` and `install`, body containing the instructions.
2. **`description` is the most important line you write** — it's the only thing in the system prompt, and the **"Use when:" convention** supplies the trigger condition the model needs.
3. **The body should read as instructions to a competent colleague**, and should include **failure modes and things not to do** — what a skill can teach that the model can't infer.
4. **Three things that make a procedural skill work**: preconditions with an explicit stop instruction, a confirmation point before irreversible steps, and a "Never" section.
5. **If the model doesn't read your skill, the `description` isn't matching** — that's almost always the cause; `/context list` confirms it's in the prompt at all.
6. **Before publishing**: strip machine-specific paths, declare `requires` honestly, include `install` specs, and remember **what you write goes directly into someone else's model prompt**.
