ワンクリックで
langchain
Expert guidance for building LLM applications with LangChain framework - chains, prompts, memory, retrievers, and integrations.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
メニュー
Expert guidance for building LLM applications with LangChain framework - chains, prompts, memory, retrievers, and integrations.
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
SOC 職業分類に基づく
Brainstorm and advise on technical decisions using structured process and MCP helpers. EXCLUSIVE to brainstormer agent. Does NOT implement — only advises.
Diagnose errors and failing tests in Laravel + React + Python applications. Use when encountering bugs, exceptions, stack traces, 500 errors, TypeErrors, failing tests, or unexpected behavior. EXCLUSIVE to debugger agent.
Review code changes for correctness, security, performance, and maintainability. Use for PR reviews, code audits, pre-merge checks, or quality validation of Laravel + React + Python code. EXCLUSIVE to reviewer agent.
Plan and implement safe database schema changes including migrations, indexes, and backfills. Use when creating tables, adding columns, optimizing queries, or managing Eloquent/SQLAlchemy relationships. EXCLUSIVE to database-admin agent.
Manage deployment, Docker, CI/CD, server hardening, and infrastructure security. EXCLUSIVE to devops-engineer agent.
Keep project documentation accurate when behavior changes. EXCLUSIVE to project-manager agent.
| name | langchain |
| description | Expert guidance for building LLM applications with LangChain framework - chains, prompts, memory, retrievers, and integrations. |
| allowed-tools | Read, Edit, Bash, Grep, mcp_codex-bridge, mcp_gemini-bridge, mcp_context7, mcp_playwright, mcp_zread, mcp_web-search-prime, mcp_web-reader, mcp_zai-mcp-server, mcp_open-bridge |
Use this skill when working with LangChain for building LLM-powered applications.
Always verify patterns with latest docs:
mcp_context7_resolve-library-id(libraryName="langchain", query="LCEL chains")
mcp_context7_query-docs(libraryId="/langchain-ai/langchain", query="RunnablePassthrough examples")
from langchain_openai import ChatOpenAI
from langchain_anthropic import ChatAnthropic
# Chat model initialization
llm = ChatOpenAI(model="gpt-4o", temperature=0)
claude = ChatAnthropic(model="claude-sonnet-4-20250514")
# Invoke with messages
from langchain_core.messages import HumanMessage, SystemMessage
response = llm.invoke([
SystemMessage(content="You are a helpful assistant."),
HumanMessage(content="Hello!")
])
from langchain_core.prompts import ChatPromptTemplate, MessagesPlaceholder
# Simple template
prompt = ChatPromptTemplate.from_messages([
("system", "You are a {role} assistant."),
("human", "{input}")
])
# With message history placeholder
prompt_with_history = ChatPromptTemplate.from_messages([
("system", "You are a helpful assistant."),
MessagesPlaceholder(variable_name="history"),
("human", "{input}")
])
# Format and invoke
chain = prompt | llm
result = chain.invoke({"role": "coding", "input": "Write a function"})
from langchain_core.output_parsers import StrOutputParser, JsonOutputParser
from pydantic import BaseModel, Field
class Answer(BaseModel):
answer: str = Field(description="The answer")
confidence: float = Field(description="Confidence 0-1")
parser = JsonOutputParser(pydantic_object=Answer)
chain = prompt | llm | parser
from langchain_core.runnables import RunnablePassthrough, RunnableLambda
# Pipe syntax for chaining
chain = prompt | llm | StrOutputParser()
# Parallel execution
from langchain_core.runnables import RunnableParallel
parallel_chain = RunnableParallel(
summary=summary_chain,
translation=translate_chain
)
# Branching with RunnableBranch
from langchain_core.runnables import RunnableBranch
branch = RunnableBranch(
(lambda x: "code" in x["topic"], code_chain),
(lambda x: "math" in x["topic"], math_chain),
default_chain
)
from langchain_community.chat_message_histories import ChatMessageHistory
from langchain_core.runnables.history import RunnableWithMessageHistory
history = ChatMessageHistory()
chain_with_history = RunnableWithMessageHistory(
chain,
lambda session_id: history,
input_messages_key="input",
history_messages_key="history"
)
# Invoke with session
result = chain_with_history.invoke(
{"input": "Hi!"},
config={"configurable": {"session_id": "user123"}}
)
from langchain_community.vectorstores import FAISS
from langchain_openai import OpenAIEmbeddings
from langchain_core.runnables import RunnablePassthrough
# Create retriever
embeddings = OpenAIEmbeddings()
vectorstore = FAISS.from_texts(texts, embeddings)
retriever = vectorstore.as_retriever(search_kwargs={"k": 4})
# RAG chain
rag_prompt = ChatPromptTemplate.from_template("""
Answer based on context:
{context}
Question: {question}
""")
rag_chain = (
{"context": retriever, "question": RunnablePassthrough()}
| rag_prompt
| llm
| StrOutputParser()
)
from langchain_core.tools import tool
@tool
def search(query: str) -> str:
"""Search for information."""
return f"Results for: {query}"
@tool
def calculator(expression: str) -> float:
"""Evaluate math expression."""
return eval(expression)
# Bind tools to model
llm_with_tools = llm.bind_tools([search, calculator])
# Or use ToolNode in LangGraph
from langgraph.prebuilt import ToolNode
tool_node = ToolNode([search, calculator])
| pipe syntax over legacy Chain classes.stream() for real-time output.ainvoke(), .astream() for concurrent operations.with_fallbacks()from langchain_core.output_parsers import PydanticOutputParser
class Output(BaseModel):
result: str
llm_structured = llm.with_structured_output(Output)
for chunk in chain.stream({"input": "Tell me a story"}):
print(chunk, end="", flush=True)
chain_with_fallback = main_chain.with_fallbacks([backup_chain])
pip install langchain langchain-core langchain-openai langchain-anthropic
pip install langchain-community # for integrations