# Skills

https://ailoy.co/docs/guides/skills/

Give an agent folders of instructions for one kind of task, in the Agent Skills format.

> **Needs a sandbox:**
> The agent reads its skills through its sandbox, so an agent with skills needs one ([Giving an agent a sandbox](https://ailoy.co/docs/guides/sandbox/)).

A skill is a folder of instructions for one kind of task, with the files those instructions use, in the [Agent Skills](https://agentskills.io/specification) format. The agent is told which skills it has and what each is for, and to read a skill's instructions when a task matches it.

## What a skill folder holds

A `SKILL.md`, and anything it refers to: scripts, references, data. `SKILL.md` opens with YAML frontmatter giving the skill's `name` and a `description` of what it does and when to use it, and the instructions follow. This is the start of the one in [`laya/shared`](https://github.com/brekkylab/ailoy-examples/tree/main/laya/shared) in ailoy-examples, whose instructions tell the agent to run `run_laya.py` from the same folder:

````markdown
---
name: laya
description: Answer typed questions about a text with Laya, a machine learning model for decisions. Use it to classify, score or answer yes or no about a message, an email or a ticket, with calibrated probabilities.
---

# Laya

Laya is a machine learning model for decisions. Given a text, such as a message, an email or a
ticket, it answers typed questions about it with calibrated probabilities. It picks one of
several options, rates on an ordered scale, or answers yes or no, and it generates no text.
You put what is to be decided to it as questions, and write the reply yourself from its
answers.

## Running it

Run `run_laya.py` from this directory with the mode and the request as its two arguments.

```sh
python3 run_laya.py bf16 '{"state": "...", "questions": {...}}'
```
````

Ailoy reads `name` and `description` and nothing else from the frontmatter, each as one line: keep each on a single line, without YAML's `>` or `|`.

## Giving the agent a skill

`skill(dir)` takes the folder's path in the agent's sandbox, not on your machine. Put the folder in the sandbox, with whatever its instructions expect to find there: Laya's instructions read its model from `/models`, which the [laya example](https://github.com/brekkylab/ailoy-examples/tree/main/laya) puts on a volume of its own. A volume, as below, keeps the skill on the virtx server between runs; baking it into the image works too ([Mounting volumes](https://virtx.sh/docs/guides/mounting-volumes/), [Images](https://virtx.sh/docs/guides/images/)). Call `skill` once for each skill.

**Python**

```python
skill = await client.create_volume("skill-laya")
for path in Path("skills/laya").iterdir():
    await skill.write_file(path.name, path.read_bytes())

sandbox = await client.create_sandbox(
    "python:3.12-slim-trixie",
    volumes=[SandboxVolume(volume=skill, path="/skills/laya", readonly=True)],
)

agent = await (
    AgentBuilder("anthropic/claude-haiku-5-5")
    .sandbox(sandbox)
    .skill("/skills/laya")
    .build()
)
```

**Node.js**

```js
const skill = await client.createVolume('skill-laya')
for (const name of readdirSync('skills/laya')) {
  await skill.writeFile(name, readFileSync(join('skills/laya', name)))
}

const sandbox = await client.createSandbox('python:3.12-slim-trixie', {
  volumes: [{ volume: skill, path: '/skills/laya', readonly: true }],
})

const agent = await new AgentBuilder('anthropic/claude-haiku-5-5')
  .sandbox(sandbox)
  .skill('/skills/laya')
  .build()
```

**Rust**

```rust
let skill = client.create_volume(Some("skill-laya")).await?;
for entry in std::fs::read_dir("skills/laya")? {
    let entry = entry?;
    skill
        .write_file(entry.file_name().to_string_lossy(), std::fs::read(entry.path())?, None)
        .await?;
}

let sandbox = client
    .create_sandbox(
        &SandboxCreateArgs::new("python:3.12-slim-trixie").readonly_volume(skill.name(), "/skills/laya"),
    )
    .await?;

let agent = AgentBuilder::new("anthropic/claude-haiku-5-5")
    .sandbox(sandbox)
    .skill("/skills/laya")
    .build()
    .await?;
```

When the agent writes the system message itself, `build()` reads the frontmatter of each `SKILL.md` through the sandbox, and fails if the `SKILL.md` of a `skill(dir)` is missing or has no `name` or `description`. The system message gets a list of the skills after the instruction: each one's name, description and location, and a line telling the model to read a skill's `SKILL.md` in full before using it. The rest of `SKILL.md` stays out of the system message; the agent reads it with its own tools. So an agent with skills needs a sandbox, which brings a tool that reads files, such as `read`.

For `anthropic` models the list is an XML block:

```text
# Skills

The following skills provide specialized instructions for specific tasks. When a task matches a skill's description, read the SKILL.md at its location in full before proceeding. When a skill refers to a relative path, resolve it against the skill's directory, the one that holds its SKILL.md.

<available_skills>
  <skill>
    <name>laya</name>
    <description>Answer typed questions about a text with Laya, a machine learning model for decisions. Use it to classify, score or answer yes or no about a message, an email or a ticket, with calibrated probabilities.</description>
    <location>/skills/laya/SKILL.md</location>
  </skill>
</available_skills>
```

For any other org, the same preamble is followed by a Markdown list, one line per skill:

```text
- `laya` at /skills/laya/SKILL.md. Answer typed questions about a text with Laya, a machine learning model for decisions. Use it to classify, score or answer yes or no about a message, an email or a ticket, with calibrated probabilities.
```

Skills are added only to the system message the agent writes itself. A `history(...)` that brings a system message keeps it: the skills are not read or added.

## Skills from the sandbox's abins

A sandbox can be made with some of virtx's own programs, its abins, at `/abin`: `index` indexes document files and searches them, `docread` reads a Word, PDF or text file a window at a time, and `display` runs GUI programs on a screen watched over VNC. Each comes with a `SKILL.md` at `/abin/skills/{name}/`, and the agent lists it among its skills without a `skill(...)` call:

**Python**

```python
sandbox = await client.create_sandbox("python:3.12-slim-trixie", abins=["index", "docread"])
```

**Node.js**

```js
const sandbox = await client.createSandbox('python:3.12-slim-trixie', { abins: ['index', 'docread'] })
```

**Rust**

```rust
let sandbox = client
    .create_sandbox(&SandboxCreateArgs::new("python:3.12-slim-trixie").abin("index").abin("docread"))
    .await?;
```

An abin with no `SKILL.md` is left out of the list rather than failing `build()`. [Setting up sandboxes](https://virtx.sh/docs/guides/setting-sandboxes/) covers the `abins` option.

## Troubleshooting

| What you see | Why, and what to do |
| --- | --- |
| `reading the skill <dir>/SKILL.md` at `build()` (a `VirtxError` with status `404` in Python and Node.js) | The `SKILL.md` of a `skill(dir)` isn't in the sandbox. `dir` is a path in the sandbox, not on your machine: check that the volume holding it is mounted there. |
| ``the frontmatter has no `name` ``, or ``no `description` `` | Add the field to the frontmatter, on one line. |
| ``a SKILL.md opens with a `---` line`` | The file must start with the frontmatter, between two `---` lines. |
| `an agent with skills needs a sandbox to read them from` | Give the agent a sandbox with `sandbox(...)`. |
| A skill's description in the system message is just `>` or `\|` | YAML's multi-line values aren't read, and no error is raised: put the description on one line. |
