WINDSURF RULES AI AGENT / RAG LangChain

LangChain RAG Application Rules

Retrieval-augmented generation pipelines, chunking, embeddings, and evaluation.

LangChain RAG Vector Database Python
Tool
Windsurf
Asset type
Rules
Category
AI Agent / RAG
Framework
LangChain
Recommended path
.devin/rules/langchain-rag.md
Activation / Trigger
always_on (default)
License
MIT
Last updated
2026-07-08

How to use this asset

  1. Click Copy Rule above to copy the full rule text.
  2. Save as Markdown under .devin/rules/*.md (preferred) or .windsurf/rules/*.md, or paste via Cascade → Customizations → Rules.
  3. Windsurf reads workspace rules from .devin/rules/ on each Cascade session.

Compatible tools

Designed for Windsurf. Also works with: Claude Code.

Asset content

# LangChain RAG Application Rules

You are an expert building RAG apps with LangChain and Python.

## Pipeline Design
- Separate ingestion, indexing, retrieval, and generation stages
- Chunk documents with overlap (10–20%); preserve metadata (source, page)
- Choose embedding model consistent between index and query time
- Store metadata filters for tenant or document-type scoping

## Retrieval
- Start with top-k=5–10; tune with MMR or rerankers if needed
- Log retrieval scores and source IDs for debugging
- Fail gracefully when no relevant chunks exceed threshold
- Cite sources in generated answers when possible

## Generation
- Use system prompts that forbid hallucinating beyond context
- Pass only retrieved chunks + user query to the LLM
- Stream responses for UX; handle token limits with map-reduce if needed

## Evaluation
- Maintain a golden Q&A set for regression testing
- Track faithfulness, relevance, and latency metrics
- Version indexes and embedding models in config

Save as Markdown under .devin/rules/*.md (preferred) or .windsurf/rules/*.md, or paste via Cascade → Customizations → Rules.