mirror of
https://github.com/sanjeed5/awesome-cursor-rules-mdc.git
synced 2026-11-28 13:42:57 +08:00
- 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
38 lines
1.2 KiB
Plaintext
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 |