canvas-populate
Skill299 starsChanged 8 months agoMITView on GitHub
Add content to existing Obsidian Canvas files. Supports all node types: images (with auto aspect ratio detection), text cards, PDFs, wiki notes, web links, Mermaid diagrams, SVGs, GIFs, AI-generated images via banana. Also adds zones (groups), edges between nodes, and imports recent banana images. Triggers on: canvas add, add to canvas, put on canvas, canvas zone, canvas connect, canvas from banana, add image to canvas, add text to canvas.
In this repository8 other files it gives its agents.
- CLAUDE.mdCLAUDE.md
- canvas-createSkill
- canvas-exportSkill
- canvas-generateSkill
- canvas-layoutSkill
- canvas-presentSkill
- canvasSkill
- canvas-templateSkill
The file
Show its rules and text
We split this skill into the rules it gives an agent
24 rules. About 0 are common, 14 are distinctive, and 10 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈14
Distinctive · estimate
This author's own choices. Worth a look.
10
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 15
Read ../canvas/references/canvas-spec.md for the full JSON format before any edit.
- Very specific: line 16
Read ../canvas/references/performance-guide.md for node limits and constraints.
- Distinctive: line 28
Spacing check: Verify the calculated position has at least 80px horizontal and 60px vertical gap from ALL existing content nodes.
- Very specific: line 30
Validate: Run python3 scripts/canvas_validate.py <path> — check for overlaps and node count.
- Very specific: line 41
If URL (starts with http): download with curl -sL [url] -o [media_dir]/[filename].
- Very specific: line 43
If local path outside canvas dir: cp [path] [media_dir]/
- Distinctive: line 44
If already canvas-relative: use as-is.
- Distinctive: line 77
Search for a file matching the page name (case-insensitive, partial match).
- Very specific: line 78
Use "type": "file" with vault-relative path.
- Distinctive: line 79
Default size: width=300, height=100.
- Distinctive: line 114
If path: copy SVG to media dir, add as file node.
- Very specific: line 115
If description: delegate to /svg skill to generate, then add the output file.
- Distinctive: line 120
If path: copy GIF to media dir, add as file node.
- Very specific: line 121
If description: delegate to /claude-gif-generate skill, then add the output.
- Distinctive: line 126
Check if banana skill is available.
- Distinctive: line 128
Wait for image generation.
- Distinctive: line 129
Add the generated image as a file node (detect aspect ratio, auto-size).
- Distinctive: line 174
If ambiguous, list matches and ask the user to clarify.
- Very specific: line 187
Add optional label if provided.
- Very specific: line 196
Check [canvas_dir]/.recent-images.txt for recently logged image paths.
- Distinctive: line 197
If not found or empty: search for images modified in the last 10 minutes:
- Distinctive: line 201
If still none: show the 5 most recently modified images.
- Distinctive: line 211
Create if it doesn't exist.
- Distinctive: line 212
All file node paths must be relative to the vault/project root.
≈ “Common” is an estimate: at least 1 in 5 of the 213,897 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
canvas-populate: Add Content to Canvases
Read ../canvas/references/canvas-spec.md for the full JSON format before any edit.
Read ../canvas/references/performance-guide.md for node limits and constraints.
General Workflow
For every add operation:
- Read the target canvas JSON. Parse
nodesandedgesarrays. - Collect existing IDs to prevent collisions.
- Generate a new ID:
[type]-[slug]-[unix-timestamp]. - Calculate position using the auto-positioning algorithm (see canvas orchestrator).
- Spacing check: Verify the calculated position has at least 80px horizontal and 60px vertical gap from ALL existing content nodes. If not, shift the position until spacing is clear.
- Append the new node to the
nodesarray (after any groups — z-index ordering). - Validate: Run
python3 scripts/canvas_validate.py <path>— check for overlaps and node count. - Write the updated canvas JSON.
- Report: "Added [description] to [zone] zone at position ([x], [y])."
Node Operations
add image (/canvas add image [path or url])
Resolve the image:
- If URL (starts with
http): download withcurl -sL [url] -o [media_dir]/[filename]. Derive filename from URL path, or useimg-[timestamp].jpgif unclear. - If local path outside canvas dir:
cp [path] [media_dir]/ - If already canvas-relative: use as-is.
Detect aspect ratio:
python3 -c "from PIL import Image; img=Image.open('[path]'); print(img.width, img.height)"
# or fallback
identify -format '%w %h' [path]Map to the sizing table in ../canvas/references/canvas-spec.md (7 ratios + PDF + fallback).
Create file node with calculated dimensions. Position using auto-layout.
add text (/canvas add text [content])
{
"id": "text-[slug]-[timestamp]",
"type": "text",
"text": "[content]",
"x": 0, "y": 0,
"width": 300, "height": 120
}For multi-line content, estimate height: count newlines, multiply by 24, add 40px padding. Minimum 120px.
add pdf (/canvas add pdf [path])
Copy to [media_dir]/ if outside canvas dir. Fixed size: width=400, height=520.
add note (/canvas add note [wiki-page])
- Search for a file matching the page name (case-insensitive, partial match).
- Use
"type": "file"with vault-relative path. Not"type": "link"— that's for URLs only. - Default size: width=300, height=100.
add link (/canvas add link [url])
{
"id": "link-[slug]-[timestamp]",
"type": "link",
"url": "[url]",
"x": 0, "y": 0,
"width": 400, "height": 120
}Obsidian fetches Open Graph preview automatically.
add mermaid (/canvas add mermaid [code])
Mermaid renders natively in Obsidian text nodes. Wrap in a fenced code block:
{
"id": "text-mermaid-[timestamp]",
"type": "text",
"text": "```mermaid\n[code]\n```",
"x": 0, "y": 0,
"width": 500, "height": 400,
"color": "5"
}Wider text nodes work better for Mermaid (min 400px wide, 300px tall).
add svg (/canvas add svg [description or path])
- If path: copy SVG to media dir, add as file node. Width=400, height based on viewBox aspect ratio.
- If description: delegate to
/svgskill to generate, then add the output file. - SVGs render as
<img>— no interactivity. Must haveviewBoxattribute.
add gif (/canvas add gif [description or path])
- If path: copy GIF to media dir, add as file node.
- If description: delegate to
/claude-gif-generateskill, then add the output. - Performance limit: max 3 GIFs per canvas, max 480px width. Warn if exceeded.
add banana (/canvas add banana [prompt])
- Check if banana skill is available. If not: "Install the banana skill for AI image generation."
- Delegate to banana skill with the prompt.
- Wait for image generation.
- Add the generated image as a file node (detect aspect ratio, auto-size).
- Log the path to
.recent-images.txtin the canvas directory.
Zone Operations
zone (/canvas zone [name] [color])
- Read canvas JSON.
- Find max_y of all existing nodes. Use
-80if canvas is empty (consistent with starter canvas layout where title is at y=-300 and default zone at y=-140):if not canvas_nodes: max_y = -80 else: max_y = max(n["y"] + n.get("height", 0) for n in canvas_nodes) + 60 - Create group node:
{
"id": "zone-[slug]-[timestamp]",
"type": "group",
"label": "[name]",
"x": -400,
"y": "[max_y]",
"width": 1000,
"height": 400,
"color": "[color or '4']"
}Valid colors: "1"=red "2"=orange "3"=yellow "4"=green "5"=cyan "6"=purple
- Insert the group node BEFORE content nodes in the array (z-index: groups render behind).
- Write and report.
Edge Operations
connect (/canvas connect [from] [to] [label])
- Read canvas JSON.
- Find
fromandtonodes by ID, label text, or partial match. - If ambiguous, list matches and ask the user to clarify.
- Create edge:
{
"id": "e-[from-slug]-[to-slug]-[timestamp]",
"fromNode": "[from-id]",
"toNode": "[to-id]",
"toEnd": "arrow"
}- Omit
fromSide/toSidefor auto-routing (better results). - Add optional
labelif provided. - Write and report.
Banana Import
from banana (/canvas from banana)
- Check
[canvas_dir]/.recent-images.txtfor recently logged image paths. - If not found or empty: search for images modified in the last 10 minutes:
find [media_dir] -name "*.png" -o -name "*.jpg" -newer /tmp/ten-min-ago - If still none: show the 5 most recently modified images.
- Present list: "Found N recent images. Add to canvas? Which zone?"
- On confirmation: add each using the add image logic.
Media Directory
- Vault mode:
_attachments/images/canvas/ - Standalone mode:
.canvases/assets/ - Create if it doesn't exist.
- All file node paths must be relative to the vault/project root.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

