Method LoadFromDirectoryAsync
LoadFromDirectoryAsync(string, bool, Action<string, Exception>, CancellationToken)
Asynchronously 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 Task<int> LoadFromDirectoryAsync(string directoryPath, bool overwrite = false, Action<string, Exception> errorHandler = null, CancellationToken cancellationToken = default)
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.cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- Task<int>
A task that represents the asynchronous operation, containing the number of skills successfully loaded.
Examples
Asynchronously loading all skills from a directory:
var registry = new SkillRegistry();
int loaded = await registry.LoadFromDirectoryAsync("./skills");
Console.WriteLine($"Loaded {loaded} skills asynchronously");
Exceptions
- ArgumentNullException
Thrown when
directoryPathisnull.- DirectoryNotFoundException
Thrown when the specified directory does not exist.
- OperationCanceledException
Thrown when the operation is cancelled.