agentleFS
mmccallammccalla/coding-agent-skill-library/skills/knowledge-retrieval-rag/SKILL.md

knowledge-retrieval-rag

Skill4 starsChanged 5 months agoApache-2.0View on GitHub

Use when implementing retrieval-augmented generation, RAG features, RAG pipelines, document-grounded coding agents, semantic search, citation-backed answers, repository/document knowledge lookup, evaluation gates, or release evaluation for RAG.

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 7 are distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈7

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when an agent needs facts from external documents, code repositories, wikis, tickets, logs, APIs, or other knowledge stores …

    line 16
  2. Distinctive:

    Prefer hybrid retrieval for coding agents:

    line 37
  3. Distinctive:

    Add retrieval tests with known questions and expected source files.

    line 48
  4. Distinctive:

    Do not answer from memory when repository evidence is required.

    line 52
  5. Distinctive:

    Do not mix authorised and unauthorised content in one context.

    line 53
  6. Distinctive:

    Do not cite chunks that do not support the claim.

    line 54
  7. Distinctive:

    Do not use raw PDFs or binary files directly if the agent cannot parse them reliably.

    line 55

≈ “Common” is an estimate: at least 1 in 5 of the 213,895 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Knowledge Retrieval (RAG)

When to use

Use this skill when an agent needs facts from external documents, code repositories, wikis, tickets, logs, APIs, or other knowledge stores before answering or modifying code.

For GraphRAG, Neo4j-native retrieval, text-to-Cypher, provenance-first graph ingestion, or KG-backed answer generation, pair this skill with skills/knowledge-graph-rag/SKILL.md.

Objective

Ground agent answers and changes in retrievable, permission-aware source evidence with inspectable citations.

Procedure

  1. Ingest documents or code into clean text.
  2. Split content into meaningful chunks that preserve context.
  3. Store metadata: source path, section, timestamp, owner, commit, permissions and content type.
  4. Index chunks using embeddings and, where useful, keyword search.
  5. Retrieve relevant chunks for the user query.
  6. Rerank or filter results for relevance, freshness and permissions.
  7. Generate an answer grounded only in retrieved evidence.
  8. Cite sources or file paths so claims are inspectable.

Retrieval strategy

Prefer hybrid retrieval for coding agents:

  • keyword/BM25 for exact symbols, filenames, errors and API names;
  • vector search for semantic questions and conceptual similarity;
  • structural search for AST symbols, imports, tests and dependency graphs;
  • reranking for final context selection.

Implementation guidance

Chunk code differently from prose. Keep functions, classes, configuration blocks and tests intact where possible. Preserve import context and neighbouring comments.

Add retrieval tests with known questions and expected source files. Measure recall before tuning generation prompts.

Guardrails

  • Do not answer from memory when repository evidence is required.
  • Do not mix authorised and unauthorised content in one context.
  • Do not cite chunks that do not support the claim.
  • Do not use raw PDFs or binary files directly if the agent cannot parse them reliably; convert to agent-readable text first.

Related skills

  • knowledge-graph-rag — graph-native retrieval when Neo4j applies
  • context-engineering — assemble retrieval context efficiently
  • guardrails-safety-patterns — validate retrieved and generated content

References

Verification

  • Sources are parsed into clean text.
  • Chunking preserves useful context.
  • Metadata and permissions are retained.
  • Retrieval quality is tested.
  • Generated output cites supporting sources.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.