# Skills

A [skill](https://agentskills.io/) is an open standard format initiated by Anthropic for extending AI agents with domain knowledge and step-by-step workflows. Each skill is a folder containing a `SKILL.md` file that explains how to handle a task; the model loads it on demand.

## Discovery priority {#discovery}

Bub discovers skills in the following order. **When names collide, the first match wins**:

1. **Workspace directory**: `<workspace>/.agents/skills/` (legacy `.agent/skills/` is also supported)
2. **User global directory**: `~/.agents/skills/`
3. **Installed Python packages**: any `skills` namespace package in the environment, including Bub's [bundled skills](#builtin-skills)

## Bundled skills {#builtin-skills}

The Bub app includes three bundled skills:

| Skill | Purpose | External dependency |
| --- | --- | --- |
| `telegram` | Send, reply to, and edit Telegram messages | Telegram Bot token |
| `gh` | Manage repositories, issues, PRs, and Actions via the GitHub CLI | `gh` installed and authenticated |
| `skill-creator` | Scaffold or update skills | None |

## Write a skill {#write-a-skill}

Try creating a skill (`<skill-name>/SKILL.md`) in your workspace or global skills directory, for example `.agents/skills/repo-map/SKILL.md`:

```markdown title=".agents/skills/repo-map/SKILL.md"
---
name: repo-map
description: Read the local repository structure before changing code.
---

1. Run `rg --files` to inspect the repository layout.
2. Read the files relevant to the requested change.
3. State which modules will be affected before editing code.
```

### Frontmatter fields and variables {#skill-fields}

YAML frontmatter fields in `SKILL.md`:

| Field | Requirement |
| --- | --- |
| `name` | **Required**. Must match the skill directory name; lowercase letters, digits, and hyphens only; max 64 characters |
| `description` | **Required**. Explains when to use the skill (used by the model to select skills); max 1,024 characters |
| `metadata` | Optional. String-to-string key-value mapping |

Helper scripts and reference files can be placed in `scripts/`, `references/`, or `assets/` inside the skill folder. The skill body supports variable interpolation:

| Variable | Expands to |
| --- | --- |
| `$SKILL_DIR` | Absolute path of the skill directory |
| `$PYTHON` | Path of the Python interpreter running Bub |
| `${config.path.to.value}` | Value of the dotted path in the Bub config file |

Scripts inside a skill do not execute automatically; instruct the model in the skill body to run them with `bash` (and ensure required CLI tools such as `rg` are installed).

Of course, if you would rather not create a skill by hand, you can ask Bub to generate one with the bundled `$skill-creator` skill:

```bash
bub run 'Use the $skill-creator skill to create a skill named `repo-map` with these steps:
1. Run `rg --files` to inspect the repository layout.
2. Read the files relevant to the requested change.
3. State which modules will be affected before editing code.'
```

## Verify and use {#verify-a-skill}

Once your skill is ready, verify and invoke it in these ways:

| Command | Description |
| --- | --- |
| `bub run ",skill"` | List all skills discovered in the current workspace |
| `bub run ",skill name=repo-map"` | Print the expanded skill body without calling the model (returns `(no such skill)` if the directory name and `name` do not match) |
| `bub run 'Use the $repo-map skill and list the top-level modules.'` | Explicitly expand the skill body into this turn's system prompt |

:::note
Even without an explicit `$skill-name` in the prompt, the model can load a skill on demand based on its `description`.
:::

## Distribute in a Python package {#include-skills-in-a-wheel}

Skills can be bundled into a Python wheel alongside plugins. See [Packaging and distribution](/docs/app/distribution/#bundle-plugins-and-skills) for directory layout and build configuration.