Install any skill in seconds. Free to start, no credit card required.
Get Started Free →LangChain skill for building LLM orchestration, agents, RAG pipelines, tools, memory, callbacks, and deployment.
.claude/skills/bilal140202-langchain/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-06 | ✗→✓ | ▲ Improved | 111% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 25% | 0% |
| case-02 | ✓→✓ | = Same ✓ | 76% | 0% |
| case-04 | ✓→✓ | = Same ✓ | 89% | 0% |
| case-05 | ✓→✓ | = Same ✓ | 68% | 0% |
Purpose
This skill teaches the agent project specific conventions and concise patterns for building AI agent workflows with LangChain in Python. Use this when implementing chatbots, RAG pipelines, tool-enabled agents, multi-agent flows, or deploying runnables.
When an AI assistant should apply this skill
Quick start
Core concepts and cheat sheet
result = llm.invoke("prompt").Examples
1) Minimal chat chain with memory
pythonfrom langchain_openai import ChatOpenAI from langchain.chains import LLMChain from langchain.prompts import ChatPromptTemplate from langchain.memory import ConversationBufferMemory prompt = ChatPromptTemplate.from_messages([ {"role": "system", "content": "You are a concise helpful assistant."}, {"role": "user", "content": "{question}"}, ]) llm = ChatOpenAI(model="gpt-4o", temperature=0) chain = LLMChain(llm=llm, prompt=prompt) chain.memory = ConversationBufferMemory() resp = chain.invoke({"question": "Explain RLHF in one paragraph."}) print(resp)
2) Define a deterministic tool and register it with an agent
pythonfrom langchain.tools import tool from langchain.agents import create_agent from langchain_openai import ChatOpenAI @tool def calc(expression: str) -> str: """Evaluate a math expression safely.""" # implement a safe eval or call a math microservice return str(eval(expression)) llm = ChatOpenAI(model="gpt-4o", temperature=0) agent = create_agent(llm, tools=[calc]) result = agent.invoke({"input": "What is 12 * 7?"}) print(result)
3) RAG pipeline pattern
pythonfrom langchain.embeddings import OpenAIEmbeddings from langchain.vectorstores import Chroma from langchain.chains import RetrievalQA from langchain_openai import ChatOpenAI # indexing (offline) emb = OpenAIEmbeddings() vect = Chroma.from_documents(docs, embedding=emb) retriever = vect.as_retriever(search_kwargs={"k": 4}) qa = RetrievalQA.from_chain_type( llm=ChatOpenAI(model="gpt-4o"), retriever=retriever, chain_type="stuff", ) answer = qa.invoke({"query": "How does caching in our app work?"}) print(answer)
4) Runnable batch and streaming
python# invoke in batch questions = ["A?", "B?", "C?"] for out in llm.batch_as_completed(questions): print(out) # streaming for token in llm.stream("Explain X step by step"): print(token, end="")
Middleware and callbacks pattern
Example callback handler
pythonfrom langchain_core.callbacks import BaseCallbackHandler class SimpleLogger(BaseCallbackHandler): def on_llm_start(self, prompts, **kwargs): print("LLM start", len(prompts)) def on_llm_end(self, response, **kwargs): print("LLM end")
Deployment snippet
bash# basic serve example langserve serve my_chain.py --host 0.0.0.0 --port 8000
Guidelines and best practices
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→fail | 8,240 | 6,606 | -20% | 1 | 1 | 0% | 1,775 | 2,556 | +44% | 0 | 0 | — |
case-02 | pass→pass | 5,399 | 2,801 | -48% | 1 | 1 | 0% | 928 | 1,637 | +76% | 0 | 0 | — |
case-03 | fail→fail | 6,379 | 6,523 | +2% | 1 | 1 | 0% | 1,247 | 2,511 | +101% | 0 | 0 | — |
case-04 | pass→pass | 4,849 | 2,741 | -43% | 1 | 1 | 0% | 903 | 1,711 | +89% | 0 | 0 | — |
case-05 | pass→pass | 5,087 | 2,530 | -50% | 1 | 1 | 0% | 1,038 | 1,748 | +68% | 0 | 0 | — |
case-06 | fail→pass | 4,133 | 2,165 | -48% | 1 | 1 | 0% | 779 | 1,642 | +111% | 0 | 0 | — |
case-07 | pass→pass | 9,176 | 5,122 | -44% | 1 | 1 | 0% | 1,869 | 2,274 | +22% | 0 | 0 | — |
case-08 | fail→pass | 6,093 | 1,179 | -81% | 1 | 1 | 0% | 1,161 | 1,446 | +25% | 0 | 0 | — |
case-09 | pass→pass | 10,762 | 3,636 | -66% | 1 | 1 | 0% | 2,047 | 1,805 | -12% | 0 | 0 | — |
case-10 | pass→pass | 4,004 | 1,938 | -52% | 1 | 1 | 0% | 841 | 1,555 | +85% | 0 | 0 | — |
case-11 | pass→pass | 4,672 | 1,880 | -60% | 1 | 1 | 0% | 908 | 1,612 | +78% | 0 | 0 | — |
case-12 | pass→pass | 3,344 | 2,700 | -19% | 1 | 1 | 0% | 625 | 1,647 | +164% | 0 | 0 | — |
case-13 | pass→pass | 3,068 | 1,464 | -52% | 1 | 1 | 0% | 572 | 1,441 | +152% | 0 | 0 | — |
case-14 | pass→pass | 15,435 | 9,529 | -38% | 1 | 1 | 0% | 2,610 | 2,859 | +10% | 0 | 0 | — |
case-15 | pass→pass | 14,229 | 5,809 | -59% | 1 | 1 | 0% | 2,494 | 2,269 | -9% | 0 | 0 | — |
case-16 | pass→pass | 12,423 | 5,684 | -54% | 1 | 1 | 0% | 2,292 | 2,286 | -0% | 0 | 0 | — |
case-17 | fail→fail | 15,436 | 8,361 | -46% | 1 | 1 | 0% | 2,540 | 2,635 | +4% | 0 | 0 | — |
case-18 | pass→pass | 12,638 | 7,087 | -44% | 1 | 1 | 0% | 2,207 | 2,374 | +8% | 0 | 0 | — |
case-19 | pass→pass | 3,298 | 3,218 | -2% | 1 | 1 | 0% | 539 | 1,765 | +227% | 0 | 0 | — |
case-20 | pass→pass | 19,702 | 12,150 | -38% | 1 | 1 | 0% | 3,726 | 3,666 | -2% | 0 | 0 | — |
case-21 | pass→pass | 7,755 | 6,154 | -21% | 1 | 1 | 0% | 1,555 | 2,473 | +59% | 0 | 0 | — |
case-22 | pass→pass | 8,082 | 4,265 | -47% | 1 | 1 | 0% | 1,668 | 2,063 | +24% | 0 | 0 | — |
case-23 | pass→pass | 6,200 | 3,625 | -42% | 1 | 1 | 0% | 1,126 | 1,899 | +69% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted. The headline lift of +9 percentage points is the difference between those two pass rates over the 23 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.