Class FileSystemSkillLoader
java.lang.Object
dev.langchain4j.skills.FileSystemSkillLoader
Loads skills from the file system.
Each skill must reside in its own directory containing a SKILL.md file.
The file must have a YAML front matter block that declares the skill's name
and description. The body of the file (below the front matter) becomes the
skill's content.
Example SKILL.md structure:
---
name: my-skill
description: Does something useful
---
Detailed instructions for the LLM go here.
Any additional files in the skill directory are loaded as SkillResources,
except SKILL.md itself and any files under a scripts/ subdirectory.
Empty files are silently skipped.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic FileSystemSkillLoads a single skill from the given directory.static List<FileSystemSkill> loadSkills(Path directory) Loads all skills found in immediate subdirectories of the given directory.
-
Constructor Details
-
FileSystemSkillLoader
public FileSystemSkillLoader()
-
-
Method Details
-
loadSkills
Loads all skills found in immediate subdirectories of the given directory. A subdirectory is treated as a skill only if it contains aSKILL.mdfile; subdirectories without one are silently skipped.- Parameters:
directory- the directory whose immediate subdirectories are scanned for skills- Returns:
- the list of loaded skills, in filesystem iteration order
- Throws:
RuntimeException- if the directory cannot be listed or a skill fails to load
-
loadSkill
Loads a single skill from the given directory. The directory must contain aSKILL.mdfile with a YAML front matter block declaring the skill'snameanddescription.- Parameters:
skillDirectory- the directory to load the skill from- Returns:
- the loaded skill
- Throws:
IllegalArgumentException- ifSKILL.mdis not found in the directoryRuntimeException- if the file cannot be read or resources cannot be loaded
-