Guide: Implementing Skill Support in a New Client
Five steps turn a directory of Markdown files into skills a model can
actually use: discover, parse, disclose, activate, manage context.
Overview
The runtime's pipeline lives in src/skills/ with trust boundaries insrc/agents/memberLore.ts and budgeting in src/core/ContextCompressor.ts.
Implement the same five stages in order; each stage has one edge case that
breaks interop if ignored.
The 5 steps
1. Discover
Scan scopes with project-over-user precedence: project .agents/skills/,
user ~/.agents/skills/, plus .claude/skills/ and the bundled skills/
directory.
Edge case: match SKILL.md case-insensitively (skill.md from other clients)
and fall back to a lenient YAML parse for malformed frontmatter — strict-only
parsers silently drop third-party skills.
2. Parse
Split YAML frontmatter from body, enforce the contract: name matches the
directory (lowercase-hyphen), description states what and when.
Edge case: keep parse() permissive and enforce the spec in a separateverify gate — skills that fail strict parsing should warn, not vanish.
3. Disclose
Send the model names + descriptions (the catalog), never full bodies. Use
3-tier progressive disclosure: catalog first, full body only for the activated
skill.
Edge case: wrap activated content in explicit trust-boundary tags (seesrc/agents/memberLore.ts) so tool output can't impersonate instructions.
4. Activate
Resolve one skill per trigger: exact slash-command match first, model-driven
selection from the catalog second, deterministic name-collision rule with a
warning when two scopes provide the same name.
Edge case: permission narrowing — declared allowed-tools may only narrow the
skill's tool surface below its profile, never widen it.
5. Manage context
Track token spend per skill and compress or defer when the budget overflows
(see src/core/ContextCompressor.ts and src/core/TokenCounter.ts).
Edge case: protect activated skill content from context compaction — pruning
the active skill mid-run produces wrong output with no error.
Validation
Troubleshooting
- Skill missing: check scope precedence and filename case first.
- Model ignores skill:
descriptionlacks aUse when …trigger. - Privilege surprise: audit
allowed-toolsagainst the profile default. - Full troubleshooting: troubleshooting.
Further reading
- Agent Skills specification — upstream format
src/skills/discovery/SkillDiscovery.ts— discovery sourcesrc/skills/discovery/SkillParser.ts— parsing source