new-chain

A code generator for LangChain LCEL chains, which connect language-model steps together. It provides starting templates for summarizing, extracting data, classifying text, and translating.

In plain words
What is it for?
Use it to create a Python chain file from a selected pattern, then customize the model, prompts, and output behavior.
Why use it?
It removes the repetitive setup needed to begin a common language-processing workflow.

Command

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add commands/codeblockz/langchain-community-plugin/new-chain
Clone the repo
git clone --depth 1 https://github.com/Codeblockz/langchain-community-plugin
Per session 15 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 2,309 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00015 $0.02309
Opus 5 $0.00008 $0.01154
Sonnet 5 $0.00003 $0.00462
Haiku 4.5 $0.00002 $0.00231

Measured 2d ago against content hash ca386e6f0718, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

new-chain scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

commands/new-chain.md · 396 lines

How it starts

The opening of the file, as written. The whole thing — 396 lines — stays where its author put it; the contents beside it link to each section on GitHub.

New Chain Command

Create a new LCEL chain file for common patterns.

Workflow

  1. Ask the user which chain type they want:

    • summarization - Summarize documents or text
    • extraction - Extract structured data
    • classification - Classify text into categories
    • translation - Translate between languages
  2. Get filename from argument or ask user (default: chain.py)

  3. Generate the chain file using the appropriate template below

  4. Inform user about customization options

Templates

Summarization Template

"""
Summarization Chain

Install: pip install langchain langchain-openai
"""
from langchain_core.prompts import ChatPromptTemplate
from langchain_core.output_parsers import StrOutputParser
from langchain_openai import ChatOpenAI


def create_summarization_chain(
    model: str = "gpt-4o",
    style: str = "concise",
    max_points: int = 5,
):
    """
    Create a summarization chain.

    Args:
        model: The model to use
        style: Summary style (concise, detailed, bullet_points)
        max_points: Maximum bullet points for bullet_points style
    """
    style_instructions = {
        "concise": "Provide a brief, 2-3 sentence summary.",
        "detailed": "Provide a comprehensive summary covering all main points.",
        "bullet_points": f"Provide a summary as {max_points} bullet points.",
    }

    prompt = ChatPromptTemplate.from_template("""
Summarize the following text.

{style_instruction}

Text:
{text}

Summary:
""")

    llm = ChatOpenAI(model=model, temperature=0)

    chain = (
        prompt.partial(style_instruction=style_instructions.get(style, style_instructions["concise"]))
        | llm
        | StrOutputParser()
    )

    return chain


def main():
    # Create chain
    chain = create_summarization_chain(style="bullet_points", max_points=5)

    # Example usage
    text = """
    Artificial intelligence (AI) is transforming industries across the globe.
    From healthcare to finance, AI applications are improving efficiency and
    enabling new capabilities. Machine learning, a subset of AI, allows systems
    to learn from data without explicit programming. Deep learning, using neural
    networks, has achieved remarkable results in image and speech recognition.
    However, challenges remain around bias, interpretability, and ethical use.
    """

    summary = chain.invoke({"text": text})
    print(summary)


if __name__ == "__main__":
    main()

Read the full file on GitHub · 396 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 396 lines · 15 tokens per session scan A ca386e6f0718

Subscribe to this mod's changes

new-chain is a command published in the GitHub repository Codeblockz/langchain-community-plugin (3 stars, last pushed 7mo ago), licensed Apache-2.0. It adds 15 tokens to every session and 2,309 once invoked, about $0.0001 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.