claude

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package claude provides data models for Claude Code configuration entities.

This package defines Go structs that model Claude Code's configuration files, including MCP server definitions, skills, commands, and agents. All types support JSON and YAML serialization with proper struct tags.

MCP Configuration

Claude Code uses MCP (Model Context Protocol) servers for extensibility. The MCPConfig type models the .mcp.json file format:

config := &claude.MCPConfig{
    MCPServers: map[string]*claude.MCPServer{
        "github": {
            Name:    "github",
            Command: "npx",
            Args:    []string{"-y", "@modelcontextprotocol/server-github"},
            Env: map[string]string{
                "GITHUB_TOKEN": "${GITHUB_TOKEN}",
            },
        },
    },
}

MCPConfig preserves unknown fields during JSON round-trips for forward compatibility with future Claude Code versions.

Skills

Skills are markdown files with YAML frontmatter defining reusable capabilities:

skill := &claude.Skill{
    Name:         "code-review",
    Description:  "Perform thorough code reviews",
    Version:      "1.0.0",
    Tools:        []string{"Read", "Grep", "Glob"},
    Triggers:     []string{"review", "code review"},
    Instructions: "When reviewing code, check for...",
}

The Instructions field contains the markdown body content and is excluded from YAML/JSON serialization (marked with "-" tag).

Commands

Commands define slash commands available in the Claude Code interface:

cmd := &claude.Command{
    Name:         "test",
    Description:  "Run test suite",
    Instructions: "Execute the test runner...",
}

Agents

Agents define specialized AI assistants with custom instructions:

agent := &claude.Agent{
    Name:         "reviewer",
    Description:  "Code review specialist",
    Instructions: "You are a code review expert...",
}

Serialization

All types support both JSON and YAML serialization. Use the standard library encoding/json package or gopkg.in/yaml.v3 for marshaling:

// JSON
data, err := json.Marshal(config)

// YAML
data, err := yaml.Marshal(skill)

Fields with ",omitempty" tags are omitted when empty to produce cleaner output.

Package claude provides Claude Code specific configuration and path handling.

Index

Constants

View Source
const (
	// ClaudeTypeStdio is the Claude Code type for local process servers.
	ClaudeTypeStdio = "stdio"
	// ClaudeTypeHTTP is the Claude Code type for remote HTTP servers.
	// Note: canonical format uses "sse" for this transport type.
	ClaudeTypeHTTP = "http"
)

Claude Code transport type constants.

View Source
const (
	VarArguments = "$ARGUMENTS"
	VarSelection = "$SELECTION"
)

Variables supported by Claude Code.

Variables

View Source
var (
	ErrAgentNotFound      = errors.New("agent not found")
	ErrInvalidAgent       = errors.New("invalid agent: name required")
	ErrAgentDirUnresolved = errors.New("cannot determine agents directory")
)

Sentinel errors for agent operations.

View Source
var (
	// ErrCommandNotFound indicates the requested command does not exist.
	ErrCommandNotFound = errors.New("command not found")

	// ErrInvalidCommand indicates the command is missing required fields.
	ErrInvalidCommand = errors.New("invalid command: name required")
)

Sentinel errors for command operations.

View Source
var (
	ErrMCPServerNotFound = errors.New("MCP server not found")
	ErrInvalidMCPServer  = errors.New("invalid MCP server: name required")
)

Sentinel errors for MCP operations.

View Source
var (
	ErrSkillNotFound = errors.New("skill not found")
	ErrInvalidSkill  = errors.New("invalid skill: name required")
)

Sentinel errors for skill operations.

View Source
var ErrUnsupportedVariable = errors.New("unsupported variable")

ErrUnsupportedVariable indicates content contains variables not supported by Claude Code.

Functions

func ListVariables

func ListVariables(content string) []string

ListVariables returns all variables found in the content. Returns an empty slice if no variables are found. The returned slice contains unique variables in the order they first appear.

func TranslateToCanonical

func TranslateToCanonical(content string) string

TranslateToCanonical converts Claude Code variable syntax to canonical format. Since Claude Code uses the canonical format, this is a pass-through.

func TranslateVariables

func TranslateVariables(content string) string

TranslateVariables converts canonical variable syntax to Claude Code format. Since Claude Code uses the canonical format ($ARGUMENTS, $SELECTION), this is essentially a pass-through that preserves the content unchanged.

func ValidateVariables

func ValidateVariables(content string) error

ValidateVariables checks if content contains only supported variables. Returns nil if valid, or an error listing unsupported variables.

