Skip to content
experience-library logo

Experience Library Update

experience-library

Capture task outcomes, score performance, and derive rules as token priors for continual learning without model weight changes. Use for post-task feedback, experience capture, pattern extraction, and learning from mistakes. Achieves continual learning for $18 per 100 samples vs $10k fine-tune cos...

SKILL.md

Full skill instructions

Experience Library Update

Purpose

Sample task answers, score outcomes, and derive rules as token priors - achieving continual learning for $18/​100 samples vs $10k fine-tune cost, without changing model weights.

When to Use

  • Post-task learning and improvement
  • Capturing successful patterns
  • Learning from failures
  • Tool call optimization
  • Building domain expertise over time
  • Pattern extraction from experience

Core Instructions

Pattern: Experience Capture Loop

def update_experience_library(task, answer, outcome):
    """
    Capture and learn from task experience
    """
    # 1. Score the outcome
    score = evaluate_outcome(answer, outcome)

    # 2. Extract patterns if successful
    if score > threshold:
        pattern = extract_pattern(task, answer)
        library.add_rule(pattern)

    # 3. Use as token prior (no weight changes)
    return library.get_relevant_rules(new_task)

Step 1: Score Task Outcome

def evaluate_outcome(answer, outcome):
    """
    Score how well the task was completed

    Returns:
        float: Score from 0.0 (failed) to 1.0 (perfect)
    """
    metrics = {
        'correctness': check_correctness(answer, outcome),
        'efficiency': measure_efficiency(answer),
        'completeness': check_completeness(answer, outcome)
    }

    # Weighted average
    score = (
        metrics['correctness'] * 0.5 +
        metrics['efficiency'] * 0.3 +
        metrics['completeness'] * 0.2
    )

    return score

Step 2: Extract Patterns

def extract_pattern(task, answer):
    """
    Extract reusable pattern from successful task
    """
    pattern = {
        'task_type': classify_task(task),
        'approach': extract_approach(answer),
        'tools_used': extract_tools(answer),
        'context': extract_context(task),
        'success_factors': analyze_success(answer),
        'applicable_to': generalize_pattern(task)
    }

    return pattern

Step 3: Store as Token Prior

class ExperienceLibrary:
    """
    Library of learned patterns (token-based, not model weights)
    """
    def __init__(self):
        self.patterns = []

    def add_rule(self, pattern):
        """Add successful pattern"""
        self.patterns.append({
            'pattern': pattern,
            'timestamp': datetime.now(),
            'usage_count': 0,
            'success_rate': 1.0
        })

    def get_relevant_rules(self, new_task):
        """
        Retrieve patterns relevant to new task
        Returns as token context (not model update)
        """
        task_type = classify_task(new_task)

        relevant = [
            p for p in self.patterns
            if task_type in p['pattern']['applicable_to']
        ]

        # Sort by success rate
        relevant.sort(
            key=lambda x: x['success_rate'],
            reverse=True
        )

        return relevant[:5]  # Top 5 patterns

Step 4: Apply to New Tasks

def execute_with_experience(new_task, library):
    """
    Execute task using learned patterns
    """
    # 1. Get relevant patterns
    patterns = library.get_relevant_rules(new_task)

    # 2. Inject as context (token prior)
    context = format_patterns_as_context(patterns)

    # 3. Execute task with learned context
    result = execute_task(new_task, context=context)

    # 4. Update pattern statistics
    for pattern in patterns:
        pattern['usage_count'] += 1
        if result.success:
            pattern['success_rate'] = update_success_rate(pattern)

    return result

Example Workflow

Initial Task (No Experience)

task = "Extract data from JSON API"
answer = execute_task(task)
outcome = {"success": True, "time": 5.2}

# Score and capture
score = evaluate_outcome(answer, outcome)  # 0.85
if score > 0.7:
    pattern = extract_pattern(task, answer)
    library.add_rule(pattern)

Extracted Pattern:

{
    'task_type': 'api_data_extraction',
    'approach': 'use_requests_with_retry',
    'tools_used': ['requests', 'json'],
    'success_factors': [
        'retry_logic',
        'timeout_handling',
        'error_checking'
    ],
    'applicable_to': [
        'api_data_extraction',
        'rest_api_calls',
        'json_parsing'
    ]
}

Similar Task Later (With Experience)

new_task = "Fetch user data from REST API"
# Library automatically provides relevant patterns
patterns = library.get_relevant_rules(new_task)

# Claude receives patterns as token context:
# "Previous successful approach:
#  - Use requests with retry logic
#  - Handle timeouts (30s)
#  - Validate JSON response
#  - Check status codes"

