api-ai-langchain
LangChain.js patterns for building LLM applications — chat models, LCEL chains, prompt templates, structured output, agents, tools, RAG, streaming, and LangSmith tracing
npx skills add majiayu000/claude-skill-registry --skill api-ai-langchain --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
What it does
Guides agents to build LLM applications using LangChain.js patterns. It emphasizes LCEL pipe composition for chains, using withStructuredOutput for type-safe responses, creating agents with createAgent() for tool-calling workflows, and integrating RAG, streaming, and LangSmith tracing. It prescribes using a unified LangChain provider interface, ensuring all @langchain/* packages share the same @langchain/core version, and avoiding legacy patterns like LLMChain, AgentExecutor, or createToolCallingAgent. It also enforces environment-based API key handling and highlights the need to avoid hardcoding keys.
How it works
The skill instructs developers to:
- Build chains by piping components with prompt.pipe(model).pipe(parser) (LCEL pattern) and avoid legacy chain classes.
- Use withStructuredOutput(zodSchema) to constrain LLM outputs to a Zod schema.
- Create agent workflows via createAgent() from langchain, enabling automatic tool-calling loops and streaming, replacing AgentExecutor patterns.
- Define tools with tool() and Zod schemas, ensuring snake_case naming.
- Implement RAG pipelines with document loaders, text splitters, embeddings, and a vector store.
- Enable streaming for chains, models, and agents, and configure LangSmith tracing for observability.
- Manage provider switches by changing imports and model names, relying on initChatModel for runtime provider selection when needed.
- Avoid hardcoded API keys; use environment variables such as OPENAI_API_KEY, ANTHROPOIC_API_KEY, etc.
When to use it
- When building multi-step LLM workflows that compose prompts, models, and output parsers into chains.
- When creating agent-like workflows where models call tools.
- When implementing RAG pipelines with document loading, embedding, and retrieval.
- When you need structured, type-safe outputs and streaming.
- When you need to switch between providers with a unified interface and to enable tracing with LangSmith.
What it can touch
- Tools defined via the tool() function and Zod schemas.
- Models from LangChain provider packages (OpenAI, Anthropic, Google GenAI).
- LangChain core components such as prompt templates, LCEL pipelines, and RunnableSequence.
- LangSmith tracing setup via environment variables.
Caveats
- Requires adhering to project conventions (kebab-case, named exports, import ordering, import type, named constants).
- Avoids legacy patterns: do not use LLMChain, AgentExecutor, createToolCallingAgent in new code.
- All @langchain/* packages must depend on the same @langchain/core version to prevent runtime type errors.
- Requires environment-based API keys; hardcoding keys is discouraged.
# LangChain.js Patterns > **Quick Guide:** Use LangChain.js (v1.x) to build composable LLM applications. Use LCEL (`prompt.pipe(model).pipe(parser)`) for all chain composition -- never use legacy `LLMChain`. Use `withStructuredOutput(zodSchema)` for typed responses. Use `createAgent()` (LangGraph-backed) for agentic workflows -- `AgentExecutor` is legacy. All `@langchain/*` packages must share the same `@langchain/core` version or you get cryptic type errors at runtime. --- <critical_requirements> ## CRITICAL: Before Using This Skill > **All code must follow project conventions in CLAUDE.md** (kebab-case, named exports, import ordering, `import type`, named constants) **(You MUST use LCEL pipe composition (`prompt.pipe(model).pipe(parser)`) for all chains -- never use legacy `LLMChain`, `ConversationChain`, or `SequentialChain`)** **(You MUST ensure all `@langchain/*` packages depend on the same version of `@langchain/core` -- version mismatches cause cryptic runtime errors)** **(You MUST use `withStructuredOutput(zodSchema)` for structured LLM responses -- never manually parse JSON from completion text)** **(You MUST use `createAgent()` from `langchain` for new agent code -- `Agen
- CRITICAL: Before Using This Skill
- Examples Index
- Philosophy
- Core Patterns
- Pattern 1: Chat Model Initialization
- Pattern 2: LCEL Chain Composition
- Pattern 3: Structured Output with Zod
- Pattern 4: Tool Definition
- Pattern 5: Agents with createAgent()
- Pattern 6: RAG Pipeline
- Pattern 7: Streaming
- Pattern 8: LangSmith Tracing
- Decision Framework
- When to Use LangChain vs Direct SDK
Recommended for non-serverless environments:
What does the api-ai-langchain skill do?
LangChain.js patterns for building LLM applications — chat models, LCEL chains, prompt templates, structured output, agents, tools, RAG, streaming, and LangSmith tracing
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill api-ai-langchain --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.
Where does this skill come from?
From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.
Is a popular skill a good skill?
Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.
