Expand description
Parse, validate, and work with Agent Skills.
This crate provides types and functions for working with Agent Skills as defined by the Agent Skills specification.
§Overview
Agent Skills are directories containing a SKILL.md file with YAML frontmatter
and markdown instructions. This crate handles:
- Parsing
SKILL.mdfiles (frontmatter + markdown body) - Validating skills against the specification
- Loading skills from directories
- Accessing skill metadata, instructions, and referenced files
§Quick Start
§Parsing a SKILL.md file
use agent_skills::Skill;
let content = r#"---
name: my-skill
description: Does something useful.
---
Follow these steps...
"#;
let skill = Skill::parse(content).unwrap();
assert_eq!(skill.name().as_str(), "my-skill");
assert!(skill.body().contains("# Instructions"));§Loading a skill from a directory
use agent_skills::SkillDirectory;
use std::path::Path;
let dir = SkillDirectory::load(Path::new("./my-skill")).unwrap();
println!("Loaded skill: {}", dir.skill().name());
// Access optional directories
if dir.has_scripts() {
for script in dir.scripts().unwrap() {
println!("Script: {}", script.display());
}
}§Creating skills programmatically
use agent_skills::{Skill, Frontmatter, SkillName, SkillDescription, Metadata};
let name = SkillName::new("my-skill").unwrap();
let desc = SkillDescription::new("Does something useful.").unwrap();
let frontmatter = Frontmatter::builder(name, desc)
.license("MIT")
.metadata(Metadata::from_pairs([("author", "example")]))
.build();
let skill = Skill::new(frontmatter, "# Instructions\n\nDo this.");§Types
Skill- A complete skill with frontmatter and bodyFrontmatter- The YAML frontmatter headerSkillName- A validated skill nameSkillDescription- A validated skill descriptionCompatibility- Environment compatibility requirementsMetadata- Arbitrary key-value metadataAllowedTools- Pre-approved tool list (experimental)SkillDirectory- A loaded skill directory with file access
§Errors
ParseError- Errors when parsing SKILL.md contentLoadError- Errors when loading skill directoriesSkillNameError- Invalid skill nameSkillDescriptionError- Invalid skill descriptionCompatibilityError- Invalid compatibility string
Structs§
- Allowed
Tools - A space-delimited list of pre-approved tools.
- Compatibility
- An optional compatibility string describing environment requirements.
- Frontmatter
- The YAML frontmatter of a SKILL.md file.
- Frontmatter
Builder - Builder for constructing
Frontmatterwith optional fields. - Metadata
- Arbitrary key-value metadata for additional properties.
- Skill
- A complete Agent Skill, combining frontmatter and markdown body.
- Skill
Description - A validated skill description.
- Skill
Directory - A loaded skill directory containing the skill and its files.
- Skill
Name - A validated skill name.
Enums§
- Compatibility
Error - Error returned when a compatibility string is invalid.
- Load
Error - Error returned when loading a skill from a directory fails.
- Parse
Error - Error returned when parsing a SKILL.md file fails.
- Skill
Description Error - Error returned when a skill description is invalid.
- Skill
Name Error - Error returned when a skill name is invalid.