pig/skill

Skill loading and parsing.

A Skill is a directory on disk containing a SKILL.md file with YAML frontmatter (name + description) and a markdown body.

Frontmatter parsing is deliberately simple: split on --- delimiters, extract name and description fields from the YAML-like block. No full YAML parser needed.

Types

Parsed frontmatter fields and remaining body.

pub type Frontmatter {
  Frontmatter(name: String, description: String, body: String)
}

Constructors

  • Frontmatter(name: String, description: String, body: String)

A loaded skill with its metadata.

pub type Skill {
  Skill(
    name: String,
    description: String,
    path: String,
    files: List(String),
  )
}

Constructors

  • Skill(
      name: String,
      description: String,
      path: String,
      files: List(String),
    )

Errors that can occur during skill loading.

pub type SkillError {
  SkillNotFound
  InvalidFrontmatter
}

Constructors

  • SkillNotFound
  • InvalidFrontmatter

Values

pub fn load(path: String) -> Result(Skill, SkillError)

Load a skill from a directory path.

Reads SKILL.md from the directory, parses frontmatter for name/description, and lists supplementary files (everything except SKILL.md).

pub fn parse_frontmatter(
  raw: String,
) -> Result(Frontmatter, SkillError)

Parse frontmatter from a SKILL.md content string.

Expects ---\n at start, content between delimiters, and closing ---\n. Extracts name: and description: fields. Returns remaining body after the closing delimiter.

This is a simple parser — not a full YAML parser. It handles:

  • key: value lines
pub fn skill_to_system_fragment(skill: Skill) -> String

Generate a system prompt fragment from a skill.

Used to inject skill descriptions into the system prompt so the agent knows what skills are available.

Search Document