Class FileSystemSkillLoader

java.lang.Object
dev.langchain4j.skills.FileSystemSkillLoader

@Experimental public class FileSystemSkillLoader extends Object
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 Details

    • FileSystemSkillLoader

      public FileSystemSkillLoader()
  • Method Details

    • loadSkills

      public static List<FileSystemSkill> loadSkills(Path directory)
      Loads all skills found in immediate subdirectories of the given directory. A subdirectory is treated as a skill only if it contains a SKILL.md file; 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

      public static FileSystemSkill loadSkill(Path skillDirectory)
      Loads a single skill from the given directory. The directory must contain a SKILL.md file with a YAML front matter block declaring the skill's name and description.
      Parameters:
      skillDirectory - the directory to load the skill from
      Returns:
      the loaded skill
      Throws:
      IllegalArgumentException - if SKILL.md is not found in the directory
      RuntimeException - if the file cannot be read or resources cannot be loaded