👉 Try the demo: https://github.com/LM-Kit/lm-kit-net-samples/tree/main/console_net/agents/skill_based_assistant
Skill-Based Assistant for C# .NET Applications
🎯 Purpose of the Demo
This demo shows how Agent Skills transform a generic LLM into task-specific specialists using simple markdown files. No code changes needed: just drop a SKILL.md file into a folder and the assistant gains a new capability.
Critically, this demo teaches two different ways to activate skills, selectable at startup:
| Mode | How It Works | Best For |
|---|---|---|
| Manual (SkillActivator) | You type slash commands (/explain, /off). The app injects skill instructions into messages. |
Predictable apps, menu-driven UIs |
| Model-driven (SkillTool) | A SkillTool is registered as a function. The model discovers and activates skills autonomously. |
Autonomous agents, conversational UIs |
Three bundled skills demonstrate the concept. Each works from a single line of input:
| Skill | You Type | You Get |
|---|---|---|
/explain |
"blockchain" | Clear, jargon-free explanation with analogy and real-world example |
/pros-cons |
"electric cars" | Balanced pros, cons, and a bottom-line summary |
/email-writer |
"thank a vendor for fast delivery" | Complete professional email with subject line |
👥 Who Should Use This Demo
- Product teams who want to give their assistants specialized behaviors without prompt engineering.
- Developers building applications where end users need different "modes" for different tasks.
- Anyone interested in reusable, shareable AI instruction sets.
🚀 What Problem It Solves
Writing good system prompts is hard and they are buried in code. Agent Skills solve this by:
- Externalizing instructions into standalone SKILL.md files anyone can read and edit.
- Making skills reusable across projects and teams.
- Enabling non-developers to create and modify AI behavior by editing a markdown file.
💻 Two Activation Modes Explained
Understanding how skills get activated is the key to using them effectively. LM-Kit supports two distinct patterns:
Mode 1: Manual Activation (SkillActivator + slash commands)
Your application controls the entire lifecycle. The user picks a skill, your code injects its instructions into the conversation, and the model follows them.
How it works:
- Load skills into a
SkillRegistry. - Create a
SkillActivatorfrom the registry. - When the user types
/explain, look up the skill and callFormatForInjection(). - Prepend the formatted instructions to the user's message.
- Send the combined prompt to the model.
var registry = new SkillRegistry();
registry.LoadFromDirectory("./skills");
var activator = new SkillActivator(registry);
// When user activates /explain and types "blockchain":
string instructions = activator.FormatForInjection(skill, SkillInjectionMode.UserMessage);
string prompt = instructions + "\n\n---\n\nUser request: blockchain";
var result = chat.Submit(prompt);
The model never knows skills exist. It simply receives enriched prompts containing the skill's instructions. This gives you full control over when and how skills are used.
Mode 2: Model-Driven Activation (SkillTool + function calling)
The model controls skill activation. You register a SkillTool as a callable function, and the model decides when to activate a skill based on the user's request.
How it works:
- Load skills into a
SkillRegistry. - Create a
SkillToolfrom the registry and register it on the conversation. - The tool's description dynamically lists all available skills.
- When the user says "explain what blockchain is", the model calls
activate_skill("explain"). - The tool returns the skill's full instructions, and the model follows them.
var registry = new SkillRegistry();
registry.LoadFromDirectory("./skills");
chat.Tools.Register(new SkillTool(registry));
// No slash commands needed. Just chat naturally:
var result = chat.Submit("explain what blockchain is");
// The model calls activate_skill internally, gets instructions, and responds.
The model discovers skills on its own. This is ideal for autonomous agents and conversational interfaces where you want the AI to choose the right skill for the job.
Side-by-Side Comparison
| Aspect | Manual (SkillActivator) | Model-Driven (SkillTool) |
|---|---|---|
| Who activates? | User via slash commands | Model via function calling |
| Key class | SkillActivator |
SkillTool |
| Requires tool calling? | No | Yes |
| Model awareness | Model sees enriched prompts | Model sees available tools |
| Control level | Full application control | Model decides autonomously |
| Best for | Menu-driven apps, predictable output | Agents, chat UIs, autonomous workflows |
✨ Key Features
- Zero-code skill creation: add a SKILL.md file, restart, done.
- Two activation patterns: manual control or autonomous model-driven discovery.
- Slash command activation (manual mode): type
/explainto switch modes instantly. - Function calling activation (model-driven mode): model activates skills on its own.
- Multi-turn context: skill instructions persist across the entire conversation.
- Clean separation: skills live in files, not in your source code.
💡 Example Usage
Manual Activation Mode
You: /explain
Skill activated: explain
You: machine learning
Assistant:
## Machine Learning
**In one sentence:** Machine learning is a way for computers to learn
patterns from data instead of being explicitly programmed.
**How it works:** Think of it like teaching a child to recognize dogs.
You show them thousands of pictures labeled "dog" or "not dog," and
eventually they figure out the pattern on their own.
**Why it matters:** It powers everything from spam filters to medical
diagnosis, letting computers handle tasks that are too complex for
traditional rules.
**Example:** When Netflix suggests a show, a machine learning model
analyzed your viewing history to predict your preferences.
Model-Driven Activation Mode
You: explain what blockchain is
[SkillTool] Model activated skill: explain
Assistant:
## Blockchain
**In one sentence:** A blockchain is a shared digital ledger that records
transactions in a way no single person can alter.
...
🏗️ Architecture
skills/ Your Application
├── explain/ ┌───────────────────────────┐
│ └── SKILL.md ──────────> │ SkillRegistry │
├── pros-cons/ │ ↓ │
│ └── SKILL.md ──────────> │ SkillActivator (manual) │
└── email-writer/ │ SkillTool (model-driven) │
└── SKILL.md ──────────> │ ↓ │
│ MultiTurnConversation │
└───────────────────────────┘
⚙️ Getting Started
📋 Prerequisites
- .NET 8.0 or later
- 4 to 16 GB VRAM depending on model choice
📥 Download
git clone https://github.com/LM-Kit/lm-kit-net-samples.git
cd lm-kit-net-samples/console_net/agents/skill_based_assistant
▶️ Run
dotnet run
🔧 Creating Your Own Skill
- Create a folder under
skills/(e.g.skills/my-skill/). - Add a
SKILL.mdfile with YAML frontmatter (name,description) and markdown instructions. - Restart the demo. Your skill appears automatically in both activation modes.