GitHub

API reference for skill.

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

AttributeTypeDescription
Frontmattertype[Frontmatter]

The YAML frontmatter of a SKILL.md, as the Agent Skills specification defines it. name is 1 to 64 lowercase letters, digits and single hyphens and names the skill's directory; description says what the skill does and when to use it, in 1 to 1024 characters; compatibility is 1 to 500 characters; allowed-tools lists, space-separated, the tools the skill asks to run without approval (hosts ignore it for a skill served over MCP unless the user approved the grant). Other keys are kept unchanged.

FRONTMATTERStructSchema[Frontmatter, Never, Never]

The schema of Frontmatter (Effect's Skill.Frontmatter).

SkillFilestype[SkillFiles]

A skill as files: its SKILL.md and its supporting files (to_files).

Classes

Functions

make

make(*, frontmatter, instructions, files=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.

ParameterTypeDescription
frontmatterFrontmatter
instructionsstr
filesMapping[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) -> 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).

ParameterTypeDescription
skillSkill

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.

ParameterTypeDescription
filesMapping[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)