pattern-learning
Enables autonomous pattern recognition, storage, and retrieval at project level with self-learning capabilities for continuous improvement
What this skill does
## Overview
This skill provides the framework for autonomous pattern learning and recognition at the project level. It enables Claude agents to:
- Automatically detect and store successful task execution patterns
- Build a knowledge base of project-specific approaches
- Recommend skills and strategies based on historical success
- Continuously improve through self-assessment and adaptation
## Pattern Recognition System
### Automatic Pattern Detection
**Task Categorization**:
Automatically classify tasks into categories:
- `refactoring`: Code restructuring and improvement
- `bug-fix`: Error resolution and debugging
- `feature`: New functionality implementation
- `optimization`: Performance improvements
- `documentation`: Docs creation and updates
- `testing`: Test suite development
- `security`: Security analysis and fixes
**Context Extraction**:
Automatically extract context from:
- Programming languages used (file extensions)
- Frameworks detected (package.json, requirements.txt, etc.)
- Project structure patterns (MVC, microservices, etc.)
- Complexity indicators (file count, LOC, dependencies)
### Pattern Storage Structure
**Directory Setup**:
```
.claude-patterns/
├── patterns.json # Main pattern database
├── skill-effectiveness.json # Skill performance metrics
└── task-history.json # Complete task execution log
```
**Pattern Data Model**:
```json
{
"version": "1.0.0",
"project_context": {
"detected_languages": ["python", "javascript"],
"frameworks": ["flask", "react"],
"project_type": "web-application"
},
"patterns": [
{
"id": "pattern-001",
"timestamp": "2025-10-20T10:30:00Z",
"task_type": "refactoring",
"task_description": "Refactor authentication module",
"context": {
"language": "python",
"framework": "flask",
"module": "authentication",
"complexity": "medium"
},
"execution": {
"skills_used": ["code-analysis", "quality-standards"],
"agents_delegated": ["code-analyzer", "quality-controller"],
"approach": "Extract method refactoring with pattern matching",
"duration_seconds": 120
},
"outcome": {
"success": true,
"quality_score": 96,
"tests_passing": true,
"standards_compliance": 98,
"documentation_complete": true
},
"lessons_learned": "Security-critical modules benefit from quality-controller validation",
"reuse_count": 5
}
],
"skill_effectiveness": {
"code-analysis": {
"total_uses": 45,
"successful_uses": 42,
"success_rate": 0.93,
"avg_quality_contribution": 15,
"recommended_for": ["refactoring", "bug-fix", "optimization"]
},
"testing-strategies": {
"total_uses": 30,
"successful_uses": 27,
"success_rate": 0.90,
"avg_quality_contribution": 20,
"recommended_for": ["testing", "feature", "bug-fix"]
}
},
"agent_effectiveness": {
"code-analyzer": {
"total_delegations": 38,
"successful_completions": 36,
"success_rate": 0.95,
"avg_execution_time": 85
}
}
}
```
## Skill Auto-Selection Algorithm
### Decision Process
**Step 1: Analyze Current Task**
```
Input: Task description
Output: Task type, context, complexity
Process:
1. Extract keywords and intent
2. Scan project files for context
3. Classify task type
4. Determine complexity level (low/medium/high)
```
**Step 2: Query Pattern Database**
```
Input: Task type, context
Output: Recommended skills, agents, approach
Process:
1. Load patterns.json
2. Filter patterns by task_type match
3. Filter patterns by context similarity
4. Rank by success_rate * reuse_count
5. Extract top 3 most successful patterns
```
**Step 3: Skill Selection**
```
Input: Top patterns, skill effectiveness data
Output: Ordered list of skills to load
Process:
1. Aggregate skills from top patterns
2. Weight by skill effectiveness scores
3. Filter by task type recommendation
4. Return ordered list (highest effectiveness first)
```
### Selection Examples
**Example 1: Refactoring Task**
```
Task: "Refactor user authentication module"
Analysis:
- Type: refactoring
- Context: authentication (security-critical)
- Language: Python (detected)
- Complexity: medium
Pattern Query Results:
- Pattern-001: refactoring + auth → success_rate: 0.96
- Pattern-015: refactoring + security → success_rate: 0.94
- Pattern-023: refactoring + Python → success_rate: 0.91
Skill Selection:
1. code-analysis (appeared in all 3 patterns, avg effectiveness: 0.93)
2. quality-standards (appeared in 2/3 patterns, avg effectiveness: 0.88)
3. pattern-learning (for continuous improvement)
Auto-Load: code-analysis, quality-standards, pattern-learning
```
**Example 2: Testing Task**
```
Task: "Add unit tests for payment processing"
Analysis:
- Type: testing
- Context: payment (critical business logic)
- Language: JavaScript (detected)
- Complexity: high
Pattern Query Results:
- Pattern-042: testing + payment → success_rate: 0.89
- Pattern-051: testing + JavaScript → success_rate: 0.92
Skill Selection:
1. testing-strategies (effectiveness: 0.90)
2. quality-standards (for test quality)
3. pattern-learning (for continuous improvement)
Auto-Load: testing-strategies, quality-standards, pattern-learning
```
## Pattern Storage Workflow
### Automatic Storage Process
**During Task Execution**:
1. Monitor task progress and decisions
2. Record skills loaded and agents delegated
3. Track execution metrics (time, resources)
4. Capture approach and methodology
**After Task Completion**:
1. Run quality assessment
2. Calculate quality score
3. Determine success/failure
4. Extract lessons learned
5. Store pattern to database
6. Update skill effectiveness metrics
7. Update agent effectiveness metrics
### Storage Implementation
**Auto-Create Pattern Directory - WITH SAFETY VALIDATION**:
```javascript
// 🚨 CRITICAL: Always validate content before applying cache_control
function safeExecuteOperation(operation, fallbackContent) {
try {
const result = operation();
// Validate result before using
if (result !== null && result !== undefined && String(result).trim().length > 0) {
return result;
}
} catch (error) {
console.log("Operation failed, using fallback");
}
// Always return meaningful fallback
return fallbackContent || "Pattern initialization in progress...";
}
// Executed automatically by orchestrator with safety checks
const dirExists = safeExecuteOperation(() => exists('.claude-patterns/'), false);
if (!dirExists) {
safeExecuteOperation(() => create_directory('.claude-patterns/'));
safeExecuteOperation(() => create_file('.claude-patterns/patterns.json', '{"version":"1.0.0","patterns":[]}'));
safeExecuteOperation(() => create_file('.claude-patterns/skill-effectiveness.json', '{}'));
safeExecuteOperation(() => create_file('.claude-patterns/task-history.json', '[]'));
}
```
**Store New Pattern - WITH COMPREHENSIVE SAFETY**:
```javascript
// 🚨 CRITICAL: Safe pattern storage with full validation
function store_pattern(task_data, execution_data, outcome_data) {
// Validate inputs first
if (!task_data || !execution_data || !outcome_data) {
console.log("Invalid pattern data, skipping storage");
return "Pattern data incomplete - storage skipped";
}
try {
const pattern = {
id: generate_id() || `pattern_${Date.now()}`,
timestamp: now() || new Date().toISOString(),
task_type: task_data.type || "unknown",
task_description: task_data.description || "Task completed",
context: extract_context(task_data) || {},
execution: execution_data,
outcome: outcome_data,
lessons_learned: analyze_lessons(execution_data, outcome_data) || "Task completed successfully",
reuse_count: 0
}
// Load existing patterns safely
const db = safeLoadPatterns('.claude-patterns/patterns.json');
if (!db) {
Related in General
modeling-omnistudio-epc-catalog
IncludedSalesforce Industries CME EPC product-modeling skill for Product2-based catalog creation. Use when creating EPC products, configuring product attributes, building offer bundles with Product Child Items, or reviewing EPC DataPack JSON metadata for product catalog changes. TRIGGER when: user creates or updates Product2 EPC records, AttributeAssignment payloads, AttributeMetadata/AttributeDefaultValues, Offer bundles, or ProductChildItem relationships. DO NOT TRIGGER when: designing OmniScripts/FlexCards/Integration Procedures (use building-omnistudio-omniscript, building-omnistudio-flexcard, or building-omnistudio-integration-procedure), implementing Apex business logic (use generating-apex), or troubleshooting deployment pipelines (use deploying-metadata).
relationship-science-coach
IncludedUse this skill for direct, practical adult relationship coaching: couples conflict, repair, trust, marriage, dating, flirting, attachment patterns, emotional connection, sex, desire differences, eroticism, kink negotiation, affection, love languages, breakups, and long-term passion. Draw on Gottman, EFT and Hold Me Tight, attachment science, modern sex research, Perel, Nagoski, Kerner, Schnarch, Love and Stosny, and flexible love-language tools. Be concrete and low-hedge. Redirect only for imminent danger, abuse, coercive control, minors, non-consent, self-harm, stalking, or medical/legal/psychiatric decisions.
building-sf-integrations
IncludedSalesforce integration architecture and runtime plumbing with 120-point scoring. Use this skill to set up Named Credentials, External Credentials, External Services, REST/SOAP callout patterns, Platform Events, and Change Data Capture. TRIGGER when: user sets up Named Credentials, External Services, REST/SOAP callouts, Platform Events, CDC, or touches .namedCredential-meta.xml files. DO NOT TRIGGER when: Connected App/OAuth config (use configuring-connected-apps), Apex-only logic (use generating-apex), or data import/export (use handling-sf-data).
venue-templates
IncludedAccess comprehensive LaTeX templates, formatting requirements, and submission guidelines for major scientific publication venues (Nature, Science, PLOS, IEEE, ACM), academic conferences (NeurIPS, ICML, CVPR, CHI), research posters, and grant proposals (NSF, NIH, DOE, DARPA). This skill should be used when preparing manuscripts for journal submission, conference papers, research posters, or grant proposals and need venue-specific formatting requirements and templates.
let-fate-decide
IncludedDraws the 12 Houses of the Zodiac Tarot spread to inject entropy into planning when prompts are vague, ambiguous, or casually delegated. Interprets the spread to guide next steps. Use when the user says 'let fate decide', 'YOLO', 'whatever', 'idk', or other nonchalant phrases, makes Yu-Gi-Oh references, or when you are about to arbitrarily pick between multiple reasonable approaches. Prefer over ask-questions-if-underspecified when the user's tone is casual or playful rather than precision-seeking.
net-ops
IncludedCross-platform network troubleshooting (Windows, macOS, Linux) via local or remote shell. Use for: DNS broken, can't resolve hostnames, nslookup/dig works but apps fail, NRPT, WFP, scutil, /etc/resolver, systemd-resolved, /etc/resolv.conf, NetworkManager, VPN DNS leak residue (ProtonVPN/Mullvad/WireGuard/AnyConnect), AV/firewall blocking DNS or DoH, Tailscale DNS interaction, intermittent connectivity, remote diagnostics over SSH.