本文へ移動
cccskills
無料GitHub で公開

langchain

Build AI agents with LangChain framework. Use when building agents, tools, memory, MCP integrations, RAG pipelines, multi-agent systems, or any LLM-powered applications using LangChain or LangGraph in Python or TypeScript.

インストール方法を見る

含まれるファイル(9)

  • SKILL.md7.6 KB
  • eval.yaml949 B
  • graders/check.py10.9 KB
  • instructions/customer-support-agent.md2.5 KB
  • references/langgraph.md3.5 KB
  • references/multi-agent.md4.4 KB
  • references/retrieval.md5.2 KB
  • rubrics/quality.md2.4 KB
  • solutions/reference-customer-support-agent2.3 KB

SKILL.md(原文)

インストールする前に、エージェントに与えられる指示の中身を確認できます。

LangChain Skill

Build production AI agents using LangChain's pre-built architecture and integrations.

Installation

pip install langchain langchain-anthropic langgraph
# For MCP support
pip install langchain-mcp-adapters

Quick Agent

from langchain.agents import create_agent
from langchain.tools import tool

@tool
def get_weather(city: str) -> str:
    """Get weather for a city."""
    return f"Sunny in {city}!"

agent = create_agent(
    model="claude-sonnet-4-5-20250929",
    tools=[get_weather],
    system_prompt="You are a helpful assistant"
)

result = agent.invoke({"messages": [{"role": "user", "content": "Weather in SF?"}]})

Tools

Define tools with @tool decorator. Type hints required, docstring becomes description:

from langchain.tools import tool, ToolRuntime
from dataclasses import dataclass

@tool
def search(query: str, limit: int = 10) -> str:
    """Search database for records."""
    return f"Found {limit} results for '{query}'"

# With runtime context access
@dataclass
class Context:
    user_id: str

@tool
def get_user_data(runtime: ToolRuntime[Context]) -> str:
    """Get current user data."""
    user_id = runtime.context.user_id
    return f"Data for {user_id}"

ToolRuntime Access

  • runtime.state - Agent state (messages, custom fields)
  • runtime.context - Immutable config (user_id, session)
  • runtime.store - Persistent memory across conversations
  • runtime.stream_writer - Stream updates during execution

Reserved Parameters

Cannot use as tool args: config, runtime

Memory

from langgraph.checkpoint.memory import InMemorySaver
from langgraph.store.memory import InMemoryStore

# Short-term (conversation) memory
checkpointer = InMemorySaver()

# Long-term (cross-conversation) memory
store = InMemoryStore()

agent = create_agent(
    model="claude-sonnet-4-5-20250929",
    tools=[...],
    checkpointer=checkpointer,
    store=store
)

# Use thread_id for conversation continuity
config = {"configurable": {"thread_id": "conversation-1"}}
agent.invoke({"messages": [...]}, config=config)

Structured Output

from dataclasses import dataclass
from langchain.agents.structured_output import ToolStrategy

@dataclass
class Response:
    answer: str
    confidence: float | None = None

agent = create_agent(
    model="claude-sonnet-4-5-20250929",
    tools=[...],
    response_format=ToolStrategy(Response)
)
# Access: result['structured_response']

MCP Integration

Connect to MCP servers for external tools:

from langchain_mcp_adapters.client import MultiServerMCPClient
from langchain.agents import create_agent

client = MultiServerMCPClient({
    "math": {
        "transport": "stdio",
        "command": "python",
        "args": ["/path/to/server.py"]
    },
    "api": {
        "transport": "http",
        "url": "http://localhost:8000/mcp",
        "headers": {"Authorization": "Bearer TOKEN"}
    }
})

tools = await client.get_tools()
agent = create_agent("claude-sonnet-4-5-20250929", tools)

MCP Interceptors

Modify tool calls, inject context, handle errors:

from langchain_mcp_adapters.interceptors import MCPToolCallRequest

async def auth_interceptor(request: MCPToolCallRequest, handler):
    runtime = request.runtime
    user_id = runtime.context.user_id
    modified = request.override(args={**request.args, "user_id": user_id})
    return await handler(modified)

client = MultiServerMCPClient({...}, tool_interceptors=[auth_interceptor])

Model Configuration

from langchain.chat_models import init_chat_model

