agentleFS
peterkrueckpeterkrueck/Claude-Code-Development-Kit/skills/bg-remove/SKILL.md

bg-remove

Skill1.4k starsChanged 6 months agoMITView on GitHub

Remove backgrounds from images using local AI (rembg). Use when removing backgrounds from character art, mascot images, photos, or any image that needs a transparent background.

  • Installs packages

Trending

Quiet since April.thin dataabout the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 1 mentionMay 2026: 0 mentionsJun 2026: 0 mentionsJul 2026: 0 mentionsAug 2026: 0 mentionsSep 2026: 0 mentionsOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the peterkrueck/Claude-Code-Development-Kit repository that our weekly crawl found: only 3 in all, so this is a hint, not a trend. There is no adoption data for this file yet.

The file

We split this skill into the rules it gives an agent

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

  • 2

    Very specific

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

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Remove backgrounds from images using rembg (local, offline, no data sent externally).

    line 9
  2. Distinctive:

    If the venv doesn't exist, install it:

    line 31
  3. Distinctive:

    Check the source image exists

    line 43
  4. Very specific:

    Use the birefnet-general model — validated in testing on illustrated/character art *and* general photos, producing clean edges across both.

    line 49
  5. Very specific:

    If --trim was requested, trim transparent padding:

    line 89
  6. Distinctive:

    Always activate the venv: before running rembg or Python with Pillow/numpy.

    line 135

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

Background Remove — Local AI Background Removal

Remove backgrounds from images using rembg (local, offline, no data sent externally). Outputs RGBA PNG with proper transparency.

Input

Arguments after /bg-remove:

  • Source image path (required) — path to the image
  • --trim (optional) — auto-trim transparent padding after removal
  • --output <path> (optional) — custom output path. Default: same directory, <name>-transparent.png

Examples:

  • /bg-remove assets/character/mascot.png
  • /bg-remove image.png --trim
  • /bg-remove image.png --output ~/Desktop/result.png

Setup

rembg is installed in a dedicated venv. Always activate it before use:

source ~/.claude/tools/rembg-env/bin/activate

If the venv doesn't exist, install it:

python3 -m venv ~/.claude/tools/rembg-env && source ~/.claude/tools/rembg-env/bin/activate && pip install "rembg[cpu,cli]"

Model files are cached in ~/.u2net/ (downloaded on first use per model, ~170MB for birefnet-general).

Process

Step 1: Verify Input

  1. Check the source image exists
  2. Get dimensions: sips -g pixelWidth -g pixelHeight <path>
  3. View the image with the Read tool to understand what we're working with

Step 2: Remove Background

Use the birefnet-general model — validated in testing on illustrated/character art and general photos, producing clean edges across both.

source ~/.claude/tools/rembg-env/bin/activate && rembg i -m birefnet-general <input> <output>

Model choice: Default to birefnet-general. In side-by-side testing it gave clean edges on both illustrated subjects and photographic ones. Avoid anime-trained models (e.g. isnet-anime): on non-anime and even some illustrated inputs they tend to add artifacts and leave dark patches around edges. If birefnet-general underperforms on a specific image, compare against another general model rather than an anime-specific one.

Step 3: Verify Result

The Read tool renders transparency as black, so you MUST verify by compositing on a colored background:

source ~/.claude/tools/rembg-env/bin/activate && python3 -c "
from PIL import Image
import numpy as np

# Load result
img = Image.open('<output>').convert('RGBA')
alpha = np.array(img)[:,:,3]
total = alpha.size
transparent = np.sum(alpha == 0)
opaque = np.sum(alpha == 255)
print(f'Dimensions: {img.size}')
print(f'Transparent: {transparent/total*100:.1f}%')
print(f'Opaque: {opaque/total*100:.1f}%')
print(f'Corners alpha: TL={alpha[0,0]} TR={alpha[0,-1]} BL={alpha[-1,0]} BR={alpha[-1,-1]}')

# Composite on magenta for visual verification
bg = Image.new('RGBA', img.size, (255, 0, 255, 255))
bg.paste(img, (0, 0), img)
bg.save('<output_dir>/verify-magenta.png')
print('Verification image saved')
"

Then view the magenta verification image with the Read tool. The magenta should only show where background was removed.

Step 4: Optional Trim

If --trim was requested, trim transparent padding:

source ~/.claude/tools/rembg-env/bin/activate && python3 -c "
from PIL import Image
import numpy as np

img = Image.open('<output>').convert('RGBA')
alpha = np.array(img)[:,:,3]

# Find bounding box of non-transparent pixels
rows = np.any(alpha > 0, axis=1)
cols = np.any(alpha > 0, axis=0)
rmin, rmax = np.where(rows)[0][[0, -1]]
cmin, cmax = np.where(cols)[0][[0, -1]]

# Add small padding (2% of dimensions)
pad_h = max(int(img.height * 0.02), 4)
pad_w = max(int(img.width * 0.02), 4)
rmin = max(0, rmin - pad_h)
rmax = min(img.height - 1, rmax + pad_h)
cmin = max(0, cmin - pad_w)
cmax = min(img.width - 1, cmax + pad_w)

cropped = img.crop((cmin, rmin, cmax + 1, rmax + 1))
cropped.save('<output>')
print(f'Trimmed: {img.size} -> {cropped.size}')
"

Step 5: Report

Done: background removed
  Source: <input_path>
  Output: <output_path>
  Dimensions: <width>x<height>
  Transparent pixels: <percent>%
  Model: birefnet-general (local, offline)

Verify before shipping: open the output in Preview.app (or any viewer that shows the checkerboard pattern) to confirm real transparency. The Read tool renders transparency as solid black, so it cannot distinguish a transparent background from a black one — composite-over-a-color (Step 3) or a checkerboard viewer is the only reliable check.

Important Rules

  1. Default to birefnet-general — in side-by-side testing it produced the cleanest edges on both illustrated and photographic inputs; anime-trained models added artifacts. Only switch models if it visibly underperforms on a specific image.
  2. Always activate the venv before running rembg or Python with Pillow/numpy.
  3. Always verify with magenta composite — don't trust the Read tool's rendering of transparency.
  4. Never send images to external services — rembg runs 100% locally.
  5. Preserve original files — output to a new file, never overwrite the source.
  6. Clean up verification images — delete the magenta composite after confirming quality.

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.