Class SkillBuilder
Fluent builder for creating AgentSkill instances programmatically.
Use this builder when you need to create skills in code rather than loading them from SKILL.md files on disk.
public sealed class SkillBuilder
- Inheritance
-
SkillBuilder
- Inherited Members
Remarks
Usage
var skill = new SkillBuilder()
.WithName("code-review")
.WithDescription("Reviews code for bugs, security issues, and best practices.")
.WithInstructions(@"
# Code Review Guidelines
When reviewing code:
1. Check for security vulnerabilities
2. Verify error handling
3. Assess code style and readability
")
.WithLicense("MIT")
.WithAllowedTools("Read", "Grep", "Bash(git diff:*)")
.Build();
Methods
- AsMode(bool)
Marks this skill as a mode command.
- Build()
Builds the AgentSkill instance.
- DisableModelInvocation(bool)
Disables automatic model invocation for this skill.
When set, the skill can only be invoked explicitly via slash command.
- SaveToFile(string, bool)
Saves the skill to disk as a SKILL.md file.
- ToSkillMdContent()
Generates the SKILL.md content as a string.
- WithAgent(string)
Sets the preferred agent type for this skill.
- WithAllowedTools(string)
Sets the allowed tools for this skill.
- WithAllowedTools(params string[])
Sets the allowed tools for this skill.
- WithAuthor(string)
Sets the author in custom metadata.
- WithBasePath(string)
Sets the base path for resource discovery.
If set, resources will be discovered from this directory when the skill is built.
- WithCompatibility(string)
Sets the compatibility requirements.
- WithContext(string)
Sets the execution context for this skill.
- WithDescription(string)
Sets the skill description.
Required. This is the primary signal agents use to determine when to invoke the skill. Include clear activation triggers (e.g., "Use when...").
- WithInstructions(string)
Sets the skill instructions (the main body content).
- WithLicense(string)
Sets the skill license.
- WithMetadata(string, object)
Adds custom metadata.
- WithModel(string)
Sets the preferred model for this skill.
- WithName(string)
Sets the skill name.
Required. Max 64 characters. Lowercase letters, numbers, and hyphens only.
- WithTags(params string[])
Sets the tags in custom metadata.
- WithVersion(string)
Sets the skill version.