[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6CBZ83GHYC76K2KZ3ZEF8RT":3,"skill-same:01M6CBZ83GHYC76K2KZ3ZEF8RT":61},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":15,"categories":16,"keywords":17,"publishedAt":25,"linkOnly":26,"markdownContent":27,"markdownBody":28,"frontMatter":29,"refName":30,"commitSha":31,"skillDirectory":32,"forksCount":33,"repositoryHtmlUrl":34,"repositoryHomepageUrl":6,"ownerHtmlUrl":35,"ownerBlogUrl":6,"ownerDescription":6,"updatedAt":36,"install":37,"resources":50},"01M6CBZ83GHYC76K2KZ3ZEF8RT","dagre-react-flow",null,"Automatic graph layout using dagre with React Flow (@xyflow\u002Freact). Use when implementing auto-layout, hierarchical layouts, tree structures, or arranging nodes programmatically. Triggers on dagre, auto-layout, automatic layout, getLayoutedElements, rankdir, hierarchical graph.","ray-manaloto\u002Fmacos-development-environment","ray-manaloto","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F227192835?v=4","01M6CBR7J13ZA01X5YB1A1QRJP","01M6CBR7P0S3NS8ZV81JYNST14",1,"MIT","https:\u002F\u002Fgithub.com\u002Fray-manaloto\u002Fmacos-development-environment\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fskills\u002Fdagre-react-flow\u002FSKILL.md",[],[18,19,20,21,22,23,24],"react","flow","dagre react flow","graph","use","auto","Nodes","2026-11-10 10:12:30",false,"---\nname: dagre-react-flow\ndescription: Automatic graph layout using dagre with React Flow (@xyflow\u002Freact). Use when implementing auto-layout, hierarchical layouts, tree structures, or arranging nodes programmatically. Triggers on dagre, auto-layout, automatic layout, getLayoutedElements, rankdir, hierarchical graph.\n---\n\n# Dagre with React Flow\n\nDagre is a JavaScript library for laying out directed graphs. It computes optimal node positions for hierarchical\u002Ftree layouts. React Flow handles rendering; dagre handles positioning.\n\n## Quick Start\n\n```bash\npnpm add @dagrejs\u002Fdagre\n```\n\n```typescript\nimport dagre from '@dagrejs\u002Fdagre';\nimport { Node, Edge } from '@xyflow\u002Freact';\n\nconst getLayoutedElements = (\n  nodes: Node[],\n  edges: Edge[],\n  direction: 'TB' | 'LR' = 'TB'\n) => {\n  const g = new dagre.graphlib.Graph();\n  g.setGraph({ rankdir: direction });\n  g.setDefaultEdgeLabel(() => ({}));\n\n  nodes.forEach((node) => {\n    g.setNode(node.id, { width: 172, height: 36 });\n  });\n\n  edges.forEach((edge) => {\n    g.setEdge(edge.source, edge.target);\n  });\n\n  dagre.layout(g);\n\n  const layoutedNodes = nodes.map((node) => {\n    const pos = g.node(node.id);\n    return {\n      ...node,\n      position: { x: pos.x - 86, y: pos.y - 18 }, \u002F\u002F Center to top-left\n    };\n  });\n\n  return { nodes: layoutedNodes, edges };\n};\n```\n\n## Core Concepts\n\n### Coordinate System Difference\n\n**Critical:** Dagre returns center coordinates; React Flow uses top-left.\n\n```typescript\n\u002F\u002F Dagre output: center of node\nconst dagrePos = g.node(nodeId); \u002F\u002F { x: 100, y: 50 } = center\n\n\u002F\u002F React Flow expects: top-left corner\nconst rfPosition = {\n  x: dagrePos.x - nodeWidth \u002F 2,\n  y: dagrePos.y - nodeHeight \u002F 2,\n};\n```\n\n### Node Dimensions\n\nDagre requires explicit dimensions. Three approaches:\n\n**1. Fixed dimensions (simplest):**\n```typescript\ng.setNode(node.id, { width: 172, height: 36 });\n```\n\n**2. Per-node dimensions from data:**\n```typescript\ng.setNode(node.id, {\n  width: node.data.width ?? 172,\n  height: node.data.height ?? 36,\n});\n```\n\n**3. Measured dimensions (most accurate):**\n```typescript\n\u002F\u002F After React Flow measures nodes\ng.setNode(node.id, {\n  width: node.measured?.width ?? 172,\n  height: node.measured?.height ?? 36,\n});\n```\n\n### Layout Directions\n\n| Value | Direction | Use Case |\n|-------|-----------|----------|\n| `TB` | Top to Bottom | Org charts, decision trees |\n| `BT` | Bottom to Top | Dependency graphs (deps at bottom) |\n| `LR` | Left to Right | Timelines, horizontal flows |\n| `RL` | Right to Left | RTL layouts |\n\n```typescript\ng.setGraph({ rankdir: 'LR' }); \u002F\u002F Horizontal layout\n```\n\n## Complete Implementation\n\n### Basic Layout Function\n\n```typescript\nimport dagre from '@dagrejs\u002Fdagre';\nimport type { Node, Edge } from '@xyflow\u002Freact';\n\ninterface LayoutOptions {\n  direction?: 'TB' | 'BT' | 'LR' | 'RL';\n  nodeWidth?: number;\n  nodeHeight?: number;\n  nodesep?: number;  \u002F\u002F Horizontal spacing\n  ranksep?: number;  \u002F\u002F Vertical spacing (between ranks)\n}\n\nexport function getLayoutedElements(\n  nodes: Node[],\n  edges: Edge[],\n  options: LayoutOptions = {}\n): { nodes: Node[]; edges: Edge[] } {\n  const {\n    direction = 'TB',\n    nodeWidth = 172,\n    nodeHeight = 36,\n    nodesep = 50,\n    ranksep = 50,\n  } = options;\n\n  const g = new dagre.graphlib.Graph();\n  g.setGraph({ rankdir: direction, nodesep, ranksep });\n  g.setDefaultEdgeLabel(() => ({}));\n\n  nodes.forEach((node) => {\n    const width = node.measured?.width ?? nodeWidth;\n    const height = node.measured?.height ?? nodeHeight;\n    g.setNode(node.id, { width, height });\n  });\n\n  edges.forEach((edge) => {\n    g.setEdge(edge.source, edge.target);\n  });\n\n  dagre.layout(g);\n\n  const layoutedNodes = nodes.map((node) => {\n    const pos = g.node(node.id);\n    const width = node.measured?.width ?? nodeWidth;\n    const height = node.measured?.height ?? nodeHeight;\n\n    return {\n      ...node,\n      position: {\n        x: pos.x - width \u002F 2,\n        y: pos.y - height \u002F 2,\n      },\n    };\n  });\n\n  return { nodes: layoutedNodes, edges };\n}\n```\n\n### React Flow Integration\n\n```tsx\nimport { useCallback } from 'react';\nimport {\n  ReactFlow,\n  useNodesState,\n  useEdgesState,\n  useReactFlow,\n  ReactFlowProvider,\n} from '@xyflow\u002Freact';\nimport { getLayoutedElements } from '.\u002Flayout';\n\nconst initialNodes = [\n  { id: '1', data: { label: 'Start' }, position: { x: 0, y: 0 } },\n  { id: '2', data: { label: 'Process' }, position: { x: 0, y: 0 } },\n  { id: '3', data: { label: 'End' }, position: { x: 0, y: 0 } },\n];\n\nconst initialEdges = [\n  { id: 'e1-2', source: '1', target: '2' },\n  { id: 'e2-3', source: '2', target: '3' },\n];\n\n\u002F\u002F Apply initial layout\nconst { nodes: layoutedNodes, edges: layoutedEdges } = getLayoutedElements(\n  initialNodes,\n  initialEdges,\n  { direction: 'TB' }\n);\n\nfunction Flow() {\n  const [nodes, setNodes, onNodesChange] = useNodesState(layoutedNodes);\n  const [edges, setEdges, onEdgesChange] = useEdgesState(layoutedEdges);\n  const { fitView } = useReactFlow();\n\n  const onLayout = useCallback((direction: 'TB' | 'LR') => {\n    const { nodes: newNodes, edges: newEdges } = getLayoutedElements(\n      nodes,\n      edges,\n      { direction }\n    );\n\n    setNodes([...newNodes]);\n    setEdges([...newEdges]);\n\n    \u002F\u002F Fit view after layout with animation\n    window.requestAnimationFrame(() => {\n      fitView({ duration: 300 });\n    });\n  }, [nodes, edges, setNodes, setEdges, fitView]);\n\n  return (\n    \u003Cdiv style={{ width: '100%', height: '100vh' }}>\n      \u003Cdiv style={{ position: 'absolute', zIndex: 10, padding: 10 }}>\n        \u003Cbutton onClick={() => onLayout('TB')}>Vertical\u003C\u002Fbutton>\n        \u003Cbutton onClick={() => onLayout('LR')}>Horizontal\u003C\u002Fbutton>\n      \u003C\u002Fdiv>\n      \u003CReactFlow\n        nodes={nodes}\n        edges={edges}\n        onNodesChange={onNodesChange}\n        onEdgesChange={onEdgesChange}\n        fitView\n      \u002F>\n    \u003C\u002Fdiv>\n  );\n}\n\nexport default function App() {\n  return (\n    \u003CReactFlowProvider>\n      \u003CFlow \u002F>\n    \u003C\u002FReactFlowProvider>\n  );\n}\n```\n\n## useAutoLayout Hook\n\nReusable hook for automatic layout:\n\n```typescript\nimport { useCallback, useEffect, useRef } from 'react';\nimport {\n  useReactFlow,\n  useNodesInitialized,\n  type Node,\n  type Edge,\n} from '@xyflow\u002Freact';\nimport dagre from '@dagrejs\u002Fdagre';\n\ninterface UseAutoLayoutOptions {\n  direction?: 'TB' | 'BT' | 'LR' | 'RL';\n  nodesep?: number;\n  ranksep?: number;\n}\n\nexport function useAutoLayout(options: UseAutoLayoutOptions = {}) {\n  const { direction = 'TB', nodesep = 50, ranksep = 50 } = options;\n  const { getNodes, getEdges, setNodes, fitView } = useReactFlow();\n  const nodesInitialized = useNodesInitialized();\n  const layoutApplied = useRef(false);\n\n  const runLayout = useCallback(() => {\n    const nodes = getNodes();\n    const edges = getEdges();\n\n    const g = new dagre.graphlib.Graph();\n    g.setGraph({ rankdir: direction, nodesep, ranksep });\n    g.setDefaultEdgeLabel(() => ({}));\n\n    nodes.forEach((node) => {\n      g.setNode(node.id, {\n        width: node.measured?.width ?? 172,\n        height: node.measured?.height ?? 36,\n      });\n    });\n\n    edges.forEach((edge) => {\n      g.setEdge(edge.source, edge.target);\n    });\n\n    dagre.layout(g);\n\n    const layouted = nodes.map((node) => {\n      const pos = g.node(node.id);\n      const width = node.measured?.width ?? 172;\n      const height = node.measured?.height ?? 36;\n\n      return {\n        ...node,\n        position: { x: pos.x - width \u002F 2, y: pos.y - height \u002F 2 },\n      };\n    });\n\n    setNodes(layouted);\n    window.requestAnimationFrame(() => fitView({ duration: 200 }));\n  }, [direction, nodesep, ranksep, getNodes, getEdges, setNodes, fitView]);\n\n  \u002F\u002F Auto-layout on initialization\n  useEffect(() => {\n    if (nodesInitialized && !layoutApplied.current) {\n      runLayout();\n      layoutApplied.current = true;\n    }\n  }, [nodesInitialized, runLayout]);\n\n  return { runLayout };\n}\n```\n\nUsage:\n\n```tsx\nfunction Flow() {\n  const { runLayout } = useAutoLayout({ direction: 'LR', ranksep: 100 });\n\n  return (\n    \u003C>\n      \u003Cbutton onClick={runLayout}>Re-layout\u003C\u002Fbutton>\n      \u003CReactFlow ... \u002F>\n    \u003C\u002F>\n  );\n}\n```\n\n## Edge Options\n\nControl edge routing with weight and minlen:\n\n```typescript\nedges.forEach((edge) => {\n  g.setEdge(edge.source, edge.target, {\n    weight: edge.data?.priority ?? 1,  \u002F\u002F Higher = more direct path\n    minlen: edge.data?.minRanks ?? 1,  \u002F\u002F Minimum ranks between nodes\n  });\n});\n```\n\n**weight**: Higher weight edges are prioritized for shorter, more direct paths.\n\n**minlen**: Forces minimum rank separation between connected nodes.\n\n```typescript\n\u002F\u002F Force 2 ranks between nodes\ng.setEdge('a', 'b', { minlen: 2 });\n```\n\n## Common Patterns\n\n### Handle Position Based on Direction\n\nAdjust handles for horizontal vs vertical layouts:\n\n```tsx\nfunction CustomNode({ data }: NodeProps) {\n  const isHorizontal = data.direction === 'LR' || data.direction === 'RL';\n\n  return (\n    \u003Cdiv>\n      \u003CHandle\n        type=\"target\"\n        position={isHorizontal ? Position.Left : Position.Top}\n      \u002F>\n      \u003Cdiv>{data.label}\u003C\u002Fdiv>\n      \u003CHandle\n        type=\"source\"\n        position={isHorizontal ? Position.Right : Position.Bottom}\n      \u002F>\n    \u003C\u002Fdiv>\n  );\n}\n```\n\n### Animated Layout Transitions\n\nSmooth position changes using CSS transitions:\n\n```css\n.react-flow__node {\n  transition: transform 300ms ease-out;\n}\n```\n\nFor programmatic animation, see [reference.md](reference.md#animated-layout-transitions).\n\n### Layout with Node Groups\n\nExclude group nodes from dagre layout:\n\n```typescript\nconst layoutWithGroups = (nodes: Node[], edges: Edge[]) => {\n  \u002F\u002F Separate regular nodes from groups\n  const regularNodes = nodes.filter((n) => n.type !== 'group');\n  const groupNodes = nodes.filter((n) => n.type === 'group');\n\n  \u002F\u002F Layout only regular nodes\n  const { nodes: layouted } = getLayoutedElements(regularNodes, edges);\n\n  \u002F\u002F Combine back\n  return { nodes: [...groupNodes, ...layouted], edges };\n};\n```\n\n## Troubleshooting\n\n### Nodes Overlapping\n\nIncrease spacing:\n\n```typescript\ng.setGraph({\n  rankdir: 'TB',\n  nodesep: 100,  \u002F\u002F Increase horizontal spacing\n  ranksep: 100,  \u002F\u002F Increase vertical spacing\n});\n```\n\n### Layout Not Updating\n\nEnsure new array references:\n\n```typescript\n\u002F\u002F Wrong - same reference\nsetNodes(layoutedNodes);\n\n\u002F\u002F Correct - new reference\nsetNodes([...layoutedNodes]);\n```\n\n### Nodes at Wrong Position\n\nCheck coordinate conversion:\n\n```typescript\n\u002F\u002F Dagre returns center, React Flow needs top-left\nposition: {\n  x: pos.x - width \u002F 2,   \u002F\u002F Not just pos.x\n  y: pos.y - height \u002F 2,  \u002F\u002F Not just pos.y\n}\n```\n\n### Performance with Large Graphs\n\n- Layout in a Web Worker\n- Debounce layout calls\n- Use `useMemo` for layout function\n- Only re-layout changed portions\n\n## Configuration Reference\n\nSee [reference.md](reference.md) for complete dagre configuration options.\n","# Dagre with React Flow\n\nDagre is a JavaScript library for laying out directed graphs. It computes optimal node positions for hierarchical\u002Ftree layouts. React Flow handles rendering; dagre handles positioning.\n\n## Quick Start\n\n```bash\npnpm add @dagrejs\u002Fdagre\n```\n\n```typescript\nimport dagre from '@dagrejs\u002Fdagre';\nimport { Node, Edge } from '@xyflow\u002Freact';\n\nconst getLayoutedElements = (\n  nodes: Node[],\n  edges: Edge[],\n  direction: 'TB' | 'LR' = 'TB'\n) => {\n  const g = new dagre.graphlib.Graph();\n  g.setGraph({ rankdir: direction });\n  g.setDefaultEdgeLabel(() => ({}));\n\n  nodes.forEach((node) => {\n    g.setNode(node.id, { width: 172, height: 36 });\n  });\n\n  edges.forEach((edge) => {\n    g.setEdge(edge.source, edge.target);\n  });\n\n  dagre.layout(g);\n\n  const layoutedNodes = nodes.map((node) => {\n    const pos = g.node(node.id);\n    return {\n      ...node,\n      position: { x: pos.x - 86, y: pos.y - 18 }, \u002F\u002F Center to top-left\n    };\n  });\n\n  return { nodes: layoutedNodes, edges };\n};\n```\n\n## Core Concepts\n\n### Coordinate System Difference\n\n**Critical:** Dagre returns center coordinates; React Flow uses top-left.\n\n```typescript\n\u002F\u002F Dagre output: center of node\nconst dagrePos = g.node(nodeId); \u002F\u002F { x: 100, y: 50 } = center\n\n\u002F\u002F React Flow expects: top-left corner\nconst rfPosition = {\n  x: dagrePos.x - nodeWidth \u002F 2,\n  y: dagrePos.y - nodeHeight \u002F 2,\n};\n```\n\n### Node Dimensions\n\nDagre requires explicit dimensions. Three approaches:\n\n**1. Fixed dimensions (simplest):**\n```typescript\ng.setNode(node.id, { width: 172, height: 36 });\n```\n\n**2. Per-node dimensions from data:**\n```typescript\ng.setNode(node.id, {\n  width: node.data.width ?? 172,\n  height: node.data.height ?? 36,\n});\n```\n\n**3. Measured dimensions (most accurate):**\n```typescript\n\u002F\u002F After React Flow measures nodes\ng.setNode(node.id, {\n  width: node.measured?.width ?? 172,\n  height: node.measured?.height ?? 36,\n});\n```\n\n### Layout Directions\n\n| Value | Direction | Use Case |\n|-------|-----------|----------|\n| `TB` | Top to Bottom | Org charts, decision trees |\n| `BT` | Bottom to Top | Dependency graphs (deps at bottom) |\n| `LR` | Left to Right | Timelines, horizontal flows |\n| `RL` | Right to Left | RTL layouts |\n\n```typescript\ng.setGraph({ rankdir: 'LR' }); \u002F\u002F Horizontal layout\n```\n\n## Complete Implementation\n\n### Basic Layout Function\n\n```typescript\nimport dagre from '@dagrejs\u002Fdagre';\nimport type { Node, Edge } from '@xyflow\u002Freact';\n\ninterface LayoutOptions {\n  direction?: 'TB' | 'BT' | 'LR' | 'RL';\n  nodeWidth?: number;\n  nodeHeight?: number;\n  nodesep?: number;  \u002F\u002F Horizontal spacing\n  ranksep?: number;  \u002F\u002F Vertical spacing (between ranks)\n}\n\nexport function getLayoutedElements(\n  nodes: Node[],\n  edges: Edge[],\n  options: LayoutOptions = {}\n): { nodes: Node[]; edges: Edge[] } {\n  const {\n    direction = 'TB',\n    nodeWidth = 172,\n    nodeHeight = 36,\n    nodesep = 50,\n    ranksep = 50,\n  } = options;\n\n  const g = new dagre.graphlib.Graph();\n  g.setGraph({ rankdir: direction, nodesep, ranksep });\n  g.setDefaultEdgeLabel(() => ({}));\n\n  nodes.forEach((node) => {\n    const width = node.measured?.width ?? nodeWidth;\n    const height = node.measured?.height ?? nodeHeight;\n    g.setNode(node.id, { width, height });\n  });\n\n  edges.forEach((edge) => {\n    g.setEdge(edge.source, edge.target);\n  });\n\n  dagre.layout(g);\n\n  const layoutedNodes = nodes.map((node) => {\n    const pos = g.node(node.id);\n    const width = node.measured?.width ?? nodeWidth;\n    const height = node.measured?.height ?? nodeHeight;\n\n    return {\n      ...node,\n      position: {\n        x: pos.x - width \u002F 2,\n        y: pos.y - height \u002F 2,\n      },\n    };\n  });\n\n  return { nodes: layoutedNodes, edges };\n}\n```\n\n### React Flow Integration\n\n```tsx\nimport { useCallback } from 'react';\nimport {\n  ReactFlow,\n  useNodesState,\n  useEdgesState,\n  useReactFlow,\n  ReactFlowProvider,\n} from '@xyflow\u002Freact';\nimport { getLayoutedElements } from '.\u002Flayout';\n\nconst initialNodes = [\n  { id: '1', data: { label: 'Start' }, position: { x: 0, y: 0 } },\n  { id: '2', data: { label: 'Process' }, position: { x: 0, y: 0 } },\n  { id: '3', data: { label: 'End' }, position: { x: 0, y: 0 } },\n];\n\nconst initialEdges = [\n  { id: 'e1-2', source: '1', target: '2' },\n  { id: 'e2-3', source: '2', target: '3' },\n];\n\n\u002F\u002F Apply initial layout\nconst { nodes: layoutedNodes, edges: layoutedEdges } = getLayoutedElements(\n  initialNodes,\n  initialEdges,\n  { direction: 'TB' }\n);\n\nfunction Flow() {\n  const [nodes, setNodes, onNodesChange] = useNodesState(layoutedNodes);\n  const [edges, setEdges, onEdgesChange] = useEdgesState(layoutedEdges);\n  const { fitView } = useReactFlow();\n\n  const onLayout = useCallback((direction: 'TB' | 'LR') => {\n    const { nodes: newNodes, edges: newEdges } = getLayoutedElements(\n      nodes,\n      edges,\n      { direction }\n    );\n\n    setNodes([...newNodes]);\n    setEdges([...newEdges]);\n\n    \u002F\u002F Fit view after layout with animation\n    window.requestAnimationFrame(() => {\n      fitView({ duration: 300 });\n    });\n  }, [nodes, edges, setNodes, setEdges, fitView]);\n\n  return (\n    \u003Cdiv style={{ width: '100%', height: '100vh' }}>\n      \u003Cdiv style={{ position: 'absolute', zIndex: 10, padding: 10 }}>\n        \u003Cbutton onClick={() => onLayout('TB')}>Vertical\u003C\u002Fbutton>\n        \u003Cbutton onClick={() => onLayout('LR')}>Horizontal\u003C\u002Fbutton>\n      \u003C\u002Fdiv>\n      \u003CReactFlow\n        nodes={nodes}\n        edges={edges}\n        onNodesChange={onNodesChange}\n        onEdgesChange={onEdgesChange}\n        fitView\n      \u002F>\n    \u003C\u002Fdiv>\n  );\n}\n\nexport default function App() {\n  return (\n    \u003CReactFlowProvider>\n      \u003CFlow \u002F>\n    \u003C\u002FReactFlowProvider>\n  );\n}\n```\n\n## useAutoLayout Hook\n\nReusable hook for automatic layout:\n\n```typescript\nimport { useCallback, useEffect, useRef } from 'react';\nimport {\n  useReactFlow,\n  useNodesInitialized,\n  type Node,\n  type Edge,\n} from '@xyflow\u002Freact';\nimport dagre from '@dagrejs\u002Fdagre';\n\ninterface UseAutoLayoutOptions {\n  direction?: 'TB' | 'BT' | 'LR' | 'RL';\n  nodesep?: number;\n  ranksep?: number;\n}\n\nexport function useAutoLayout(options: UseAutoLayoutOptions = {}) {\n  const { direction = 'TB', nodesep = 50, ranksep = 50 } = options;\n  const { getNodes, getEdges, setNodes, fitView } = useReactFlow();\n  const nodesInitialized = useNodesInitialized();\n  const layoutApplied = useRef(false);\n\n  const runLayout = useCallback(() => {\n    const nodes = getNodes();\n    const edges = getEdges();\n\n    const g = new dagre.graphlib.Graph();\n    g.setGraph({ rankdir: direction, nodesep, ranksep });\n    g.setDefaultEdgeLabel(() => ({}));\n\n    nodes.forEach((node) => {\n      g.setNode(node.id, {\n        width: node.measured?.width ?? 172,\n        height: node.measured?.height ?? 36,\n      });\n    });\n\n    edges.forEach((edge) => {\n      g.setEdge(edge.source, edge.target);\n    });\n\n    dagre.layout(g);\n\n    const layouted = nodes.map((node) => {\n      const pos = g.node(node.id);\n      const width = node.measured?.width ?? 172;\n      const height = node.measured?.height ?? 36;\n\n      return {\n        ...node,\n        position: { x: pos.x - width \u002F 2, y: pos.y - height \u002F 2 },\n      };\n    });\n\n    setNodes(layouted);\n    window.requestAnimationFrame(() => fitView({ duration: 200 }));\n  }, [direction, nodesep, ranksep, getNodes, getEdges, setNodes, fitView]);\n\n  \u002F\u002F Auto-layout on initialization\n  useEffect(() => {\n    if (nodesInitialized && !layoutApplied.current) {\n      runLayout();\n      layoutApplied.current = true;\n    }\n  }, [nodesInitialized, runLayout]);\n\n  return { runLayout };\n}\n```\n\nUsage:\n\n```tsx\nfunction Flow() {\n  const { runLayout } = useAutoLayout({ direction: 'LR', ranksep: 100 });\n\n  return (\n    \u003C>\n      \u003Cbutton onClick={runLayout}>Re-layout\u003C\u002Fbutton>\n      \u003CReactFlow ... \u002F>\n    \u003C\u002F>\n  );\n}\n```\n\n## Edge Options\n\nControl edge routing with weight and minlen:\n\n```typescript\nedges.forEach((edge) => {\n  g.setEdge(edge.source, edge.target, {\n    weight: edge.data?.priority ?? 1,  \u002F\u002F Higher = more direct path\n    minlen: edge.data?.minRanks ?? 1,  \u002F\u002F Minimum ranks between nodes\n  });\n});\n```\n\n**weight**: Higher weight edges are prioritized for shorter, more direct paths.\n\n**minlen**: Forces minimum rank separation between connected nodes.\n\n```typescript\n\u002F\u002F Force 2 ranks between nodes\ng.setEdge('a', 'b', { minlen: 2 });\n```\n\n## Common Patterns\n\n### Handle Position Based on Direction\n\nAdjust handles for horizontal vs vertical layouts:\n\n```tsx\nfunction CustomNode({ data }: NodeProps) {\n  const isHorizontal = data.direction === 'LR' || data.direction === 'RL';\n\n  return (\n    \u003Cdiv>\n      \u003CHandle\n        type=\"target\"\n        position={isHorizontal ? Position.Left : Position.Top}\n      \u002F>\n      \u003Cdiv>{data.label}\u003C\u002Fdiv>\n      \u003CHandle\n        type=\"source\"\n        position={isHorizontal ? Position.Right : Position.Bottom}\n      \u002F>\n    \u003C\u002Fdiv>\n  );\n}\n```\n\n### Animated Layout Transitions\n\nSmooth position changes using CSS transitions:\n\n```css\n.react-flow__node {\n  transition: transform 300ms ease-out;\n}\n```\n\nFor programmatic animation, see [reference.md](reference.md#animated-layout-transitions).\n\n### Layout with Node Groups\n\nExclude group nodes from dagre layout:\n\n```typescript\nconst layoutWithGroups = (nodes: Node[], edges: Edge[]) => {\n  \u002F\u002F Separate regular nodes from groups\n  const regularNodes = nodes.filter((n) => n.type !== 'group');\n  const groupNodes = nodes.filter((n) => n.type === 'group');\n\n  \u002F\u002F Layout only regular nodes\n  const { nodes: layouted } = getLayoutedElements(regularNodes, edges);\n\n  \u002F\u002F Combine back\n  return { nodes: [...groupNodes, ...layouted], edges };\n};\n```\n\n## Troubleshooting\n\n### Nodes Overlapping\n\nIncrease spacing:\n\n```typescript\ng.setGraph({\n  rankdir: 'TB',\n  nodesep: 100,  \u002F\u002F Increase horizontal spacing\n  ranksep: 100,  \u002F\u002F Increase vertical spacing\n});\n```\n\n### Layout Not Updating\n\nEnsure new array references:\n\n```typescript\n\u002F\u002F Wrong - same reference\nsetNodes(layoutedNodes);\n\n\u002F\u002F Correct - new reference\nsetNodes([...layoutedNodes]);\n```\n\n### Nodes at Wrong Position\n\nCheck coordinate conversion:\n\n```typescript\n\u002F\u002F Dagre returns center, React Flow needs top-left\nposition: {\n  x: pos.x - width \u002F 2,   \u002F\u002F Not just pos.x\n  y: pos.y - height \u002F 2,  \u002F\u002F Not just pos.y\n}\n```\n\n### Performance with Large Graphs\n\n- Layout in a Web Worker\n- Debounce layout calls\n- Use `useMemo` for layout function\n- Only re-layout changed portions\n\n## Configuration Reference\n\nSee [reference.md](reference.md) for complete dagre configuration options.\n",{"name":5,"description":7},"main","716b17df3ef6719d88aeac180015008b7ddfff6f",".claude\u002Fskills\u002Fskills\u002Fdagre-react-flow",0,"https:\u002F\u002Fgithub.com\u002Fray-manaloto\u002Fmacos-development-environment","https:\u002F\u002Fgithub.com\u002Fray-manaloto","2026-08-03 16:55:50",{"source":8,"skillName":5,"commands":38,"prompt":48,"zipAvailable":49},[39,42,45],{"tool":40,"command":41},"npx","npx skills add ray-manaloto\u002Fmacos-development-environment --skill dagre-react-flow",{"tool":43,"command":44},"bunx","bunx skills add ray-manaloto\u002Fmacos-development-environment --skill dagre-react-flow",{"tool":46,"command":47},"pnpm","pnpm dlx skills add ray-manaloto\u002Fmacos-development-environment --skill dagre-react-flow","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fray-manaloto\u002Fmacos-development-environment\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fskills\u002Fdagre-react-flow\u002FSKILL.md",true,[51,57],{"path":52,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":55,"sourceHtmlUrl":56},"agents\u002Fopenai.yaml","REFERENCE","参考文档",145,"https:\u002F\u002Fgithub.com\u002Fmalinskibeniamin\u002Fskills\u002Fblob\u002Fmain\u002Fcodex-skills\u002Fmatt-to-spec\u002Fagents\u002Fopenai.yaml",{"path":58,"resourceType":53,"resourceTypeDesc":54,"sizeBytes":59,"sourceHtmlUrl":60},"reference.md",8176,"https:\u002F\u002Fgithub.com\u002Fray-manaloto\u002Fmacos-development-environment\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fskills\u002Fdagre-react-flow\u002Freference.md",[62,79,97,116,133,147],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":25},"01M6CC8DXNJ39YWERYTWCGGCGG","next-workflow-step","Use this skill when the user wants to transition to the next workflow step, wrap up a session cleanly, prepare a handoff, or says things like \"next step\", \"continue the workflow\", \"wrap up\", \"hand off\", \"move to the next phase\", \"what's next in embrace\", or \"prepare for \u002Fclear\". Also triggers when the current octo:embrace phase appears complete and no explicit next action is set.","https:\u002F\u002Fgithub.com\u002Fray-manaloto\u002Fmacos-development-environment\u002Fblob\u002Fmain\u002Frsm-subagents\u002Fplugins\u002Fworkflow-toolkit\u002Fskills\u002Fnext-workflow-step\u002FSKILL.md",[],[69,70,71,22,72,73,74,75,76,77,78],"next workflow step","workflow","up","session","user","wrap up","continue","handoff","prepare","SET",{"skillNo":80,"name":81,"nameZh":6,"description":82,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":83,"categories":84,"keywords":85,"publishedAt":25},"01M6CC8BRZBQHEBXGMKPDM422P","source-discovery","This skill should be used when the user asks to \"find sources\", \"discover URLs\", \"catalog a source\", \"classify a URL\", \"search for libraries\", \"check what exists\", or mentions source discovery, URL cataloging, source classification, or research source management.","https:\u002F\u002Fgithub.com\u002Fray-manaloto\u002Fmacos-development-environment\u002Fblob\u002Fmain\u002Frsm-subagents\u002Fplugins\u002Fresearch-review-toolkit\u002Fskills\u002Fsource-discovery\u002FSKILL.md",[],[86,87,88,89,90,91,92,93,94,73,95,96],"discovery","source discovery","research","libraries","search","classification","find","check","management","catalog","find sources",{"skillNo":98,"name":99,"nameZh":6,"description":100,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":101,"categories":102,"keywords":103,"publishedAt":25},"01M6CC89CGJP69A0PS22G2H1FV","review-synthesis","This skill should be used when the user asks to \"summarize review findings\", \"prioritize fixes\", \"rank review issues\", \"combine reviewer feedback\", \"create action items from review\", or mentions review synthesis, finding prioritization, severity ranking, or review result summarization.","https:\u002F\u002Fgithub.com\u002Fray-manaloto\u002Fmacos-development-environment\u002Fblob\u002Fmain\u002Frsm-subagents\u002Fplugins\u002Fresearch-review-toolkit\u002Fskills\u002Freview-synthesis\u002FSKILL.md",[],[104,105,106,107,108,109,110,73,111,112,113,114,115],"review","review synthesis","Synthesis","prioritize","create action","feedback","reviewer","summarize","prioritization","create","issues","severity",{"skillNo":117,"name":118,"nameZh":6,"description":119,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":120,"categories":121,"keywords":122,"publishedAt":25},"01M6CC872EZ9GRJY0HRCG0RT2M","research-scoring","This skill should be used when the user asks to \"score research\", \"check research quality\", \"evaluate coverage\", \"measure improvement\", \"assess research completeness\", or mentions research scoring, quality metrics, coverage gaps, improvement baseline, or research pipeline status.","https:\u002F\u002Fgithub.com\u002Fray-manaloto\u002Fmacos-development-environment\u002Fblob\u002Fmain\u002Frsm-subagents\u002Fplugins\u002Fresearch-review-toolkit\u002Fskills\u002Fresearch-scoring\u002FSKILL.md",[],[123,88,124,125,126,127,128,129,93,73,130,131,132],"research scoring","status","coverage gaps","metrics","pipeline","baseline","quality","coverage","pipeline status","research quality",{"skillNo":134,"name":135,"nameZh":6,"description":136,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":137,"categories":138,"keywords":139,"publishedAt":25},"01M6CC852HSDS1FE4EJAT0RHGR","notebooklm-integration","This skill should be used when the user asks to \"ingest into NotebookLM\", \"query NotebookLM\", \"add sources to notebook\", \"cross-source synthesis\", \"check stale sources\", or mentions NotebookLM, notebook integration, source ingestion, or knowledge consolidation.","https:\u002F\u002Fgithub.com\u002Fray-manaloto\u002Fmacos-development-environment\u002Fblob\u002Fmain\u002Frsm-subagents\u002Fplugins\u002Fresearch-review-toolkit\u002Fskills\u002Fnotebooklm-integration\u002FSKILL.md",[],[140,141,142,143,93,73,144,145,146,106],"notebooklm integration","notebooklm","integration","knowledge","ingestion","ingest","stale",{"skillNo":148,"name":149,"nameZh":6,"description":150,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":6,"repositoryNo":12,"starsCount":13,"licenseSpdxId":14,"licenseFileUrl":6,"sourceHtmlUrl":151,"categories":152,"keywords":153,"publishedAt":25},"01M6CC82Z4V3205KCJWQZPS2VG","evidence-synthesis","This skill should be used when the user asks to \"synthesize findings\", \"combine research\", \"cross-reference sources\", \"summarize evidence\", \"write a deep review\", or mentions evidence synthesis, finding consolidation, cross-source analysis, or research summarization.","https:\u002F\u002Fgithub.com\u002Fray-manaloto\u002Fmacos-development-environment\u002Fblob\u002Fmain\u002Frsm-subagents\u002Fplugins\u002Fresearch-review-toolkit\u002Fskills\u002Fevidence-synthesis\u002FSKILL.md",[],[154,106,155,111,88,156,157,158,73,159,104],"evidence synthesis","evidence","deep review","analysis","write","reference"]