Skip to content
Back to skills

Context Retrieval

ASecurity

Retrieve relevant episodic context from memory for informed decision-making. Use when you need past episodes, patterns, or solutions to similar tasks.

  • 666 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added February 8, 2026
ai-agentsrustsql

Security analysis

A100/100

Scanned February 12, 2026

npx -y skills add majiayu000/claude-skill-registry --skill context-retrieval --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Context Retrieval?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Context Retrieval
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/majiayu000-context-retrieval/badge)](https://www.skillsdirectory.com/skills/majiayu000-context-retrieval)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: context-retrieval
description: Retrieve relevant episodic context from memory for informed decision-making. Use when you need past episodes, patterns, or solutions to similar tasks.
---

# Context Retrieval

Retrieve relevant episodic context from memory for informed decision-making.

## Retrieval Methods

### Semantic Search (Preferred)
When embeddings available:
```rust
let context = memory
    .retrieve_relevant_context(
        "implement async batch updates",
        task_context,
        limit: 5
    )
    .await?;
```

**Advantages**: Finds semantically similar tasks, captures intent

### Keyword Search (Fallback)
```rust
// SQL index-based search
SELECT * FROM episodes
WHERE task_type = ? AND tags LIKE ?
ORDER BY timestamp DESC
LIMIT ?;
```

**Advantages**: Fast, no embedding computation, deterministic

## Retrieval Strategy

1. Parse query (key terms, domain, task type)
2. Check embedding availability
3. Query cache (redb) first, fall back to Turso
4. Rank by relevance or recency
5. Filter and limit results
6. Format context structure

## Context Filtering

```rust
// By domain
TaskContext { domain: "storage".to_string(), .. }

// By task type
task_type_filter: Some("implementation")

// By recency (last 30 days)
since: Some(now - Duration::days(30))

// By success only
verdict: Some(Verdict::Success)
```

## Response Format

```rust
pub struct RetrievedContext {
    pub episodes: Vec<EpisodeSummary>,
    pub patterns: Vec<Pattern>,
    pub heuristics: Vec<Heuristic>,
    pub relevance_scores: Vec<f32>,
}

pub struct EpisodeSummary {
    pub id: String,
    pub task_description: String,
    pub verdict: Verdict,
    pub key_steps: Vec<String>,
    pub reflection: String,
    pub relevance: f32,
}
```

## Usage Examples

```rust
// Find similar implementation tasks
let retrieved = memory
    .retrieve_relevant_context(query, context, 10)
    .await?;

// Find common tool sequences
let patterns = memory
    .get_patterns_by_type("ToolSequence")
    .filter(|p| p.success_rate > 0.8)
    .await?;

// Find error resolutions
let solutions = memory
    .retrieve_error_resolutions("borrow checker error", 5)
    .await?;
```

## Troubleshooting

| Issue | Solution |
|-------|----------|
| Low recall | Check embeddings, expand tags, increase limit |
| Slow retrieval | Check cache, verify indexes, reduce result set |
| Poor relevance | Use semantic search, improve query, filter by domain |

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.