> ## Documentation Index
> Fetch the complete documentation index at: https://docs.restate.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Skills

> Give an agent instructions for kinds of tasks, which the model loads only when a task needs them.

A skill holds instructions for one kind of task. The model receives the name and description of each skill, and loads a skill's instructions with the built-in `load_skill` tool when a task matches:

```typescript {"CODE_LOAD::harness/src/agents.ts#skills"}  theme={null}
const writer = agent({
  model,
  instructions: "You write for a software team.",
  skills: skills([
    {
      name: "release-notes",
      description: "Write release notes from a list of changes.",
      instructions: "Group the changes into Added, Changed, and Fixed. Follow the layout in template.md.",
      files: {"template.md": "## <version>\n### Added\n...\n### Changed\n...\n### Fixed\n..."},
    },
  ]),
});
```

A skill name has up to 64 characters: lowercase letters and digits, in groups joined by single hyphens. `skills()` throws for an invalid name, an empty description, or a duplicate name. The model reads a skill's files with the built-in `read_skill_file` tool.

## Custom skill sources

To load skills from files, a repository, or a database, pass your own `SkillSource` with the async functions `list`, `load`, and optionally `read`.
This source reads a folder with one subfolder per skill. Each subfolder holds a `SKILL.md` file, with the skill's name and description in its frontmatter and the instructions after it, and the files that the instructions refer to:

```text theme={null}
skills/
  release-notes/
    SKILL.md
    template.md
```

```typescript {"CODE_LOAD::harness/src/skills.ts#source"}  theme={null}
/** Reads the name and description from a SKILL.md file's frontmatter, and the instructions after it. */
function parseSkill(text: string) {
  const frontmatter = /^---\n([\s\S]*?)\n---\n/.exec(text);
  const field = (key: string) => new RegExp("^" + key + ":\\s*(.+)", "m").exec(frontmatter?.[1] ?? "")?.[1]?.trim() ?? "";
  return {name: field("name"), description: field("description"), body: text.slice(frontmatter?.[0].length ?? 0).trim()};
}

/** Every folder in `root` with a SKILL.md file is a skill. */
export function folderSkills(root: string): SkillSource {
  return {
    async list() {
      const entries = await readdir(root, {withFileTypes: true});
      const folders = entries.filter(
        (entry) => entry.isDirectory() && existsSync(join(root, entry.name, "SKILL.md")),
      );
      return Promise.all(
        folders.map(async (folder) => {
          const location = join(root, folder.name);
          const {name, description} = parseSkill(await readFile(join(location, "SKILL.md"), "utf8"));
          return {name, description, location};
        }),
      );
    },
    async load({location}) {
      return parseSkill(await readFile(join(location!, "SKILL.md"), "utf8")).body;
    },
    async read({location}, path) {
      return readFile(join(location!, path), "utf8");
    },
  };
}

const writer = agent({
  model,
  instructions: "You write for a software team.",
  skills: folderSkills("skills"),
});
```

* **Location.** `list` returns each skill's name, description, and `location`, here the skill's folder. Restate Harness doesn't send the location to the model. Restate Harness passes the skill with its location to `load` and `read`.
* **Journaled calls.** Restate Harness journals each call. `list` runs once per run, so the skill list stays the same for the whole run, also on replay.
* **Skill files.** The model gets `read_skill_file` only if the source implements `read`. Restate Harness rejects paths that start with `/` or contain a `..` segment before it calls `read`.
* **Invalid skills.** Restate Harness skips an invalid skill from a custom source and logs a warning.

This parser reads only single-line `name` and `description` fields. The [skills lesson](https://github.com/restatedev/ai-examples/blob/main/restate-harness/examples/src/lessons/19_skills.ts) parses multiline frontmatter values, and the [reference architecture](https://github.com/restatedev/ai-examples/blob/main/restate-harness/reference-architecture/packages/libs/core/src/integrations/skills.ts) reads skills from a GitHub repository.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.