build-langchain-ts-app
Use if building TypeScript apps with langchain/@langchain — agents, RAG, structured output.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Use if building TypeScript apps with langchain/@langchain — agents, RAG, structured output.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Use skill if you are exhaustively testing or release-gating martool CLI commands in a source checkout or deployed Coolify container over SSH, without local Docker or provider spend.
Use if driving agent-browser for Chrome/CDP automation, @ref snapshots, tabs, or verification.
Use if testing or debugging an iOS app via agent-device CLI — simulator flows, evidence, bug triage.
Use if supervising Jean agents through MCP and Computer Use for monitoring, recovery, or closure.
Use if auditing or designing a CLI for agent/LLM use — JSON output, exit codes, non-interactive.
Use if auditing or designing an MCP server for agent-readiness — framework, security, context.
| name | build-langchain-ts-app |
| description | Use if building TypeScript apps with langchain/@langchain — agents, RAG, structured output. |
Build LangChain.js v1 and LangGraph.js applications in TypeScript. Choose one implementation path before coding, keep the spine small, and load only the bundled references the chosen path needs.
createAgent from langchain and Zod-typed tools.Document loader, splitter, embeddings, vector store, and retriever.StateGraph from @langchain/langgraph with explicit state, routing, fan-out/fan-in, or interrupts.withStructuredOutput, responseFormat, toolStrategy, or providerStrategy.thread_id-keyed memory.@langchain/mcp-adapters.Do not use this skill when:
openai.chat.completions.create) is enough — pull in the provider SDK directly.mcp-use MCPAgent — use build-mcp-use-agent.@effect/* even if it calls LLMs — use build-effect-ts-v3.Treat these as the strong-positive signals for this skill:
| Signal | Example |
|---|---|
langchain package import | import { createAgent } from "langchain" |
@langchain/core/* | import { tool } from "@langchain/core/tools" |
@langchain/langgraph | import { StateGraph, MemorySaver, Annotation } from "@langchain/langgraph" |
| Provider packages | @langchain/openai, @langchain/anthropic, @langchain/google-genai, @langchain/azure-openai |
| Retrieval stack | @langchain/textsplitters, RecursiveCharacterTextSplitter, OpenAIEmbeddings, InMemoryVectorStore, *.asRetriever() |
| MCP adapters | import { MultiServerMCPClient } from "@langchain/mcp-adapters" |
| Structured output / streaming | model.withStructuredOutput(schema), responseFormat, toolStrategy, providerStrategy, agent.stream(..., { streamMode: "updates" }) |
| Persistence | MemorySaver, checkpointer, thread_id, store |
| LangSmith | langsmith, LANGSMITH_API_KEY, traceable, openevals |
If none of these appear and the task is plain chat completion, route away from this skill.
Before coding, inspect the target repo and record:
package.json: module type, scripts, framework, existing LangChain packages, and test command.npm ls langchain @langchain/core @langchain/langgraph @langchain/openai when dependencies are installed; for drift checks use references/start/version-discipline.md.scripts/check-langchain-versions.sh for a read-only package report; docs live in scripts/check-langchain-versions.sh.md.OPENAI_API_KEY, OPENROUTER_API_KEY, Anthropic/Google/Azure keys, LangSmith keys, MCP credentials.scripts/scaffold-createagent-app.sh only for a minimal createAgent app; docs live in scripts/scaffold-createagent-app.sh.md.For first-runnable apps and recovery from common failures, consult references/start/getting-started.md and references/start/common-errors.md.
Force the architecture choice before writing code:
createAgent when external actions or business functions are needed and graph state/routing is not explicit.StateGraph only when the app needs explicit state, routing, interrupts, fan-out/fan-in, or durable graph execution.| Path | Output shape | First reference | Verification |
|---|---|---|---|
createAgent tool-calling assistant | Messages state plus optional structuredResponse; tools call real project functions. | references/agents/agents.md, then references/agents/tools.md | Assert tool call/result behavior, final message, max-step limit, optional structured response. |
| RAG pipeline | Answer plus retrieved/source Document[], citations, grounding metadata. | references/rag/rag.md | Assert retrieval count, source IDs, answer contract, no-answer behavior. |
Raw StateGraph | Typed graph state returned from invoke/stream; transitions are explicit. | references/langgraph/langgraph.md, then references/langgraph/langgraph-execution.md | Assert node outputs, conditional routes, recursion limit, persisted state when enabled. |
| Structured output | Validated schema object or explicit parse/retry failure path. | references/agents/structured-output.md | Assert schema success, invalid-output handling, provider/tool strategy behavior. |
| Streaming UI/API | Chosen token/event/update contract with cancellation and error events. | references/agents/streaming.md | Assert event order, chunk shape, completion signal, abort behavior. |
| Human-in-the-loop | Interrupted graph paused on review/edit/approve nodes. | references/langgraph/human-in-the-loop.md | Assert interrupt payload, resume path, replay behavior. |
| MCP integration | Namespaced MCP tools, lifecycle management, explicit auth/transport config. | references/providers/mcp.md | Assert server connection, tool discovery/filtering, timeout, cleanup, credential failure. |
| Memory / persistence | Stable thread_id, selected checkpointer/store, retention rules, replay. | references/langgraph/memory-checkpointers.md plus references/langgraph/memory-stores.md | Assert multi-turn continuity, isolation between threads, persistence across restart if durable. |
| Multi-agent / knowledge-domain | Supervisor/router/handoff state plus domain safety constraints. | references/agents/multi-agent.md or references/agents/knowledge-agents.md | Assert route selection, handoff messages, domain guardrails, failure fallback. |
toolStrategy as the portable structured-output default; choose providerStrategy only when the selected provider is known to support it.Use path-specific package subsets and pin compatible versions in real apps:
| Path | Baseline packages |
|---|---|
createAgent | langchain @langchain/core zod plus a provider package such as @langchain/openai |
| RAG | langchain @langchain/core @langchain/openai @langchain/textsplitters zod plus the chosen vector-store package |
| Raw LangGraph | @langchain/langgraph @langchain/core zod plus provider/checkpointer packages as needed |
| MCP | langchain @langchain/core @langchain/mcp-adapters @modelcontextprotocol/sdk zod |
| LangSmith eval/tracing | langsmith plus openevals only when evaluation workflows need it |
Use @latest only in update commands or exploratory refreshes, not as the documented tested state. When package APIs matter, verify the current package matrix before editing examples and record the research date. See references/start/version-discipline.md.
For existing apps, run scripts/check-langchain-versions.sh before diagnosing API drift or changing package pins. The paired docs are scripts/check-langchain-versions.sh.md.
For greenfield createAgent demos, run scripts/scaffold-createagent-app.sh to generate the smallest pinned TypeScript app. The paired docs are scripts/scaffold-createagent-app.sh.md.
For RAG, make these decisions before implementation:
| Decision | Local default | Production requirement |
|---|---|---|
| Corpus size / update cadence | Small static fixture | Ingestion and re-indexing plan |
| Embedding model / dimension | OpenAIEmbeddings, text-embedding-3-small | Stable model, recorded dimension, migration plan |
| Vector store | InMemoryVectorStore | Persistent store with backups and filters |
| Metadata filtering | Source ID only | Typed metadata schema and filter tests |
| Retriever type | Similarity retriever | Chosen retriever/reranker based on eval results |
| Grounding contract | Return source documents | Citations, refusal/no-answer policy, regression eval |
| Evaluation metric | Manual smoke test | Retrieval recall, faithfulness, answer relevance |
Before productionizing any path, define max steps or recursion limits, token budget, retry/fallback policy, rate-limit strategy, and failure surface. Route details to references/middleware/middleware-catalog.md, references/middleware/middleware-patterns.md, references/ops/observability-tracing.md, and references/ops/observability-evaluation.md.
For deployment shape and platform constraints (Node version, edge runtimes, container/cloud targets), read references/ops/deployment-local.md and references/ops/deployment-production.md.
For provider/model selection, capability differences, and key wiring, read references/providers/models.md and references/providers/providers.md.
Use LangSmith/observability for development debugging, production traces, cost/token tracking, RAG evaluation, and user feedback or online evals. Verify current pricing before quoting costs.
Load only the files needed for the selected path.
langchain/chains only when documenting migrations or anti-patterns.