Agent skill

Context Retrieval

by seb1n in seb1n/awesome-ai-agent-skills

Retrieve relevant information from a knowledge base using semantic, keyword, or hybrid search to ground a query.

MITAuto-check passedAI & LLM Engineering

Install Context Retrieval

skills CLI
$ npx skills add seb1n/awesome-ai-agent-skills --skill context-retrieval -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install seb1n/awesome-ai-agent-skills context-retrieval --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/seb1n/awesome-ai-agent-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/context-engineering/context-retrieval .claude/skills/context-retrieval && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
context-retrieval
GitHub stars
206
Token cost
~2.1k tokens
SKILL.md length
1,020 words
Files
1
Skills in repo
91
Repo updated
First seen
Licence
MIT

At a glance

Retrieve relevant information from a knowledge base using semantic, keyword, or hybrid search to ground a query.

  • Works in 6 steps: Embed the Query: Convert the user's… → Search the Vector Store: Send the query… → Rerank the Results: Pass the candidate… → …
  • The task starts with a corpus
  • SKILL.md covers Workflow, Key Concepts, Usage and Examples, plus 2 more sections
  • Needs JWT_SECRET

What it does

Context Retrieval is an agent skill from seb1n/awesome-ai-agent-skills. Retrieve relevant information from a knowledge base using semantic, keyword, or hybrid search to ground a query. Use when the task starts with a corpus or index that must be searched; use context-ranking when candidate chunks already exist and only need ordering.

Its SKILL.md is about 2.1k tokens, which your agent loads only when the skill is triggered. It is a single SKILL.md file with no bundled scripts.

It sits in AI & LLM Engineering, covering Retrieval-augmented generation, Context engineering and Knowledge bases. The repository describes itself as: 103 ready-to-use AI agent skills for Claude Code, OpenAI Codex, Gemini CLI, Cursor, GitHub Copilot, Windsurf, and other Agent Skills-compatible tools. Complete SKILL.md… The licence is MIT.

When your agent uses it

  • The task starts with a corpus
  • Index that must be searched
  • Use context-ranking when candidate chunks already exist and only need ordering

Example prompts

  • “/context-retrieval”

Requirements

  • A credential in JWT_SECRET

Workflow steps

