A standalone Agent Skill value for local agents and MCP servers (Effect's
effect/ai/Skill).
A Skill is an Agent Skill (https://agentskills.io/specification) as plain
data: validated YAML frontmatter, markdown instructions and supporting
files, with SKILL.md as its file format (to_files, from_files)::
refunds = skill.make(
frontmatter={"name": "refunds", "description": "Process customer refunds"},
instructions="Read references/policy.md before issuing a refund.",
files={"references/policy.md": "Refunds over $100 require approval."},
)
skill.to_files(refunds)["SKILL.md"] # '---\n"name": "refunds"\n...'
mcp_server.skill("skill://billing/refunds/SKILL.md", refunds)Re-exports#
Values#
| Attribute | Type | Description |
|---|---|---|
Frontmatter | type[Frontmatter] | The YAML frontmatter of a |
FRONTMATTER | StructSchema[Frontmatter, Never, Never] | The schema of |
SkillFiles | type[SkillFiles] | A skill as files: its |
Classes#
Functions#
make#
make(*, frontmatter, instructions, files=None) -> SkillA validated Skill. Raises SchemaError when the frontmatter is
not valid Agent Skills frontmatter or a file's path is SKILL.md or
leaves the skill; use from_files for untrusted input.
| Parameter | Type | Description |
|---|---|---|
frontmatter | Frontmatter | |
instructions | str | |
files | Mapping[str, str | bytes] | None = None |
Returns Skill
def make(
*,
frontmatter: Frontmatter,
instructions: str,
files: Mapping[str, str | bytes] | None = None,
) -> Skill:
"""A validated ``Skill``. Raises ``SchemaError`` when the frontmatter is
not valid Agent Skills frontmatter or a file's path is ``SKILL.md`` or
leaves the skill; use ``from_files`` for untrusted input."""
return Skill(frontmatter=frontmatter, instructions=instructions, files=dict(files or {}))to_files#
to_files(skill) -> SkillFilesThe skill as files: a SKILL.md holding its frontmatter and
instructions, and its supporting files. Each frontmatter key and value
is written as JSON, which YAML reads back unchanged (from_files).
| Parameter | Type | Description |
|---|---|---|
skill | Skill |
Returns SkillFiles
def to_files(skill: Skill, /) -> SkillFiles:
"""The skill as files: a ``SKILL.md`` holding its frontmatter and
instructions, and its supporting files. Each frontmatter key and value
is written as JSON, which YAML reads back unchanged (``from_files``)."""
frontmatter = "\n".join(
f"{stringify(key)}: {stringify(value)}" for key, value in skill.frontmatter.items()
)
files: dict[str, str | bytes] = {
"SKILL.md": f"---\n{frontmatter}\n---\n\n{skill.instructions}",
**skill.files,
}
return cast("SkillFiles", files)from_files#
from_files(files) -> Effect[Skill, IllegalArgumentError]The skill a SKILL.md and its supporting files hold. Fails with
IllegalArgumentError when SKILL.md is missing, is not UTF-8,
does not begin with YAML frontmatter, or the skill is not valid.
| Parameter | Type | Description |
|---|---|---|
files | Mapping[str, str | bytes] |
Returns Effect[Skill, IllegalArgumentError]
def from_files(files: Mapping[str, str | bytes], /) -> Effect[Skill, IllegalArgumentError]:
"""The skill a ``SKILL.md`` and its supporting files hold. Fails with
``IllegalArgumentError`` when ``SKILL.md`` is missing, is not UTF-8,
does not begin with YAML frontmatter, or the skill is not valid."""
def parse() -> Effect[Skill, IllegalArgumentError]:
supporting = dict(files)
skill_md = supporting.pop("SKILL.md", None)
if skill_md is None:
return fail(IllegalArgumentError("Skill is missing SKILL.md"))
if isinstance(skill_md, bytes):
try:
skill_md = skill_md.decode("utf-8")
except UnicodeDecodeError:
return fail(IllegalArgumentError("SKILL.md is not valid UTF-8"))
split = split_skill_md(skill_md)
if split is None:
return fail(IllegalArgumentError("SKILL.md is missing valid YAML frontmatter"))
frontmatter, instructions = split
decoded = _decode_skill(
{"frontmatter": frontmatter, "instructions": instructions, "files": supporting}
)
return decoded.map_error(lambda error: IllegalArgumentError(error.message))
return suspend(parse)