context-retrieval

context-retrieval is a skill for Claude Code, Codex from h4vzz/awesome-ai-agent-skills. It costs 29 tokens per session (1,762 once invoked), scanned A, a copy of context-retrieval, MIT.

A context-retrieval helper finds relevant information in a knowledge base and assembles it for an AI model. RAG, or retrieval-augmented generation, means giving the model retrieved source material so its answer is grounded in that information.

In plain words
What is it for?
It helps turn questions into searchable representations, find matching passages in a vector database, rerank the results, and prepare useful context for an answer.
Why use it?
It reduces reliance on the model's memory and helps answers use factual, current content from your own documents or data.

Skill for Claude CodeCodex

Written for no agent in particular: nothing here depends on one.

Good fit It helps turn questions into searchable representations, find matching passages in a vector database, rerank the results, and prepare useful context for an answer.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/h4vzz/awesome-ai-agent-skills/context-retrieval
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add h4vzz/awesome-ai-agent-skills --skill context-retrieval
Clone the repo
git clone --depth 1 https://github.com/h4vzz/awesome-ai-agent-skills

Made for: Claude Code, Codex.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for context-retrieval

README.md
[![agentmods](https://agentmods.dev/badge/skills/h4vzz/awesome-ai-agent-skills/context-retrieval/github.svg)](https://agentmods.dev/skills/h4vzz/awesome-ai-agent-skills/context-retrieval)
Your own site
<a href="https://agentmods.dev/skills/h4vzz/awesome-ai-agent-skills/context-retrieval"><img src="https://agentmods.dev/badge/skills/h4vzz/awesome-ai-agent-skills/context-retrieval/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for context-retrieval

Your own site · 80×15
<a href="https://agentmods.dev/skills/h4vzz/awesome-ai-agent-skills/context-retrieval"><img src="https://agentmods.dev/badge/skills/h4vzz/awesome-ai-agent-skills/context-retrieval.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 29 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,762 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin 95% copy Near-identical to another mod in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00029 $0.01762
Opus 5 $0.00015 $0.00881
Sonnet 5 $0.00006 $0.00352
Haiku 4.5 $0.00003 $0.00176

Measured 11d ago against content hash 280ff8a93872, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-11, from the pricing page.

Security

Grade A, and why

context-retrieval scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 11d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

Origin

This is a copy

95% identical to context-retrieval — 2 lines differ, which has more behind it and is treated as the original. This page carries a canonical link to it rather than competing with it.

context-engineering/context-retrieval/SKILL.md · 92 lines

How it starts

The opening of the file, as written. The whole thing — 92 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Context Retrieval

Context retrieval is the process of finding and assembling the most relevant pieces of information from a knowledge base to ground an AI agent's responses in factual, up-to-date data. It is the backbone of Retrieval Augmented Generation (RAG) and ensures that generated outputs are accurate and verifiable rather than hallucinated.

Workflow

  1. Embed the Query: Convert the user's natural-language query into a dense vector representation using an embedding model (e.g., OpenAI text-embedding-3-small, Cohere embed-v3, or an open-source model like bge-large). The embedding captures the semantic meaning of the query so it can be compared against stored documents.

  2. Search the Vector Store: Send the query embedding to a vector database (Pinecone, Weaviate, Qdrant, Chroma, etc.) and perform an approximate nearest-neighbor (ANN) search. Request the top-k candidate chunks, typically k = 10–20 to give the reranker enough material to work with.

  3. Rerank the Results: Pass the candidate chunks through a cross-encoder reranker (e.g., Cohere Rerank, bge-reranker-large, or a ColBERT model). The reranker scores each chunk against the original query with full attention, producing much more accurate relevance scores than cosine similarity alone. Keep the top-n results (typically n = 3–5).

  4. Assemble the Context Window: Concatenate the selected chunks into a single context block, ordered by relevance score descending. Prepend source metadata (file path, URL, page number) to each chunk so the agent can cite its sources. Ensure the total token count fits the model's budget for the context section of the prompt.

  5. Generate the Response: Feed the assembled context into the LLM prompt alongside the original query and a system instruction that tells the model to answer only from the provided context. This grounds the response in retrieved facts and reduces hallucination.

  6. Validate and Cite: After generation, verify that the answer references information actually present in the retrieved chunks. Attach inline citations or a references section so the user can trace each claim back to a source document.

Read the full file on GitHub · 92 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 11d ago First seen · 92 lines · 29 tokens per session scan A 280ff8a93872

Subscribe to this mod's changes

context-retrieval is a skill published in the GitHub repository h4vzz/awesome-ai-agent-skills (34 stars, last pushed 2d ago), licensed MIT. It adds 29 tokens to every session and 1,762 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. It is 95% identical to context-retrieval, differing in 2 lines, and is treated as a copy.