agentleFS
duckduckgoduckduckgo/apple-browsers/.claude/skills/ddg-drk-add-icon/SKILL.md

ddg-drk-add-icon

Skill275 starsChanged 5 days agoApache-2.0View on GitHub

Invoke ONLY when the user explicitly runs /ddg-drk-add-icon or names this skill by name (e.g. "use ddg-drk-add-icon to add these SVGs"). Do NOT auto-invoke from symptom/intent matching — the skill mutates the apple-browsers asset catalog and Swift files and creates a git commit, so it must be user-initiated. If the user asks about adding icons or Swift package assets without naming this skill, answer directly instead. Inputs are a list of local paths and/or HTTP URLs (one entry per icon); category (Glyph/Color/Recolorable) and size are derived from each filename. Handles imageset/symbolset creation, Contents.json variants, and the camelCase accessor in the matching DesignSystemImages+*.swift file, in a single batch commit.

The file

We split this skill into the rules it gives an agent

9 rules. About 0 are common, 4 are distinctive, and 5 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.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    If the file you were given doesn't match, rename it to match before continuing.

    line 35
  2. Distinctive:

    Run steps 1–6 for each input icon in the list (they're independent — fetch all first, then process).

    line 39
  3. Very specific:

    Get the file locally: If input is a URL, curl -fL -o /tmp/<basename> <url>.

    line 41
  4. Very specific:

    Copy the SVG into that directory: If needed, rename the SVG to match the imageset/symbolset directory name (e.g.

    line 51
  5. Distinctive:

    When the input list has more than one icon:

    line 124
  6. Very specific:

    One commit for the batch: Don't make a commit per icon.

    line 126
  7. Very specific:

    Swift edits coalesce: All Glyphs land in DesignSystemImages+Glyphs.swift, all Colors in +Color.swift, all Recolorables in …

    line 127
  8. Very specific:

    Same size + same category = same enum: When several icons share a size and category, insert them all into the same Size{N} block in one …

    line 128
  9. Distinctive:

    Independent failures: If one input is malformed (bad filename, wrong size bucket), stop and confirm with the user — don't silently skip it …

    line 129

≈ “Common” is an estimate: at least 1 in 5 of the 372,429 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

ddg-drk-add-icon

Overview

Imports one or more SVGs into the DesignResourcesKitIcons Swift package at SharedPackages/Infrastructure/DesignResourcesKitIcons. For each icon, three things must always change together:

  1. An *.imageset/ (or *.symbolset/ for Recolorable) directory under DesignSystemImages.xcassets/{Category}/{Size}/ containing the SVG.
  2. A Contents.json in that directory — format differs by category.
  3. A public static var accessor in the matching DesignSystemImages+Glyphs.swift / +Color.swift / +Recolorable.swift, inserted alphabetically inside the right SizeN enum.

Forgetting any of the three leaves the icon unusable.

Inputs

  • Required: one or more local paths and/or http(s) URLs to SVGs. A single icon is just a list of length one — treat the singular and batch cases the same way.
  • Optional, only if a filename doesn't follow convention: category, size, accessor name (per-icon).

Inputs may mix local paths and URLs in the same invocation, and may span multiple categories/sizes — they don't have to be homogeneous.

Filename convention (drives everything else)

CategoryFilenameExample
GlyphTitle-Case-{size}.svgPin-Remove-12.svg
ColorTitle-Case-Color-{size}.svgChat-Color-12.svg
Recolorablelower-case-recolorable-{size}.svgcheck-recolorable-24.svg

Allowed sizes: Glyph 12/16/20/24, Color 12/16/24/32/42/72/96/128, Recolorable 24.

If the file you were given doesn't match, rename it to match before continuing. Don't invent new size buckets — confirm with the user instead.

Steps

Run steps 1–6 for each input icon in the list (they're independent — fetch all first, then process). Step 7 is a single verification pass at the end.

  1. Get the file locally. If input is a URL, curl -fL -o /tmp/<basename> <url>. If local, just note the path. When given multiple URLs, you may run the curls in parallel.
  2. Parse the filename to derive:
    • Category (Glyph / Color / Recolorable — by presence of -Color- or -Recolorable-).
    • Size (trailing number before .svg).
    • Base name (everything before the category/size suffix).
    • Accessor name = base name lowerCamelCased. For Color, drop the Color suffix from the variable name but keep it in the resource name (e.g. Chat-Color-12.svg → accessor chat, resource .chatColor12). For Recolorable, same shape — drop Recolorable from the variable name but keep it in the resource (e.g. check-recolorable-24.svg → accessor check, resource .checkRecolorable24). For Glyph, no suffix to drop — the whole base name becomes the camelCased variable and the resource is <variable><size> (e.g. Pin-Remove-12.svg → accessor pinRemove, resource .pinRemove12).
  3. Create the imageset/symbolset directory:
    • Glyph: SharedPackages/Infrastructure/DesignResourcesKitIcons/Sources/DesignResourcesKitIcons/DesignSystemImages.xcassets/Glyphs/{size}px/{Filename-without-.svg}.imageset/
    • Color: same root, Color/{size}px/...imageset/ — exception: Color/32x/ (no p, matches existing repo state).
    • Recolorable: Recolorable/{size}px/{Title-Cased-filename-without-.svg}.symbolset/ — the directory is Title-Case (e.g. Check-Recolorable-24.symbolset/) to match how Glyph and Color imageset directories are cased. (The existing check-recolorable-24.svg SVG predates this convention; new icons should follow it.)
  4. Copy the SVG into that directory. If needed, rename the SVG to match the imageset/symbolset directory name (e.g. drop Check-Recolorable-24.svg inside Check-Recolorable-24.symbolset/). he filename field in Contents.json (next step) must reference the SVG file name exactly.
  5. Write Contents.json in that same directory. Use the variant for the category:

    Glyph:

    {
      "images" : [{ "filename" : "Pin-Remove-12.svg", "idiom" : "universal" }],
      "info" : { "author" : "xcode", "version" : 1 },
      "properties" : { "template-rendering-intent" : "template" }
    }

    Glyph with Recolorable in the filename (e.g. Check-Recolorable-16.svg) — same category and folder layout as a regular Glyph, but omit the properties block entirely so the asset is treated as "Default image" (preserves the SVG's own colors) instead of "Template image" (tinted by foreground color):

    {
      "images" : [{ "filename" : "Check-Recolorable-16.svg", "idiom" : "universal" }],
      "info" : { "author" : "xcode", "version" : 1 }
    }

    The accessor still keeps the full base name (including Recolorable), e.g. checkRecolorable: DesignSystemImage { .init(resource: .checkRecolorable16) }. Only the Recolorable (.symbolset) category drops the suffix from the accessor — Glyphs do not.

    Color (no properties):

    {
      "images" : [{ "filename" : "Chat-Color-12.svg", "idiom" : "universal" }],
      "info" : { "author" : "xcode", "version" : 1 }
    }

    Recolorable (symbols array, .symbolset, hierarchical rendering):

    {
      "info" : { "author" : "xcode", "version" : 1 },
      "properties" : { "symbol-rendering-intent" : "hierarchical" },
      "symbols" : [{ "filename" : "Check-Recolorable-24.svg", "idiom" : "universal" }]
    }
  6. Add the Swift accessor to the right file in SharedPackages/Infrastructure/DesignResourcesKitIcons/Sources/DesignResourcesKitIcons/:

    • Glyph → DesignSystemImages+Glyphs.swift
    • Color → DesignSystemImages+Color.swift
    • Recolorable → DesignSystemImages+Recolorable.swift

    Find the public enum Size{N} block matching the icon's size and insert a new line in alphabetical order by accessor name:

    public static var pinRemove: DesignSystemImage { .init(resource: .pinRemove12) }

    The .pinRemove12 reference is auto-generated by Xcode at build time from the imageset folder name — do not try to define it manually.

  7. Verify (once, after all icons are processed): git status should show, per icon, one new imageset/symbolset directory with two files (the SVG and Contents.json), plus modifications to the DesignSystemImages+*.swift file(s) for each category touched. The number of modified Swift files equals the number of distinct categories in the batch (1–3). Build the package in Xcode (or rely on the user's next build) — if any accessor still red-underlines, the corresponding imageset folder name is mistyped.

Worked example

Input: ~/Downloads/Pin-Remove-12.svg

  • Category: Glyph (no -Color- / -Recolorable-). Size: 12. Base: Pin-Remove. Accessor: pinRemove.
  • New dir: .../Glyphs/12px/Pin-Remove-12.imageset/ with Pin-Remove-12.svg and the Glyph Contents.json (template intent).
  • Inserted in DesignSystemImages+Glyphs.swift Size12 enum between pin and platform:
    public static var pinRemove: DesignSystemImage { .init(resource: .pinRemove12) }

Common mistakes

  • Wrong Contents.json for category. Glyph without template-rendering-intent renders as filled black — not tinted. Color with template-rendering-intent strips the colors. Exception: Glyphs whose filename contains Recolorable (e.g. Check-Recolorable-16.svg) must omit template-rendering-intent so they render as Default and keep their own colors.
  • .imageset for Recolorable. Recolorable must be .symbolset with symbols (not images) — Xcode silently ignores it otherwise.
  • Color/32px/ instead of Color/32x/. The 32-size directory is 32x in this repo. All other sizes are {N}px.
  • Alphabetical insertion drift. Several existing files (notably +Color.swift Size32 and Size128) aren't strictly alphabetical. Don't replicate the disorder — insert your line in the correct alphabetical position and leave neighbours alone.
  • Recolorable casing. The .symbolset directory is Title-Case (e.g. Check-Recolorable-24.symbolset/) like the Glyph and Color imageset directories. The SVG inside should ideally follow the directory's casing (Title-Case) — note that the existing check-recolorable-24.svg uses lowercase historically; either works, but match the directory for new icons. The filename field in Contents.json must reference whatever the SVG is actually named.
  • Manually editing ImageResource. The .pinRemove12, .chatColor12, etc. accessors are generated by Xcode from the asset catalog. Don't grep for them — they only exist post-build.

Batching notes

When the input list has more than one icon:

  • One commit for the batch. Don't make a commit per icon. Commit message convention from recent history: Add <Title> and <Title> {size}px icons (two icons, same size) or Add <N> icons / Add <Title>, <Title>, and <Title> icons when sizes/categories are mixed — match the style of nearby commits in git log for the asset catalog.
  • Swift edits coalesce. All Glyphs land in DesignSystemImages+Glyphs.swift, all Colors in +Color.swift, all Recolorables in +Recolorable.swift. Open each file at most once; insert every new accessor in its correct Size{N} enum (alphabetically) before moving on.
  • Same size + same category = same enum. When several icons share a size and category, insert them all into the same Size{N} block in one pass so you don't re-locate the block per icon.
  • Independent failures. If one input is malformed (bad filename, wrong size bucket), stop and confirm with the user — don't silently skip it and ship the rest, since the user is expecting the full set.
  • Don't parallelise file writes. Asset-catalog directory creation and Swift edits are cheap and ordering-sensitive (alphabetical insertion); run them sequentially. Only the initial curl fetches are worth parallelising.

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.