Class AgentSkill
Represents an Agent Skill - a modular capability that extends an agent's functionality with specialized knowledge, workflows, and resources.
Agent Skills follow the Agent Skills specification, packaging instructions, metadata, and optional resources (scripts, templates) that agents use automatically when relevant.
public sealed class AgentSkill
- Inheritance
-
AgentSkill
- Inherited Members
Examples
Loading a skill from disk:
var skill = AgentSkill.Load("./skills/pdf-processing");
Console.WriteLine($"Loaded skill: {skill.Name}");
Console.WriteLine($"Description: {skill.Description}");
// Instructions are loaded on first access
string instructions = skill.Instructions;
// Resources are loaded on demand
foreach (var resource in skill.GetResources(SkillResourceType.Script))
{
string code = resource.GetContent();
}
Remarks
Skill Structure
A skill is a directory containing at minimum a SKILL.md file with YAML frontmatter
(metadata) followed by Markdown content (instructions). Optional directories include:
scripts/- Executable code that agents can run.references/- Additional documentation agents can read when needed.assets/- Templates, images, or data files.
Progressive Disclosure
Skills implement progressive disclosure for efficient context management:
- Discovery: Only Name and Description are loaded initially.
- Activation: Full Instructions are loaded when the skill is invoked.
- Execution: Resources are loaded on-demand as needed.
Thread Safety
This class is thread-safe for concurrent reads after construction.
Resource content loading is synchronized internally.
Properties
- BasePath
Gets the absolute path to the skill directory.
- Description
Gets a description of what this skill does and when to use it.
This is the primary signal agents use to determine when to invoke the skill. Keep it action-oriented and specific about activation triggers.
- DisableModelInvocation
Gets a value indicating whether automatic model invocation is disabled for this skill.
- Instructions
Gets the Markdown instructions from the body of the SKILL.md file.
These instructions are loaded on first access and cached for subsequent calls. The full instruction content is what the agent receives when the skill is activated.
- IsFullyLoaded
Gets a value indicating whether this skill has been fully loaded, including instructions and resources.
- IsMode
Gets a value indicating whether this skill is a "mode command" that modifies agent behavior.
- License
Gets the license for this skill, if specified.
- Metadata
Gets the full metadata from the SKILL.md frontmatter.
- Name
Gets the unique identifier for this skill.
Lowercase letters, numbers, and hyphens only. Max 64 characters. This value is used to reference the skill in slash commands (e.g.,
/pdf-processing).
- Resources
Gets all resources bundled with this skill.
Resources are discovered on first access and cached. Content of individual resources is loaded on demand via GetContent(Encoding).
- Version
Gets the version of this skill, if specified.
Methods
- GetAllowedTools()
Gets the allowed tools list parsed from metadata.
- GetResource(string)
Gets a resource by its relative path.
- GetResources(SkillResourceType)
Gets resources of a specific type.
- HasResource(string)
Checks if a resource exists at the specified relative path.
- Load(string)
Loads an Agent Skill from a directory containing a SKILL.md file.
- LoadAsync(string, CancellationToken)
Asynchronously loads an Agent Skill from a directory containing a SKILL.md file.
- ToString()
Returns the skill name.
- TryLoad(string, out AgentSkill)
Tries to load an Agent Skill from a directory.
- Validate(out IReadOnlyList<string>)
Validates this skill according to the Agent Skills specification.