Types

type Agent

type Agent struct {
	// Name is the agent's identifier.
	Name string `yaml:"name" json:"name"`

	// Description explains the agent's purpose and capabilities.
	Description string `yaml:"description,omitempty" json:"description,omitempty"`

	// Instructions contains the agent's markdown body content.
	// This field is not part of the YAML frontmatter.
	Instructions string `yaml:"-" json:"-"`
}

Agent represents a Claude Code agent definition. Agents are markdown files that define specialized AI assistants.

func (*Agent) GetDescription

func (a *Agent) GetDescription() string

GetDescription returns the agent's description.

func (*Agent) GetInstructions

func (a *Agent) GetInstructions() string

GetInstructions returns the agent's instructions.

func (*Agent) GetName

func (a *Agent) GetName() string

GetName returns the agent's name.

type AgentManager

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

AgentManager handles CRUD operations for Claude Code agents. Agents are markdown files stored in the agents directory.

func NewAgentManager

func NewAgentManager(paths *ClaudePaths) *AgentManager

NewAgentManager creates a new AgentManager with the given path resolver.

func (*AgentManager) AgentDir

func (m *AgentManager) AgentDir() string

AgentDir returns the agents directory path. This is a convenience method that delegates to the underlying ClaudePaths.

func (*AgentManager) AgentPath

func (m *AgentManager) AgentPath(name string) string

AgentPath returns the path to a specific agent file. This is a convenience method that delegates to the underlying ClaudePaths.

func (*AgentManager) Exists

func (m *AgentManager) Exists(name string) bool

Exists checks if an agent with the given name exists.

func (*AgentManager) Get

func (m *AgentManager) Get(name string) (*Agent, error)

Get retrieves an agent by name. Returns ErrAgentNotFound if the agent file doesn't exist.

func (*AgentManager) Install

func (m *AgentManager) Install(a *Agent) error

Install writes an agent to the agents directory. Creates the agents directory if it doesn't exist. Overwrites any existing agent with the same name.

func (*AgentManager) List

func (m *AgentManager) List() ([]*Agent, error)

List returns all agents in the agents directory. Returns an empty slice if the directory doesn't exist.

func (*AgentManager) Names

func (m *AgentManager) Names() ([]string, error)

Names returns a list of all agent names in the agents directory. Returns an empty slice if the directory doesn't exist.

func (*AgentManager) Uninstall

func (m *AgentManager) Uninstall(name string) error

Uninstall removes an agent file. Returns nil if the agent doesn't exist (idempotent).

type ClaudePaths

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

ClaudePaths provides Claude-specific path resolution. It wraps the generic paths package with Claude-specific defaults.

func NewClaudePaths

func NewClaudePaths(scope Scope, projectRoot string) *ClaudePaths

NewClaudePaths creates a new ClaudePaths instance. For ScopeProject, projectRoot must be non-empty. For ScopeUser, projectRoot is ignored.

func (*ClaudePaths) AgentDir

func (p *ClaudePaths) AgentDir() string

AgentDir returns the agents directory. Returns <base>/agents/

func (*ClaudePaths) AgentPath

func (p *ClaudePaths) AgentPath(name string) string

AgentPath returns the path to a specific agent file. Returns <agents>/<name>.md Returns empty string if name is empty.

func (*ClaudePaths) BaseDir

func (p *ClaudePaths) BaseDir() string

BaseDir returns the base configuration directory. For ScopeUser: ~/.claude/ For ScopeProject: <projectRoot>/.claude/ Returns empty string if projectRoot is empty for ScopeProject.

func (*ClaudePaths) CommandDir

func (p *ClaudePaths) CommandDir() string

CommandDir returns the commands directory. Returns <base>/commands/

func (*ClaudePaths) CommandPath

func (p *ClaudePaths) CommandPath(name string) string

CommandPath returns the path to a specific command file. Returns <commands>/<name>.md Returns empty string if name is empty.

func (*ClaudePaths) InstructionsPath

func (p *ClaudePaths) InstructionsPath() string

InstructionsPath returns the path to the CLAUDE.md instructions file. For ScopeUser: ~/.claude/CLAUDE.md For ScopeProject: <projectRoot>/CLAUDE.md (note: at project root, not .claude/)

func (*ClaudePaths) MCPConfigPath

func (p *ClaudePaths) MCPConfigPath() string

MCPConfigPath returns the path to the MCP servers configuration file.