model = init_chat_model(
    "claude-sonnet-4-5-20250929",  # or "gpt-4o", "gemini-1.5-pro"
    temperature=0.5,
    timeout=10,
    max_tokens=1000
)

State Updates from Tools

Return Command to update state or control flow:

from langgraph.types import Command
from langchain.messages import RemoveMessage

@tool
def clear_history() -> Command:
    """Clear conversation."""
    return Command(update={"messages": [RemoveMessage(id="__all__")]})

@tool  
def complete_task() -> Command:
    """End agent run."""
    return Command(update={"status": "done"}, goto="__end__")

Common Patterns

Full Production Agent

from dataclasses import dataclass
from langchain.agents import create_agent
from langchain.chat_models import init_chat_model
from langchain.tools import tool, ToolRuntime
from langchain.agents.structured_output import ToolStrategy
from langgraph.checkpoint.memory import InMemorySaver

@dataclass
class Context:
    user_id: str

@tool
def search_orders(query: str, runtime: ToolRuntime[Context]) -> str:
    """Search user orders."""
    return f"Orders for {runtime.context.user_id}: {query}"

@dataclass
class Response:
    answer: str
    order_ids: list[str] | None = None

agent = create_agent(
    model=init_chat_model("claude-sonnet-4-5-20250929", temperature=0),
    system_prompt="You are a customer service agent.",
    tools=[search_orders],
    context_schema=Context,
    response_format=ToolStrategy(Response),
    checkpointer=InMemorySaver()
)

result = agent.invoke(
    {"messages": [{"role": "user", "content": "Find my recent orders"}]},
    config={"configurable": {"thread_id": "session-1"}},
    context=Context(user_id="user123")
)

Anti-Patterns to Avoid

  • Tools without type hints or docstrings — the docstring is the tool description the model sees; a missing or vague one means the agent misuses the tool
  • Global state in tools — tools that read globals instead of ToolRuntime[Context] are untestable and unsafe in concurrent runs
  • No checkpointer, then wondering why the agent forgets — multi-turn agents need checkpointer=InMemorySaver() (or a persistent saver) plus a stable thread_id
  • Rebuilding everything as one giant system prompt — tools, structured output (ToolStrategy/with_structured_output), and retrieval exist to keep prompts small
  • Letting raw tool exceptions reach the model — wrap tools, catch, and return structured error strings so the agent can recover
  • Using deprecated LLMChain/SequentialChain APIs — current LangChain builds on create_agent and LangGraph; the old chains are removed from recent versions
  • Stuffing whole documents into context — use the retrieval patterns in retrieval.md instead of naive full-document injection

When to Use / Not Use

Use this skill when:

  • Building agents with LangChain or LangGraph (Python or TypeScript)
  • Wiring tools, memory, MCP servers, or structured output into an LLM app
  • Implementing RAG, multi-agent handoffs, routers, or stateful workflows

Do NOT use this skill when:

  • A single stateless LLM call is all you need — the plain provider SDK is lighter
  • The project standardizes on another agent framework (e.g., smolagents) — follow the project's stack
  • The agent is code-first and benefits from the smaller SmolAgents execution model — see the smolagents skill

References

For detailed patterns, see:

  • references/langgraph.md - LangGraph workflows, graphs, persistence
  • references/multi-agent.md - Handoffs, routers, subagents
  • references/retrieval.md - RAG, vector stores, embeddings

Key Links

レビュー

まだレビューはありません。使ってみた感想をお寄せください。

同じリポジトリのスキル

概要と使いどころ

Adaption AI SDK for synthetic data augmentation and dataset adaptation. Use when building data pipelines with the Adaption Python SDK, uploading datasets (local files, Hugging Face, Kaggle), running augmentation/adaptation jobs, configuring brand controls (hallucination mitigation, safety categories, length), recipe specifications (reasoning traces, deduplication, preference pairs, prompt rephrase), evaluating dataset quality, downloading results, or any workflow involving `pip install adaption`, `from adaption import Adaption`, Adaptive Data, or the adaptionlabs.ai API. Also trigger when the user mentions synthetic data generation for fine-tuning, dataset augmentation pipelines, DPO preference pair generation, or grounding-based hallucination reduction on training data.

