Skip to main content

Crate skill_embed

Crate skill_embed 

Source
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.
ForceRequired
Every destination install left alone, and why the list is worth printing.
InstallOptions
The inputs shared by install, uninstall and list.
InstallResult
The outcome for one skill at one destination.
InstallStatus
The state of one skill at one destination.
InstallTarget
One destination directory and the agents that read from it.
Installer
Installs embedded skills into agent directories.
Skill
One embedded skill directory.
SkillSet
A collection of embedded skills, in name order.

Enums§

Action
What install or uninstall did at one destination.
AgentSelector
Names one agent, or a group of them, as --agent accepts 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 list prints: 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.