AGENT SKILL

langchain-core-workflow-a

Build LangChain LCEL chains with prompts, parsers, and composition. Use when creating prompt templates, building RunnableSequence pipelines, parallel/branching chains, or multi-step processing workflows. Trigger: "langchain chains", "langchain prompts", "LCEL workflow", "langchain pipeline", "prompt template", "RunnableSequence".

License 许可
MIT
最近更新
2026-07-13
Stars
★ 1
Forks
0

01 前言 Front Matter

name
langchain-core-workflow-a
tags
[ "saas", "langchain", "llm", "workflow" ]
author
Jeremy Longshore <jeremy@intentsolutions.io>
license
MIT
version
1.0.0
description
Build LangChain LCEL chains with prompts, parsers, and composition. Use when creating prompt templates, building RunnableSequence pipelines, parallel/branching chains, or multi-step processing workflows. Trigger: "langchain chains", "langchain prompts", "LCEL workflow", "langchain pipeline", "prompt template", "RunnableSequence".
allowed-tools
Read, Write, Edit
compatible-with
claude-code, codex, openclaw

03 SKILL.md 正文

LangChain Core Workflow A: Chains & Prompts

Overview

Build production chains using LCEL (LangChain Expression Language). Covers prompt templates, output parsers, RunnableSequence, RunnableParallel, RunnableBranch, RunnablePassthrough, and chain composition patterns.

Prerequisites

  • langchain-install-auth completed
  • @langchain/core and at least one provider installed

Prompt Templates

ChatPromptTemplate

import { ChatPromptTemplate, MessagesPlaceholder } from "@langchain/core/prompts";

// Simple template
const simple = ChatPromptTemplate.fromTemplate(
  "Translate '{text}' to {language}"
);

// Multi-message template with chat history slot
const chat = ChatPromptTemplate.fromMessages([
  ["system", "You are a {role}. Respond in {style} style."],
  new MessagesPlaceholder("history"),  // dynamic message injection
  ["human", "{input}"],
]);

// Inspect required variables
console.log(chat.inputVariables);
// ["role", "style", "history", "input"]

Partial Templates

// Pre-fill some variables, leave others for later
const partial = await chat.partial({
  role: "senior engineer",
  style: "concise",
});

// Now only needs: history, input
const result = await partial.invoke({
  history: [],
  input: "Explain LCEL",
});

Output Parsers

import { StringOutputParser } from "@langchain/core/output_parsers";
import { JsonOutputParser } from "@langchain/core/output_parsers";
import { StructuredOutputParser } from "@langchain/core/output_parsers";
import { z } from "zod";

// String output (most common)
const strParser = new StringOutputParser();

// JSON output with Zod schema
const jsonParser = StructuredOutputParser.fromZodSchema(
  z.object({
    answer: z.string(),
    confidence: z.number(),
    sources: z.array(z.string()),
  })
);

// Get format instructions to inject into prompt
const instructions = jsonParser.getFormatInstructions();

Chain Composition Patterns

Sequential Chain (RunnableSequence)

import { ChatOpenAI } from "@langchain/openai";
import { ChatPromptTemplate } from "@langchain/core/prompts";
import { StringOutputParser } from "@langchain/core/output_parsers";
import { RunnableSequence } from "@langchain/core/runnables";

const model = new ChatOpenAI({ model: "gpt-4o-mini" });

// Extract key points, then summarize
const extractPrompt = ChatPromptTemplate.fromTemplate(
  "Extract 3 key points from:\n{text}"
);
const summarizePrompt = ChatPromptTemplate.fromTemplate(
  "Summarize these points in one sentence:\n{points}"
);

const chain = RunnableSequence.from([
  // Step 1: extract points
  {
    points: extractPrompt
      .pipe(model)
      .pipe(new StringOutputParser()),
  },
  // Step 2: summarize
  summarizePrompt,
  model,
  new StringOutputParser(),
]);

const summary = await chain.invoke({
  text: "Long article text here...",
});

Parallel Execution (RunnableParallel)

import { RunnableParallel } from "@langchain/core/runnables";

// Run multiple chains simultaneously on the same input
const analysis = RunnableParallel.from({
  summary: ChatPromptTemplate.fromTemplate("Summarize: {text}")
    .pipe(model)
    .pipe(new StringOutputParser()),

  keywords: ChatPromptTemplate.fromTemplate("Extract 5 keywords from: {text}")
    .pipe(model)
    .pipe(new StringOutputParser()),

  sentiment: ChatPromptTemplate.fromTemplate("Sentiment of: {text}")
    .pipe(model)
    .pipe(new StringOutputParser()),
});

