Table of Contents

Class SkillRegistry

Namespace
LMKit.Agents.Skills
Assembly
LM-Kit.NET.dll

Registry for AgentSkill instances that can be discovered and activated by agents.

The registry provides skill discovery, matching, and lifecycle management. It supports progressive disclosure by loading only metadata during discovery and full instructions on activation.

public sealed class SkillRegistry
Inheritance
SkillRegistry
Inherited Members

Remarks

Responsibilities

  • Registers and manages skill instances by name.
  • Discovers skills from filesystem directories.
  • Matches user requests to relevant skills.
  • Provides skill metadata for agent context injection.

Thread Safety
This class is thread-safe for concurrent reads and writes. Registration and removal operations are synchronized internally.

Typical Usage

var registry = new SkillRegistry();

// Load skills from a directory
int loaded = registry.LoadFromDirectory("./skills");

// Or register individual skills
var skill = AgentSkill.Load("./skills/pdf-processing");
registry.Register(skill);

// Find relevant skills for a user request
var matches = registry.FindMatches("Can you help me extract text from this PDF?");
foreach (var match in matches)
{
    Console.WriteLine($"{match.Skill.Name}: {match.Score:P0}");
}

// Get skill by name for slash commands
if (registry.TryGet("pdf-processing", out var pdfSkill))
{
    string instructions = pdfSkill.Instructions;
}

Constructors

SkillRegistry()

Initializes a new instance of the SkillRegistry class.

Properties

Count

Gets the number of skills currently registered.

Skills

Gets a read-only view of all skills currently registered.

Methods

Clear()

Removes all skills from the registry.

Contains(string)

Checks if a skill with the specified name is registered.

FindMatches(string, int, float)

Finds skills that match a user request based on description keywords.

This is a simple keyword-based matching implementation. For more sophisticated matching, consider using FindMatchesWithEmbeddings(string, Func<string, float[]>, int, float) with an embedding model.

FindMatchesWithEmbeddings(string, Func<string, float[]>, int, float)

Finds skills that match a user request using embedding-based semantic similarity.

Get(string)

Gets a skill by name.

GetDiscoveryContext()

Gets the discovery context for all registered skills.

This generates a compact summary of all skills suitable for injection into an agent's system prompt or tool description.

LoadAndRegister(string, bool)

Loads and registers a skill from a directory.

LoadAndRegisterAsync(string, bool, CancellationToken)

Asynchronously loads and registers a skill from a directory.

LoadFromDirectories(IEnumerable<string>, bool, Action<string, Exception>)

Loads skills from multiple directories.

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.

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.

LoadFromGitHubAsync(string, string, string, string, bool, CancellationToken)

Asynchronously loads and registers a skill from a GitHub repository.

LoadFromUrlAsync(string, bool, CancellationToken)

Asynchronously loads and registers a skill from a remote URL.

Register(AgentSkill, bool)

Registers a skill in the registry.

Remove(string)

Removes a skill from the registry.

TryGet(string, out AgentSkill)

Tries to get a skill by name.

TryParseSlashCommand(string, out AgentSkill, out string)

Parses a slash command and returns the matching skill.

ValidateAll(out IReadOnlyDictionary<string, IReadOnlyList<string>>)

Validates all registered skills.

Events

SkillRegistered

Occurs when a skill is registered.

SkillRemoved

Occurs when a skill is removed.