skill

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package skill provides the Skill Library domain — reusable Claude Code skill definitions extracted from successful sessions.

Index

Constants

This section is empty.

Variables

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

ErrNotFound is returned when a Skill row cannot be found for the given ID.

Functions

This section is empty.

Types

type AddParams

type AddParams struct {
	WorkspaceID           *string
	Name                  string
	Description           string
	Triggers              []string
	Steps                 []string
	FailureModes          []string
	VerificationChecklist []string
	Examples              []any
	SourceAtomIDs         []string
}

AddParams carries the inputs for creating a new Skill row.

type SearchFilter

type SearchFilter struct {
	WorkspaceID *string
	Query       string
	Limit       int
}

SearchFilter constrains a Search or ListRelevant query.

type Skill

type Skill struct {
	ID                    string     `json:"id"`
	WorkspaceID           *string    `json:"workspace_id,omitempty"`
	Name                  string     `json:"name"`
	Description           string     `json:"description"`
	Triggers              []string   `json:"triggers"`
	Steps                 []string   `json:"steps"`
	FailureModes          []string   `json:"failure_modes"`
	VerificationChecklist []string   `json:"verification_checklist"`
	Examples              []any      `json:"examples"`
	SourceAtomIDs         []string   `json:"source_atom_ids"`
	SuccessCount          int        `json:"success_count"`
	FailureCount          int        `json:"failure_count"`
	LastUsedAt            *time.Time `json:"last_used_at,omitempty"`
	CreatedAt             time.Time  `json:"created_at"`
	UpdatedAt             time.Time  `json:"updated_at"`
}

Skill is a reusable skill definition extracted from a Claude Code session.

type Store

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

Store is the Postgres-backed implementation of StoreIface.

func New

func New(pool *pgxpool.Pool, workspaceID *uuid.UUID) *Store

New returns a Store backed by the given pool, scoped to the optional workspaceID. nil workspaceID = legacy unscoped mode.

func (*Store) Add

func (s *Store) Add(ctx context.Context, p AddParams) (*Skill, error)

Add inserts a new skill and returns the persisted record.

func (*Store) IncrementSuccess

func (s *Store) IncrementSuccess(ctx context.Context, id string, workspaceID *string) (*Skill, error)

IncrementSuccess increments success_count and sets last_used_at = NOW().

func (*Store) ListRelevant

func (s *Store) ListRelevant(ctx context.Context, workspaceID *string, query string, limit int) ([]*Skill, error)

ListRelevant returns skills ordered by success_count DESC, last_used_at DESC, optionally filtered by query (name/description ILIKE).

func (*Store) Search

func (s *Store) Search(ctx context.Context, f SearchFilter) ([]*Skill, error)

Search returns skills whose name or description match f.Query (ILIKE), ordered by success_count DESC.

func (*Store) UpdateFromOutcome

func (s *Store) UpdateFromOutcome(ctx context.Context, p UpdateFromOutcomeParams, workspaceID *string) (*Skill, error)

UpdateFromOutcome increments the success or failure counter, appends an example entry, and refreshes last_used_at / updated_at.

type StoreIface

type StoreIface interface {
	// Add inserts a new skill and returns the persisted record.
	Add(ctx context.Context, p AddParams) (*Skill, error)

	// Search returns skills whose name or description match f.Query (ILIKE/LIKE),
	// scoped to f.WorkspaceID when non-nil, ordered by success_count DESC.
	Search(ctx context.Context, f SearchFilter) ([]*Skill, error)

	// IncrementSuccess increments success_count and sets last_used_at = NOW().
	// Returns ErrNotFound when no matching row exists.
	IncrementSuccess(ctx context.Context, id string, workspaceID *string) (*Skill, error)

	// UpdateFromOutcome increments the success or failure counter, appends an
	// example entry {"outcome_id":"…","notes":"…","at":"…"} to examples, and
	// sets last_used_at = NOW(). Returns ErrNotFound when no matching row exists.
	UpdateFromOutcome(ctx context.Context, p UpdateFromOutcomeParams, workspaceID *string) (*Skill, error)

	// ListRelevant returns skills ordered by success_count DESC, last_used_at DESC,
	// optionally filtered by query (name/description LIKE), scoped to workspaceID.
	ListRelevant(ctx context.Context, workspaceID *string, query string, limit int) ([]*Skill, error)
}

StoreIface is the backend-agnostic contract for the Skill Library bounded context. Both the Postgres-backed *Store and the SQLite-backed *SkillStore satisfy this interface.

type UpdateFromOutcomeParams

type UpdateFromOutcomeParams struct {
	SkillID   string
	OutcomeID string // code-layer reference; Memory-3 outcome row ID (TEXT, no FK)
	Success   bool
	Notes     string
}

UpdateFromOutcomeParams carries inputs for recording an outcome against a skill.

Jump to

Keyboard shortcuts

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