rag-pipeline
Skill9 starsChanged 5 months agoApache-2.0View on GitHub
Builds and tunes retrieval-augmented-generation pipelines (chunking, embeddings, vector store, retrieval, reranking, grounding) when an agent needs an LLM to answer over a private corpus or knowledge base.
4 other projects use a version of this.
Adopted by
Most recently taken up by
- Red-empty-potato/ai-agent-skillstheir own version, first seen Aug 29, 2026
- brightdata/skillstheir own version, first seen Jun 25, 2026
- param087/agent-ml-skillstheir own version, first seen Jun 6, 2026
- yiweiwan/skillstheir own version, first seen May 12, 2026
Other versions4 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 4
- brightdata/skills★ 263same name
- param087/agent-ml-skills★ 11same name
- yiweiwan/skills★ 1same name
- Red-empty-potato/ai-agent-skills★ 0same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository147 other files it gives its agents.
- second-brain/AGENTS.mdAGENTS.md
- second-brain/CLAUDE.mdCLAUDE.md
- agent-tool-mcp-builderSkill
- api-design-reviewSkill
- async-concurrency-correctnessSkill
- audit-accessibility-wcagSkill
- audit-license-complianceSkill
- audit-technical-seoSkill
- auth-jwt-sessionSkill
- author-codemodSkill
- brainstorm-designSkill
- build-audit-loggingSkill
- build-cdc-streaming-pipelineSkill
- build-cli-toolSkill
- build-data-tableSkill
- build-etl-pipelineSkill
- build-form-validationSkill
- build-native-mobile-uiSkill
- build-office-docsSkill
- build-offline-first-syncSkill
- build-react-componentSkill
- build-realtime-channelSkill
- build-spreadsheetSkill
- build-vector-searchSkill
- caching-strategySkill
- cicd-pipeline-authorSkill
- cloud-cost-optimizeSkill
- code-commentsSkill
- code-reviewSkill
- compose-local-dev-stackSkill
- configure-bundler-buildSkill
- configure-dns-tlsSkill
- configure-reverse-proxy-lbSkill
- configure-security-headers-cspSkill
- contract-testingSkill
- datetime-timezone-correctnessSkill
- db-migration-safetySkill
- debug-ci-pipeline-failureSkill
- debug-flaky-testsSkill
- debug-frontend-browserSkill
- debug-root-causeSkill
- defend-llm-prompt-injectionSkill
- deliver-webhooksSkill
- dependency-upgradeSkill
- deploy-releaseSkill
- design-api-paginationSkill
- design-authorization-modelSkill
- design-backup-dr-recoverySkill
- design-event-sourcing-cqrsSkill
- design-multi-tenancySkill
- design-protobuf-grpc-serviceSkill
- design-relational-schemaSkill
- design-search-index-infraSkill
- design-state-machineSkill
- design-token-systemSkill
- diff-table-paritySkill
- distributed-locks-leasesSkill
- dockerfile-optimizeSkill
- encrypt-sensitive-dataSkill
- error-messageSkill
- The first 60 shown.
The file
We split this skill into the rules it gives an agent
4 rules. 0 are common, 2 are distinctive, and 2 are very specific to this project.
0
Common
Most of the 3 edited versions we read keep these.
2
Distinctive
This author's own choices. Worth a look.
2
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 49
Recall@k on the labeled set: run all example questions, confirm the gold chunk lands in top-k for a clear majority.
- Distinctive: line 50
Grounding check: ask a question whose answer is NOT in the corpus.
- Very specific: line 51
Citation check: every claim in a sample of answers maps to a retrieved [n] chunk.
- Distinctive: line 52
Idempotent re-index: run indexing twice on an unchanged corpus — second run re-embeds ~nothing (hash cache working) and produces an …
“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
When to Use
- "Chat over my docs / code / DB" — corpus too big or too private to stuff in the prompt.
- Answers are wrong/made-up because the model never saw the source → grounding problem, not a model problem.
- Retrieval returns junk: right answer exists in corpus but never reaches the LLM (low recall).
- You need to pick chunk size, embedding model, vector store, or a reranker and want a non-guessing default.
Do NOT use for: wording/format of a single prompt (use prompt-engineering); scoring final answer quality (use llm-eval-harness). RAG is plumbing that gets the right text into context; those skills shape and grade the output.
Steps
- Pin the corpus + query shape first. Write down: doc count & avg length, modality (prose / code / tables / mixed), update frequency (static vs hourly), and 10–20 real example questions. Two facts decide everything downstream: (a) are queries lookup ("what is X") or multi-hop ("compare X and Y across docs"), (b) does stale data return wrong answers (→ need re-index or freshness filter). Skip this and you will tune chunk size against questions that don't exist.
- Chunk by structure, not by character count. Default 400–800 tokens, 10–15% overlap. Split on natural boundaries: prose → headings/paragraphs; code → whole functions/classes (AST-aware, never mid-function — a half function embeds to garbage); markdown → keep a section together, prepend the heading path to each chunk. Tables → keep the header row with every row-group. Store metadata on every chunk:
source_path,title,section,chunk_index,updated_at. You will need it for filtering and citations. - Embed deterministically and store the contract. Pick one model and freeze it; record
model_name,dim, andnormalize. Two non-negotiables: (a) embed the query with the exact same model as the docs, (b) if your similarity metric is cosine, L2-normalize both sides. Batch 50–200 chunks/call. Hash each chunk (sha256(text)) and skip re-embedding unchanged chunks on re-index — this is the single biggest cost saver. For code or asymmetric search, prefer an embedding model trained for retrieval (query/doc asymmetry) over a generic sentence model. - Choose the store by ops reality, not benchmarks. Already on Postgres → use the pgvector extension (one DB, transactional, metadata filters in SQL). Need managed/huge scale → a hosted vector DB. Prototype/local → an embedded vector store. Index params that actually matter: HNSW
m(16–32) andef_construction(64–200) for build,ef_searchat query time for the recall/latency trade. Set the distance metric to match how you embedded (cosine vs inner product vs L2) — a mismatch silently returns wrong neighbors with no error. - Retrieve hybrid + rerank, not top-k dense alone. Pull dense (top 20–50) AND keyword/BM25 (top 20–50), fuse with Reciprocal Rank Fusion. Dense misses exact IDs, error codes, rare tokens, function names; BM25 catches them. Apply metadata filters (date, source, type) before scoring, not after, or you lose your top-k to filtered-out rows. Then rerank the fused ~40 candidates with a cross-encoder reranker down to the final 3–8 that go in the prompt. Reranking is usually the highest-leverage relevance win per dollar.
- Write a grounding prompt that can say "I don't know." Inject retrieved chunks with explicit source labels (
[1] path#section). Instruct: answer ONLY from the provided context, cite the[n]you used, and if the context doesn't contain the answer, say so instead of guessing. Put the question after the context. Order chunks best-last if the model shows lost-in-the-middle behavior on long contexts. - Measure retrieval and end-to-end as TWO separate numbers. Retrieval: from your example questions, label which chunk(s) are correct, then compute recall@k and MRR — "is the right chunk in the top-k at all." End-to-end: is the final answer correct AND grounded in cited chunks. Diagnosis rule: bad recall@k → fix chunking/embeddings/hybrid (step 2–5); good recall but bad answer → fix the grounding prompt (step 6) or model. Optimizing blindly without splitting these wastes days.
- Tune cost/latency last, once relevant. Cache query embeddings (same question hits often). Persist doc embeddings — never re-embed on every run. Drop
ef_search/top-k until recall@k degrades, then back off one notch. Consider a smaller embedding dim only after confirming recall holds. Add a cheap query-router so trivial lookups skip the reranker.
Common Errors
- Query/doc embedding model mismatch — docs embedded with model A, queries with model B (or different version). Vectors live in different spaces; recall craters with zero errors thrown. Pin one model id everywhere and assert it at query time.
- Metric mismatch — embedded normalized for cosine but index configured for L2/inner product (or vice versa). Returns plausible-but-wrong neighbors silently. Set the index metric explicitly to match your normalization.
- Mid-function / mid-sentence chunks — fixed character splitting cuts a function or sentence in half; each half embeds to a meaningless vector that never retrieves. Always split on structural boundaries.
- Filtering after retrieval — fetching top-k then filtering by date/source leaves you with 1–2 rows when most of the top-k got filtered out. Push filters into the vector query (pre-filter).
- Lost context on chunks — a chunk says "it supports this" with no idea what "it" is. Prepend the doc title + heading path to each chunk so it's self-contained.
- Re-embedding everything on each index run — burns API cost and time for unchanged docs. Hash chunks and skip unchanged ones.
- No "I don't know" path — without an explicit refuse-when-no-context instruction, the model fabricates fluently from its weights. The grounding prompt must license abstention.
- Tuning against a single number — chasing end-to-end accuracy while retrieval recall is the real bottleneck (or vice versa). Always split the two metrics before tuning.
- Stale index treated as fresh — corpus changed, index didn't; users get confidently outdated answers. Track
updated_atand re-index or filter on freshness.
Verify
- Sanity probe: embed one known query, fetch top-5, eyeball that the expected source chunk is present. If not, stop — embedding/metric is broken, nothing downstream matters.
- Recall@k on the labeled set: run all example questions, confirm the gold chunk lands in top-k for a clear majority. Below target → revisit chunking/hybrid/rerank, not the prompt.
- Grounding check: ask a question whose answer is NOT in the corpus. A correct pipeline refuses or says it lacks context — it must not fabricate.
- Citation check: every claim in a sample of answers maps to a retrieved
[n]chunk; no uncited assertions. - Idempotent re-index: run indexing twice on an unchanged corpus — second run re-embeds ~nothing (hash cache working) and produces an identical index.
- Latency/cost budget: end-to-end p95 latency and per-query cost are within target with caching on.
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
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.

