skill

package
v0.2.75 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 18, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package skill loads SKILL.md capability bundles from disk and exposes them to an agent.

A skill is a folder holding a SKILL.md whose YAML frontmatter carries at least a name and a description, followed by markdown instructions and optional bundled resources:

skills/
  incident-triage/
    SKILL.md
    runbook.md
    queries/slow-requests.sql

Progressive disclosure

Only each skill's name and description sit in the model's context. The instructions load when the model chooses a skill and calls load_skill. That property is the whole point: twenty skills cost twenty one-line descriptions rather than twenty documents, so a large library stays affordable.

What this package will not do

It does not execute anything. A skill is instructions and reference material; bundled files are read, never run. A format that silently executes code from a folder someone cloned is a supply-chain problem, and loading a skill is not a decision a user makes consciously enough to carry that risk.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Tools

func Tools(lib *Library) []interfaces.Tool

Tools returns the tools that expose a library to a model.

Two tools, deliberately: one to read a skill's instructions, one to read a bundled file. Registering a tool per skill instead would put every skill's full schema in context on every request, which is exactly the cost progressive disclosure exists to avoid.

Types

type Library

type Library struct {
	// contains filtered or unexported fields
}

Library is a set of loaded skills.

func LoadDir

func LoadDir(root string) (*Library, error)

LoadDir loads every skill under root.

A directory containing a SKILL.md is a skill. Directories are walked one level deep, which matches how skill collections are laid out in practice and avoids surprising recursion into unrelated trees.

func NewLibrary

func NewLibrary() *Library

NewLibrary creates an empty library.

func (*Library) Add

func (l *Library) Add(s *Skill) error

Add puts a skill in the library, replacing any skill of the same name.

func (*Library) Catalog

func (l *Library) Catalog() string

Catalog renders the name-and-description index that sits in the model's context.

This is the entire context cost of a skill library until one is invoked.

func (*Library) Get

func (l *Library) Get(name string) (*Skill, bool)

Get returns a skill by name.

func (*Library) Len

func (l *Library) Len() int

Len returns how many skills are loaded.

func (*Library) List

func (l *Library) List() []*Skill

List returns every skill, in load order.

func (*Library) LoadDir

func (l *Library) LoadDir(root string) error

LoadDir adds every skill under root to the library.

type Skill

type Skill struct {
	// Name identifies the skill to the model. Required.
	Name string `yaml:"name"`

	// Description tells the model when to use it. Required, and the only part
	// besides the name that is always in context -- so it is what determines
	// whether the skill is ever chosen.
	Description string `yaml:"description"`

	// Version is optional metadata.
	Version string `yaml:"version,omitempty"`

	// Tags are optional grouping labels.
	Tags []string `yaml:"tags,omitempty"`

	// Instructions is the markdown body, loaded on demand.
	Instructions string `yaml:"-"`

	// Dir is the skill's directory on disk.
	Dir string `yaml:"-"`

	// Resources are the bundled files, relative to Dir.
	Resources []string `yaml:"-"`
}

Skill is one loaded capability bundle.

func LoadFile

func LoadFile(path string) (*Skill, error)

LoadFile loads a single SKILL.md.

func Parse

func Parse(content string) (*Skill, error)

Parse reads a SKILL.md's frontmatter and body.

func (*Skill) ReadResource

func (s *Skill) ReadResource(name string) (string, error)

ReadResource returns a bundled file's contents.

The path is confined to the skill's directory: a resource name that escapes it, by traversal or symlink, is refused. A skill folder arrives by git clone, so treating its contents as trusted paths would let one read arbitrary files off the host.

func (*Skill) Validate

func (s *Skill) Validate() error

Validate reports whether a skill is usable.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL