Discovery¶
Functions for skill discovery.
validate_skill_dir
¶
Validate a directory as a skill directory.
A valid skill directory must contain a SKILL.md file with a valid name and description in its frontmatter.
Cosmetic issues (e.g. name/directory mismatch) are returned as warnings so the skill is still loaded. Fatal issues (e.g. missing SKILL.md, unparseable frontmatter) are raised as errors so the caller can skip the skill and emit a SkillSkippedWarning.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dir
|
Path
|
Path to the directory to validate. |
required |
Returns:
| Type | Description |
|---|---|
tuple[SkillFrontmatter, list[SkillValidationWarning]]
|
Tuple[SkillFrontmatter, list[SkillValidationWarning]]: A pair where the first element is the validated skill metadata, and the second element is a list of warnings for cosmetic issues. An empty list means no issues. |
Raises:
| Type | Description |
|---|---|
SkillValidationError
|
If the skill directory has a fatal issue that prevents the skill from being loaded. |
Source code in src/llm_agents_from_scratch/skills/discovery.py
discover_skills
¶
Scan directories for skills across the provided scopes.
Scopes are processed in the order given — on name collision, the last
scope wins. To give SkillScope.PROJECT priority over SkillScope.USER,
pass them as [SkillScope.USER, SkillScope.PROJECT].
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
scopes
|
list[SkillScope]
|
The scopes to scan, in processing order. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Skill]
|
dict[str, Skill]: Discovered skills keyed by name, deduplicated with last-scope precedence. |