affinity
Skill2 starsChanged 27 days agoMITView on GitHub
Control Affinity by Canva (the Photoshop/Illustrator/InDesign alternative, formerly Affinity Photo, Designer and Publisher) through its built-in MCP server and JavaScript SDK - edit photos, retouch, crop, resize, remove objects or backgrounds, blur backgrounds, outpaint, build vector graphics, logos, posters, social posts, layouts and multi-page documents, set Arabic or Latin typography, apply filters and adjustments, run Canva AI (generate image, generative edit, select subject), and export PNG/JPEG/PDF/SVG while keeping editable layers. Use this skill whenever the user mentions Affinity, Affinity by Canva, Affinity Photo/Designer/Publisher, .af/.afphoto/.afdesign files, the Affinity MCP or execute_script, or asks to design or edit an image "in Affinity" - including misspellings like "Infinity" and Arabic phrasing such as أفينيتي - even if they do not name the skill. Not for Affinity CRM (affinity.co).
2 other projects use a version of this.
Adopted by
Most recently taken up by
- Pearl1531/Archetype-talktheir own version, first seen Oct 13, 2026
- jablonkai/skillstheir own version, first seen Oct 1, 2026
Other versions2 projects use a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 2
- jablonkai/skills★ 2same name
- Pearl1531/Archetype-talk★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
The file
We split this skill into the rules it gives an agent
12 rules. About 0 are common, 4 are distinctive, and 8 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈4
Distinctive · estimate
This author's own choices. Worth a look.
8
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 12
Look for the Affinity MCP tools (execute_script, render_spread, read_sdk_documentation_topic, ...).
- Distinctive: line 14
If they are missing or the connection is refused, the app is not serving MCP.
- Distinctive: line 22
Follow this loop for every task.
- Very specific: line 24
Orient once per session: Read the preamble topic with read_sdk_documentation_topic - it carries the SDK conventions plus hints recorded on …
- Very specific: line 36
Look things up instead of guessing APIs: Use search_sdk_hints for the problem, then the matching reference file below, then …
- Very specific: line 40
Verify visually after every visible change: Call render_spread(sessionUuid, 0) (or render_selection) and actually judge the image: framing, …
- Very specific: line 44
Optionally teach the next session: After solving something by experiment, add_sdk_hint records it in this machine's preamble (it may be …
- Very specific: line 48
Read references/safety.md once.
- Very specific: line 50
Canva AI costs the user's Canva credits: Ask before generateImage or generativeEditImage, and say what you are about to generate.
- Very specific: line 51
Only touch documents you created or the user pointed you at: Never save(), close() or overwrite an export the user did not ask for.
- Distinctive: line 117
No clipboard, no tool or panel switching, no mouse/keyboard events, no painting brush strokes, no files outside the Desktop.
- Distinctive: line 119
When a request hits a limit, say so plainly and offer the nearest thing the SDK can do, or tell the user which UI button to press.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 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
Affinity by Canva
You drive a real design application. Affinity by Canva runs a local MCP server; its execute_script tool runs JavaScript inside the app against the full SDK (vector, pixel, layout, text, filters, export and Canva AI). You write small scripts, the app does the work, and you look at the result with render_spread before moving on. The output is a genuine Affinity document with layers, so a human designer can continue where you stopped - that is a large part of the value, so keep work non-destructive and well layered when you can.
1. Make sure the connection exists
Look for the Affinity MCP tools (execute_script, render_spread, read_sdk_documentation_topic, ...). The server name varies by client (affinity, Affinity).
If they are missing or the connection is refused, the app is not serving MCP. Tell the user how to fix it instead of guessing:
- Affinity > Settings > Model Context Protocol > enable Enable Affinity MCP (and the permissions they want).
- Quit Affinity completely and reopen it - the server only starts on launch.
- Connect the client to
http://localhost:6767/sse(SSE). Per-client commands are inreferences/setup.md.
2. The working loop
Follow this loop for every task. Each step exists because skipping it has caused real failures.
Orient once per session. Read the
preambletopic withread_sdk_documentation_topic- it carries the SDK conventions plus hints recorded on this machine. Then inspect what is open:const { Document } = require('/document.js'); for (const d of Document.all) console.log(d.sessionUuid, d.title, d.path, d.widthPixels + 'x' + d.heightPixels, 'dirty:', d.isDirty); const d = Document.current; for (const l of d.layers) console.log(l.constructor.name, l.description, JSON.stringify(l.baseBox));- Protect the user's file before the first edit. If the work targets a document the user cares about,
saveAsa copy with a new name on the Desktop and work on the copy (references/recipes/save-copy.md). Ask before saving over, closing, or exporting over anything you did not create. - Look things up instead of guessing APIs. Use
search_sdk_hintsfor the problem, then the matching reference file below, thenread_sdk_documentation_topicfor the exact wrapper source (document.js,commands.js,nodes.js, ...). Large topics come back as a saved file; grep it rather than reading it whole. - Execute in small scripts. One logical step per
execute_scriptcall, withconsole.logof what changed (sizes, layer counts, return values). Scripts return nothing unless you log it. Re-acquire the target document each time (bysessionUuidwhen more than one is open) instead of trustingDocument.current. - Verify visually after every visible change. Call
render_spread(sessionUuid, 0)(orrender_selection) and actually judge the image: framing, centring, artefacts, halos, text direction. If it is wrong,doc.undo()(checkdoc.undoDescriptionfirst) and try again. Never report success you have not seen. - Deliver. Save the
.af(layers intact) and export what the user needs (references/export.md). Report the file paths, the size, and anything that is not perfect. - Optionally teach the next session. After solving something by experiment,
add_sdk_hintrecords it in this machine's preamble (it may be shared anonymously if the user enabled hint sharing).
3. Rules that protect the user
Read references/safety.md once; the short version:
- Canva AI costs the user's Canva credits. Ask before
generateImageorgenerativeEditImage, and say what you are about to generate.selectSubjectandremoveBackgroundare not counted against the monthly limit but still need a paid Canva plan. - Only touch documents you created or the user pointed you at. Never
save(),close()or overwrite an export the user did not ask for.close()on an unsaved document discards it silently. - Files are limited to the Desktop (
Environment.fileSystemRoots). Paths elsewhere fail withPERMISSION_DENIED;NOT_ALLOWEDmeans the user disabled that permission in Affinity settings - tell them, do not work around it. - Never run community scripts blindly. They execute with the user's file and network permissions.
Dialog.runModal()blocks until a human answers; do not use it in unattended work.
4. Core patterns you will use constantly
const { Document } = require('/document.js');
const { DocumentCommand } = require('/commands.js');
const { Transform } = require('affinity:geometry');
const d = Document.current;
// Layers are ordered bottom-first: d.layers.at(0) is the lowest layer.
const layer = d.layers.at(0);
d.selection = [layer]; // select nodes (raster pixel selection is separate)
// Every edit is a command; most have Document shortcuts (d.mergeVisible(), d.boolOpUnion(sel), ...).
const t = new Transform(); t.translate(100, 0); // translate() mutates in place
d.executeCommand(DocumentCommand.createTransform(d.selection, t));
d.executeCommand(DocumentCommand.createTransform(d.selection, new Transform(), { duplicateNodes: true })); // duplicate
console.log(d.undoDescription); d.undo(); // everything lands in History; the user can undo tooCreating things follows XxxNodeDefinition.create(...) then d.addNode(def). Read positions from node.spreadBaseBox or node.transform.data after a transform - baseBox does not move. More traps: references/gotchas.md.
5. Where to look
| Task | Read |
| Modules, documents, nodes, selections, commands, history | references/sdk-core.md |
Find the right command among all 372 DocumentCommand.create* | references/commands-index.md |
| Shapes, curves, booleans, fills, strokes, effects, transforms, QR codes | references/vector.md |
| Pixels, selections, filters (destructive and live), adjustments, resampling | references/pixel.md |
| Text, fonts, Arabic/RTL, tables, pages, artboards, picture frames | references/text-layout.md |
| Export formats and areas, the 62 presets | references/export.md |
| Canva AI commands, credits, prompting, what only the UI can do | references/ai.md |
| MCP tools, permissions, files, network, dialogs, macros, limits | references/system.md |
| Connecting Claude Code, Claude Desktop, Cursor, Codex | references/setup.md |
| Known traps and their fixes | references/gotchas.md |
6. Proven recipes
Recipes in references/recipes/ come from runs on Affinity 3.3.1; cutout.md is not yet verified end to end, and social-post.md combines individually verified steps. Start from the closest one and adapt it:
| Recipe | Use it for |
inspect.md | Report what is open: documents, layers, sizes, selection |
save-copy.md | Protect the original before editing |
new-document.md | Create a canvas with exact pixel size and DPI |
crop.md | Crop the canvas to any rectangle (e.g. a square around a face) |
resize.md | Resample the whole document up or down |
remove-object.md | Remove a person, hand, logo or blemish with generative edit (credits) |
blur-background.md | Portrait look: sharp subject, blurred background |
cutout.md | Remove the background for a transparent PNG |
outpaint.md | Extend the canvas (re-centre a subject, widen a photo) |
arabic-text.md | Correctly shaped right-to-left Arabic typography |
social-post.md | A complete designed post: background, shapes, headline, export |
profile-photo.md | The full chain: crop, clean up, blur, centre, export for LinkedIn/X/WhatsApp |
export.md | Export PNG/JPEG/PDF of a document, page or selection |
7. Know the limits before promising
- Scripts cannot choose the AI model (Nano Banana, GPT Image, Seedream, FLUX...), size, seed or count - the app UI owns those. Generative Fill/Expand/Upscale, Generate Vector, Generate 3D and Decompose Layer have no script command;
outpaint.mdshows a working substitute for Expand. generativeEditImageedits the whole selected layer and ignores pixel selections, so describe precisely what to change and what to keep.- No clipboard, no tool or panel switching, no mouse/keyboard events, no painting brush strokes, no files outside the Desktop.
When a request hits a limit, say so plainly and offer the nearest thing the SDK can do, or tell the user which UI button to press.
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.

