Skills¶
AgentSkills.io-compatible packaged instruction bundles (SKILL.md
files) that agents load on demand via progressive disclosure:
- L1: the skill catalog (names + descriptions) appears in the system prompt.
- L2: the agent activates a skill — full instructions are loaded.
- L3: the agent reads supporting resource files (
scripts/,references/,assets/).
Attach via AgentConfig.skills=[skill_or_path, ...].
Skill
dataclass
¶
Skill(name: str, description: str, instructions: str = '', path: Path | None = None, allowed_tools: list[str] | None = None, metadata: dict[str, Any] = dict(), license: str | None = None, compatibility: str | None = None)
A skill — packaged instructions for an agent.
Skills follow the AgentSkills.io specification.
Example
skill = Skill( ... name="code-review", ... description="Review code for quality and security issues.", ... instructions="# Code Review\n1. Check error handling...", ... )
Load from filesystem¶
skill = Skill.from_file(Path("./skills/code-review"))
from_file
classmethod
¶
Load a skill from a directory containing SKILL.md.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path | str
|
Path to skill directory or SKILL.md file. |
required |
Returns:
| Type | Description |
|---|---|
Skill
|
Loaded Skill instance. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If SKILL.md not found. |
ValueError
|
If required fields missing. |
Source code in src/locus/skills/models.py
from_content
classmethod
¶
Parse a skill from raw SKILL.md content.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
str
|
Raw SKILL.md file content. |
required |
path
|
Path | None
|
Optional filesystem path for resource resolution. |
None
|
Returns:
| Type | Description |
|---|---|
Skill
|
Parsed Skill instance. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If required fields (name, description) missing. |
Source code in src/locus/skills/models.py
from_directory
classmethod
¶
Load all skills from a parent directory.
Scans subdirectories for SKILL.md files.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
Path | str
|
Parent directory containing skill subdirectories. |
required |
Returns:
| Type | Description |
|---|---|
list[Skill]
|
List of loaded skills. |
Source code in src/locus/skills/models.py
list_resources ¶
List resource files from scripts/, references/, assets/ directories.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
max_files
|
int
|
Maximum number of files to list. |
20
|
Returns:
| Type | Description |
|---|---|
list[str]
|
List of relative file paths. |
Source code in src/locus/skills/models.py
SkillsPlugin ¶
Bases: Plugin
Plugin that provides AgentSkills.io skill discovery and activation.
Injects a compact XML catalog of available skills into the system prompt.
Registers a skills tool that the agent calls to load full instructions.
Example
from locus.skills import Skill, SkillsPlugin
plugin = SkillsPlugin( ... skills=[ ... Skill.from_file("./skills/code-review"), ... Skill( ... name="summarize", description="Summarize text", instructions="..." ... ), ... ] ... )
agent = Agent( ... config=AgentConfig( ... model=model, ... plugins=[plugin], ... ) ... )
Initialize with skill sources.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
skills
|
list[Skill | str | Path]
|
List of Skill instances, paths to skill directories, or paths to parent directories containing skills. |
required |
max_resource_files
|
int
|
Max resource files to list per skill. |
20
|
Source code in src/locus/skills/plugin.py
activated_skills
property
¶
Get list of activated skill names (most recent last).
on_before_model_call
async
¶
Inject skills catalog XML into messages before model call.
Source code in src/locus/skills/plugin.py
get_activation_tool ¶
Create the skills activation tool.
Returns a Tool that the agent calls to load skill instructions.
Source code in src/locus/skills/plugin.py
get_hooks ¶
Discover all @hook decorated methods.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dict mapping hook method names to bound methods. |
Source code in src/locus/hooks/plugin.py
get_tools ¶
Discover all @tool decorated methods.
Returns:
| Type | Description |
|---|---|
list[Any]
|
List of Tool instances found on the plugin. |
Source code in src/locus/hooks/plugin.py
init_agent ¶
Called when plugin is attached to an agent.
Override to perform setup that requires the agent instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
agent
|
Any
|
The agent this plugin is being attached to. |
required |