agentleFS
asmamestasmamest/Nexus-Skills/skills/ai-engineering/rag-pipeline-engineering/SKILL.md

rag-pipeline-engineering

Skill1 starsChanged 17 days agoMITView on GitHub

Build or improve retrieval-augmented generation pipelines, from document ingestion and chunking to retrieval, grounding, citations, and production evaluation.

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:

    Clean carefully: Remove boilerplate and duplicates without deleting qualifications, table relationships, code, or critical context.

    line 14
  2. Distinctive:

    Chunk semantically: Prefer section-aware boundaries and preserve parent/child relationships.

    line 15
  3. Distinctive:

    Handle insufficient evidence: Ask a clarifying question, search again under a bounded policy, or abstain.

    line 20
  4. Distinctive:

    Evaluate end to end: Test ingestion, retrieval, answer quality, permissions, latency, and cost separately and together.

    line 21
  5. Distinctive:

    Use metadata filtering for tenant, time, type, and access scope.

    line 30
  6. Distinctive:

    Consider reranking, query rewriting, multi-query, or agentic retrieval only when a baseline demonstrates a gap.

    line 33
  7. Distinctive:

    Keep a deterministic baseline before adding agent loops.

    line 34

≈ “Common” is an estimate: at least 1 in 5 of the 308,232 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

RAG Pipeline Engineering

Goal

Build a retrieval-augmented generation (RAG) pipeline that retrieves authorized, relevant evidence and uses it to answer questions with traceable support. RAG reduces some knowledge gaps; it does not guarantee correctness.

Workflow

  1. Define the knowledge task. Identify query types, source systems, freshness requirements, access controls, languages, document types, and answerability criteria.
  2. Inventory and ingest. Extract text and structure from supported formats. Preserve headings, tables, page/section identifiers, source URI, timestamp, tenant/ACL metadata, and document version.
  3. Clean carefully. Remove boilerplate and duplicates without deleting qualifications, table relationships, code, or critical context. Record extraction failures.
  4. Chunk semantically. Prefer section-aware boundaries and preserve parent/child relationships. Tune chunk size and overlap using evaluation rather than defaults alone.
  5. Select retrieval. Compare lexical search, dense vectors, hybrid retrieval, metadata filters, and domain-specific query expansion. Enforce authorization filters before returning content.
  6. Rerank when justified. Rerank a bounded candidate set if measured gains outweigh latency and cost. Preserve source metadata through every transformation.
  7. Construct grounded context. Deduplicate, order evidence, cap token budget, and instruct the model to distinguish supported claims from missing evidence.
  8. Generate with citations. Make citations refer to actual retrieved chunks or stable document locations. Validate citation IDs before returning them.
  9. Handle insufficient evidence. Ask a clarifying question, search again under a bounded policy, or abstain. Do not fabricate a citation or answer merely to appear helpful.
  10. Evaluate end to end. Test ingestion, retrieval, answer quality, permissions, latency, and cost separately and together.

Evaluation dimensions

  • Retrieval: recall@k, precision@k, MRR/nDCG where appropriate.
  • Answer: correctness, faithfulness to evidence, relevance, completeness, citation validity.
  • Operations: index freshness, ingestion errors, p95 latency, token use, cost, and failure rate.
  • Security: cross-tenant retrieval, ACL enforcement, poisoned documents, prompt injection, sensitive-data exposure.

Design decisions

  • Use metadata filtering for tenant, time, type, and access scope.
  • Reindex or incrementally update documents with idempotent jobs and deletion handling.
  • Version chunking, embedding model, index configuration, and prompt together.
  • Consider reranking, query rewriting, multi-query, or agentic retrieval only when a baseline demonstrates a gap.
  • Keep a deterministic baseline before adding agent loops.

Avoid

  • Assuming vector similarity equals relevance.
  • Treating retrieved text as trusted instructions.
  • Losing provenance during chunking or reranking.
  • Evaluating only a few hand-picked happy paths.
  • Exposing documents because the model was asked to respect permissions; permissions must be enforced by the retrieval layer.

Deliverable

Provide a pipeline diagram or sequence, ingestion/chunking choices, retrieval configuration, citation strategy, evaluation dataset and results, access-control design, and known limitations.

References

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.