featherweight.skills¶
skills ¶
Skills: instructions an agent can read when it needs them, as typed Pydantic models.
A skill follows the Agent Skills specification (https://agentskills.io/specification): a directory with a SKILL.md
(YAML frontmatter, then Markdown instructions) and, optionally, other files such as references/, scripts/ and
assets/. Skills are loaded in steps, so that they cost little context until they are needed:
- the
nameanddescriptionare in the agent's prompt (that is how the agent knows the skill exists), - the instructions are read with the
get_skilltool when the agent decides the skill applies, - other files of the skill are read with
get_skilltoo, only when the instructions point to them.
A Skill is plain data, so it is defined as an instance (or as a subclass with defaults) and listed in an agent's
skills; or it is loaded from a skill directory with Skill.from_directory. Scripts are kept as text for the agent
to read: nothing here runs them. allowed_tools is kept but not enforced. A skill whose text lives elsewhere is a subclass that
overrides aread.
SkillError ¶
Bases: ValueError
A skill directory or SKILL.md that does not follow the specification.
Skill ¶
Bases: BaseModel
read ¶
read(resource: str = '') -> str
The instructions, with the other files of the skill listed; or the text of one other file.
aread
async
¶
aread(resource: str = '') -> str
read, asynchronously: the one the runner's get_skill tool awaits. The default returns read. A skill whose text is
somewhere else (a database, an object store) is a subclass that overrides this and fetches without blocking the event loop.
It should return text; if it raises, the agent is told the skill could not be read, and the error is logged.
from_markdown
classmethod
¶
from_markdown(
text: str, *, resources: dict[str, str] | None = None
) -> Skill
Parse the text of a SKILL.md: YAML frontmatter between --- lines, then the instructions.
from_directory
classmethod
¶
from_directory(path: str | Path) -> Skill
Load a skill directory: SKILL.md, and every other text file below it as a resource.
The name in SKILL.md must match the name of the directory, as the specification says. Files that are not UTF-8 text are left out (and logged), because the agent can only read text.
clean_resource ¶
clean_resource(resource: str) -> str | None
The path that a model asked for, as a path inside the skill, or None when it is not one (docs/specs/skills.md).
The empty string is the skill itself. A . segment is dropped and // is one /. Refused: a path that starts with /, has a backslash,
a .. segment (it is not resolved), a control character (NUL and newline included), is longer than MAX_RESOURCE_CHARS, or is only dots
and slashes. The model chose it, so this is the one place that decides, for every skill.