
# Your app's icon and link preview

Every app starts with a default icon drawn from its name. To give it its own, have the agent draw an SVG and run `agc icon use icon.svg`: Agent Cloud sanitizes it, stores it as the next version, and makes the favicon, home-screen icons, manifest and link preview from it.

Success: `agc icon use` exits 0 with a `version` of 1 or more, and `agc icon` shows the same version with each file's console address.

## Execution contract

- **Before starting:** a linked app folder and a Builder agent of a person who can see the app (`agc icon` answers `may_change: true`).
- **Do:** draw `icon.svg` by the rules below, run `agc icon use icon.svg`, then optionally `agc icon preview --title "<name>" --tagline "<line>"`.
- **Success:** exit 0, `data.version` ≥ 1, no unexpected names in `data.dropped`.
- **If blocked:** read `error.code` and `error.fix`; after an unanswered call, run `agc icon` before trying again.
- **Human handoff:** none; a person only needs to look at the result in the console.

## Ask your agent

```text
Our app still has the default letter icon. Draw it a simple icon of its own
that still reads as a browser tab icon, set it, and give the link preview
the tagline "Book camps in two taps".
```

The agent answers with the new version number. You see the icon on the app's tile in the console's app list and on the app's page.

## How do I draw an icon Agent Cloud accepts?

Draw it as SVG, by hand. These are the rules `agc help icon` gives the agent:

- a square `viewBox`, like `viewBox="0 0 512 512"`;
- one simple mark, in at most 3 flat colors, with at most one letter of text;
- a plain or transparent background;
- a mark that still reads at 16 px;
- your own design: never another company's logo or a person's likeness. A file you set is the app owner's responsibility.

```xml
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
  <rect width="512" height="512" rx="112" fill="#15803d"/>
  <path d="M136 352 256 144l120 208z" fill="#ffffff"/>
</svg>
```

The root needs `xmlns="http://www.w3.org/2000/svg"`. Text renders in the one font Agent Cloud bundles, Inter Bold, so `font-family` is dropped. A square PNG of 512 to 4096 px (at most 1 MB) works too, but SVG is the better source: it also gives `favicon.svg`.

## Steps

```bash
agc icon use icon.svg        # set it: sanitized, stored as the next version, files derived
agc icon                     # the current version, its source and each file's address
agc icon history             # every version, with current marking one
agc icon use --version 2     # go back to version 2, as a new version
```

Set the link preview's words, or your own image instead:

```bash
agc icon preview --title "Camp Bookings" --tagline "Book camps in two taps"
agc icon preview --file preview.png    # exactly 1200×630, at most 1 MB
```

### What does `agc icon` answer?

| Field | Meaning |
|---|---|
| `version` | 0 is the default drawn from the name; 1 and up are versions someone set |
| `source`, `source_url` | `svg`, `png`, or the default; the stored source's address |
| `title`, `tagline` | The preview's words; the title starts as the app's name |
| `files` | Each derived file by name, at its console address. A person who can see the app opens them signed in to the console |
| `set_by`, `set_at` | Who set this version and when |
| `may_change` | Whether this credential may set the icon |

`agc icon use` adds `before` (the version it replaced), `dropped` when sanitizing removed anything, and `from_version` when you went back.

## How it works

**Sanitizing.** Control parses the SVG strictly and keeps only an allowlist: the elements `svg`, `g`, `defs`, `title`, `desc`, `path`, `rect`, `circle`, `ellipse`, `line`, `polyline`, `polygon`, `text`, `tspan`, `linearGradient`, `radialGradient`, `stop`, `clipPath`, `mask` and `use`, with geometry, paint and text attributes. Scripts, styles, images, links, filters, event attributes, `font-family` and any URL other than `#id` are dropped, and `data.dropped` names them. Control then writes a new SVG from what it kept and stores that, never the uploaded bytes. A file it can't make safe is refused with `icon.unsafe_svg`.

**Derived files.** From the source, control makes:

| File | Size |
|---|---|
| `favicon.ico` | 16, 32 and 48 px |
| `favicon.svg` | the sanitized SVG (SVG sources only) |
| `apple-touch-icon.png` | 180 px |
| `icon-192.png`, `icon-512.png` | 192 and 512 px |
| `icon-maskable-512.png` | 512 px, the icon inside the maskable safe zone on its main color |
| `site.webmanifest` | names the title and the icons |
| `preview.png` | 1200×630 link preview |

One pinned renderer and one bundled font draw them, so the same source always gives the same bytes.

**The link preview.** `preview.png` shows the icon, the title and the tagline on the icon's main color, from one fixed template. It's redrawn whenever the icon, title or tagline changes. A custom preview from `--file` stays through later icon and word changes.

**Versions.** The default is version 0: the first letter of the app's name, white, on a color picked from the name. Every change, a preview change included, is a new version, with no release; none is ever overwritten. `agc icon use --version <v>` copies that version's whole set, words and preview included, into a new version, so history only grows.