For ScopeUser: ~/.claude.json (the main user config file, NOT ~/.claude/.mcp.json) For ScopeProject: <projectRoot>/.claude/.mcp.json

Note: Claude Code stores user-level MCP servers in the main user config file at ~/.claude.json, not in a separate file within the .claude directory.

func (*ClaudePaths) SkillDir

func (p *ClaudePaths) SkillDir() string

SkillDir returns the skills directory. Returns <base>/skills/

func (*ClaudePaths) SkillPath

func (p *ClaudePaths) SkillPath(name string) string

SkillPath returns the path to a specific skill's SKILL.md file. Returns <skills>/<name>/SKILL.md Returns empty string if name is empty.

type ClaudePlatform

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

ClaudePlatform provides the unified platform adapter for Claude Code. It aggregates all Claude-specific managers and provides a consistent interface for the aix CLI.

func NewClaudePlatform

func NewClaudePlatform(opts ...Option) *ClaudePlatform

NewClaudePlatform creates a new ClaudePlatform with the given options. Default configuration uses ScopeUser with no project root.

func (*ClaudePlatform) AddMCP

func (p *ClaudePlatform) AddMCP(s *MCPServer) error

AddMCP adds an MCP server configuration.

func (*ClaudePlatform) AgentDir

func (p *ClaudePlatform) AgentDir() string

AgentDir returns the agents directory for the current scope.

func (*ClaudePlatform) BackupPaths

func (p *ClaudePlatform) BackupPaths() []string

BackupPaths returns all config files/directories that should be backed up. For Claude Code, this includes:

  • ~/.claude.json (MCP config)
  • ~/.claude/ directory (skills, commands, agents)

func (*ClaudePlatform) CommandDir

func (p *ClaudePlatform) CommandDir() string

CommandDir returns the commands directory for the current scope.

func (*ClaudePlatform) DisableMCP

func (p *ClaudePlatform) DisableMCP(name string) error

DisableMCP disables an MCP server by name.

func (*ClaudePlatform) DisplayName

func (p *ClaudePlatform) DisplayName() string

DisplayName returns a human-readable platform name.

func (*ClaudePlatform) EnableMCP

func (p *ClaudePlatform) EnableMCP(name string) error

EnableMCP enables an MCP server by name.

func (*ClaudePlatform) GetAgent

func (p *ClaudePlatform) GetAgent(name string) (*Agent, error)

GetAgent retrieves an agent by name.

func (*ClaudePlatform) GetCommand

func (p *ClaudePlatform) GetCommand(name string) (*Command, error)

GetCommand retrieves a command by name.

func (*ClaudePlatform) GetMCP

func (p *ClaudePlatform) GetMCP(name string) (*MCPServer, error)

GetMCP retrieves an MCP server by name.

func (*ClaudePlatform) GetSkill

func (p *ClaudePlatform) GetSkill(name string) (*Skill, error)

GetSkill retrieves a skill by name.

func (*ClaudePlatform) GlobalConfigDir

func (p *ClaudePlatform) GlobalConfigDir() string

GlobalConfigDir returns the global configuration directory (~/.claude/).

func (*ClaudePlatform) InstallAgent

func (p *ClaudePlatform) InstallAgent(a *Agent) error

InstallAgent installs an agent.

func (*ClaudePlatform) InstallCommand

func (p *ClaudePlatform) InstallCommand(c *Command) error

InstallCommand installs a slash command.

func (*ClaudePlatform) InstallSkill

func (p *ClaudePlatform) InstallSkill(s *Skill) error

InstallSkill installs a skill to the skill directory.

func (*ClaudePlatform) InstructionsPath

func (p *ClaudePlatform) InstructionsPath(projectRoot string) string

InstructionsPath returns the path to the instructions file. For user scope, this is ~/.claude/CLAUDE.md. For project scope, this is <projectRoot>/CLAUDE.md.

func (*ClaudePlatform) IsAvailable

func (p *ClaudePlatform) IsAvailable() bool

IsAvailable checks if Claude Code is available on this system. Returns true if the ~/.claude/ directory exists.

func (*ClaudePlatform) ListAgents

func (p *ClaudePlatform) ListAgents() ([]*Agent, error)

ListAgents returns all installed agents.

func (*ClaudePlatform) ListCommands

func (p *ClaudePlatform) ListCommands() ([]*Command, error)

ListCommands returns all installed commands.

func (*ClaudePlatform) ListMCP

func (p *ClaudePlatform) ListMCP() ([]*MCPServer, error)

