# Skills

> What a skill is made of, how zelk keeps its instructions out of the model's context until they are needed, and what it records when one is used.

A skill is a packaged set of instructions the model picks up when a task
fits it: how to cut a release, how to review a diff. This page says what a
skill is made of, how zelk keeps it out of the model's context until it is
needed, and what zelk records when one is used.

## What a skill is

A skill is a directory with a `SKILL.md` in it, and optionally scripts and
reference files beside it. `SKILL.md` says when the skill applies and what
to do. The model reads it when a task fits, and follows it with the tools it
already has. zelk reads the open Agent Skills format, so skills written for
Claude Code or Codex work unchanged.

```markdown title=".zelk/skills/release/SKILL.md"
---
name: release
description: Cut a release by updating the changelog, running the tests and tagging it. Use when asked to ship a version.
allowed-tools: Bash(git tag:*)
---

Cut the release the user asks for.

Tests: !`go test ./...`

1. Add this version to @CHANGELOG.md.
2. Follow checklist.md step by step.
3. Draft the notes: scripts/notes.sh
```

A skill is neither of the two things it can be mistaken for:

- **Project instructions** come with the session. The repository's
  `AGENTS.md` is in the context whether or not a task needs it
  ([project instructions](/cli/memory/#project-instructions)). A skill costs
  the model one line until a task needs it.
- **Tools** are code the model calls. A skill holds no tool. It is text the
  model reads, and a script it carries runs through the Bash tool (on
  Windows, PowerShell or Bash), under the usual permissions.

A model's context is bounded and every token in it costs, so zelk can't put
every skill there. It shows the model one line for each, and brings in the
rest only when a skill is used.
[Disclosure](#disclosure-one-level-at-a-time) shows how.

## Anatomy of a skill

Here is the skill above as it sits on disk, with `SKILL.md` open. Each
number points at a part and says what it is and when it reaches the model.


The same, as a table:

| Part | What it is, and when it reaches the model |
|---|---|
| release/ | a directory; its name matches `name` |
| SKILL.md | the one file a skill must have |
| name + description | always in the index, about 30 tokens |
| allowed-tools | allow rules while the skill is active, if it is yours |
| body | the instructions, loaded when the skill is used |
| `!` line | runs only when you invoke it, after the permission check |
| `@` file | attached only when you invoke it, if the skill is yours |
| checklist.md | read on demand as `skill://release/checklist.md` |
| scripts/notes.sh | published read-only so it can run |
| templates/notes.md | read on demand as `skill://release/templates/notes.md` |

### Where skill directories live

A skill's directory sits inside a skills directory. zelk never looks for
skills on its own: the host passes them. The `zelk` command passes these,
in this order:

1. The skills built into zelk: `init`, `statusline` and `zelk`.
2. Your own, from `~/.zelk/skills`, `~/.agents/skills` and
   `~/.claude/skills`.
3. The project's, from `.zelk/skills`, `.agents/skills` and
   `.claude/skills` in the working directory, then in each directory above
   it up to the repository root. Outside a repository, only the working
   directory counts.
4. A package's, from the same three directories below the working
   directory, once the session reads, edits or searches there.

The order matters when two skills share a name. The one from the higher
trust wins, so yours beats the project's. Then the earlier in this list
wins, so a skill of yours named `init` is ignored, and a skill nearer the
working directory beats one above it. A warning names the one ignored.

A file in a `commands` directory is a skill of one file, with no directory
of its own. The [skills guide](/cli/skills/#commands) covers them.

### SKILL.md: the frontmatter

`SKILL.md` opens with frontmatter between two `---` lines, written in a
small subset of YAML. A key may appear once, and the block is at most
64 KiB. Two fields are required. The rest are optional.

| Field | Required | What it does |
|---|---|---|
| `name` | yes | 1 to 64 lowercase letters, digits and single hyphens, with none at either end. It matches the directory's name. |
| `description` | yes | Up to 1,024 characters: what the skill does and when to use it. It is all the model has to choose by. |
| `when_to_use` | no | More on when to load it. The index shows it after the description, and the two are cut together at 1,536 characters. |
| `allowed-tools` | no | Permission rules, such as `Bash(git tag:*)`, as a string or a list. While the skill is active and is yours, they are allow rules. |
| `arguments` | no | Names for the arguments you type after `/name`, which the body uses as `$name`. |
| `argument-hint` | no | Text that says what to type, such as `[issue] [branch]`, where a host offers the skill. |
| `disable-model-invocation` | no | `true` keeps the skill out of the index. Only you load it, with `/name`. |
| `user-invocable` | no | `false` keeps the skill from you: it is not offered, and typing its name does not run it. |
| `license` | no | Kept as written. zelk does nothing with it. |
| `compatibility` | no | Up to 500 characters. Kept as written. zelk does nothing with it. |
| `metadata` | no | A map of strings to strings. Kept as written. |

Any other field is kept as written and draws no warning, so a skill written
for another agent loads unchanged. A `description` under three words, or two
that share most of their words, does draw a warning, since the model can't
choose by them.

### SKILL.md: the body

Everything after the closing `---` is the body: markdown the model follows.
zelk asks for no structure in it.

When you invoke the skill with `/name`, the body can use what you typed.
`$ARGUMENTS` is all of it, `$0`, `$1` and so on are its words, and `$name`
is the argument a skill's `arguments` field declares. When no placeholder
takes what you typed, zelk adds it to the end as an `ARGUMENTS:` line.

### Pulling in files and commands

Two kinds of text in the body act only when you invoke the skill. When the
model loads it, neither does anything.

- `@CHANGELOG.md` names a file in the workspace. Invoked, zelk attaches the
  file to the message, as it does for any `@` you type. A skill's own text
  attaches files only if the skill is yours.
- `` !`go test ./...` `` is a shell line. Invoked, zelk runs the command
  first and puts its output where the line stood. A fenced block opened by
  ```` ```! ```` does the same for several lines.

[Files and shell lines](#files-and-shell-lines) says how each is decided.

### Scripts

A script is a file the instructions tell the model to run. Keep scripts in
a `scripts/` directory: zelk gives that name a meaning. The model runs a
script with Bash, so each run is decided like any command. On Windows the
model may use PowerShell instead, and the same holds. zelk adds two
things.

- **A script has to be somewhere the environment can run it.** A skill in
  the workspace runs in place. For any other skill, such as one in your home
  directory, zelk publishes a copy: `-skill-cache DIR` names an existing,
  private directory in the workspace, and needs a sandbox. Tool commands
  can run the published scripts and cannot modify them. Without it, those scripts can't
  run, and zelk tells the model so. The
  [skills guide](/cli/skills/#scripts-in-skills) has the details.
- **A script runs only as it was loaded.** Before Bash or PowerShell runs a
  command that names one of the skill's scripts, zelk checks the file against the digest
  recorded when the skill loaded. A script that changed or vanished since
  is refused.

A shell line can run a script as `${ZELK_SKILL_DIR}/scripts/notes.sh`. That
works only for a skill in the workspace. A skill elsewhere has no directory
the environment can see, and a line that names it refuses the invocation.

### Reference files

Every other file is a reference file: a checklist, a template, a page of
notes. None of them enters the context when the skill loads. The load lists
them, and the model reads one with Read at `skill://release/checklist.md`
when the instructions send it there. A file can be read only after its skill
is loaded, and what is served is the bytes recorded at the load.

### Limits

The bundle is `SKILL.md` and the regular files under the directory,
including hidden files and files in hidden directories under `scripts/`.
It holds at
most 1,000 files and 16 MiB in all. A skill past a limit is skipped with a
warning, since zelk records a bundle whole when it loads and never loads
half of one.

### What zelk ignores

- A directory in a skills directory that has no `SKILL.md`, and any name
  that starts with a dot, are skipped without a word.
- A skill's directory may be a link, and so may its `SKILL.md`, which is
  read wherever it points. Any other link or device inside a skill is
  never followed or bundled, and a warning names it.
- Outside `scripts/`, hidden files and directories such as `.env` and
  `.git` are silently excluded from the bundle and unavailable through
  `skill://`. A skill can still bring a dotfile into the conversation by
  naming it with `@` or reading it in a `!` line.
- Hidden paths under `scripts/`, such as `scripts/.setup.sh` and
  `scripts/.d/setup.sh`, are bundled so Bash can check their digests.
- A skill that fails validation is skipped with a warning that says why: no
  frontmatter, a key twice, a bad or mismatched `name`, a missing or long
  `description`, a field of the wrong shape, an `allowed-tools` entry that
  isn't a permission rule, a `SKILL.md` that isn't UTF-8 text, or a bundle
  over a limit.

## Where skills come from

A host passes **sources**: directories of skills, or skills defined in code
([Go guide](/go/skills-subagents/)). [Where skill directories
live](#where-skill-directories-live) lists the ones the `zelk` command
passes.

Each source has a **trust** level. Your own skills speak with your
authority. A project's skills come from the repository, so they are framed
as lower-trust guidance, like project instructions.

zelk loads the sources again each time an execution starts, so a skill
added or edited since the last run is the one a new index, the Skill tool
and `/name` find.

## Disclosure, one level at a time

What the model holds of a skill grows in three steps, and each step happens
only when the one before it isn't enough.

1. **The index.** One line per skill, its name and description, in the
   context that follows the cached system prompt and tools, so the cached
   prefix isn't disturbed. It is bounded to 1% of the model's window. A
   skill that doesn't fit is listed by name only, and still loads by name. A
   skill marked explicit-only isn't listed at all.
2. **The body.** The model calls the Skill tool, or you type `/name` and
   arguments, and the instructions arrive framed by the skill's trust, with
   the paths of its other files and the tools it allows. The skill is
   **active** from then until the run ends or another skill loads. When the
   context is compacted, the active skill's instructions are carried across.
3. **The files.** The skill's other files stay out of the context until the
   model reads one.

Tokens in the diagram are estimated at four bytes each, the rate zelk
budgets the index at. A real body is usually longer than this one.

Four skills sit in the model’s context as an index of 139 tokens (a token is about 4 bytes). Four scenes follow what happens when one is used:

- **The model loads it**. Only the index is in the context until the model asks. Each skill costs a line, its name and description. When the model calls Skill, the body arrives as the call’s result. The files it names stay out until the model reads one.
   - The context holds the index of 4 skills, each a folded card (release 30, review 22, changelog 23, migrate 24), 139 tokens in all.
   - You say “Cut release 2.4” (4 tokens).
   - The model calls `Skill {"name":"release"}` (6 tokens). Its card is the one that unfolds.
   - The release body unfolds as the call’s result: 230 tokens, the body’s 59 and 171 of framing (trust, files, publication). The shell lines stay as written. The other skills stay folded. The context is 379 tokens.
   - The model reads `skill://release/checklist.md`, 69 tokens. The context is 448 tokens.
- **You invoke it**. Your invocation prepares the message first. The @ files are attached and every shell line is decided as a Bash call before any runs. A person is asked about a line no rule allows. Outputs replace the lines, then the message is sent.
   - The context holds the index of 4 skills, each a folded card (release 30, review 22, changelog 23, migrate 24), 139 tokens in all.
   - You type `/release 2.4`. The release card is the one that opens, but nothing has joined the context yet.
   - The skill’s own text names `@CHANGELOG.md` (25 tokens); it is attached because the skill is yours.
   - Every shell line is decided before any runs: `git describe --tags` is allowed (it only reads); `go test ./...` is asked of a person (no rule allows it).
   - You approve `go test ./...`, once.
   - `git describe --tags` runs and prints `v2.3.1`, which takes its line’s place.
   - `go test ./...` runs and prints `ok  example.com/app  0.41s`, which takes its line’s place.
   - The message is sent: the release body with its outputs, 215 tokens, and `CHANGELOG.md` 25 tokens attached. The context is 379 tokens.
- **A line is refused**. One refused line refuses the whole invocation. Nothing ran and nothing was sent, so the context is as it was. A deny rule, a hook, or no one to ask has the same effect.
   - The context holds the index of 4 skills, each a folded card (release 30, review 22, changelog 23, migrate 24), 139 tokens in all.
   - You type `/release 2.4`. The release card is the one that opens, but nothing has joined the context yet.
   - The skill’s own text names `@CHANGELOG.md` (25 tokens); it is attached because the skill is yours.
   - Every shell line is decided before any runs: `git describe --tags` is allowed (it only reads); `go test ./...` is asked of a person (no rule allows it).
   - You decline `go test ./...`.
   - The invocation is refused (go test ./... wasn’t approved). Nothing ran, nothing is sent, and the context stays at 139 tokens.
- **The log keeps the bytes**. A loaded skill is the recorded one, not the file on disk. The log holds each file’s digest and the blob store its bytes. Edit the file and a resumed session still unfolds what was recorded. Only a new load reads the file, and it records its own revision.
   - The load records `skill_loaded` with a manifest of 3 files, each a digest and a size (revision b10a905e), and stores the bytes as blobs.
   - Because the skill has scripts (scripts/notes.sh) and the environment can publish, the recorded bundle is written read-only and `skill_materialized` records it.
   - The file on disk changes: SKILL.md now has revision d4765fa8. The log is untouched. The change: - 4. Tag it and stop. Do not push. + 4. Tag it and push the tag.
   - A new process resumes the session and unfolds revision b10a905e from the log: “4. Tag it and stop. Do not push.” Revision d4765fa8, on disk, isn’t read.
   - If the model loads the skill again, it gets the file as it is now: a new `skill_loaded` records revision d4765fa8 beside the first, and the line reads “4. Tag it and push the tag.”

A skill added, removed or given a new description while a session is under
way reaches the model as a note before its next call. The index itself
changes at the next compaction.

## Files and shell lines

A skill's `@` files and shell lines happen only when you invoke it. This is
how each is decided.

**`@` files.** An `@path` in your arguments is attached, as in any message.
So is one in the skill's own text, if the skill is yours. Naming a file is
you reading it, so no permission rule is asked. A project's skill can't
attach files, since a repository's text isn't you reading anything. The
model reads the file with Read, under the session's rules.

**Shell lines.** A line written `` !`command` ``, or a fenced block opened
by `` ```! ``, runs before the message is sent, and its output takes the
line's place. Each command is decided as a Bash call would be. The session's
PreToolUse hooks for Bash see it first (for PowerShell, where the command
runs there), and a hook's deny refuses it even
in bypass mode. Then the permission rules decide, with the skill's
`allowed-tools` counted as allow rules if the skill is yours.

zelk decides every command before it runs any. A refused one refuses the
whole invocation, and nothing runs. A command no rule allows is asked of a
person, in the terminal UI's approval dialog or ACP's permission request, and
approving it runs it once and keeps no rule. With nobody to ask, as in print
mode, it is refused, and the error names a rule that would allow it.

Commands run as the Bash tool's do, in the agent's environment, with a
two-minute timeout. On Windows they run in Bash where the session has it and
otherwise in PowerShell: with no Git for Windows, or under MXC, which can't
start Bash. One that fails or times out refuses the invocation and
shows the end of its output, because a message built on a failed command
would mislead the model.

When the model loads the skill, its shell lines stay as written. The model is
told they weren't run and to run what it needs with Bash, where each command
is decided like any call.

## Safety

- A skill can't change the permission mode or get around the
  [decision](/concepts/permissions/#the-decision).
- `allowed-tools` pre-approves, as in Claude Code. While a skill that is
  yours is active, each entry is an allow rule beside the session's. Deny
  rules, plan mode, protected paths and human-only rules still come first,
  and auto mode still drops rules that would run any code. Tools the skill
  doesn't list keep their usual permission.
- A project's skill grants nothing this way: a repository's files can't
  approve their own actions. A host can switch grants off for every skill,
  which `zelk` does under a managed policy that keeps only its own allow
  rules.
- A script runs only from a skill in the workspace, or from a published
  copy, and Bash refuses a command that names a loaded skill's script whose
  content has changed or vanished since the load.

## What the log records

When a skill loads, zelk stores each file of its bundle as a blob, then
records the load: the skill's name, source and trust, each file's SHA-256
digest and size, and a **revision**, which is a digest of those. The log
holds the manifest, and the blob store holds the bytes.

Replay uses only what was recorded and reads no skill file. A later
execution, a resume among them, loads the skill sources again, so a skill
added or edited since can be found and loaded, and a changed index is
recorded. A skill the session already loaded keeps the bundle it was loaded
with: the instructions the model received are in the log as the result of
its call, an invocation records the text it rendered, so a replay never
expands it twice, and `Read` of a `skill://` path serves the recorded
bytes.

So a session that loaded a skill keeps that version, whatever happens to the
files. Edit `SKILL.md` on disk, and a session resumed tomorrow, replayed or
forked still unfolds the version it recorded. Only a new load reads the
files as they are, and it records its own revision beside the first.

**Publication.** When a skill's [scripts](#scripts) are published, zelk
writes the recorded bundle into a read-only directory and records the
publication. A skill in the workspace needs none: it runs in place, after a
check against its recorded digests.

Publication writes the recorded bytes from the blob store, never the
source. Each new execution verifies or recreates a publication before
anything depends on it, so cleanup or a restart can't swap in the skill's
current files. Publishing grants no permission to run anything.

## Skills and subagents

A subagent is a session of its own, with its own context, and it doesn't
inherit the skills its parent loaded. It can load skills only if its tools
include Skill: the built-in `explore` type has it, and a definition that
names other tools leaves it out, so its session records no index.
[Extending zelk](/concepts/extending/#subagents) explains subagents, and the
[Go guide](/go/skills-subagents/#subagents) shows how to define them.

## Where to go deeper

- [Skills and commands](/cli/skills/): write a skill, where `zelk` finds
  them, and `-skill-cache` for scripts
- [Skills and subagents](/go/skills-subagents/): sources and trust in Go
- [The skills contract](/internals/skills/): the lifecycle, argument
  expansion, shell lines and their permissions, and every warning
- [Context and compaction](/concepts/context/) and
  [Permissions](/concepts/permissions/): where the index goes, and how
  commands are decided
- [Recorded skill publication](/internals/durability/#recorded-skill-publication):
  how the log and the environment agree on a published bundle
