Skills System
One-line summary
The skills system loads SKILL.md files from three sources (bundled, workspace, plugins), builds a catalog with hard token limits, and injects it into the system prompt so the agent can discover and use specialized capabilities.
Responsibilities
- Discover skills from bundled directory (52 skills), agent workspace, and plugin extensions
- Parse SKILL.md frontmatter for metadata (requirements, invocation policy, description)
- Build a skills catalog (name + description + path) for system prompt injection
- Enforce hard limits on catalog size (max 150 skills, max 30,000 chars)
- Compact skill paths (
~substitution) to save tokens - Support hot-reload via filesystem watchers and snapshot versioning
Architecture diagram
Key source files
Token optimization impact
Hard limits (workspace.ts:95-98)
Token budget breakdown
Key optimization: catalog only, not full content
The system prompt contains only the catalog (name + description + file path), not the full SKILL.md content. The agent reads the full SKILL.md only when it selects a specific skill. This is a critical design decision that keeps the fixed token cost manageable.
Prompt instruction overhead
disableModelInvocation frontmatter flag
Skills with disable-model-invocation: true are excluded from the model-facing catalog but remain available for user-invoked slash commands. This reduces catalog size for skills that should only be triggered explicitly.
Data flow
Loading
Runtime selection
How it connects to other modules
-
Depends on:
config/— skill settings, bundled allowlist- File system — SKILL.md discovery and watching
-
Depended by:
system-prompt.ts— receives skill prompt for injectionpi-embedded-runner/— receives skills snapshotauto-reply/skill-commands.ts— user-invoked skill commands
My blind spots
- Exact binary search algorithm in
applySkillsPromptLimits()— how it prioritizes which skills to include - Whether workspace skills override bundled skills with the same name
-
tools-dir.tsvsbundled-dir.ts— different discovery strategies - Skill snapshot caching behavior and invalidation triggers
- How plugin-provided skills are registered and discovered
Related contributions
- None yet
Change frequency
workspace.ts: Medium — limits tuning and loading logic evolverefresh.ts: Low — watcher pattern is stablefrontmatter.ts: Low — metadata schema is additiveconfig.ts: Low — eligibility checks rarely change