cross-task-learner
Enable agent loops to learn from similar past tasks and share patterns across loops
What this skill does
# Cross-Task Learner Skill
Enable agent loops to learn from similar past tasks and share discovered patterns across multiple concurrent or sequential loops.
**Research Foundation**: REF-013 MetaGPT - 159% improvement with shared state
**Version 2.0**: Multi-loop awareness with loop_id tracking
---
## Overview
This skill provides two core capabilities:
1. **Pattern Extraction** - On loop completion, extract reusable patterns from execution history
2. **Pattern Injection** - On loop start, inject relevant patterns from previous loops
### Benefits
| Benefit | Impact |
|---------|--------|
| Faster resolution | Patterns eliminate redundant debugging |
| Higher success rates | Proven approaches applied automatically |
| Accumulated wisdom | System gets smarter over time |
| Anti-pattern detection | Failed approaches flagged and avoided |
### Research Basis
From REF-013 MetaGPT:
- **159% improvement** with shared state across agents
- **Publish-subscribe pattern** enables knowledge sharing
- **Structured outputs** become inputs for other agents
- **Memory persistence** critical for cross-session learning
---
## Pattern Extraction (On Loop Completion)
### Trigger
- Agent loop completion (success, partial, or failure)
- Manual extraction request via `aiwg ralph-extract-patterns {loop_id}`
### Process
```yaml
extraction_steps:
1_analyze_loop_history:
- Load loop state from .aiwg/ralph/loops/{loop_id}/state.json
- Load iteration analytics
- Load debug memory
- Load reflection history
2_identify_error_fix_pairs:
- Scan iterations for test failures
- Identify fixes that resolved errors
- Extract error signature + fix approach
- Compute initial success rate (1.0 for first occurrence)
3_identify_successful_approaches:
- Analyze task category (testing, debugging, refactoring, etc.)
- Extract step sequence that led to success
- Note tools used and iteration count
- Identify preconditions and benefits
4_identify_failure_patterns:
- Detect repeated same errors (anti-patterns)
- Note approaches that led to scope creep
- Flag patterns that caused quality degradation
- Record better alternatives if discovered
5_extract_code_templates:
- Identify successful code changes
- Generalize with placeholders
- Document use case and placeholders
- Tag by language and purpose
6_check_for_duplicates:
- Compare against existing patterns in registry
- Merge if >80% similar
- Update usage count and success rate if duplicate
7_store_in_registry:
- Add to .aiwg/ralph/shared/patterns/{type}-patterns.json
- Update patterns index for semantic search
- Link to source loop_id
8_update_effectiveness_metrics:
- Increment pattern counts
- Update cross-loop benefit statistics
- Log extraction event
```
### Example Extraction
**Input** (from loop `ralph-fix-auth-a1b2c3d4`):
```yaml
iteration_2:
error:
type: "TypeError"
message: "Cannot read property 'email' of null"
location: "src/auth/validate.ts:42"
iteration_3:
fix_applied:
description: "Added null check for user object"
diff: |
+ if (user == null) {
+ throw new ValidationError("User is required");
+ }
test_results:
passed: 12
failed: 0
```
**Output** (extracted pattern):
```yaml
pattern_id: "pat-error-null-check-015"
type: "error_pattern"
error_signature:
error_type: "TypeError"
error_pattern: "Cannot read property '.*' of null"
error_location_hints:
- "*.ts:validate*"
fix_approach:
description: "Add null check before property access"
fix_category: "add_null_check"
code_template: |
if ({{variable}} == null) {
throw new ValidationError("{{message}}");
}
code_template_language: "typescript"
source_loops:
- loop_id: "ralph-fix-auth-a1b2c3d4"
timestamp: "2026-02-02T15:00:00Z"
contributed_by: "software-implementer"
success_rate: 1.0
usage_count: 1
first_discovered: "2026-02-02T15:00:00Z"
last_used: "2026-02-02T15:00:00Z"
tags:
- "typescript"
- "null-safety"
- "validation"
```
### Configuration
```yaml
# In aiwg.yml or .aiwg/config.yml
ralph:
cross_loop_learning:
extraction:
enabled: true
auto_extract_on_completion: true
min_success_rate_threshold: 0.6
min_usage_count_for_evaluation: 3
extract_code_templates: true
merge_similar_patterns: true
similarity_threshold: 0.80
```
---
## Pattern Injection (On Loop Start)
### Trigger
- Agent loop start
- Manual injection request via `aiwg ralph-inject-patterns {loop_id}`
### Process
```yaml
injection_steps:
1_analyze_task_description:
- Extract task text
- Identify task category (testing, debugging, refactoring, etc.)
- Generate task embedding for semantic matching
2_search_error_patterns:
- Query error patterns by task category
- Match error signatures to likely error types
- Filter by min success rate (default 0.6)
- Sort by effectiveness
3_search_success_patterns:
- Query success patterns by task category match
- Use semantic similarity on task description
- Filter by min success rate
- Sort by average iterations (lower is better)
4_search_anti_patterns:
- Query anti-patterns by task category
- Identify failure modes to avoid
- Include better alternatives
5_search_code_templates:
- Query templates by language and task type
- Filter by success rate
- Sort by usage count
6_filter_and_rank:
- Combine all pattern types
- Remove duplicates
- Rank by relevance × effectiveness
- Take top-k (default k=5)
7_inject_into_context:
- Format patterns for display
- Add to loop context as "Cross-Loop Learning Context"
- Track which patterns were injected (for effectiveness measurement)
8_track_usage:
- Log pattern injection event
- Record loop_id and injected pattern_ids
- Enable later effectiveness analysis
```
### Example Injection
**Input** (loop `ralph-fix-validation-b2c3d4e5` starting):
```yaml
task: "Fix TypeScript type errors in user validation"
category: "debugging"
```
**Patterns Retrieved**:
```yaml
retrieved_patterns:
error_patterns:
- pattern_id: "pat-error-null-check-015"
relevance: 0.95
success_rate: 1.0
usage_count: 1
- pattern_id: "pat-error-type-mismatch-003"
relevance: 0.88
success_rate: 0.94
usage_count: 18
success_patterns:
- pattern_id: "pat-success-type-fixing-002"
relevance: 0.92
success_rate: 0.87
average_iterations: 2.8
anti_patterns:
- pattern_id: "pat-anti-premature-optimization-001"
relevance: 0.65
failure_rate: 0.85
```
**Injected Context** (top 5 patterns):
```markdown
## Cross-Loop Learning Context
Patterns from previous loops that may help with this task:
### Error Patterns
1. **TypeError: null property access** (100% success, 1 use)
- Error: "Cannot read property '.*' of null"
- Fix: Add null check before property access
- Template:
```typescript
if ({{variable}} == null) {
throw new ValidationError("{{message}}");
}
```
- Source: ralph-fix-auth-a1b2c3d4
2. **TypeError: type mismatch** (94% success, 18 uses)
- Error: "Type 'X' is not assignable to type 'Y'"
- Fix: Update interface definition or add type assertion
- Source: 18 previous loops
### Success Patterns
1. **Type error fixing approach** (87% success, avg 2.8 iterations)
- Steps:
1. Run tsc --noEmit to see all errors
2. Group errors by file/type
3. Fix interface definitions first
4. Fix usages second
5. Verify with tsc again
- Source: 12 successful loops
### Anti-Patterns to Avoid
1. **Premature optimization** (85% failure rate)
- Don't optimize before tests pass
- Complete primary task first
- Better alternative: pat-success-refactor-module-002
```
### Configuration
```yaml
ralph:
cross_loop_learRelated in AI Agents
skill-development
IncludedComprehensive meta-skill for creating, managing, validating, auditing, and distributing Claude Code skills and slash commands (unified in v2.1.3+). Provides skill templates, creation workflows, validation patterns, audit checklists, naming conventions, YAML frontmatter guidance, progressive disclosure examples, and best practices lookup. Use when creating new skills, validating existing skills, auditing skill quality, understanding skill architecture, needing skill templates, learning about YAML frontmatter requirements, progressive disclosure patterns, tool restrictions (allowed-tools), skill composition, skill naming conventions, troubleshooting skill activation issues, creating custom slash commands, configuring command frontmatter, using command arguments ($ARGUMENTS, $1, $2), bash execution in commands, file references in commands, command namespacing, plugin commands, MCP slash commands, Skill tool configuration, or deciding between skills vs slash commands. Delegates to docs-management skill for official documentation.
reprompter
IncludedTransform messy prompts into well-structured, effective prompts — single or multi-agent. Use when: "reprompt", "reprompt this", "clean up this prompt", "structure my prompt", rough text needing XML tags and best practices, "reprompter teams", "repromptception", "run with quality", "smart run", "smart agents", multi-agent tasks, audits, parallel work, anything going to agent teams. Don't use when: simple Q&A, pure chat, immediate execution-only tasks. See "Don't Use When" section for details. Outputs: Structured XML/Markdown prompt, quality score (before/after), optional team brief + per-agent sub-prompts, agent team output files. Success criteria: Single mode quality score ≥ 7/10; Repromptception per-agent prompt quality score 8+/10; all required sections present, actionable and specific.
adaptive-compaction
IncludedAdaptive add-on policy and recovery layer that decides WHEN to compact, prune, snapshot, or fork -- replacing fixed-percent auto-compaction across Claude Code, Codex, and MCP-capable hosts. Trigger on auto-compact timing or damage: "when should I compact", "is it safe to compact now or start a fresh session", "auto-compact fires too early/mid-task", "switching to an unrelated task but the window still has space", "context rot", "answers get worse the longer the session runs", "the agent forgot the plan or my decisions after it summarized", "add a layer on top that manages context without changing the agent", raising autoCompactWindow to give the policy room, or installing/tuning a cross-tool compaction policy or PreCompact hook -- even when "compaction" is never said but the problem is context-window pressure or post-summarization memory loss. Do NOT use to summarize a conversation, build RAG, write a summarization prompt (decides WHEN not HOW), or answer max-context-length trivia.
agent-skill-creator
IncludedCreate cross-platform agent skills from workflow descriptions. Activates when users ask to create an agent, automate a repetitive workflow, create a custom skill, or need advanced agent creation. Triggers on phrases like create agent for, automate workflow, create skill for, every day I have to, daily I need to, turn process into agent, need to automate, create a cross-platform skill, validate this skill, export this skill, migrate this skill. Supports single skills, multi-agent suites, transcript processing, template-based creation, interactive configuration, cross-platform export, and spec validation.
llm-wiki
IncludedUse when building or maintaining a persistent personal knowledge base (second brain) in Obsidian where an LLM incrementally ingests sources, updates entity/concept pages, maintains cross-references, and keeps a synthesis current. Triggers include "second brain", "Obsidian wiki", "personal knowledge management", "ingest this paper/article/book", "build a research wiki", "compound knowledge", "Memex", or whenever the user wants knowledge to accumulate across sessions instead of being re-derived by RAG on every query.
skill-master
IncludedAgent Skills authoring, evaluation, and optimization. Create, edit, validate, benchmark, and improve skills following the agentskills.io specification. Use when designing SKILL.md files, structuring skill folders (references, scripts, assets), ingesting external documentation into skills, running trigger evals, benchmarking skill quality, optimizing descriptions, or performing blind A/B comparisons. Keywords: agentskills.io, SKILL.md, skill authoring, eval, benchmark, trigger optimization.