
Knowledge Base Rag
- 106 installs
- 31 repo stars
- Updated April 12, 2026
- itallstartedwithaidea/agent-skills
knowledge-base-rag is an agent skill that implements the full RAG pipeline from document ingestion to cited, retrieval-grounded answers.
About
knowledge-base-rag is an agent skill that walks solo builders through implementing Retrieval-Augmented Generation for private corpora. When your product must answer from policies, docs, or support archives that never appeared in base model training, plain prompting fails; this skill sequences ingestion, chunking, embedding, indexing, semantic retrieval, and citation-aware generation so responses stay factual and attributable. It stresses that chunking beats model shopping for quality: semantic chunks that respect paragraphs, recursive splits that honor headings and code blocks, and overlaps that preserve continuity across segment boundaries. The audience is builders shipping agent features or internal copilots, not marketers tuning distribution. Expect integration decisions around vector databases and embedding APIs during Build, with operational tuning later. Use it when you are ready to wire data paths and retrieval policies, not when you are only validating whether RAG is the right approach on a napkin prototype.
- End-to-end RAG: document ingestion through grounded response generation with cited sources
- Production chunking guidance: semantic, recursive structure-aware splits, and overlap windows
- Addresses post-training cutoff and private data gaps via retrieval-injected context
- Embedding generation and vector store indexing as first-class pipeline stages
- Positions chunking strategy as higher leverage than raw model choice for answer quality
Knowledge Base Rag by the numbers
- 106 all-time installs (skills.sh)
- +9 installs in the week ending Aug 2, 2026 (Skillselion tracking)
- Ranked #4,152 of 16,546 AI & Agent Building skills by installs in the Skillselion catalog
- Security screen: CRITICAL risk (skills.sh audit)
- Data as of Aug 4, 2026 (Skillselion catalog sync)
npx skills add https://github.com/itallstartedwithaidea/agent-skills --skill knowledge-base-ragAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 106 |
|---|---|
| repo stars | ★ 31 |
| Security audit | 2 / 3 scanners passed |
| Last updated | April 12, 2026 |
| Repository | itallstartedwithaidea/agent-skills ↗ |
What it does
Stand up a private knowledge-base RAG pipeline—ingest, chunk, embed, index, retrieve, and cite answers for your agent product.
Who is it for?
Best when you're adding doc Q&A or support copilots to a SaaS or agent product with a defined corpus to ingest.
Skip if: Simple chat wrappers with no private docs, one-off summaries without a vector index, or teams skipping ingestion design and expecting model upgrades alone to fix recall.
When should I use this skill?
Building or extending an agent that must answer questions from a private knowledge base using ingest, chunk, embed, index, retrieve, and cite workflow.
What you get
You deploy an indexed knowledge base with intentional chunking and retrieval so the agent returns grounded answers with source citations and fewer fabrications.
- Ingestion and chunking pipeline configuration
- Indexed vector store with retrieval integration into agent prompts
- Grounded response path with cited source snippets
By the numbers
- Covers semantic chunking, recursive structure-aware splitting, and overlap window strategies as production-tested approa
Files
Knowledge Base RAG
Part of Agent Skills™ by googleadsagent.ai™
Description
Knowledge Base RAG implements the complete Retrieval-Augmented Generation pipeline: document ingestion, intelligent chunking, embedding generation, vector store indexing, semantic retrieval, and grounded response generation. The agent builds RAG systems that answer questions from private knowledge bases with cited sources and reduced hallucination.
RAG solves the fundamental limitation of large language models: they cannot access information created after their training cutoff or proprietary information they were never trained on. By retrieving relevant documents from a vector store and injecting them into the prompt context, RAG grounds the model's responses in factual, up-to-date, organization-specific knowledge.
The quality of a RAG system depends on chunking strategy more than model choice. This skill encodes production-tested chunking approaches: semantic chunking that preserves paragraph coherence, recursive splitting that respects document structure (headings, code blocks, tables), and overlap windows that maintain context across chunk boundaries. Each strategy is matched to the document type for optimal retrieval quality.
Use When
- Building question-answering systems over private documents
- Creating a searchable knowledge base from documentation, wikis, or PDFs
- Reducing hallucination by grounding LLM responses in retrieved facts
- Implementing semantic search across large document collections
- Building customer support bots with product-specific knowledge
- The user asks about RAG, vector search, or document embedding
How It Works
graph TD
A[Documents: PDF, MD, HTML] --> B[Ingestion Pipeline]
B --> C[Extract Text + Metadata]
C --> D[Intelligent Chunking]
D --> E[Generate Embeddings]
E --> F[Index in Vector Store]
G[User Query] --> H[Embed Query]
H --> I[Semantic Search: Top-K]
I --> J[Re-rank Results]
J --> K[Construct Prompt with Context]
K --> L[LLM Generation]
L --> M[Response with Citations]The pipeline has two phases: offline ingestion (documents to vectors) and online retrieval (query to answer). The re-ranking step applies a cross-encoder to refine the initial vector search results, improving precision before the generation step.
Implementation
from dataclasses import dataclass
import hashlib
@dataclass
class Chunk:
text: str
metadata: dict
embedding: list[float] | None = None
@property
def id(self) -> str:
return hashlib.sha256(self.text.encode()).hexdigest()[:16]
class RecursiveChunker:
def __init__(self, max_tokens: int = 512, overlap: int = 64):
self.max_tokens = max_tokens
self.overlap = overlap
self.separators = ["\n## ", "\n### ", "\n\n", "\n", ". ", " "]
def chunk(self, text: str, metadata: dict) -> list[Chunk]:
chunks = self._split(text, self.separators)
return [
Chunk(text=c.strip(), metadata={**metadata, "chunk_index": i})
for i, c in enumerate(chunks) if c.strip()
]
def _split(self, text: str, separators: list[str]) -> list[str]:
if not separators or self._token_count(text) <= self.max_tokens:
return [text]
sep = separators[0]
parts = text.split(sep)
chunks, current = [], ""
for part in parts:
candidate = current + sep + part if current else part
if self._token_count(candidate) > self.max_tokens and current:
chunks.append(current)
overlap_text = current[-self.overlap * 4:]
current = overlap_text + sep + part
else:
current = candidate
if current:
chunks.append(current)
result = []
for chunk in chunks:
if self._token_count(chunk) > self.max_tokens:
result.extend(self._split(chunk, separators[1:]))
else:
result.append(chunk)
return result
def _token_count(self, text: str) -> int:
return len(text) // 4
class RAGPipeline:
def __init__(self, embedder, vector_store, llm):
self.embedder = embedder
self.store = vector_store
self.llm = llm
self.chunker = RecursiveChunker()
async def ingest(self, documents: list[dict]) -> int:
all_chunks = []
for doc in documents:
chunks = self.chunker.chunk(doc["text"], doc["metadata"])
for chunk in chunks:
chunk.embedding = await self.embedder.embed(chunk.text)
all_chunks.extend(chunks)
await self.store.upsert(all_chunks)
return len(all_chunks)
async def query(self, question: str, top_k: int = 5) -> dict:
query_embedding = await self.embedder.embed(question)
results = await self.store.search(query_embedding, top_k=top_k)
context = "\n\n".join(
f"[Source: {r.metadata.get('source', 'unknown')}]\n{r.text}" for r in results
)
prompt = f"""Answer the question based on the provided context. Cite sources.
If the context does not contain the answer, say so explicitly.
Context:
{context}
Question: {question}"""
response = await self.llm.generate(prompt)
return {"answer": response, "sources": [r.metadata for r in results]}Best Practices
- Use recursive chunking that respects document structure (headings, paragraphs, code blocks)
- Set chunk size to 256-512 tokens with 10-15% overlap for most use cases
- Re-rank vector search results with a cross-encoder before passing to the LLM
- Include source metadata in every chunk for citation generation
- Deduplicate chunks by content hash before indexing to avoid retrieval noise
- Instruct the LLM to say "I don't know" when the context lacks the answer
Platform Compatibility
| Platform | Support | Notes |
|---|---|---|
| Cursor | Full | Pipeline code generation |
| VS Code | Full | Python/TS RAG implementation |
| Windsurf | Full | RAG workflow support |
| Claude Code | Full | End-to-end RAG building |
| Cline | Full | Vector store integration |
| aider | Partial | Code-level support |
Related Skills
- AI Chat Studio
- Workflow Orchestration
- Knowledge Base Injection
- Entity Memory Management
Keywords
rag retrieval-augmented-generation vector-search embeddings chunking knowledge-base semantic-search document-qa
---
© 2026 googleadsagent.ai™ | Agent Skills™ | MIT License
Related skills
How it compares
Skill-encoded RAG methodology for agents, not a turnkey hosted search appliance or a single MCP connector.
FAQ
Who is knowledge-base-rag for?
Developers and teams building LLM agents that must query organization-specific knowledge with citations and controlled hallucination risk.
When should I use knowledge-base-rag?
During Build agent-tooling while designing ingestion, chunking, embeddings, and vector retrieval; revisit during Operate iterate when tuning recall and index freshness.
Is knowledge-base-rag safe to install?
RAG skills often imply external APIs and document processing—review the Security Audits panel on this Prism page and scope network and secret access before production ingest.