6 steps, taken from the first numbered list in SKILL.md.

  1. Embed the Query: Convert the user's natural-language query into a dense vector representation using an embedding model (e.g., OpenAI…
  2. Search the Vector Store: Send the query embedding to a vector database (Pinecone, Weaviate, Qdrant, Chroma, etc.) and perform an…
  3. Rerank the Results: Pass the candidate chunks through a cross-encoder reranker (e.g., Cohere Rerank, bge-reranker-large, or a ColBERT…
  4. Assemble the Context Window: Concatenate the selected chunks into a single context block, ordered by relevance score descending. Prepend…
  5. Generate the Response: Feed the assembled context into the LLM prompt alongside the original query and a system instruction that tells the…
  6. Validate and Cite: After generation, verify that the answer references information actually present in the retrieved chunks. Attach inline…

What it can do on your machine

Read from SKILL.md and the folder at commit 75865a5. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    No scripts in the folder and no shell commands in SKILL.md.

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names these keys or tokens, usually read from environment variables:

    • JWT_SECRET

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Context Retrieval loads about 2.1k tokens when it runs. Until then it costs about 70 tokens; SKILL.md has 1,020 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~70
When it runs · the whole SKILL.md, loaded when a task matches
~2.1k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from seb1n/awesome-ai-agent-skills at commit 75865a5, republished under its MIT licence (© seb1n). 1,020 words, ~2,071 tokens.

Download SKILL.mdSave it as .claude/skills/context-retrieval/SKILL.md (or your agent's skills folder).
name
context-retrieval
description
Retrieve relevant information from a knowledge base using semantic, keyword, or hybrid search to ground a query. Use when the task starts with a corpus or index that must be searched; use context-ranking when candidate chunks already exist and only need ordering.
license
MIT
metadata.author
awesome-ai-agent-skills
metadata.version
1.0.0

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.

Key Concepts

  • Semantic Search: Uses vector embeddings to find documents by meaning rather than exact keyword match. Excels at paraphrasing and synonym handling but can miss precise technical terms.
  • Keyword Search (BM25): Traditional term-frequency search that excels at exact matches and rare terms. Fast and interpretable but blind to synonyms.
  • Hybrid Search: Combines semantic and keyword search (e.g., weighted fusion of BM25 + cosine similarity scores) to get the best of both worlds. Most production RAG systems use hybrid retrieval.
  • Chunking Strategies: Documents must be split into chunks before indexing. Common strategies include fixed-size token windows (256–512 tokens with 50-token overlap), sentence-boundary splitting, and recursive character splitting. Smaller chunks improve precision; larger chunks preserve more context.
  • Embedding Models: The choice of embedding model affects retrieval quality. Larger models (1024+ dimensions) capture more nuance but cost more to store and query. Always benchmark on your domain before choosing.

Usage

To use this skill, you need a pre-indexed knowledge base with document embeddings stored in a vector database. Provide a natural-language query as input. The skill returns the retrieved context block ready for prompt assembly, along with source metadata for citation.

Examples

Example 1: Retrieving Codebase Context for a Code Question

Query: "How does the authentication middleware validate JWT tokens?"

Retrieved Chunks (after reranking):

RankSourceScoreSnippet
1src/middleware/auth.ts:14-380.94export function validateToken(req, res, next) { const token = req.headers.authorization?.split(' ')[1]; if (!token) return res.status(401).json({ error: 'Missing token' }); try { const decoded = jwt.verify(token, process.env.JWT_SECRET); req.user = decoded; next(); } catch (e) { return res.status(403).json({ error: 'Invalid token' }); } }
2docs/auth-flow.md:8-220.87"The JWT is signed with HS256 using the JWT_SECRET env var. Tokens expire after 24 hours. The middleware extracts the token from the Authorization header, verifies the signature, and attaches the decoded payload to req.user."
3tests/auth.test.ts:5-190.72Test cases covering valid token, expired token, and malformed token scenarios.

Assembled Prompt:

Answer the following question using ONLY the provided context. Cite file paths.

Context:
[1] src/middleware/auth.ts:14-38 — export function validateToken(req, res, next) { ... }
[2] docs/auth-flow.md:8-22 — The JWT is signed with HS256 using the JWT_SECRET env var...
[3] tests/auth.test.ts:5-19 — Test cases covering valid token, expired token...

Question: How does the authentication middleware validate JWT tokens?
Show full SKILL.md (396 more words)Show less
Example 2: Retrieving Product Docs for a Support Question

Query: "How do I reset my password if I no longer have access to my email?"

Retrieved Chunks:

  1. help/account-recovery.md (score 0.91) — "If you cannot access your registered email, navigate to Settings > Account > Identity Verification. You will be asked to verify your identity using your phone number or a government-issued ID. Once verified, you can set a new email and reset your password."
  2. help/password-reset.md (score 0.85) — "To reset your password, click 'Forgot Password' on the login page. A reset link will be sent to your registered email address. The link expires after 1 hour."

Generated Answer: "Since you no longer have access to your email, use the identity verification flow: go to Settings > Account > Identity Verification, verify via phone number or government ID, update your email address, then reset your password from the login page. [Sources: help/account-recovery.md, help/password-reset.md]"

Best Practices

  • Use hybrid retrieval in production — combining BM25 keyword search with semantic vector search consistently outperforms either approach alone.
  • Always rerank — a cross-encoder reranker on the top-20 results dramatically improves precision compared to relying on embedding cosine similarity alone.
  • Chunk with overlap — use 10–20% token overlap between adjacent chunks to prevent splitting critical information across chunk boundaries.
  • Include metadata — store file paths, section headings, timestamps, and authors alongside embeddings so retrieved context is traceable and citable.
  • Tune top-k empirically — retrieve more candidates than you need (k = 15–20), then let the reranker narrow to the best 3–5. This balances recall and precision.
  • Benchmark regularly — measure retrieval quality with metrics like Recall@k, MRR, and NDCG on a labeled evaluation set from your domain.

Edge Cases

  • No relevant results found: When the top retrieval score is below a confidence threshold (e.g., < 0.5), the agent should acknowledge that it does not have enough information rather than fabricating an answer.
  • Contradictory sources: If retrieved chunks contain conflicting information, surface both perspectives and note the discrepancy rather than silently picking one.
  • Stale or outdated content: Documents indexed months ago may be outdated. Include timestamps in metadata and prefer more recent chunks when scores are close.
  • Very short or very long queries: Single-word queries may produce noisy results — consider query expansion. Very long queries may benefit from decomposition into sub-queries with results merged.
  • Multi-language knowledge bases: Ensure the embedding model supports the languages present in the corpus, or use a translation step before embedding.

© seb1n, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

Just SKILL.md in context-engineering/context-retrieval of seb1n/awesome-ai-agent-skills.

Open the folder on GitHubat commit 75865a5

Compare with similar skills

Context Retrieval next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Context Retrieval compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Context Retrieval this skillseb1n/awesome-ai-agent-skills206—~2.1kAutomated safety check: PassMIT
Langchain4j RAG Implementation Patternsgiuseppe-trisciuoglio/developer-kit3551 repos~3.3kAutomated safety check: NotesMIT
RAG Pipelinebrightdata/skills264—~1.9kAutomated safety check: PassMIT
AWS Cloudformation Bedrockgiuseppe-trisciuoglio/developer-kit355—~3.2kAutomated safety check: NotesMIT
Blockify Integrationiternal-technologies-partners/blockify-agentic-data-optimization316—~6.2kAutomated safety check: NotesCustom licence
Agentsop Difyagentsope/SkillAlchemy459—~5.4kAutomated safety check: NotesMIT

Similar skills

  • Langchain4j RAG Implementation Patterns

    giuseppe-trisciuoglio/developer-kit

    Provides Retrieval-Augmented Generation (RAG) implementation patterns with LangChain4j for Java.

    355 GitHub starsUsed in 1 repo~3.3k tokens
    AI & LLM EngineeringAuto-check: notes
  • RAG Pipeline

    brightdata/skills

    Build a RAG (retrieval-augmented generation) pipeline or a custom search engine on top of Bright Data's Discover API — using intent-ranked web results + parsed page content as the…

    264 GitHub stars~1.9k tokensUpdated yesterday
    AI & LLM EngineeringAuto-check passed
  • AWS Cloudformation Bedrock

    giuseppe-trisciuoglio/developer-kit

    Provides AWS CloudFormation patterns for Amazon Bedrock resources including agents, knowledge bases, data sources, guardrails, prompts, flows, and inference profiles.

    355 GitHub stars~3.2k tokensUpdated 28 days ago
    AI & LLM EngineeringAuto-check: notes
  • Blockify Integration

    iternal-technologies-partners/blockify-agentic-data-optimization

    Process documents with Blockify API to create optimized IdeaBlocks for RAG.

    316 GitHub stars~6.2k tokensUpdated 5 mo ago
    AI & LLM EngineeringAuto-check: notes
  • Agentsop Dify

    agentsope/SkillAlchemy

    SOP for building LLM applications on Dify — visual workflow + chatflow + agent + RAG knowledge base + plugin marketplace + observability, self-hostable.

    459 GitHub stars~5.4k tokensUpdated 1 mo ago
    AI & LLM EngineeringAuto-check: notes
  • Penguin SDK

    Prism-Shadow/penguin-harness

    A skill your agent uses whenever the user wants to build an agent application — their own program with an embedded agent, such as an AI app, an agentic app or a RAG app.

    2.5k GitHub stars~11k tokensUpdated yesterday
    AI & LLM EngineeringAuto-check passed

More from seb1n/awesome-ai-agent-skills

All 91 skills in this repo
  • Agent Red Teaming

    seb1n/awesome-ai-agent-skills

    Plan, execute, document, and retest authorized security assessments of AI agents and multi-agent workflows using safe adversarial cases, synthetic identities, canaries, and evidence-based findings.

    206 GitHub stars~2.8k tokensUpdated 2 mo ago
    Auto-check passed
  • Eu AI Act Readiness

    seb1n/awesome-ai-agent-skills

    Build a preliminary, evidence-based EU AI Act readiness assessment across AI-system inventory, territorial scope, operator roles, prohibited-practice screening, risk classification, transparency…

    206 GitHub stars~3.3k tokensUpdated 2 mo ago
    Auto-check passed
  • Human In The Loop

    seb1n/awesome-ai-agent-skills

    Design and verify auditable human oversight, approval gates, escalation paths, and safe state transitions for AI agent workflows.

    206 GitHub stars~2.5k tokensUpdated 2 mo ago
    Auto-check passed
  • MCP Server Building

    seb1n/awesome-ai-agent-skills

    Design, implement, harden, and verify Model Context Protocol (MCP) servers with precise tool contracts, least-privilege authorization, safe transports, structured errors, and interoperability tests.

    206 GitHub stars~2.5k tokensUpdated 2 mo ago
    Auto-check passed
  • Skill Supply Chain Audit

    seb1n/awesome-ai-agent-skills

    Audit agent skills, plugins, prompts, manifests, scripts, dependencies, and bundled assets for provenance, prompt-injection, permission, execution, exfiltration, persistence, and update risk.

    206 GitHub stars~2.4k tokensUpdated 2 mo ago
    Auto-check passed
  • Spreadsheet Analysis

    seb1n/awesome-ai-agent-skills

    Inspect, profile, clean, reconcile, analyze, visualize, and verify spreadsheet data while preserving formulas, formatting, types, and source files.

    206 GitHub stars~2.5k tokensUpdated 2 mo ago
    Auto-check passed

Questions about Context Retrieval

What does Context Retrieval do?

Retrieve relevant information from a knowledge base using semantic, keyword, or hybrid search to ground a query. Context Retrieval is an agent skill from seb1n/awesome-ai-agent-skills. Retrieve relevant information from a knowledge base using semantic, keyword, or hybrid search to ground a query.

When should I use Context Retrieval?

Context Retrieval fits situations like: the task starts with a corpus; index that must be searched; use context-ranking when candidate chunks already exist and only need ordering.

How do I install Context Retrieval in Claude Code?

Run `npx skills add seb1n/awesome-ai-agent-skills --skill context-retrieval -a claude-code`. Or copy the skill folder (context-engineering/context-retrieval in seb1n/awesome-ai-agent-skills) into .claude/skills/context-retrieval in your project. Claude Code loads it when a task matches its description.

How do I install Context Retrieval in Codex?

Run `npx skills add seb1n/awesome-ai-agent-skills --skill context-retrieval -a codex`. Or copy the skill folder (context-engineering/context-retrieval in seb1n/awesome-ai-agent-skills) into .agents/skills/context-retrieval in your project. Codex loads it when a task matches its description.

Can I use Context Retrieval in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add seb1n/awesome-ai-agent-skills --skill context-retrieval -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/context-retrieval, .gemini/skills/context-retrieval, .github/skills/context-retrieval and .opencode/skills/context-retrieval in your project.

What does Context Retrieval need to run?

Going by SKILL.md and its folder, Context Retrieval needs credentials named JWT_SECRET. Our summary lists: A credential in JWT_SECRET.

Does Context Retrieval access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Context Retrieval safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Context Retrieval use?

Context Retrieval is published under the MIT licence (declared in SKILL.md). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Context Retrieval use?

About 2.1k tokens (SKILL.md is roughly 8.3k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full.

What are the alternatives to Context Retrieval?

Skills that share tags, products or a category with Context Retrieval: Langchain4j RAG Implementation Patterns (giuseppe-trisciuoglio/developer-kit, 355 stars), RAG Pipeline (brightdata/skills, 264 stars), AWS Cloudformation Bedrock (giuseppe-trisciuoglio/developer-kit, 355 stars) and Blockify Integration (iternal-technologies-partners/blockify-agentic-data-optimization, 316 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Context Retrieval?

seb1n (a GitHub user) maintains it in seb1n/awesome-ai-agent-skills, which has 206 GitHub stars. The repository holds 91 skills in this directory. The repository was last updated on August 9, 2026.

Source: seb1n/awesome-ai-agent-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.