skills

package
v0.48.0 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package skills provides skill loading, parsing, and system prompt composition.

Skills are markdown instruction files with optional YAML frontmatter that provide domain-specific context, instructions, and workflows to the agent. They follow a hierarchical discovery pattern similar to extensions:

~/.config/kit/skills/           global skills directory
.kit/skills/                    project-local skills directory

Skills can be single .md/.txt files or subdirectories containing a SKILL.md file.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FormatForPrompt

func FormatForPrompt(skills []*Skill) string

Types

type PromptBuilder

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

PromptBuilder composes a system prompt from a base prompt, skills, and arbitrary named sections.

func NewPromptBuilder

func NewPromptBuilder(basePrompt string) *PromptBuilder

NewPromptBuilder creates a PromptBuilder with the given base system prompt. The base prompt is always emitted first.

func (*PromptBuilder) Build

func (pb *PromptBuilder) Build() string

Build assembles the final system prompt. The base prompt comes first, followed by each section separated by double newlines.

func (*PromptBuilder) WithSection

func (pb *PromptBuilder) WithSection(name, content string) *PromptBuilder

WithSection appends a named section. Duplicate names are allowed (both will appear). Returns the builder for chaining.

func (*PromptBuilder) WithSkills

func (pb *PromptBuilder) WithSkills(skills []*Skill) *PromptBuilder

WithSkills appends a formatted skills section. If skills is empty, no section is added. The section has no header because FormatForPrompt includes its own preamble text. Returns the builder for chaining.

type PromptTemplate

type PromptTemplate struct {
	// Name is the human-readable identifier for this template.
	Name string
	// Content is the raw template text with {{variable}} placeholders.
	Content string
	// Variables lists the placeholder names discovered in Content.
	Variables []string
}

PromptTemplate is a named text template with {{variable}} placeholders.

func LoadPromptTemplate

func LoadPromptTemplate(path string) (*PromptTemplate, error)

LoadPromptTemplate reads a template from a file. The template name is derived from the filename (without extension).

func NewPromptTemplate

func NewPromptTemplate(name, content string) *PromptTemplate

NewPromptTemplate creates a PromptTemplate, automatically extracting variable names from {{...}} placeholders in content.

func (*PromptTemplate) Expand

func (t *PromptTemplate) Expand(values map[string]string) string

Expand replaces all {{variable}} placeholders with values from the provided map. Missing variables are left as-is (no error).

func (*PromptTemplate) ExpandStrict

func (t *PromptTemplate) ExpandStrict(values map[string]string) (string, error)

ExpandStrict replaces all {{variable}} placeholders and returns an error if any variable in the template has no corresponding value.

type Skill

type Skill struct {
	// Name is the human-readable identifier for this skill.
	Name string `yaml:"name" json:"name"`
	// Description summarises what this skill provides.
	Description string `yaml:"description" json:"description"`
	// Content is the full markdown body (after frontmatter).
	Content string `yaml:"-" json:"content"`
	// Path is the absolute filesystem path the skill was loaded from.
	Path string `yaml:"-" json:"path"`
	// Tags are optional labels for categorisation.
	Tags []string `yaml:"tags,omitempty" json:"tags,omitempty"`
	// When controls automatic inclusion: "always", "on-demand", or a
	// file-glob like "file:*.go".  Empty defaults to "on-demand".
	When string `yaml:"when,omitempty" json:"when,omitempty"`
}

Skill represents a markdown-based instruction file that provides domain-specific context and workflows to the agent.

func LoadSkill

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

LoadSkill reads a single skill file (markdown with optional YAML frontmatter). If no frontmatter is present the skill name is derived from the filename.

func LoadSkills

func LoadSkills(cwd string) ([]*Skill, error)

LoadSkills auto-discovers skills from standard directories:

  1. Global: $XDG_CONFIG_HOME/kit/skills/ (default ~/.config/kit/skills/)
  2. Project-local: <cwd>/.kit/skills/

Skills from project-local directories take precedence (appended last). cwd is the working directory for project-local discovery; if empty the current working directory is used.

func LoadSkillsFromDir

func LoadSkillsFromDir(dir string) ([]*Skill, error)

LoadSkillsFromDir loads all skills from a single directory. It looks for:

  • *.md and *.txt files directly in dir
  • SKILL.md (case-insensitive) in immediate subdirectories

Files that fail to parse are skipped with a warning logged via the returned error list.

Jump to

Keyboard shortcuts

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