# Execute with learned context
result = execute_with_experience(new_task, library)
# Faster, more reliable due to learned patterns

Performance Characteristics

ApproachCostTimePermanence
Fine-tuning$10,000DaysPermanent (model weights)
Experience Library$18/​100 samplesMinutesSession-based (token context)

Advantages of Token Priors:

  • Cost: 555x cheaper ($18 vs $10,000)
  • Speed: Minutes vs days
  • Flexibility: Easy to update/​remove patterns
  • No model changes: Works with any Claude version
  • Transparency: Patterns are human-readable

Trade-offs:

  • Token cost per request (small, ~100-200 tokens)
  • Not permanent across sessions (unless persisted)
  • Requires pattern storage and retrieval system

Pattern Storage

# Save patterns to disk
import json

def save_library(library, filename='experience_library.json'):
    """Persist patterns"""
    with open(filename, 'w') as f:
        json.dump(library.patterns, f, default=str)

def load_library(filename='experience_library.json'):
    """Load patterns"""
    library = ExperienceLibrary()
    with open(filename) as f:
        library.patterns = json.load(f)
    return library

Best Practices

Pattern Quality

  • Only store patterns from successful tasks (score > 0.7)
  • Include context: task type, tools, environment
  • Generalize appropriately (not too specific, not too vague)
  • Update success rates based on actual usage

Pattern Pruning

  • Remove low-performing patterns (success_rate < 0.5)
  • Merge similar patterns to reduce redundancy
  • Keep library size manageable (<100 patterns)

Context Injection

  • Top 5 most relevant patterns per task
  • Format as clear, actionable guidance
  • Include success factors and pitfalls

Version

v1.0.0 (2025-10-23) - Based on meta-learning and ReAct optimization patterns

More skills from majiayu000

xiaohongshu logo
majiayu000/claude-arsenal

xiaohongshu

xiaohongshu

286 148
View
agent-task-conductor logo
majiayu000/claude-skill-registry

agent-task-conductor

Conduct multi-agent task orchestration and workflow coordination.

663 1
View
conductor-setup logo
majiayu000/claude-skill-registry

conductor-setup

Initialize project with Conductor artifacts (product definition,

663 1
View
animation-designer logo
majiayu000/claude-skill-registry

animation-designer

Expert in web animations, transitions, and motion design using Framer Motion and CSS

663 1
View
diagramming logo
majiayu000/claude-skill-registry

diagramming

Creates Mermaid and ASCII diagrams for flowcharts, architecture, ERDs, state machines, mindmaps, and more. Use when user mentions diagram, flowchart, mermaid, ASCII diagram, text diagram, terminal diagram, visualize, C4, mindmap, architecture diagram, sequence diagram, ERD, or needs visual docume...

663 1
View
h3-pg logo
majiayu000/claude-skill-registry-data

h3-pg

PostgreSQL bindings for H3 hexagonal grid system. Use when working with H3 cells in Postgres, including spatial indexing, geometry/geography integration, and raster analysis.

23 1
View
conductor-development logo
majiayu000/claude-skill-registry

conductor-development

Context-Driven Development skill for projects using Conductor. Use this skill when you detect a `conductor/` directory in the project, when working on tasks defined in a `plan.md` file, or when the user asks about tracks, specs, or plans. Automatically applies TDD workflow, tracks task completion...

663 1
View
conductor-status logo
majiayu000/claude-skill-registry

conductor-status

Display project status, active tracks, and next actions

663 1
View
dockerization logo
majiayu000/claude-skill-registry

dockerization

Official Stakpak application containerization standard operating procedure, a step-by-step guidline to properly dockerize applications. This is a rule book curated by the Stakpak Team.

663 1
View

Popular AI tools

Kaiber logo
Video

Kaiber

Generate, edit, and beat-sync AI video with leading models in one workspace.

Paid
View
Vimcal logo
Productivity

Vimcal

The world's fastest calendar for remote work

Free
View

Transform Your Design with AI Designer by ImgCreator.ai

Freemium
View
Akool AI logo
Content & writing

Akool AI

Revolutionizing Video Production with AI-Powered Creativity

Paid
View

Extend an image past the frame and let AI fill the new aspect ratio.

Freemium
View
StarByFace logo
Security

StarByFace

Discover your celebrity doppelgänger with StarByFace!

Free
View
C

ChainClarity explains 700+ crypto whitepapers in plain English, with layered summaries, comparisons, research tools, alerts, and a $4.99 Pro plan.

Freemium
View
Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View