**Who can set it.** Any credential of the app reads the icon. Setting it takes a Builder agent working for someone who can see the app, or the agent that made an app nobody has claimed yet. Any other credential, deploy keys included, gets `agent.not_allowed`.

**On the record.** Each change is on the app's activity as `app.icon_changed`, with who changed it and the versions before and after, like `version 1 → 2`.

**The nudge.** While an app is on its default icon (version 0), with no fallback recorded and no `[app] icon` declared, agc reminds its agent to draw one:

- `agc init` that creates an app puts the icon step in `next`, before the first `agc ship`.
- A ship that goes live adds a warning to `data.warnings` and puts the icon step first in `next`.
- `agc status` answers `data.icon: { "on_default": true }`, with the same warning and step.
- `agc check` adds the warning to `data.warnings`, never a failure.

The step is `agc help icon`, saying to draw `icon.svg` by its rules, declare it and ship.

## Errors

agc refuses a file of the wrong type or size before sending anything, so a local refusal doesn't count toward the day's 30. Every code, its exit and fix: [Error code catalog](/docs/reference/error-code-catalog.md).

| Code | Exit | Cause | Fix |
|---|---|---|---|
| `cli.usage` | 2 | No file named, no file at that path, a `--version` that isn't a number, a title over 40 or a tagline over 90 characters, or `--file` with `--title`/`--tagline` | Follow `error.fix` |
| `icon.invalid` | 1 | Neither SVG nor PNG; an SVG without a square `viewBox`; a PNG that isn't square or is under 512×512; a preview that isn't a 1200×630 PNG | Give the root `<svg>` a square `viewBox`, or resize |
| `icon.too_complex` | 1 | Over 256 KB (SVG) or 1 MB (PNG or preview); over 2,000 elements or 32 levels deep, counting what `use`, clip paths and masks draw; an attribute over 64 KB; a PNG over 4096×4096; over 2 s to render | Simplify the SVG, or use a smaller PNG (512 px is enough) |
| `icon.unsafe_svg` | 1 | A `DOCTYPE` or processing instruction, not UTF-8, a root that isn't `<svg>` with the SVG namespace, an `#id` that names nothing, references that loop, or XML that doesn't parse | Remove what the message names |
| `icon.no_version` | 1 | `--version` names a version the app doesn't have | Run `agc icon history` |
| `icon.limit` | 1 | 30 attempts in the last 24 hours, refused uploads included; the message says when the next frees (`retryable: true`) | Wait until that time |
| `agent.not_allowed` | 12 | This credential reads the icon but may not set it | A person who builds the app sets it from their own Builder agent |

```bash
agc icon use logo.jpg
```

```json
{
  "ok": false,
  "product": "agent.cloud",
  "command": "icon use",
  "error": {
    "code": "icon.invalid",
    "message": "logo.jpg is neither an SVG nor a PNG.",
    "fix": "Draw the icon as SVG with a square viewBox, like viewBox=\"0 0 512 512\", or use a square PNG of 512 to 4096 px. Nothing was sent.",
    "retryable": false,
    "docs": "agc help icon"
  },
  "next": [{ "cmd": "agc help icon", "why": "what an icon file may hold" }]
}
```

## Limits

| Limit | Value |
|---|---|
| SVG source | 256 KB, square `viewBox`, 2,000 elements, 32 levels deep, 64 KB per attribute |
| PNG source | square, 512 to 4096 px, 1 MB |
| Rendering | 2 s and 256 MB per upload |
| Preview title / tagline | 1 to 40 / up to 90 characters |
| Custom preview | PNG, exactly 1200×630, 1 MB |
| Changes | 30 `use` and `preview` attempts per app in any 24 hours, refused uploads included |

## Agent notes

- Draw the icon yourself; don't fetch a logo from the web. Never copy another company's mark.
- Read `data.dropped` after `agc icon use`. If it names something your drawing relied on (a `style` block, a `filter`), redraw with plain attributes and set it again.
- If agc says agent.cloud didn't answer the icon change, it may have landed: run `agc icon` and check the version before running `use` again, since each try counts.
- `agc icon use --version 3` works; so does `agc icon use --version=3`.
- Going back never deletes a version; it adds one.

## Related

- [Local development with agc up](/docs/build/local-development-with-agc-up.md)
- [Working with your coding agent](/docs/getting-started/working-with-your-coding-agent.md)
- [What agents can and can't do](/docs/concepts/what-agents-can-and-cant-do.md)
- [Error code catalog](/docs/reference/error-code-catalog.md)

<!-- feedback:start -->
---
Wrong, outdated or unclear? Run `agc feedback docs "build/your-apps-icon: <what is wrong>" --body <file>` with the sentence quoted in the file. No code or app data is sent.
<!-- feedback:end -->
