Favicon & App Icon ToolsVerifyBuild
AI Builders
DevEx

How AI Coding Agents Handle Favicons (and Where They Fail)

· 6 min read

The model writes the markup fine. The trouble is everything the markup points at.

Why the model can't just make the icon

A favicon is binary image data. A .ico is a container of bitmaps; a .png is compressed pixels. Producing either means running an encoder, and an encoder is code, not prose. An AI coding agent is a text model, so on its own it can write the HTML that references favicon.ico all day but it cannot emit the bytes of favicon.ico.

This is the gap that trips people up. The agent sounds confident, the <head> looks correct, and the build passes. Then the tab is blank, because the files the markup names do not exist in the repo.

The fix is not a better prompt. The fix is to hand the agent a tool that produces the real files, so it stops improvising around the thing it structurally cannot do.

The pattern that works

  1. 1

    Give the agent a generator it can call

    A CLI it runs in a shell, an MCP server it calls as a tool, or a skill that wraps one. The generator does the encoding the model can't: it writes favicon.ico, the PNG sizes, the apple-touch-icon, the Android icons, and the manifest to disk. See adding app icons with AI for the end-to-end flow.

  2. 2

    Let it patch the <head>

    Once the files exist, wiring the link tags is a text job, which is exactly what the model is good at. It adds the icon, apple-touch-icon, and manifest links to the shared layout or template.

  3. 3

    Verify the files, not just the markup

    The agent should confirm each referenced path resolves to a real file in the commit, and ideally that /favicon.ico serves a 200. A tag that points at a missing file is the single most common way this breaks.

How agents fake it (and what to reject)

When an agent has no generator, it reaches for something it can express in text. Watch for these, because they all render as a broken or half-broken icon:

A base64 data URI stuffed into the href. It looks like it works in one browser, but it bloats the HTML, skips the .ico that crawlers request at /favicon.ico, and gives you nothing for iOS or Android home screens.

A lone SVG treated as the whole set. An SVG favicon is great as one entry, but Safari's older versions and every home-screen surface still need raster PNGs and an .ico. Shipping only the SVG leaves real gaps. See the SVG favicon guide for where it does and doesn't cover.

Markup that references files the commit never contained. The classic tell: the diff adds five <link> tags and zero image files. If the icons aren't in the tree, the tags are pointing at 404s.

Common questions

Can an AI agent create a favicon?

Not by itself. The model can write the HTML that references a favicon, but it can't encode the PNG or ICO bytes, because that's a job for an image encoder, not a text model. Give it a generator (a CLI, an MCP server, or a skill) and it can produce real files and wire them up.

Why does my AI-generated favicon show a broken image?

Almost always because the link tags point at files that were never created. The agent wrote correct-looking markup but had no way to produce the actual images, so the paths resolve to 404s. Check that each referenced icon exists in the repo and that /favicon.ico serves a 200.

Is a base64 data URI favicon a good idea?

No. It's what an agent falls back to when it can't write real files. It inflates your HTML, skips the /favicon.ico that crawlers request, and provides nothing for iOS or Android home screens. Ship real files instead.

How do I get an agent to make favicons reliably?

Wire it to a generator it can call, then have it verify the output. The durable order is: call the generator to write files, patch the <head>, then confirm every referenced path resolves before calling it done.

Keep reading