ListMCP returns all configured MCP servers.

func (*ClaudePlatform) ListSkills

func (p *ClaudePlatform) ListSkills() ([]*Skill, error)

ListSkills returns all installed skills.

func (*ClaudePlatform) MCPConfigPath

func (p *ClaudePlatform) MCPConfigPath() string

MCPConfigPath returns the path to the MCP servers configuration file.

func (*ClaudePlatform) Name

func (p *ClaudePlatform) Name() string

Name returns the platform identifier.

func (*ClaudePlatform) ProjectConfigDir

func (p *ClaudePlatform) ProjectConfigDir(projectRoot string) string

ProjectConfigDir returns the project-scoped configuration directory.

func (*ClaudePlatform) RemoveMCP

func (p *ClaudePlatform) RemoveMCP(name string) error

RemoveMCP removes an MCP server by name.

func (*ClaudePlatform) SkillDir

func (p *ClaudePlatform) SkillDir() string

SkillDir returns the skills directory for the current scope.

func (*ClaudePlatform) TranslateToCanonical

func (p *ClaudePlatform) TranslateToCanonical(content string) string

TranslateToCanonical converts Claude Code variable syntax to canonical format. Since Claude Code uses the canonical format, this is a pass-through.

func (*ClaudePlatform) TranslateVariables

func (p *ClaudePlatform) TranslateVariables(content string) string

TranslateVariables converts canonical variable syntax to Claude Code format. Since Claude Code uses the canonical format, this is a pass-through.

func (*ClaudePlatform) UninstallAgent

func (p *ClaudePlatform) UninstallAgent(name string) error

UninstallAgent removes an agent by name.

func (*ClaudePlatform) UninstallCommand

func (p *ClaudePlatform) UninstallCommand(name string) error

UninstallCommand removes a command by name.

func (*ClaudePlatform) UninstallSkill

func (p *ClaudePlatform) UninstallSkill(name string) error

UninstallSkill removes a skill by name.

func (*ClaudePlatform) ValidateVariables

func (p *ClaudePlatform) ValidateVariables(content string) error

ValidateVariables checks if content contains only supported variables.

func (*ClaudePlatform) Version

func (p *ClaudePlatform) Version() (string, error)

Version returns the Claude Code version. Currently returns an empty string as version detection is not yet implemented.

type Command

type Command struct {
	// Name is the command's identifier (used as /name in the interface).
	Name string `yaml:"name" json:"name"`

	// Description explains what the command does.
	Description string `yaml:"description,omitempty" json:"description,omitempty"`

	// ArgumentHint provides hint text shown for command arguments in the UI.
	ArgumentHint string `yaml:"argument-hint,omitempty" json:"argumentHint,omitempty"`

	// DisableModelInvocation prevents the model from invoking this command automatically.
	DisableModelInvocation bool `yaml:"disable-model-invocation,omitempty" json:"disableModelInvocation,omitempty"`

	// UserInvocable indicates whether the user can invoke this command directly.
	UserInvocable bool `yaml:"user-invocable,omitempty" json:"userInvocable,omitempty"`

	// AllowedTools lists the tool permissions available to this command.
	// Can be a space-delimited string or a list of strings.
	AllowedTools ToolList `yaml:"allowed-tools,omitempty" json:"allowedTools,omitempty"`

	// Model specifies which model to use when executing this command.
	Model string `yaml:"model,omitempty" json:"model,omitempty"`

	// Context specifies the context mode for this command (e.g., "none", "file", "repo").
	Context string `yaml:"context,omitempty" json:"context,omitempty"`

	// Agent specifies the agent to use when executing this command.
	Agent string `yaml:"agent,omitempty" json:"agent,omitempty"`

	// Hooks lists hooks to run during command execution.
	Hooks []string `yaml:"hooks,omitempty" json:"hooks,omitempty"`

	// Instructions contains the command's markdown body content.
	// This field is not part of the YAML frontmatter.
	Instructions string `yaml:"-" json:"-"`
}

Command represents a Claude Code slash command definition. Commands are markdown files that define custom slash commands.

func (*Command) GetName

func (c *Command) GetName() string

GetName returns the command's name.

func (*Command) SetInstructions

func (c *Command) SetInstructions(instructions string)

SetInstructions sets the command's instructions.

func (*Command) SetName

func (c *Command) SetName(name string)

SetName sets the command's name.

type CommandManager

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

CommandManager provides CRUD operations for Claude Code slash commands. Commands are stored as markdown files in the commands directory.

