skills/langchain-basics/SKILL.md
To utilize the LangChain framework to build complex LLM applications by chaining together components (Models, Prompts, Parsers) into composable workflows. Use when: When building complex chains (e.g., Retrieval -> Augmentation -> Generation); When you need to swap LLM providers easily (e.g., OpenAI to Anthropic); When integrating structured output parsing.
npx skillsauth add jyjeanne/ai-setup-forge langchain-basicsInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
To utilize the LangChain framework to build complex LLM applications by chaining together components (Models, Prompts, Parsers) into composable workflows.
Install core LangChain packages and the OpenAI integration.
npm install @langchain/core @langchain/openai zod
Use LangChain Expression Language (LCEL) for declarative chain definitions.
import { ChatOpenAI } from "@langchain/openai";
import { ChatPromptTemplate } from "@langchain/core/prompts";
import { StringOutputParser } from "@langchain/core/output_parsers";
// 1. Initialize Model
const model = new ChatOpenAI({
modelName: "gpt-4o",
temperature: 0,
apiKey: process.env.OPENAI_API_KEY
});
// 2. Define Prompt
const prompt = ChatPromptTemplate.fromMessages([
["system", "You are a technical documentation expert."],
["user", "Explain {topic} in one sentence."]
]);
// 3. Create Chain
// Input -> Prompt -> Model -> String Output
const chain = prompt.pipe(model).pipe(new StringOutputParser());
// Usage
async function runChain() {
const result = await chain.invoke({ topic: "Dependency Injection" });
console.log(result);
}
Use StructuredOutputParser with Zod to guarantee type-safe responses.
import { z } from "zod";
import { StructuredOutputParser } from "@langchain/core/output_parsers";
// Define Schema
const schema = z.object({
sentiment: z.enum(["positive", "negative", "neutral"]),
keywords: z.array(z.string()).describe("List of up to 5 keywords"),
summary: z.string().describe("Brief summary of the text")
});
const parser = StructuredOutputParser.fromZodSchema(schema);
const analysisChain = ChatPromptTemplate.fromTemplate(
"Analyze the following text.\n{format_instructions}\n\nText: {text}"
).pipe(model).pipe(parser);
async function analyzeText(text: string) {
return await analysisChain.invoke({
text,
format_instructions: parser.getFormatInstructions()
});
}
Manage conversation history for chatbots.
import { RunnableWithMessageHistory } from "@langchain/core/runnables";
import { InMemoryChatMessageHistory } from "@langchain/core/chat_history";
const messageHistory = new InMemoryChatMessageHistory();
const chatChain = new RunnableWithMessageHistory({
runnable: prompt.pipe(model),
getMessageHistory: async (sessionId) => messageHistory,
inputMessagesKey: "input",
historyMessagesKey: "history",
});
LangSmith for tracing if available.package.json.A composable pipeline that reliably transforms inputs into structured outputs, leveraging the power of chained LLM operations.
development
Generate breadboard circuit mockups and visual diagrams using HTML5 Canvas drawing techniques. Use when asked to create circuit layouts, visualize electronic component placements, draw breadboard diagrams, mockup 6502 builds, generate retro computer schematics, or design vintage electronics projects. Supports 555 timers, W65C02S microprocessors, 28C256 EEPROMs, W65C22 VIA chips, 7400-series logic gates, LEDs, resistors, capacitors, switches, buttons, crystals, and wires.
development
Apply lean thinking to UX: hypothesis-driven design, collaborative sketching, and rapid experiments instead of heavy deliverables. Use when the user mentions "Lean UX", "design hypothesis", "UX experiment", "collaborative design", or "outcome over output". Covers hypothesis statements, MVPs for UX, and cross-functional collaboration. For Build-Measure-Learn, see lean-startup. For usability audits, see ux-heuristics.
development
Design MVPs, validated learning experiments, and pivot-or-persevere decisions using Build-Measure-Learn. Use when the user mentions "MVP scope", "validated learning", "pivot or persevere", "vanity metrics", or "test assumptions". Covers innovation accounting and actionable metrics. For 5-day prototype testing, see design-sprint. For customer motivation analysis, see jobs-to-be-done.
tools
Instrument, trace, evaluate, and monitor LLM applications and AI agents with LangSmith. Use when setting up observability for LLM pipelines, running offline or online evaluations, managing prompts in the Prompt Hub, creating datasets for regression testing, or deploying agent servers. Triggers on: langsmith, langchain tracing, llm tracing, llm observability, llm evaluation, trace llm calls, @traceable, wrap_openai, langsmith evaluate, langsmith dataset, langsmith feedback, langsmith prompt hub, langsmith project, llm monitoring, llm debugging, llm quality, openevals, langsmith cli, langsmith experiment, annotate llm, llm judge.