/major-ai-skills:langchainfrom major-ai-skills
Build production LangChain LCEL pipelines and LangGraph agents with create_agent, bounded tools, checkpointing, middleware guardrails, and retrieval grounding agents routinely skip.
Ships in major-ai-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
LangChain v1 composes Runnables (LCEL) for linear prompt → model → parser graphs, and LangGraph for stateful tool loops. Prefer langchain.agents.create_agent for agents (returns a compiled graph); keep LCEL for RAG and ETL-style chains. Provider packages (langchain-openai, langchain-anthropic) own model clients; core stays thin. Treat tool I/O and retrieved context as untrusted until validated.
┌─────────────────────────────────────────────────────────────┐
│ LangChain / LangGraph runtime │
│ │
│ LCEL (linear) │
│ Prompt | Model | Parser (+ Retriever / RunnableParallel) │
│ │
│ Agents (create_agent → CompiledStateGraph) │
│ ├── model node ↔ tools node (tool_calls loop) │
│ ├── middleware: retries, summarization, human approval │
│ ├── checkpointer / store (thread_id persistence) │
│ └── response_format / structured output strategies │
│ │
│ Observability │
│ └── LangSmith traces (redact secrets); pin package majors │
└─────────────────────────────────────────────────────────────┘
Use when
@openai-api / @anthropic-api to @qdrant / @chromadb with shared Runnable interfaces.Do not use when
@openai-api / @anthropic-api only.@llamaindex.create_agent for tool loops — do not revive legacy LLMChain / AgentExecutor in new code.langchain, langgraph, langchain-openai (or anthropic) in lockfiles; model ids explicit in config, not scattered string literals.thread_id for multi-turn agents; never persist secrets in checkpoint state.from langchain_openai import ChatOpenAI, OpenAIEmbeddings
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.runnables import RunnablePassthrough
from langchain_core.output_parsers import StrOutputParser
from langchain_qdrant import QdrantVectorStore
from qdrant_client import QdrantClient
client = QdrantClient(url="http://localhost:6333")
vectorstore = QdrantVectorStore(
client=client,
collection_name="policies",
embedding=OpenAIEmbeddings(model="text-embedding-3-small"),
)
retriever = vectorstore.as_retriever(search_kwargs={"k": 4})
prompt = ChatPromptTemplate.from_messages([
("system",
"Answer using ONLY the context. If missing, say you do not know.\n"
"Cite source filenames from metadata.\n\nContext:\n{context}"),
("human", "{question}"),
])
llm = ChatOpenAI(model="gpt-4.1-mini", temperature=0)
def format_docs(docs):
return "\n\n".join(
f"[{d.metadata.get('source', '?')}]\n{d.page_content}" for d in docs
)
rag = (
{"context": retriever | format_docs, "question": RunnablePassthrough()}
| prompt
| llm
| StrOutputParser()
)
print(rag.invoke("What is the refund window for annual plans?"))
create_agentfrom langchain.agents import create_agent
def lookup_order(order_id: str) -> str:
"""Return order status for a verified order_id (read-only)."""
# Call your service with validated order_id only
return f"order {order_id}: shipped"
agent = create_agent(
model="openai:gpt-4.1-mini",
tools=[lookup_order],
system_prompt=(
"You are a support assistant. Use lookup_order only for real order ids. "
"Never invent refunds or PII."
),
)
result = agent.invoke(
{"messages": [{"role": "user", "content": "Status of order ORD-1042?"}]}
)
Validation loop:
python -c "from my_agent.agent import agent; print(agent.get_graph().draw_mermaid())"
# Run fixed golden questions with temperature=0; assert citations / abstain
| Signature | Likely cause | Fix path |
|---|---|---|
ModuleNotFoundError: langchain_openai | Split packages; only langchain installed | pip install langchain-openai (or anthropic) extras |
| Agent loops forever / burns tokens | No iteration cap / recursive tools | Middleware max steps; shrink tool set; require confirmation for writes |
| Hallucinated “citations” | Weak retrieval or no grounding rule | Raise retriever k quality; force “unknown”; return source nodes |
Import of deprecated AgentExecutor | Stale tutorials | Migrate to create_agent / LangGraph |
| Flaky CI evals | temperature>0 or unpinned model | Pin model id; temp=0; golden set (@ai-evaluation-dataset) |
| Checkpoint restores wrong user | Missing / reused thread_id | Pass unique configurable.thread_id per conversation |
| Secrets in LangSmith | Full prompt logging | Redact callbacks; exclude .env from traces |
| Qdrant filter ignored | Metadata not in payload / wrong key | Align metadata keys; pair with @qdrant payload indexes |
astream_events / graph stream); batch for offline jobs.response_format / Pydantic over brittle regex parses.@llamaindex — retrieval/ingestion-first alternative@openai-api / @anthropic-api — direct provider SDKs@qdrant / @chromadb — vector backends@ai-evaluation-dataset — golden sets and hash-bound metrics@fastapi — serving agents behind HTTP@mlflow — experiment / cost trackingMANDATORY: Use LCEL for linear pipelines and
create_agent(LangGraph) for tool loops. Allowlist and validate tools; never ship unrestricted shell/FS tools. Pin provider packages and model ids. Ground factual answers with retrieval + abstain rules. Redact secrets from traces. Validate with temperature-0 golden questions before declaring success.
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub alivirgo/major-ai-skills --plugin major-ai-skills412 skills in this plugin
/3d-slicerAutomate 3D Slicer research workflows with MRML, VTK/ITK, DICOM data, and Segment Editor. Use for software workflows, not clinical interpretation./abbreviated-git-statusInspect Git branch, staging, and working-tree changes with short or porcelain status output when a compact repository check is needed./ableton-liveAutomate Ableton Live sessions with Python MIDI Remote Scripts, Max for Live, AbletonOSC, and Link synchronization.Other plugins' skills for the same job
/act-as-a-personal-tutorExplain a subject step by step, assess prior knowledge, and use short exercises to check understanding before advancing.