日本語の概要は準備中です。原文の説明を表示しています。

svngoku/coding-agents-skills122026年8月14日 更新

Design and review intuitive, scalable, maintainable HTTP APIs. Use this skill whenever the user wants to design a new REST API, review an existing API or spec, write OpenAPI 3.x definitions, or work with HTTP semantics (GET/POST/PUT/PATCH/DELETE), status codes, idempotency (Idempotency-Key), error envelopes (RFC 7807 problem+json), pagination, filtering, versioning, or API auth (API keys, OAuth2 client credentials, rate limits). Also trigger for "API design", "RESTful", "endpoints", "OpenAPI", "Swagger", "ReDoc", "contract testing", or GraphQL and gRPC design questions.

日本語の概要は準備中です。原文の説明を表示しています。

svngoku/coding-agents-skills122026年8月14日 更新

Design relational database schemas (and choose when to go NoSQL) that stay maintainable and fast. Use this skill whenever the user mentions tables, DDL, entities and relationships, normalization (1NF/2NF/3NF), primary and foreign keys, UUID vs bigint IDs, indexes (B-tree, composite, covering, partial), EXPLAIN, constraints (CHECK, UNIQUE, exclusion), transactions and isolation levels, migrations (Alembic, Prisma, Flyway, expand-contract, backfilling), or SQL vs NoSQL (MongoDB, DynamoDB, Cassandra, graph databases). Also trigger for "design the database", "model this domain", "which database should I use", or writing ORM models and migration files for PostgreSQL, MySQL, SQLite, or SQL Server.

日本語の概要は準備中です。原文の説明を表示しています。

svngoku/coding-agents-skills122026年8月14日 更新

ddd

無料

Domain-Driven Design system for software development. Use when designing new systems with DDD principles, refactoring existing codebases toward DDD, generating code scaffolding (entities, aggregates, repositories, domain events), facilitating Event Storming sessions, creating bounded context maps, or performing code reviews with a DDD lens. Covers both strategic design (bounded contexts, subdomains, context maps, ubiquitous language) and tactical design (entities, value objects, aggregates, domain services, repositories). Supports all major architecture patterns (Hexagonal/Ports & Adapters, CQRS, Event Sourcing, Clean Architecture) with language-agnostic guidance and concrete examples in Python and TypeScript.

日本語の概要は準備中です。原文の説明を表示しています。

svngoku/coding-agents-skills122026年8月14日 更新

genai-tk

無料

Build GenAI and agentic applications with the genai-tk toolkit (https://github.com/tclatos/genai-tk) — a YAML-driven wrapper over LangChain, LangGraph, and 100+ LLM providers. Use this skill whenever the user mentions genai-tk, genai_tk, the GenAI Toolkit, `cli init`, `LangchainAgent`, `get_llm`/`get_embeddings`, `RetrieverFactory`/`ManagedRetriever`, the four bundled agent frameworks (ReAct, Deep, Deer-flow, SmolAgents), the OpenSandbox Docker integration, the `model_id@provider` identifier format, the `global_config()`/`OmegaConfig` system with `app_conf.yaml` and `:merge`, BAML structured extraction, SkillsMiddleware, writing or editing the toolkit's YAML profiles (langchain.yaml, deerflow.yaml, llm.yaml, retrievers.yaml), composing retrievers (vector/bm25/ensemble/reranked/pg_hybrid/zero_entropy), or extending the CLI with `CliTopCommand`. Trigger even when the user only says "the toolkit" in context.

日本語の概要は準備中です。原文の説明を表示しています。

svngoku/coding-agents-skills122026年8月14日 更新

Decompose systems into microservices and apply canonical distributed-systems patterns. Use this skill whenever the user wants to split a monolith into services, design service boundaries, choose between microservices and a modular monolith, implement sagas or the outbox pattern, set up CQRS or event sourcing, configure an API gateway or BFF, add resilience (circuit breakers, retries, timeouts), or implement distributed tracing with OpenTelemetry. Also trigger for distributed transactions, service discovery, event-driven architecture, contract testing with Pact, canary releases, and idempotent consumers.

日本語の概要は準備中です。原文の説明を表示しています。

svngoku/coding-agents-skills122026年8月14日 更新

svngoku のスキルをすべて見る

このスキルの問題を報告する