Skip to main content

SkillToolkit

class SkillToolkit(BaseToolkit):
Toolkit for loading SKILL.md content. Skills are discovered from filesystem roots and loaded on-demand.

init

def __init__(
    self,
    working_directory: Optional[str] = None,
    timeout: Optional[float] = None
):

_build_description

def _build_description(self):

_get_skills

def _get_skills(self):

clear_cache

def clear_cache(self):
Clear the cached skills to force rescanning on next access.

_scan_skills

def _scan_skills(self):
Returns: Dict[str, Dict[str, str]]: Mapping of skill name to metadata.

_skill_roots

def _skill_roots(self):
Returns: List[Tuple[str, Path]]: List of (scope, path) tuples.

_is_hidden_path

def _is_hidden_path(self, path: Path, root: Path):
Check if a path contains hidden directories (starting with dot). Parameters:
  • path (Path): The path to check.
  • root (Path): The root directory to compute relative path from.
Returns: bool: True if the path contains hidden directories.

_parse_skill

def _parse_skill(self, path: Path):
Parse a SKILL.md file and extract metadata. Parameters:
  • path (Path): Path to the SKILL.md file.
Returns: Optional[Dict[str, str]]: Parsed skill data with name, description, and body. Returns None if parsing fails.

_split_frontmatter

def _split_frontmatter(self, contents: str):
Split YAML frontmatter from the body of a SKILL.md file. Parameters:
  • contents (str): The full contents of the file.
Returns: Tuple[Optional[str], str]: A tuple of (frontmatter, body). frontmatter is None if no valid frontmatter delimiter is found.

list_skills

def list_skills(self):
Returns: List[Dict[str, str]]: Skill metadata entries including name, description, path, and scope.

list_skill_files

def list_skill_files(self, name: str):
List files and directories in a skill folder. Parameters:
  • name (str): The skill identifier.
Returns: str: Formatted list of files/directories, or error message.

_load_single_skill

def _load_single_skill(self, name: str):
Load a single skill by name. Parameters:
  • name (str): The skill identifier.
Returns: str: The skill content, or error message if not found.

get_skill

def get_skill(self, name: Union[str, List[str]]):
Load one or more skills by name. Parameters:
  • name (Union[str, List[str]]): A single skill name or list of names.
Returns: str: The skill content(s), or error message if not found.

get_tools

def get_tools(self):
Return the skill tools with injected available skills.