skill

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package skill provides skills: focused instructions for the model, optionally with resource files.

To save context, the system prompt only lists the skill catalog (names and summaries); when the model needs a skill it loads its full instructions with a tool, then reads its resource files as needed. A Source decides where skills come from: this package provides a local directory, an fs.FS and memory, and a database or remote service can implement the same interface. NewToolset turns a source into a toolset for an Agent.

Index

Constants

View Source
const (
	// LoadToolName is the name of the tool that loads skill instructions; ReadResourceToolName is the name of the tool that reads skill resource files.
	LoadToolName         = "load_skill"
	ReadResourceToolName = "read_skill_resource"
)

Variables

View Source
var ErrNotFound = errors.New("skill: not found")

ErrNotFound means the requested skill or resource does not exist or is not visible now.

Functions

func NewToolset

func NewToolset(src Source) tool.Toolset

NewToolset wraps a skill source as a toolset; add it to Agent.Toolsets to use it.

It appends the skill catalog to the system prompt and provides two tools: load_skill loads a skill's full instructions and resource list, and read_skill_resource reads one of the resource files. When the source has no visible skills, it provides no tools and no instructions.

Types

type Info

type Info struct {
	Name        string
	Description string
}

Info is a skill catalog entry visible to the model.

type Skill

type Skill struct {
	Name        string
	Description string
	// Instructions are the skill's full instructions, which only enter the context after the model loads the skill.
	Instructions string
	// Resources are the paths of the skill's resource files (relative to the skill root, separated by /); read their content with ReadResource.
	Resources []string
}

Skill is the complete content of a skill.

type Source

type Source interface {
	// List returns the skill catalog the model may currently see. It is called once at the start of each run.
	List(ctx context.Context) ([]Info, error)
	// Load returns the complete content of a skill, or ErrNotFound when it does not exist or is not visible.
	Load(ctx context.Context, name string) (Skill, error)
	// ReadResource reads one resource file of a skill, or returns ErrNotFound when it does not exist.
	ReadResource(ctx context.Context, name, path string) ([]byte, error)
}

Source is where skills come from. The business layer can implement it to apply permissions, publishing state or scenario filters, or to read from a database or object storage. Its methods may be called concurrently.

func Dir

func Dir(dir string) Source

Dir returns a source that reads skills from a local directory; see FS.

func FS

func FS(fsys fs.FS, root string) Source

FS returns a source that reads skills from an fs.FS, compatible with go:embed.

Every directory under root that contains a SKILL.md is a skill, and directories may be nested into groups. The frontmatter at the top of SKILL.md gives name and description (the directory name when there is no name), the rest is the skill's instructions, and the other files in the directory are its resources. Files are read again on every call, so changes take effect on the next run.

func Static

func Static(skills ...Skill) Source

Static returns a source made of skills in memory; on duplicate names the later one wins. These skills have no resource files.

Jump to

Keyboard shortcuts

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