# Langchain

> LangChain Skill

- Skill: `ashish7802/langchain` (Agent Skill, multi-file: 3 files)
- Install (CLI): `npx skillmds@latest add ashish7802/langchain`
- Raw SKILL.md: https://api.skillmd.com/api/skills/ashish7802/langchain/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: Coding & Dev Tools
- Author: ashish7802 (https://skillmd.com/u/ashish7802)
- Updated: 2026-09-21
- Page: https://skillmd.com/skills/ashish7802/langchain

---

# LangChain Skill

> Framework for developing applications powered by language models.

## Ecosystem Graph Preview

```mermaid
graph LR
  langchain["langchain"]:::core
  classDef core fill:#f9f,stroke:#333,stroke-width:4px;
  langchain -- "alternative to" --> llamaindex
  langchain -- "integrates with" --> openai
  langchain -- "integrates with" --> pinecone
  llamaindex -- "alternative to" --> langchain
  ollama -- "integrates with" --> langchain
  vllm -- "integrates with" --> langchain
```

## Recommended Next Skills

- **[llamaindex](/skills/llamaindex)** (Score: 0.93)
  *Why: Direct relationship, Both are AI, Shared ecosystem (ai), Can deploy to any, Similar network profile*
- **[ollama](/skills/ollama)** (Score: 0.83)
  *Why: Direct relationship, Both are AI, Shared ecosystem (ai), Similar network profile*
- **[vllm](/skills/vllm)** (Score: 0.82)
  *Why: Direct relationship, Both are AI, Shared ecosystem (ai), Similar network profile*

## Quick Start
LangChain provides standard interfaces for LLMs, Vector Stores, and Memory, allowing you to chain them together to build complex Agents and Retrieval-Augmented Generation (RAG) pipelines.

```bash
pip install langchain langchain-openai
```

## Production Patterns
### LCEL (LangChain Expression Language)
Avoid using massive legacy chain classes (like `ConversationalRetrievalChain`). Migrate entirely to LCEL, which uses Python pipe operators (`|`) to compose prompts, models, and output parsers declaratively. It automatically handles streaming and async logic.

## Architecture & Scaling
### Agents vs Chains
A Chain is a deterministic sequence of operations. An Agent utilizes an LLM's reasoning to dynamically determine which Tools to execute and in what order to solve a complex goal.

## Error Recovery
LLMs frequently output invalid JSON when asked for structured data. Use LangChain's `OutputFixingParser` which automatically catches parsing errors and feeds the broken output back to the LLM with instructions to fix it.

## Security Notes
Never give an Agent unmitigated access to destructive Tools (e.g., SQL DELETE capabilities or Shell execution). Always enforce human-in-the-loop approval or strict sandbox environments.

## References
- [LangChain Docs](https://python.langchain.com/docs/get_started/introduction)

## Why use this skill
Use this when your agent works with **langchain** — structured patterns beat pasted docs and prevent common hallucinations.

## AI pitfalls
- Using deprecated model IDs or wrong API endpoints
- Confusing chat vs completions vs embeddings APIs
- Omitting rate-limit and token budget handling

## Production checklist
- [ ] Secrets in environment variables, not source code
- [ ] Error handling and logging in place
- [ ] Rate limits and timeouts configured

## Related skills
- [`llamaindex`](../llamaindex/SKILL.md) — alternative to
- [`openai`](../openai/SKILL.md) — integrates with
- [`pinecone`](../pinecone/SKILL.md) — integrates with

---
> **Last Verified:** 2026-07-02

