Sketch

From G1Joshi/Agent-Skills · View interactive version

Sketch is an AI agent skill from the GitHub repository G1Joshi/Agent-Skills. Expert Sketch assistance covering vector UI/UX design, symbol libraries, design tokens, color variables, and developer handoff workflows. Use when creating design systems in Sketch, managing shared libraries, exporting asset slices, or integrating Sketch with prototyping tools.

How to use this skill

Skill file

Sketch

Sketch is a native macOS design platform providing vector editing, shared design system libraries, symbols, and developer asset handoff workflows.

When to Use

Quick Start

1. Export Assets via Sketchtool CLI

# Export all artboards to @2x PNG
sketchtool export artboards "MyDesign.sketch" --scales="1, 2" --output="assets/exports"

# Export specific slices
sketchtool export slices "MyDesign.sketch" --formats="svg,png"

2. Design Token Organization

Core Concepts

Sketch JavaScript API: Automated Token Exporter

Writing an automated Sketch script to export document color variables to JSON tokens:

// export-tokens.js (Run via Sketch Developer Console)
const sketch = require("sketch");
const document = sketch.getSelectedDocument();

const colors = document.colors.map((colorAsset) => ({
  name: colorAsset.name || "Untitled",
  hex: colorAsset.color,
}));

const designTokens = {
  version: "1.0.0",
  palette: colors.reduce((acc, curr) => {
    const slug = curr.name.toLowerCase().replace(/\s+/g, "-");
    acc[slug] = curr.hex;
    return acc;
  }, {}),
};

console.log(JSON.stringify(designTokens, null, 2));

Sketch Plugin Manifest (`manifest.json`)

Creating a developer handoff plugin for Sketch:

{
  "name": "Design Token Exporter",
  "identifier": "com.company.sketch.token-exporter",
  "version": "1.0.0",
  "description": "Exports Sketch color variables and text styles to Tailwind CSS tokens.",
  "author": "Engineering Design Team",
  "appcast": "https://raw.githubusercontent.com/company/sketch-plugin/main/appcast.xml",
  "commands": [
    {
      "name": "Export Tokens to JSON",
      "identifier": "export-tokens",
      "script": "./plugin.js",
      "handler": "onExportTokens"
    }
  ],
  "menu": {
    "title": "Design Tokens",
    "items": ["export-tokens"]
  }
}

Exporting SVG Assets with Clean Paths

```bash

sketchtool export slices "DesignSystem.sketch" --output="./dist/assets/" --formats="svg,png"

```

Common Patterns

Reusable Symbol Design with Smart Layout

Problem: Buttons and card components break layout when text labels change in length.

Solution:

{
  "group": "Button/Primary",
  "smartLayout": {
    "direction": "HORIZONTAL_CENTER",
    "minWidth": 120,
    "padding": { "top": 12, "right": 24, "bottom": 12, "left": 24 }
  }
}

Design System Token Export to Code

Problem: Sync Sketch color variables and typography to CSS variables or Tailwind tokens.

Solution: Export JSON tokens via Sketch Cloud API or sketchtool.

{
  "colors": {
    "primary": { "value": "#4F46E5" },
    "background": { "value": "#0F172A" }
  },
  "spacing": {
    "sm": { "value": "8px" },
    "md": { "value": "16px" }
  }
}

Best Practices

Do:

Don't:

Troubleshooting

| Error | Cause | Solution |

| --------------------------------------------------------------- | ----------------------------------------------------------------- | ------------------------------------------------------------------------------------------------ |

| sketchtool: command not found | Sketch command line tools not linked in system path | Run sudo /Applications/Sketch.app/Contents/Resources/sketchtool/bin/sketchtool-install.sh. |

| Symbol overrides reset when library updates | Symbol layer structure was modified or layer names desynchronized | Keep layer names identical in both base library and modified components to preserve overrides. |

| Exported SVG icons have nested clipped paths and extra wrappers | Sketch exports artboard backgrounds or hidden masks | Disable artboard background in export settings and flatten combined vector shapes before export. |

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.