Files
main/rules-mdc/langgraph.mdc
T
sanjeed5 8fbf269085 Regenerate all MDC rules with fresh Exa data and December 2025 best practices
- Refreshed all 241 library rules with current best practices
- Updated Exa search results for all libraries with 2025 content
- Fixed --regenerate-all flag logic to properly process all libraries
- Removed duplicate astro entry in rules.json (merged tags)
- Added missing docker.mdc and vim.mdc files
- All rules now include modern patterns and anti-patterns
- Updated with framework-specific recommendations for 2025

Technical improvements:
- Fixed retry_failed_only logic in generate_mdc_files.py
- Improved progress tracking for regeneration scenarios
- Ensured proper handling of --refresh-exa flag
2025-12-17 22:40:28 +05:30

38 lines
1.2 KiB
Plaintext

---
description: This guide provides definitive best practices for building robust, maintainable, and performant AI agent workflows using LangGraph.
globs: **/*.py
---
# langgraph Best Practices
## Code Organization and Structure
### 1. Explicit Graph Topology & Modularity
Define clear, single responsibilities for each node. Encapsulate common patterns into reusable subgraphs. Prefer Directed Acyclic Graphs (DAGs); use cycles only when essential for feedback loops.
✅ GOOD: Focused nodes, composable subgraphs
```python
from langgraph.graph import StateGraph, END
from typing import TypedDict, List
class AgentState(TypedDict):
messages: List[str]
tool_output: str | None
def fetch_data_node(state: AgentState) -> AgentState:
return {"messages": state["messages"] + ["Data fetched."]}
def analyze_data_node(state: AgentState) -> AgentState:
return {"messages": state["messages"] + ["Data analyzed."]}
def build_subgraph():
builder = StateGraph(AgentState)
builder.add_node("fetch", fetch_data_node)
builder.add_node("analyze", analyze_data_node)
builder.add_edge("fetch", "analyze")
builder.set_entry_point("fetch")
builder.set_finish_point("analyze")
return builder.compile()
```
### 2. Functional API Preference
Prior