agentleFS
MohamedAbdallah-14MohamedAbdallah-14/prompt-to-asset/.cursor/skills/transparent-bg/SKILL.md

transparent-bg

Skill18 starsChanged 7 months agoMITView on GitHub

Produce a truly RGBA-transparent asset from a brief. Handles the #1 pain (Gemini/Imagen rendering checkerboard pixels instead of real alpha). Routes to native-RGBA providers; falls back to BiRefNet / BRIA RMBG / LayerDiffuse / difference matting.

The file

We split this skill into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Do not ask for transparency in the prompt: Ask for pure white:

    line 64

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

Transparent background

The problem (see research 13 + 04)

Almost every modern T2I VAE is RGB-only. Asking Imagen 3/4 or Gemini 2.5/3 Flash Image for a "transparent logo" triggers one of two failures:

  1. Flat background — DALL·E 3, Stable Diffusion families render a white/gray background that must be matted.
  2. Checkerboard as RGB pixels — Gemini/Imagen literally render the gray-and-white 8×8 tile pattern (because Photoshop screenshots in their training data show transparency that way). This is the "weird boxes" users report. It cannot be fixed by prompting.

Fix hierarchy (apply first that fits)

1. Route to a native-RGBA provider

ProviderMechanism
gpt-image-1 / gpt-image-1.5API param background: "transparent" + output_format: "png" or "webp"
Ideogram 3 TurboDedicated /ideogram-v3/generate-transparent endpoint; set rendering_speed: "TURBO" for Turbo tier
Recraft V3native SVG output (alpha is trivial); rasterize if raster needed
LayerDiffuse on SDXL / FluxIn-diffusion-loop transparency adapter; better edges than post-matte

2. Post-process matte (for everything else)

Matting modelLicenseStrength
BiRefNetMITDefault choice 2026; best soft-edge handling
BRIA RMBG-2.0CC-BY-NC-4.0 (hosted API for commercial)Best overall quality
U²-NetApache-2.0Legacy fallback
rembgwrapper around U²-Net / BiRefNetEasy CLI integration
SAM 2Apache-2.0For complex/multi-object scenes; 2-stage (segment → matte)

3. Difference matting (for semi-transparency: glass, hair, smoke)

  1. Generate the same subject on pure-white background.
  2. Generate again with same seed on pure-black background.
  3. alpha = (white_version - black_version + 255) / 2 in luminance.
  4. Works for true semi-transparent objects where rembg/BiRefNet produce hard-cutout artifacts.

4. Vectorize-and-drop (for flat marks)

  1. Generate raster at 1024² on white background.
  2. BiRefNet matte → K-means quantize to N colors → vtracer or potrace.
  3. SVG has alpha trivially. Rasterize at target sizes with @resvg/resvg-js for RGBA PNGs.

Validation (never ship without)

Tier-0 alpha validator (see packages/mcp-server/src/pipeline/validate.ts):

1. Check PNG/WebP header has alpha channel type (RGBA, not RGB).
2. Reject if no pixels have alpha < 255 (it's opaque).
3. Reject if >5% of pixels have alpha ∈ [0.05, 0.95] AND FFT signature shows gray-tile band frequency (Gemini fake checkerboard).
4. Alpha coverage: subject pixels (alpha > 0.5) should occupy 30–85% of frame (sanity check).
5. Premultiplied-alpha check: no RGB values where alpha==0 (cleanup artifacts).

Prompt scaffold for fallback matting flow

Do not ask for transparency in the prompt. Ask for pure white:

[SUBJECT, concrete].
Centered, isolated, no surrounding context or props.
Solid pure white #FFFFFF background.
Clean silhouette with distinct outline.
No drop shadow, no ground plane, no reflection.
1:1 square, 1024x1024.

Then post-process with BiRefNet / BRIA.

Never do this

  • "transparent background" as a prompt to Imagen or Gemini (checkerboard result).
  • Trust output_format: "png" alone to produce alpha (PNG supports alpha, but the model has to emit it).
  • Algorithmic #FFFFFF → alpha=0 thresholding (loses anti-aliasing, creates jagged edges).
  • Post-resize RGBA with non-premultiplied alpha (dark fringes).

Output

transparent/
├── mark.png         # RGBA, validated
├── mark@2x.png      # optional high-DPI
├── mark.svg         # if vector path chosen
└── meta.json        # alpha_coverage, matting_method, validation_hash

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.