Method LoadAsync
LoadAsync(string, CancellationToken)
Asynchronously loads an Agent Skill from a directory containing a SKILL.md file.
public static Task<AgentSkill> LoadAsync(string skillPath, CancellationToken cancellationToken = default)
Parameters
skillPathstringThe path to the skill directory. Must contain a SKILL.md file.
cancellationTokenCancellationTokenA token to cancel the operation.
Returns
- Task<AgentSkill>
A task that represents the asynchronous operation, containing the loaded Agent Skill.
Examples
Asynchronous loading with cancellation support:
var cts = new CancellationTokenSource(TimeSpan.FromSeconds(10));
var skill = await AgentSkill.LoadAsync("./skills/code-review", cts.Token);
Console.WriteLine($"Loaded: {skill.Name}");
Exceptions
- ArgumentNullException
Thrown when
skillPathisnull.- DirectoryNotFoundException
Thrown when the specified directory does not exist.
- FileNotFoundException
Thrown when SKILL.md is not found in the specified directory.
- SkillParseException
Thrown when the SKILL.md file cannot be parsed.
- OperationCanceledException
Thrown when the operation is cancelled.