pub struct Skill { /* private fields */ }Expand description
An agent skill: metadata shown in the system prompt up front, and instructions the agent loads
on demand through the skills tool (Skill).
Skills are directories holding a SKILL.md file: YAML frontmatter (name, description,
optional allowed-tools, metadata, license, compatibility) followed by the markdown
instructions.
use strands::vended_plugins::skills::{Skill, SkillLoadOptions};
let skill = Skill::from_content(
"---\nname: my-skill\ndescription: Does something useful\n---\n# Instructions\nFollow these steps...",
SkillLoadOptions::default(),
)?;
assert_eq!(skill.name(), "my-skill");
assert_eq!(skill.instructions(), "# Instructions\nFollow these steps...");Implementations§
Source§impl Skill
impl Skill
Sourcepub fn new(config: SkillConfig) -> Self
pub fn new(config: SkillConfig) -> Self
Creates a skill from its configuration (new Skill(config)); nothing is validated.
Sourcepub fn description(&self) -> &str
pub fn description(&self) -> &str
What the skill does.
Sourcepub fn instructions(&self) -> &str
pub fn instructions(&self) -> &str
The full markdown instructions; empty when there are none.
Sourcepub fn allowed_tools(&self) -> Option<&[String]>
pub fn allowed_tools(&self) -> Option<&[String]>
Tool names the skill may use (experimental, not enforced).
Sourcepub fn metadata(&self) -> &JsonObject
pub fn metadata(&self) -> &JsonObject
Additional frontmatter metadata.
Sourcepub fn compatibility(&self) -> Option<&str>
pub fn compatibility(&self) -> Option<&str>
The compatibility information.
Sourcepub fn from_file(
skill_path: impl AsRef<Path>,
options: SkillLoadOptions,
) -> Result<Self>
pub fn from_file( skill_path: impl AsRef<Path>, options: SkillLoadOptions, ) -> Result<Self>
Loads a skill from a directory holding SKILL.md (or skill.md), or from the SKILL.md
file itself. The skill’s path is the absolute skill directory.
§Errors
A path that is neither, a directory without SKILL.md, an unreadable file, or the
from_content errors, including the directory-name check in strict
mode.
Sourcepub fn from_content(content: &str, options: SkillLoadOptions) -> Result<Self>
pub fn from_content(content: &str, options: SkillLoadOptions) -> Result<Self>
Parses SKILL.md content (YAML frontmatter and markdown body) into a skill. In lenient
mode (the default) a name that breaks the naming rules logs a warning; strict mode fails
instead.
§Errors
Content without --- frontmatter delimiters, YAML that does not parse (after retrying
with unquoted colons quoted), a missing or empty name or description, or, in strict
mode, an invalid name.
Sourcepub async fn from_url(url: &str, options: SkillLoadOptions) -> Result<Self>
pub async fn from_url(url: &str, options: SkillLoadOptions) -> Result<Self>
Fetches raw SKILL.md content from an https:// URL and parses it. The
request sends User-Agent: strands-agents-sdk and times out after 30 seconds.
§Errors
A URL that is not https:// (url=<url> | not a valid HTTPS URL), an HTTP error status
(url=<url> | HTTP 404: Not Found), any other fetch failure
(url=<url> | failed to fetch skill: ..), or the from_content
errors.
Sourcepub fn from_directory(
skills_dir: impl AsRef<Path>,
options: SkillLoadOptions,
) -> Result<Vec<Self>>
pub fn from_directory( skills_dir: impl AsRef<Path>, options: SkillLoadOptions, ) -> Result<Vec<Self>>
Loads every skill in the subdirectories of skills_dir, in name order.
Subdirectories without SKILL.md are skipped; a skill that fails to load logs a warning
and is skipped.
§Errors
skills_dir is not a directory (path=<dir> | skills directory does not exist), or it
cannot be listed.
Trait Implementations§
Source§impl From<Skill> for SkillSource
impl From<Skill> for SkillSource
Source§impl From<SkillConfig> for Skill
impl From<SkillConfig> for Skill
Source§fn from(config: SkillConfig) -> Self
fn from(config: SkillConfig) -> Self
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 UnsafeUnpin 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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more