rag-ingestion
Skill0 starsChanged 8 days agoMITView on GitHub
Prepare business documents for retrieval-augmented generation (RAG) - source inventory, cleaning, heading-aware chunking with overlap, metadata (source, title, heading path, hashes, access level, dates), exact and near-duplicate removal, chunk-size QA and a retrieval smoke test - with a script that chunks Markdown, HTML and text into JSONL and reports size distribution, tiny/oversized chunks and duplicates. Use when building or fixing a knowledge base for a chatbot or agent, when answers miss facts that are in the docs, when choosing chunk size and overlap, or before loading documents into a vector or search index.
In this repository9 other files it gives its agents.
- AGENTS.mdAGENTS.md
- agent-deployment-checklistSkill
- agent-scopingSkill
- conversation-log-analysisSkill
- cost-latency-estimatorSkill
- eval-harnessSkill
- guardrails-and-safetySkill
- system-prompt-reviewSkill
- tool-schema-designSkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 3 are distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈3
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
- Distinctive: line 36
Clean before chunking: Remove navigation, cookie banners, footers, "related articles", tracking text.
- Distinctive: line 56
Prefer hybrid (keyword + vector) search for product names, codes and numbers.
- Distinctive: line 57
Smoke-test retrieval: Write 20-50 real questions with the expected source.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 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.
Files
RAG ingestion
Retrieval quality is decided at ingestion: clean text, sensible chunks, rich metadata and no duplicates. Fix those before tuning embeddings or prompts.
Paths below are relative to this skill's folder.
When to use
- Building a knowledge base from help-center articles, policies, product docs, wikis, exports
- "The bot says it doesn't know, but it's in the docs", "answers quote outdated policy"
- Choosing chunk size and overlap, or auditing an existing index
- Re-ingesting after a documentation migration
When not to use
- Structured data (orders, stock, prices): expose it through tools, not embeddings
- PDFs or scans: convert to Markdown/HTML/text first (layout-aware converter, OCR), then come back
- Ranking/embedding model selection: out of scope here; measure with
eval-harness
Workflow
- Inventory sources. For each source: owner, format, count, update frequency, audience (public / internal / restricted), and whether it is the source of truth. Drop drafts, duplicates of other systems and archived content unless explicitly needed.
- Clean before chunking. Remove navigation, cookie banners, footers, "related articles",
tracking text; keep headings, lists, tables and code. Convert PDFs and Office files with
a converter that keeps headings. Run
guardrails-and-safetyscans for PII and injected instructions on anything user-generated or scraped. - Chunk and measure.
Each JSONL row haspython3 scripts/chunk_docs.py docs/ --max-tokens 400 --overlap 50 --out chunks.jsonl python3 scripts/chunk_docs.py docs/ --dedup --out chunks.jsonl --json python3 scripts/chunk_docs.py help-center/*.html --max-tokens 300 --fail-on-issuesid,source,title,heading_path,chunk_index,text,chars,est_tokens,sha256and duplicate markers. Token counts are estimates (characters / 4). - Read the stats. Many tiny chunks: headings with little text; raise
--min-tokensor restructure docs. Oversized chunks: long tables or code; split the source. Many duplicates: boilerplate or copied pages; use--dedupand fix the source. Defaults and trade-offs are in references/chunking-guide.md. - Add business metadata your retriever will filter on:
audience/access level, product, language, region,effective_date,last_reviewed,source_url. Never index restricted content into a shared index; filter by access at query time. - Embed or index with your stack (embedding model, vector database or keyword search). Prefer hybrid (keyword + vector) search for product names, codes and numbers.
- Smoke-test retrieval. Write 20-50 real questions with the expected source; check that the right chunk appears in the top 3-5. Log misses and fix the chunking or the source. Re-run after every ingestion change. See the test recipe in references/chunking-guide.md.
- Plan updates. Re-ingest changed documents by
source+sha256; delete chunks of removed documents; record ingestion date per chunk.
Output
212 files -> 1,873 chunks, 1,790 written (--dedup)
tokens: total 512,400, min 12, median 286, max 400
tiny (<40): 41, oversized (>400): 0, without heading: 18
exact duplicates: 61 (cookie notice + "contact us" footer), near duplicates: 22 (EN/UK pages)
Actions: strip footer boilerplate, merge 14 one-line FAQ pages, add audience metadata,
retrieval smoke test 44/50 top-5 hits; misses are all in pricing tables -> convert to text.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.

