Expand description
Ship agent skills inside a Rust binary, and give that binary a
skill install command.
It is the reverse of gh skill install. A tool carries its own skills in
the executable, and writes them into the directory the user’s agent reads
from. The agent directories and the flag set are taken from
gh skill install, so a user who knows that command already knows this one.
Skills live under skills/<name>/SKILL.md, which is the layout defined by
the Agent Skills specification.
use std::process::ExitCode;
use std::sync::LazyLock;
use include_dir::{Dir, include_dir};
use skill_embed::{Installer, SkillSet};
static SKILLS_DIR: Dir<'static> = include_dir!("$CARGO_MANIFEST_DIR/skills");
static SKILLS: LazyLock<Installer> = LazyLock::new(|| {
Installer::new(SkillSet::from_include_dir(&SKILLS_DIR).expect("valid skills"))
.with_tool_name("mytool")
.with_version(env!("CARGO_PKG_VERSION"))
});
fn main() -> ExitCode {
if let Some(code) = SKILLS.intercept() {
return code;
}
// the rest of your tool
ExitCode::SUCCESS
}Installer::intercept gives a tool the skill subcommand in one line.
Installer::run is for a tool that parses its own arguments, and the
skill-embed-clap crate wires the same commands into
clap.
Modules§
- meta
- Frontmatter keys written into an installed
SKILL_FILE.
Structs§
- Agent
- A coding agent that reads skills from a known directory.
- File
- One file on its way into a
SkillSet. - Force
Required - Every destination install left alone, and why the list is worth printing.
- Install
Options - The inputs shared by install, uninstall and list.
- Install
Result - The outcome for one skill at one destination.
- Install
Status - The state of one skill at one destination.
- Install
Target - One destination directory and the agents that read from it.
- Installer
- Installs embedded skills into agent directories.
- Skill
- One embedded skill directory.
- Skill
Set - A collection of embedded skills, in name order.
Enums§
- Action
- What install or uninstall did at one destination.
- Agent
Selector - Names one agent, or a group of them, as
--agentaccepts it. - Error
- Everything this library refuses to do, and why.
- Scope
- Where skills are installed.
- State
- What is already present at a destination.
Constants§
- SKILL_
FILE - The manifest every skill directory must contain, as defined by the Agent Skills specification.
Functions§
- render_
results - Lists what install or uninstall did at each destination.
- render_
status - Everything
listprints: each skill once with its description, then a row per destination.
Type Aliases§
- Result
- The result of anything in this crate that can be refused.