skilltool

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package skilltool implements the SkillTool — the agent's way to invoke slash-command skills (plugin commands and ~/.claude/commands/*.md files).

When the model calls SkillTool with a skill name, the tool:

  1. Looks up the command body from the loaded plugin/skill registry.
  2. Substitutes $ARGUMENTS with the supplied args string.
  3. Runs a nested agent loop with the skill body as the first user message.
  4. Returns the nested agent's final text response.

This mirrors SkillTool.ts executeForkedSkill() — a forked sub-agent that runs the skill prompt in an isolated context and returns its result.

Reference: src/tools/SkillTool/SkillTool.ts

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	// QualifiedName is the slash-command name ("pluginName:commandName" or just "commandName").
	QualifiedName string
	// Description is shown in /skills and the system prompt skill listing.
	Description string
	// Body is the markdown body (frontmatter stripped).
	Body string
}

Command is one resolved skill command, ready to execute.

type Input

type Input struct {
	Skill string `json:"skill"`
	Args  string `json:"args,omitempty"`
}

type Loader

type Loader interface {
	// FindCommand looks up a command by name (with or without leading slash,
	// with or without plugin prefix). Returns nil if not found.
	FindCommand(name string) *Command
}

Loader discovers available skill commands. Implemented by the plugin loader.

type SubAgent

type SubAgent interface {
	Run(ctx context.Context, messages []api.Message, handler func(interface{})) ([]api.Message, error)
}

SubAgent is the minimal interface the SkillTool needs from the agent loop to spawn a nested run.

type Tool

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

Tool implements the SkillTool.

func New

func New(loader Loader, runAgent func(ctx context.Context, prompt string) (string, error)) *Tool

New returns a SkillTool. runAgent is a closure that runs a nested agent loop with the given prompt as the first user message and returns the final assistant text.

func (*Tool) Description

func (*Tool) Description() string

func (*Tool) Execute

func (t *Tool) Execute(ctx context.Context, raw json.RawMessage) (tool.Result, error)

func (*Tool) InputSchema

func (*Tool) InputSchema() json.RawMessage

func (*Tool) IsConcurrencySafe

func (*Tool) IsConcurrencySafe(json.RawMessage) bool

func (*Tool) IsReadOnly

func (*Tool) IsReadOnly(json.RawMessage) bool

func (*Tool) Name

func (*Tool) Name() string

Jump to

Keyboard shortcuts

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