agentleFS
HarambeeAIHarambeeAI/bayes-ship/skills/langchain-fundamentals/SKILL.md

langchain-fundamentals

Skill1 starsChanged 8 months agoMITView on GitHub

Build agents with LangChain's create_agent, tools, structured output, and middleware. Use when implementing AI agent features with the LangChain framework. Covers tool calling, agent loops, and integration patterns.

4 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

2 rules. 0 are common, 2 are distinctive, and 0 are very specific to this project.

  • 0

    Common

    Most of the 3 edited versions we read keep these.

  • 2

    Distinctive

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    When building AI-powered features that require tool-calling agents, structured LLM output, or LangChain middleware patterns.

    line 9
  2. Distinctive:

    Always prefer LCEL for chains:

    line 56

“Common” is measured: kept by at least 6 in 10 of the 3 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

LangChain Fundamentals

When to use

When building AI-powered features that require tool-calling agents, structured LLM output, or LangChain middleware patterns. Applicable during execution phase tasks tagged with AI/agent functionality.

Core patterns

Agent creation (Python)

from langchain_anthropic import ChatAnthropic
from langchain.agents import create_agent

llm = ChatAnthropic(model="claude-sonnet-4-20250514")
agent = create_agent(
    model=llm,
    tools=[tool_a, tool_b],
    system_prompt="You are a helpful assistant."
)
result = agent.invoke({"messages": [{"role": "user", "content": "..."}]})

Tool definition

from langchain_core.tools import tool

@tool
def search_database(query: str) -> str:
    """Search the product database. Use when user asks about products."""
    # Implementation
    return results

Structured output

from pydantic import BaseModel

class Analysis(BaseModel):
    summary: str
    key_points: list[str]
    confidence: float

structured_llm = llm.with_structured_output(Analysis)
result = structured_llm.invoke("Analyze this document...")

LCEL (LangChain Expression Language)

Always prefer LCEL for chains:

from langchain_core.runnables import RunnablePassthrough

chain = (
    {"context": retriever, "question": RunnablePassthrough()}
    | prompt
    | llm
    | output_parser
)

Dependencies

langchain>=0.3
langchain-anthropic>=0.3
langchain-core>=0.3

Reference

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.