Class ClassPathSkillLoader

java.lang.Object
dev.langchain4j.skills.ClassPathSkillLoader

@Experimental public class ClassPathSkillLoader extends Object
Loads skills from the classpath.

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.

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.

  • Method Details

    • loadSkills

      public static List<FileSystemSkill> loadSkills(String directoryOnClasspath)
      Loads all skills found in immediate subdirectories of the given classpath directory. Uses the thread's context class loader.
      Parameters:
      directoryOnClasspath - the classpath directory whose immediate subdirectories are scanned for skills
      Returns:
      the list of loaded skills
    • loadSkills

      public static List<FileSystemSkill> loadSkills(String directoryOnClasspath, ClassLoader classLoader)
      Loads all skills found in immediate subdirectories of the given classpath directory.
      Parameters:
      directoryOnClasspath - the classpath directory whose immediate subdirectories are scanned for skills
      classLoader - the class loader to use
      Returns:
      the list of loaded skills
    • loadSkill

      public static FileSystemSkill loadSkill(String skillDirectoryOnClasspath)
      Loads a single skill from the given classpath directory. Uses the thread's context class loader.
      Parameters:
      skillDirectoryOnClasspath - the classpath path to the skill directory
      Returns:
      the loaded skill
    • loadSkill

      public static FileSystemSkill loadSkill(String skillDirectoryOnClasspath, ClassLoader classLoader)
      Loads a single skill from the given classpath directory.
      Parameters:
      skillDirectoryOnClasspath - the classpath path to the skill directory
      classLoader - the class loader to use
      Returns:
      the loaded skill