Table of Contents

Method LoadFromDirectory

Namespace
LMKit.Agents.Skills
Assembly
LM-Kit.NET.dll

LoadFromDirectory(string, bool, Action<string, Exception>)

Loads all skills from subdirectories of the specified path.

Each immediate subdirectory is checked for a SKILL.md file. Invalid skills are skipped and logged via errorHandler.

public int LoadFromDirectory(string directoryPath, bool overwrite = false, Action<string, Exception> errorHandler = null)

Parameters

directoryPath string

The path containing skill subdirectories.

overwrite bool

Whether to overwrite existing skills.

errorHandler Action<string, Exception>

Optional callback for handling parse errors. If null, errors are silently ignored.

Returns

int

The number of skills successfully loaded.

Examples

Loading all skills from a directory with error handling:

var registry = new SkillRegistry();

// Basic loading
int loaded = registry.LoadFromDirectory("./skills");
Console.WriteLine($"Loaded {loaded} skills");

// With error handling
loaded = registry.LoadFromDirectory("./skills", errorHandler: (path, ex) =>
{
    Console.WriteLine($"Failed to load {path}: {ex.Message}");
});

Exceptions

ArgumentNullException

Thrown when directoryPath is null.

DirectoryNotFoundException

Thrown when the specified directory does not exist.