const results = await analysis.invoke({ text: "Your input text" });
// { summary: "...", keywords: "...", sentiment: "..." }

Conditional Branching (RunnableBranch)

import { RunnableBranch } from "@langchain/core/runnables";

const technicalChain = ChatPromptTemplate.fromTemplate(
  "Give a technical explanation: {input}"
).pipe(model).pipe(new StringOutputParser());

const simpleChain = ChatPromptTemplate.fromTemplate(
  "Explain like I'm 5: {input}"
).pipe(model).pipe(new StringOutputParser());

const router = RunnableBranch.from([
  [
    (input: { input: string; level: string }) => input.level === "expert",
    technicalChain,
  ],
  // Default fallback
  simpleChain,
]);

const answer = await router.invoke({ input: "What is LCEL?", level: "expert" });

Context Injection (RunnablePassthrough)

import { RunnablePassthrough } from "@langchain/core/runnables";

// Pass through original input while adding computed fields
const chain = RunnablePassthrough.assign({
  wordCount: (input: { text: string }) => input.text.split(" ").length,
  uppercase: (input: { text: string }) => input.text.toUpperCase(),
}).pipe(
  ChatPromptTemplate.fromTemplate(
    "The text has {wordCount} words. Summarize: {text}"
  )
).pipe(model).pipe(new StringOutputParser());

Python Equivalent

from langchain_openai import ChatOpenAI
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser
from langchain_core.runnables import RunnableParallel, RunnablePassthrough

llm = ChatOpenAI(model="gpt-4o-mini")

# Sequential: prompt | model | parser
chain = ChatPromptTemplate.from_template("Summarize: {text}") | llm | StrOutputParser()

# Parallel
analysis = RunnableParallel(
    summary=ChatPromptTemplate.from_template("Summarize: {text}") | llm | StrOutputParser(),
    keywords=ChatPromptTemplate.from_template("Keywords: {text}") | llm | StrOutputParser(),
)

# Passthrough with computed fields
chain = (
    RunnablePassthrough.assign(context=lambda x: fetch_context(x["query"]))
    | prompt | llm | StrOutputParser()
)

Error Handling

Error Cause Fix
Missing value for input Template variable not provided Check inputVariables on your prompt
Expected mapping type Passing string instead of object Use { input: "text" } not "text"
OutputParserException LLM output doesn't match schema Use .withStructuredOutput() instead of manual parsing
Parallel timeout One branch hangs Add timeout to model config

Resources

Next Steps

Proceed to langchain-core-workflow-b for agents and tool calling.

04 同仓库更多 Skills

jukeyman
jukeyman/jukeyman-skills

zustand-store-creator

Create zustand store creator operations. Auto-activating skill for Frontend Development. Triggers on: zustand store creator, zustand store creator Part of the Frontend Development skill category. Use when working with zustand store creator functionality. Trigger with phrases like "zustand store creator", "zustand creator", "zustand".

★ 1
jukeyman
jukeyman/jukeyman-skills

zero-trust-config-helper

Configure with zero trust config helper operations. Auto-activating skill for Security Advanced. Triggers on: zero trust config helper, zero trust config helper Part of the Security Advanced skill category. Use when configuring systems or services. Trigger with phrases like "zero trust config helper", "zero helper", "zero".

★ 1
jukeyman
jukeyman/jukeyman-skills

zapier-integration-helper

Assist with zapier integration helper operations. Auto-activating skill for Business Automation. Triggers on: zapier integration helper, zapier integration helper Part of the Business Automation skill category. Use when working with APIs or building integrations. Trigger with phrases like "zapier integration helper", "zapier helper", "zapier".

★ 1
jukeyman
jukeyman/jukeyman-skills

yaml-config-validator

Validate yaml config validator operations. Auto-activating skill for DevOps Basics. Triggers on: yaml config validator, yaml config validator Part of the DevOps Basics skill category. Use when configuring systems or services. Trigger with phrases like "yaml config validator", "yaml validator", "yaml".

★ 1
jukeyman
jukeyman/jukeyman-skills

xvary-stock-research

Thesis-driven equity analysis from public SEC EDGAR and market data; /analyze, /score, /compare workflows with bundled Python tools (Claude Code, Cursor, Codex).

★ 1
jukeyman
jukeyman/jukeyman-skills

xss-vulnerability-scanner

Scan xss vulnerability scanner operations. Auto-activating skill for Security Fundamentals. Triggers on: xss vulnerability scanner, xss vulnerability scanner Part of the Security Fundamentals skill category. Use when working with xss vulnerability scanner functionality. Trigger with phrases like "xss vulnerability scanner", "xss scanner", "xss".

★ 1