agentleFS
aboalrejalaiaboalrejalai/affinity-mcp/skills/affinity/SKILL.md

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

  • Other versions2 projects use a version of this.

    Word for word · 0

    None found.

    Edited · 0

    None found.

    Wrote their own version · 2

    1. jablonkai/skills★ 2same name
    2. 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.

  • In this repository2 other files it gives its agents.

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
  1. Very specific:

    Look for the Affinity MCP tools (execute_script, render_spread, read_sdk_documentation_topic, ...).

    line 12
  2. Distinctive:

    If they are missing or the connection is refused, the app is not serving MCP.

    line 14
  3. Distinctive:

    Follow this loop for every task.

    line 22
  4. Very specific:

    Orient once per session: Read the preamble topic with read_sdk_documentation_topic - it carries the SDK conventions plus hints recorded on …

    line 24
  5. Very specific:

    Look things up instead of guessing APIs: Use search_sdk_hints for the problem, then the matching reference file below, then …

    line 36
  6. Very specific:

    Verify visually after every visible change: Call render_spread(sessionUuid, 0) (or render_selection) and actually judge the image: framing, …

    line 40
  7. Very specific:

    Optionally teach the next session: After solving something by experiment, add_sdk_hint records it in this machine's preamble (it may be …

    line 44
  8. Very specific:

    Read references/safety.md once.

    line 48
  9. Very specific:

    Canva AI costs the user's Canva credits: Ask before generateImage or generativeEditImage, and say what you are about to generate.

    line 50
  10. Very specific:

    Only touch documents you created or the user pointed you at: Never save(), close() or overwrite an export the user did not ask for.

    line 51
  11. Distinctive:

    No clipboard, no tool or panel switching, no mouse/keyboard events, no painting brush strokes, no files outside the Desktop.

    line 117
  12. Distinctive:

    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.

    line 119

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

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:

  1. Affinity > Settings > Model Context Protocol > enable Enable Affinity MCP (and the permissions they want).
  2. Quit Affinity completely and reopen it - the server only starts on launch.
  3. Connect the client to http://localhost:6767/sse (SSE). Per-client commands are in references/setup.md.

2. The working loop

Follow this loop for every task. Each step exists because skipping it has caused real failures.

  1. Orient once per session. Read the preamble topic with read_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));
  2. Protect the user's file before the first edit. If the work targets a document the user cares about, saveAs a 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.
  3. Look things up instead of guessing APIs. Use search_sdk_hints for the problem, then the matching reference file below, then read_sdk_documentation_topic for 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.
  4. Execute in small scripts. One logical step per execute_script call, with console.log of what changed (sizes, layer counts, return values). Scripts return nothing unless you log it. Re-acquire the target document each time (by sessionUuid when more than one is open) instead of trusting Document.current.
  5. Verify visually after every visible change. Call render_spread(sessionUuid, 0) (or render_selection) and actually judge the image: framing, centring, artefacts, halos, text direction. If it is wrong, doc.undo() (check doc.undoDescription first) and try again. Never report success you have not seen.
  6. 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.
  7. Optionally teach the next session. After solving something by experiment, add_sdk_hint records 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 generateImage or generativeEditImage, and say what you are about to generate. selectSubject and removeBackground are 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 with PERMISSION_DENIED; NOT_ALLOWED means 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 too

Creating 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

TaskRead
Modules, documents, nodes, selections, commands, historyreferences/sdk-core.md
Find the right command among all 372 DocumentCommand.create*references/commands-index.md
Shapes, curves, booleans, fills, strokes, effects, transforms, QR codesreferences/vector.md
Pixels, selections, filters (destructive and live), adjustments, resamplingreferences/pixel.md
Text, fonts, Arabic/RTL, tables, pages, artboards, picture framesreferences/text-layout.md
Export formats and areas, the 62 presetsreferences/export.md
Canva AI commands, credits, prompting, what only the UI can doreferences/ai.md
MCP tools, permissions, files, network, dialogs, macros, limitsreferences/system.md
Connecting Claude Code, Claude Desktop, Cursor, Codexreferences/setup.md
Known traps and their fixesreferences/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:

RecipeUse it for
inspect.mdReport what is open: documents, layers, sizes, selection
save-copy.mdProtect the original before editing
new-document.mdCreate a canvas with exact pixel size and DPI
crop.mdCrop the canvas to any rectangle (e.g. a square around a face)
resize.mdResample the whole document up or down
remove-object.mdRemove a person, hand, logo or blemish with generative edit (credits)
blur-background.mdPortrait look: sharp subject, blurred background
cutout.mdRemove the background for a transparent PNG
outpaint.mdExtend the canvas (re-centre a subject, widen a photo)
arabic-text.mdCorrectly shaped right-to-left Arabic typography
social-post.mdA complete designed post: background, shapes, headline, export
profile-photo.mdThe full chain: crop, clean up, blur, centre, export for LinkedIn/X/WhatsApp
export.mdExport 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.md shows a working substitute for Expand.
  • generativeEditImage edits 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.

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.