func NewCommandManager

func NewCommandManager(paths *ClaudePaths) *CommandManager

NewCommandManager creates a new CommandManager with the given paths configuration.

func (*CommandManager) Get

func (m *CommandManager) Get(name string) (*Command, error)

Get retrieves a command by name. Returns ErrCommandNotFound if the command file doesn't exist.

func (*CommandManager) Install

func (m *CommandManager) Install(c *Command) error

Install writes a command to disk. Creates the commands directory if it doesn't exist. Overwrites any existing command with the same name.

func (*CommandManager) List

func (m *CommandManager) List() ([]*Command, error)

List returns all commands in the commands directory. Returns an empty slice if the directory doesn't exist or contains no .md files.

func (*CommandManager) Uninstall

func (m *CommandManager) Uninstall(name string) error

Uninstall removes a command from disk. This operation is idempotent; removing a non-existent command returns nil.

type MCPConfig

type MCPConfig struct {
	// MCPServers maps server names to their configurations.
	MCPServers map[string]*MCPServer `json:"mcpServers"`
	// contains filtered or unexported fields
}

MCPConfig represents the root structure of Claude Code's .mcp.json file. It preserves unknown fields for forward compatibility with future versions.

func (*MCPConfig) MarshalJSON

func (c *MCPConfig) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler to include unknown fields in output.

func (*MCPConfig) UnmarshalJSON

func (c *MCPConfig) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler to capture unknown fields.

type MCPManager

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

MCPManager provides CRUD operations for MCP server configurations.

func NewMCPManager

func NewMCPManager(paths *ClaudePaths) *MCPManager

NewMCPManager creates a new MCPManager instance.

func (*MCPManager) Add

func (m *MCPManager) Add(server *MCPServer) error

Add adds or updates an MCP server in the configuration. Returns ErrInvalidMCPServer if the server name is empty.

func (*MCPManager) Disable

func (m *MCPManager) Disable(name string) error

Disable sets Disabled=true for the specified server. Returns ErrMCPServerNotFound if the server does not exist.

func (*MCPManager) Enable

func (m *MCPManager) Enable(name string) error

Enable sets Disabled=false for the specified server. Returns ErrMCPServerNotFound if the server does not exist.

func (*MCPManager) Get

func (m *MCPManager) Get(name string) (*MCPServer, error)

Get returns a single MCP server by name. Returns ErrMCPServerNotFound if the server does not exist.

func (*MCPManager) List

func (m *MCPManager) List() ([]*MCPServer, error)

List returns all MCP servers from the configuration file. Returns an empty slice if the config file does not exist. The returned servers are sorted by name for deterministic ordering.

func (*MCPManager) Remove

func (m *MCPManager) Remove(name string) error

Remove removes an MCP server from the configuration by name. This operation is idempotent - removing a non-existent server does not error.

type MCPServer

type MCPServer struct {
	// Name is the server's identifier, populated from the map key when loading.
	// Not serialized to JSON as it's the map key itself.
	Name string `json:"-"`

	// Type specifies the server transport type: "stdio" or "http".
	// Note: Claude Code uses "http" for remote servers, while canonical uses "sse".
	Type string `json:"type,omitempty"`

	// Command is the executable to run for stdio transport.
	Command string `json:"command,omitempty"`

	// Args are command-line arguments passed to the command.
	Args []string `json:"args,omitempty"`

	// URL is the server endpoint for HTTP transport.
	URL string `json:"url,omitempty"`

	// Env contains environment variables passed to the server process.
	Env map[string]string `json:"env,omitempty"`

	// Headers contains HTTP headers for HTTP transport connections.
	Headers map[string]string `json:"headers,omitempty"`

	// Platforms restricts the server to specific OS platforms (e.g., "darwin", "linux").
	Platforms []string `json:"platforms,omitempty"`

	// Disabled indicates whether the server is temporarily disabled.
	Disabled bool `json:"disabled,omitempty"`
}

MCPServer represents an MCP (Model Context Protocol) server configuration. It supports both stdio-based (Command/Args) and HTTP-based (URL) transports.

type MCPTranslator

type MCPTranslator struct{}

MCPTranslator converts between canonical and Claude Code MCP formats.

Claude Code uses a "mcpServers" key with these differences from canonical:

  • Field "type" instead of "transport"
  • Value "http" instead of "sse" for remote servers
  • Name is stored as map key only, not inside server object

func NewMCPTranslator

