Method LoadFromDirectory
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
directoryPathstringThe path containing skill subdirectories.
overwriteboolWhether to overwrite existing skills.
errorHandlerAction<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
directoryPathisnull.- DirectoryNotFoundException
Thrown when the specified directory does not exist.