
Langchain Architecture
Design LangGraph and LangChain RAG pipelines with retrievers, state graphs, and LLM nodes for solo AI products.
Overview
Langchain Architecture is an agent skill most often used in Build (also Validate, Ship) that documents LangGraph and LangChain RAG patterns with retrievers, typed state, and async LLM nodes for production agents.
Install
npx skills add https://github.com/wshobson/agents --skill langchain-architectureWhat is this skill?
- Worked LangGraph RAG pattern with retrieve and generate nodes on typed state
- Integrates ChatAnthropic, Voyage embeddings, and Pinecone vector retrieval
- Async node design with ainvoke for production-style agent graphs
- Prompt templates grounded on retrieved document context
- Architecture patterns section for extending beyond single-shot chains
- RAG example uses retriever search_kwargs k=4
Adoption & trust: 8.9k installs on skills.sh; 36.5k GitHub stars; 2/3 security scanners passed (skills.sh audits).
What problem does it solve?
You know you need RAG but your agent keeps producing flat LangChain scripts without graph state, retrieval boundaries, or async orchestration.
Who is it for?
Builders implementing Python RAG or LangGraph services with Anthropic models and managed vector indexes.
Skip if: Pure prompt-only apps with no retrieval, or teams standardized on non-LangChain frameworks only.
When should I use this skill?
Designing or implementing LangChain/LangGraph RAG, multi-node agents, or vector-backed LLM services.
What do I get? / Deliverables
You leave with copy-ready graph nodes, embedding and vector store wiring, and a template to extend into multi-step agent flows.
- LangGraph node implementations
- RAG state schema
- Retriever and prompt integration sketch
Recommended Skills
Journey fit
Spans multiple journey phases - primary shelf plus alternate fits below.
Building agent features is the canonical shelf—architecture choices happen while you wire models, vector stores, and graphs. Agent-tooling is where LangChain/LangGraph composition belongs rather than generic frontend or docs work.
Where it fits
Sketch a minimal retrieve-generate graph to test answer quality before full product scope.
Implement StateGraph nodes with Pinecone retriever and ChatAnthropic generation.
Expose the graph as an API service with clear context boundaries per request.
Tune retriever k and async invokes before load-testing the agent path.
How it compares
Skill package for graph-based RAG design—not a hosted MCP server or no-code agent builder.
Common Questions / FAQ
Who is langchain-architecture for?
Solo and indie developers building AI features in Python who want Claude Code or Cursor to follow LangGraph RAG structure instead of one-file demos.
When should I use langchain-architecture?
In Build when wiring retrievers and graphs, in Validate when proving a RAG prototype architecture, and in Ship when hardening async agent nodes before production.
Is langchain-architecture safe to install?
Check this page’s Security Audits panel; the patterns assume API keys and external vector DB access you must scope in your own secrets policy.
SKILL.md
READMESKILL.md - Langchain Architecture
# langchain-architecture — detailed patterns and worked examples ## Architecture Patterns ### Pattern 1: RAG with LangGraph ```python from langgraph.graph import StateGraph, START, END from langchain_anthropic import ChatAnthropic from langchain_voyageai import VoyageAIEmbeddings from langchain_pinecone import PineconeVectorStore from langchain_core.documents import Document from langchain_core.prompts import ChatPromptTemplate from typing import TypedDict, Annotated class RAGState(TypedDict): question: str context: Annotated[list[Document], "retrieved documents"] answer: str # Initialize components llm = ChatAnthropic(model="claude-sonnet-4-6") embeddings = VoyageAIEmbeddings(model="voyage-3-large") vectorstore = PineconeVectorStore(index_name="docs", embedding=embeddings) retriever = vectorstore.as_retriever(search_kwargs={"k": 4}) # Define nodes async def retrieve(state: RAGState) -> RAGState: """Retrieve relevant documents.""" docs = await retriever.ainvoke(state["question"]) return {"context": docs} async def generate(state: RAGState) -> RAGState: """Generate answer from context.""" prompt = ChatPromptTemplate.from_template( """Answer based on the context below. If you cannot answer, say so. Context: {context} Question: {question} Answer:""" ) context_text = "\n\n".join(doc.page_content for doc in state["context"]) response = await llm.ainvoke( prompt.format(context=context_text, question=state["question"]) ) return {"answer": response.content} # Build graph builder = StateGraph(RAGState) builder.add_node("retrieve", retrieve) builder.add_node("generate", generate) builder.add_edge(START, "retrieve") builder.add_edge("retrieve", "generate") builder.add_edge("generate", END) rag_chain = builder.compile() # Use the chain result = await rag_chain.ainvoke({"question": "What is the main topic?"}) ``` ### Pattern 2: Custom Agent with Structured Tools ```python from langchain_core.tools import StructuredTool from pydantic import BaseModel, Field class SearchInput(BaseModel): """Input for database search.""" query: str = Field(description="Search query") filters: dict = Field(default={}, description="Optional filters") class EmailInput(BaseModel): """Input for sending email.""" recipient: str = Field(description="Email recipient") subject: str = Field(description="Email subject") content: str = Field(description="Email body") async def search_database(query: str, filters: dict = {}) -> str: """Search internal database for information.""" # Your database search logic return f"Results for '{query}' with filters {filters}" async def send_email(recipient: str, subject: str, content: str) -> str: """Send an email to specified recipient.""" # Email sending logic return f"Email sent to {recipient}" tools = [ StructuredTool.from_function( coroutine=search_database, name="search_database", description="Search internal database", args_schema=SearchInput ), StructuredTool.from_function( coroutine=send_email, name="send_email", description="Send an email", args_schema=EmailInput ) ] agent = create_react_agent(llm, tools) ``` ### Pattern 3: Multi-Step Workflow with StateGraph ```python from langgraph.graph import StateGraph, START, END from typing import TypedDict, Literal class WorkflowState(TypedDict): text: str entities: list analysis: str summary: str current_step: str async def extract_entities(state: WorkflowState) -> WorkflowState: """Extract key entities from text.""" prompt = f"Extract key entities from: {state['text']}\n\nReturn as JSON list." response = await llm.ainvoke(prompt) return {"entities": response.content, "current_step": "analyze"} async def analyze_entities(state: WorkflowState) -> WorkflowState: """Analyze extracted entities.""" p