---
name: canvas-layout
description: >
  Re-layout existing Obsidian Canvas nodes using 6 spatial algorithms: grid
  (galleries, mood boards), dagre (flowcharts, org charts), radial (mind maps),
  force-directed (knowledge graphs), linear (timelines), and auto-detect.
  Preserves group membership, snaps to 20px grid, refits zones around content.
  Triggers on: canvas layout, re-layout canvas, arrange canvas, auto-layout,
  organize canvas, fix canvas layout, canvas grid, canvas dagre.
user-invocable: false
---

# canvas-layout: Re-Layout Canvas Nodes

Read `../canvas/references/layout-algorithms.md` for algorithm details and selection guide.
Read `../canvas/references/performance-guide.md` for node limits.

---

## Workflow

1. **Identify target canvas**: Use the active canvas or ask which one (`/canvas list` to show options).
2. **Select algorithm**: Use the user-specified algorithm, or run `auto` detection.
3. **Confirm before applying**: Show what will happen:
   "Will apply [algorithm] layout to [canvas] ([N] nodes, [M] groups). Create backup? [Y/n]"
4. **Run the layout script**:
   ```bash
   python3 scripts/canvas_layout.py [canvas_path] [algorithm] [options]
   ```
5. **Report results**: "Moved [N] of [M] nodes. [G] groups refitted. Backup at [path].bak"
6. **Validate**: Run `python3 scripts/canvas_validate.py [canvas_path]` to confirm valid output.

---

## Algorithm Selection

When the user says `/canvas layout auto` or doesn't specify an algorithm, use the auto-detection in the script. It analyzes edge density, node types, and connection patterns.

For explicit requests, map user intent to algorithm:

| User says | Algorithm | Options |
|-----------|-----------|---------|
| "organize these images" | grid | `--sort-by type` |
| "make a grid" | grid | |
| "flowchart layout" | dagre | `--direction TB` |
| "left to right flow" | dagre | `--direction LR` |
| "mind map layout" | radial | |
| "expand from [node]" | radial | `--center [node-id]` |
| "untangle this" | force | |
| "spread out the nodes" | force | |
| "make a timeline" | linear | `--axis horizontal` |
| "vertical sequence" | linear | `--axis vertical` |
| "auto-layout" | auto | |
| "fix the layout" | auto | |

---

## Options Forwarding

Pass algorithm-specific options to the script:

- **grid**: `--columns N` (override auto-detection), `--sort-by type|size`
- **dagre**: `--direction TB|LR|BT|RL`
- **radial**: `--center node-id` (override auto-detection of hub node)
- **force**: `--iterations N` (default 100, reduce to 50 for 50+ nodes)
- **linear**: `--axis horizontal|vertical`

Add `--dry-run` to preview without writing.

---

## For Complex Layouts (30+ Nodes)

When a canvas has more than 30 nodes, dispatch the `canvas-layout` agent instead of running the script directly. The agent can:

- Analyze the canvas content to choose sub-groups for different algorithms
- Split large canvases into zone-by-zone layouts
- Handle edge crossing minimization that the basic dagre doesn't cover
- Refine positions after the algorithm runs for better visual balance

---

## Edge Cases

- **Empty canvas**: Report "No nodes to layout" and skip.
- **Single node**: Center it at (0, 0) and skip.
- **No edges + dagre requested**: Warn "dagre works best with edges. Using grid instead." Fall back to grid.
- **100+ nodes**: Warn about performance. Suggest splitting into sub-canvases.
- **Backup conflict**: If `.bak` already exists, use `.bak2`, `.bak3`, etc.


---
Source attribution: AgriciDaniel
Original project: https://github.com/AgriciDaniel/claude-canvas/blob/05b808cafd906bb3b8ff1c597ed8cd33ff5145c0/skills/canvas-layout/SKILL.md
License: MIT
License information: https://opensource.org/license/mit
Original upstream instructions; downloaded from Dave AI.

## Upstream license notice

MIT License

Copyright (c) 2026 AgriciDaniel

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.



# Dave AI resource metadata

Creator / publisher: AgriciDaniel
Original project: https://github.com/AgriciDaniel/claude-canvas/blob/05b808cafd906bb3b8ff1c597ed8cd33ff5145c0/skills/canvas-layout/SKILL.md
Attribution basis: Source repository record

Fields of work: Design, Marketing, Project & Program Management
Roles: Content Marketer, Graphic Designer, Project Manager, SEO Specialist, UX Designer
Specialties: Design, Frontend
Tools: Obsidian
Country applicability: Country not specified
Classification basis: Source catalog labels
Instruction SHA-256: 595a9091a70b630fd6407f2e1fd8ea6affb60c6a98e77fe86fa72f6dfb21dd69
