pub struct Skill { /* private fields */ }Expand description
A complete Agent Skill, combining frontmatter and markdown body.
This is the main type for working with skills. It can be loaded from a SKILL.md file or constructed programmatically.
§Examples
use agent_skills::Skill;
// Parse from SKILL.md content
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"));Implementations§
Source§impl Skill
impl Skill
Sourcepub fn new(frontmatter: Frontmatter, body: impl Into<String>) -> Self
pub fn new(frontmatter: Frontmatter, body: impl Into<String>) -> Self
Creates a new skill with frontmatter and body.
§Examples
use agent_skills::{Skill, Frontmatter, SkillName, SkillDescription};
let name = SkillName::new("my-skill").unwrap();
let desc = SkillDescription::new("Does something.").unwrap();
let frontmatter = Frontmatter::new(name, desc);
let skill = Skill::new(frontmatter, "# Instructions\n\nDo this.");Sourcepub fn parse(content: &str) -> Result<Self, ParseError>
pub fn parse(content: &str) -> Result<Self, ParseError>
Parses a skill from SKILL.md content.
The content must start with --- (the YAML frontmatter delimiter),
followed by valid YAML, another --- delimiter, and then the
markdown body.
§Errors
Returns ParseError if:
- The content doesn’t start with
--- - The YAML frontmatter is invalid
- Required fields are missing or invalid
§Examples
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");Sourcepub const fn description(&self) -> &SkillDescription
pub const fn description(&self) -> &SkillDescription
Returns the skill description.
Sourcepub const fn frontmatter(&self) -> &Frontmatter
pub const fn frontmatter(&self) -> &Frontmatter
Returns the frontmatter.
Sourcepub fn body_trimmed(&self) -> &str
pub fn body_trimmed(&self) -> &str
Returns the body trimmed of leading/trailing whitespace.
Trait Implementations§
impl Eq for Skill
impl StructuralPartialEq for Skill
Auto Trait Implementations§
impl Freeze for Skill
impl RefUnwindSafe for Skill
impl Send for Skill
impl Sync for Skill
impl Unpin for Skill
impl UnwindSafe for Skill
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.