Skip to main content

Module skills

Module skills 

Source
Expand description

Progressive-disclosure skill discovery for .claude/skills/ (#2069, vision spec §5.3, Resolved Decision #7).

Why: A skill catalog’s full Markdown bodies cost far more tokens than the PM/agents need up front — most skills in a session are never invoked. Splitting discovery into cheap, always-cached metadata (name + description) and an on-demand-loaded body is the token-efficiency layer P1B wires into prompt::assemble_system_prompt_for_mode’s DailyDriver arm. What: SkillMetadata, locate_skills_dir (.claude/skills, the Claude-Code-compatible path), discover_skill_metadata, load_skill_body (the lazy on-invoke loader), format_skill_catalog (prompt-injection rendering), and FsSkillResolver (the concrete tools::SkillResolver impl the use_skill tool is built on). Test: skills::tests::*. Progressive-disclosure skill discovery for .claude/skills/ (#2069, vision spec §5.3, Resolved Decision #7).

Why: A project’s .claude/skills/ catalog can hold dozens of skills, but any given task only ever invokes a handful of them. Injecting every skill’s full Markdown body into the system prompt up front wastes 500-1000+ tokens per session for a 20-skill catalog (spec §5.3 impact estimate) when ~80% of skills are never invoked. Splitting a skill into cheap, always-cached metadata (name + one-line description, ~100 tokens per skill) and an on-demand-loaded body lets the PM/agents see the full catalog for free and pay the body’s token cost only for skills they actually use. This module mirrors agents::discover_agents’s directory scanning pattern, adapted for the Claude-Code skill layout: one subdirectory per skill, each holding a SKILL.md with YAML-ish frontmatter (name:, description:, …) followed by the Markdown body. What: SkillMetadata (the cached catalog entry), locate_skills_dir (resolves <project_root>/.claude/skills — the Claude-Code-compatible path; deliberately NOT ~/.trusty-mpm/skills/), discover_skill_metadata (scans the directory and parses just the frontmatter of every skill), load_skill_body (the lazy, on-invoke full-body loader), and format_skill_catalog (renders the metadata list for prompt injection). FsSkillResolver implements tools::traits::SkillResolver over this discovery layer, giving the tool-registry layer a ready-to-register concrete resolver. discover_skill_metadata falls back to crate::assets::DEFAULT_SKILLS (#2895) when the disk directory has no skills — a project with no .claude/skills/ (or an empty one) still gets trusty-mpm’s universal skill catalog. A disk directory with even one skill is used as-is (never merged with the embedded set) — disk always wins. Test: skills::tests::* — discovery over tempdir fixtures (happy path, missing dir, missing SKILL.md, malformed/no-frontmatter file), lazy body load (found + unknown-name), catalog formatting (empty + populated), embedded-fallback threshold, and FsSkillResolver’s SkillResolver trait conformance.

Modules§

protocol
skills.* JSON-RPC methods — the daemon’s SKILL CATALOG management surface (issue #3449), backing the Foundry GUI’s Skills management tab.

Structs§

FsSkillResolver
Filesystem-backed SkillResolver over a .claude/skills/ directory.
SkillMetadata
Cheap, always-cached catalog entry for one discovered skill.

Enums§

SkillError
Errors from lazily loading a skill’s full body.

Functions§

discover_skill_metadata
Discover skill metadata from every <dir>/<skill-name>/SKILL.md.
format_skill_catalog
Render the compact, always-injected skill catalog for prompt assembly.
load_skill_body
Lazily load one skill’s full Markdown body (the frontmatter stripped off).
locate_skills_dir
Locate the Claude-Code-compatible skills directory for a project root.