Overview
SkillsManager implements Agent Skills: SKILL.md files on disk, discovered and rendered into a prompt section the agent sends to the model. It supports the tiered loading model — name/description metadata kept in memory for context-aware activation (Tier 1), and a skill’s full body pulled on demand (Tier 2).
Every Agent builds one automatically as agent.skills. It is also usable standalone.
Import
Design
The manager never mutates the agent. It returns prompt text and the caller decides what to do with it, which keeps the class testable on its own:Agent.call_llm then sends that section with every LLM call: as a leading system message when the call carries messages, otherwise in front of the task string. The tool-summary call gets it too. agent.system_prompt never changes, so repeated runs do not stack copies of the skills.
Constructor
Union[str, List[str]]
A directory, or a list of directories, containing skill folders. Each folder holds a
SKILL.md file with YAML frontmatter. Directories are read in order. When two directories hold a skill with the same name, the later directory wins and a warning is logged. None disables skills entirely.float
default:"0.3"
Minimum task/skill similarity for a skill to be selected during dynamic loading.
Attributes
Optional[Union[str, List[str]]]
The configured skills directory or directories.
float
The threshold passed to the dynamic loader.
List[Dict[str, str]]
Metadata for the skills loaded so far.
bool
Read-only.
True when at least one configured directory exists on disk.Skill format
Each skill is a folder containing aSKILL.md with YAML frontmatter:
SKILL.md
name in its frontmatter falls back to its folder name.
Methods
prompt_for_task
str
When provided, only skills whose description is similar to the task are loaded (dynamic). When
None, every skill is loaded (static)."" when nothing loaded. Populates metadata as a side effect.
- Dynamic
- Static
DynamicSkillsLoader, which scores each skill’s description against the task by cosine similarity and keeps those at or above similarity_threshold. The loader is built lazily on first use and reused afterwards, so it reads the skill directories once. Call set_skills_dir() to make it re-read them.load_metadata
name, description, path, and content. Defaults to the configured directories. A missing directory is logged and contributes nothing, so the result is [] when none exist. Within a directory, skill folders are read in sorted order. Across directories, a later skill replaces an earlier one with the same name.
build_prompt
"" for an empty list. The # Available Skills header is emitted exactly once, followed by each skill’s name, description, and body.
load_full_skill
metadata. Returns None when the skill is unknown or the file has since become unreadable.
set_skills_dir
metadata and the dynamic loader.
Agent integration
Skills are selected at
run() time, not construction. Each run(task) calls handle_skills(task) when skills_dir is set, so the selection follows the current task and replaces the previous one. agent.system_prompt never includes the skills.
Several directories
Pass a list to combine skill sets, for example your own skills and a shared team folder:code-review, the one in ./my_skills is used and a warning names the overridden file.
Standalone use
Related
Agent Skills
Guide to authoring and using skills
Agent
The class that owns the manager