Help us shape the future of Go! Take the 2026 Go Developer Survey

skills

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package skills discovers Agent Skills (folders holding a SKILL.md) in the project's and the user's .agents/skills directories, renders the catalog added to the system prompt, and loads a skill's instructions or one of its bundled files for the skill tool.

Index

Constants

View Source
const (
	// MaxSkillFileBytes caps how much of a SKILL.md or bundled file is read.
	MaxSkillFileBytes = 1 << 20
	// MaxCatalogChars caps the catalog section in the system prompt.
	MaxCatalogChars = 8000

	// MaxListedFiles caps the bundled file list in a skill's result.
	MaxListedFiles = 100
)

Bounds.

View Source
const (
	ScopeProject = "project"
	ScopeUser    = "user"
	ScopePlugin  = "plugin"
)

Scopes.

View Source
const ContentPrefix = "<skill_content name=\""

ContentPrefix starts every successful instructions result.

View Source
const ToolName = "skill"

ToolName is the tool that loads a skill.

Variables

This section is empty.

Functions

func ProjectDirs

func ProjectDirs(root string) []string

ProjectDirs returns the .agents/skills directories to scan for root, nearest first: root and each parent up to the repository root (the nearest directory containing .git), or root alone when there is no .git above it.

func UserDir

func UserDir() string

UserDir returns $HOME/.agents/skills (%USERPROFILE%\.agents\skills on Windows), or "" when the home directory is unknown.

Types

type PluginSource added in v0.9.0

type PluginSource struct {
	Plugin string
	Root   string
	Dir    string
}

PluginSource is one plugin's skills/ directory. Root is the plugin's filesystem-resolved root: the skills directory, each skill directory and its SKILL.md must resolve inside it.

type Set

type Set struct {
	Skills []Skill
	// Omitted counts valid skills left out because the catalog was full.
	Omitted int
}

Set is the skills discovered for one run, sorted by name.

func Discover

func Discover(root, userDir string) (*Set, []string)

Discover scans the project directories for root, then userDir ("" skips the user scope). Problems never fail discovery: each is returned as a warning and the affected skill is skipped (or loaded, for cosmetic name problems).

func DiscoverWith added in v0.9.0

func DiscoverWith(root, userDir string, plugins []PluginSource) (*Set, []string)

DiscoverWith is Discover plus plugin skills, which rank below project and user skills, in the order given.

func (*Set) Catalog

func (s *Set) Catalog() string

Catalog returns the system prompt section listing every skill, or "" when there are none. Descriptions are shortened when the full list would exceed MaxCatalogChars.

func (*Set) Get

func (s *Set) Get(name string) (Skill, bool)

Get returns the skill named name.

func (*Set) Len

func (s *Set) Len() int

Len returns the number of skills; a nil Set has none.

func (*Set) Load

func (s *Set) Load(name, file string) (string, error)

Load returns the instructions of the skill named name, or, when file is set, the text of that file inside the skill directory.

func (*Set) Names

func (s *Set) Names() []string

Names returns the skill names in catalog order.

func (*Set) Spec

func (s *Set) Spec() model.ToolSpec

Spec returns the skill tool definition, its name constrained to the discovered names.

type Skill

type Skill struct {
	Name        string
	Description string
	Scope       string // ScopeProject, ScopeUser or ScopePlugin
	Plugin      string // the plugin's name, for ScopePlugin
	Dir         string // absolute skill directory
	Path        string // absolute SKILL.md path
}

Skill is one discovered skill.

Jump to

Keyboard shortcuts

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