func NewMCPTranslator() *MCPTranslator

NewMCPTranslator creates a new Claude Code MCP translator.

func (*MCPTranslator) FromCanonical

func (t *MCPTranslator) FromCanonical(cfg *mcp.Config) ([]byte, error)

FromCanonical converts canonical MCP configuration to Claude Code format.

Output format:

{"mcpServers": {"name": {...}, ...}}

Mapping:

  • canonical "transport" → Claude "type"
  • canonical "sse" → Claude "http"
  • canonical "stdio" → Claude "stdio"

The output is formatted with 2-space indentation for readability.

func (*MCPTranslator) Platform

func (t *MCPTranslator) Platform() string

Platform returns the platform identifier for this translator.

func (*MCPTranslator) ToCanonical

func (t *MCPTranslator) ToCanonical(platformData []byte) (*mcp.Config, error)

ToCanonical converts Claude Code MCP configuration to canonical format.

Input format:

{"mcpServers": {"name": {...}, ...}}

or just the servers map:

{"name": {...}, ...}

Mapping:

  • Claude "type" → canonical "transport"
  • Claude "http" → canonical "sse"
  • Claude "stdio" → canonical "stdio"

type Option

type Option func(*ClaudePlatform)

Option configures a ClaudePlatform instance.

func WithProjectRoot

func WithProjectRoot(root string) Option

WithProjectRoot sets the project root directory for project-scoped paths.

func WithScope

func WithScope(scope Scope) Option

WithScope sets the scope (user or project) for path resolution.

type Scope

type Scope int

Scope defines whether paths resolve to user-level or project-level configuration.

const (
	// ScopeUser resolves paths relative to ~/.claude/
	ScopeUser Scope = iota
	// ScopeProject resolves paths relative to <projectRoot>/.claude/
	ScopeProject
)

type Skill

type Skill struct {
	// Name is the skill's unique identifier (required).
	// Must be 1-64 chars, lowercase alphanumeric + hyphens, no --, no start/end -.
	Name string `yaml:"name" json:"name"`

	// Description explains what the skill does (required).
	Description string `yaml:"description" json:"description"`

	// License is the SPDX license identifier (optional).
	License string `yaml:"license,omitempty" json:"license,omitempty"`

	// Compatibility lists compatible AI assistants (optional).
	// E.g., ["claude-code", "opencode", "codex"]
	Compatibility []string `yaml:"compatibility,omitempty" json:"compatibility,omitempty"`

	// Metadata contains optional key-value pairs like author, version, repository.
	Metadata map[string]string `yaml:"metadata,omitempty" json:"metadata,omitempty"`

	// AllowedTools lists the tool permissions required by this skill.
	// Can be a space-delimited string or a list of strings.
	AllowedTools ToolList `yaml:"allowed-tools,omitempty" json:"allowed-tools,omitempty"`

	// Instructions contains the skill's markdown body content.
	// This field is not part of the YAML frontmatter.
	Instructions string `yaml:"-" json:"-"`
}

Skill represents a skill definition per the Agent Skills Specification. Skills are markdown files with YAML frontmatter that define reusable capabilities. See: https://agentskills.io/specification

type SkillManager

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

SkillManager handles CRUD operations for Claude Code skills.

func NewSkillManager

func NewSkillManager(paths *ClaudePaths) *SkillManager

NewSkillManager creates a new SkillManager with the given paths configuration.

func (*SkillManager) Get

func (m *SkillManager) Get(name string) (*Skill, error)

Get retrieves a skill by name. Returns ErrSkillNotFound if the skill doesn't exist.

func (*SkillManager) Install

func (m *SkillManager) Install(s *Skill) error

Install creates or overwrites a skill. Creates the skill directory if it doesn't exist.

func (*SkillManager) List

func (m *SkillManager) List() ([]*Skill, error)

List returns all skills in the skill directory. Returns an empty slice if the directory doesn't exist or is empty.

func (*SkillManager) Uninstall

func (m *SkillManager) Uninstall(name string) error

Uninstall removes a skill by name. This operation is idempotent - returns nil if skill doesn't exist.

type ToolList

type ToolList []string

ToolList is a list of allowed tools. It supports unmarshaling from both a space-delimited string and a list of strings.

func (ToolList) String

func (t ToolList) String() string

String returns the space-delimited string representation.

func (*ToolList) UnmarshalYAML

func (t *ToolList) UnmarshalYAML(value *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler.

Jump to

Keyboard shortcuts

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