bg-remover
Remove backgrounds from images using FAL.ai's BiRefNet model. Use when users ask to remove background, make transparent PNG, extract subject from image, or create cutouts. Trigger phrases include "remove background", "transparent background", "cut out", "extract subject", or any background removal request.
Best use case
bg-remover is best used when you need a repeatable AI agent workflow instead of a one-off prompt.
Remove backgrounds from images using FAL.ai's BiRefNet model. Use when users ask to remove background, make transparent PNG, extract subject from image, or create cutouts. Trigger phrases include "remove background", "transparent background", "cut out", "extract subject", or any background removal request.
Teams using bg-remover should expect a more consistent output, faster repeated execution, less prompt rewriting.
When to use this skill
- You want a reusable workflow that can be run more than once with consistent structure.
When not to use this skill
- You only need a quick one-off answer and do not need a reusable workflow.
- You cannot install or maintain the underlying files, dependencies, or repository context.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/bg-remover/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How bg-remover Compares
| Feature / Agent | bg-remover | Standard Approach |
|---|---|---|
| Platform Support | Not specified | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | Unknown | N/A |
Frequently Asked Questions
What does this skill do?
Remove backgrounds from images using FAL.ai's BiRefNet model. Use when users ask to remove background, make transparent PNG, extract subject from image, or create cutouts. Trigger phrases include "remove background", "transparent background", "cut out", "extract subject", or any background removal request.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
SKILL.md Source
# Background Remover Skill
Remove backgrounds from images using FAL.ai's BiRefNet v2 model. Uses Bun for fast TypeScript execution with inline scripts.
## Prerequisites
This skill requires:
- **Bun** - Fast JavaScript runtime
- **FAL_KEY** - FAL.ai API key set as environment variable
### Checking for Bun
Before running scripts, verify Bun is installed:
```bash
which bun
```
If Bun is not installed, **ask the user for permission** before installing:
```bash
npm install -g bun
```
### Setting up FAL.ai
1. Get an API key from https://fal.ai/dashboard/keys
2. Set the environment variable: `export FAL_KEY="your-key-here"`
## Basic Usage
Remove background from an image using a heredoc script:
```bash
bun run - << 'EOF'
import { fal } from "@fal-ai/client";
import { readFileSync, writeFileSync } from "fs";
import { basename, dirname, join } from "path";
const imagePath = "INPUT_IMAGE_PATH";
const imageBuffer = readFileSync(imagePath);
const fileName = basename(imagePath);
const mimeType = imagePath.endsWith(".png") ? "image/png" : "image/jpeg";
// Upload to FAL storage
const file = new File([imageBuffer], fileName, { type: mimeType });
const imageUrl = await fal.storage.upload(file);
console.log("Uploaded:", imageUrl);
// Remove background
const result = await fal.subscribe("fal-ai/birefnet/v2", {
input: {
image_url: imageUrl,
model: "General Use (Light)",
operating_resolution: "1024x1024",
output_format: "png"
},
logs: true,
onQueueUpdate: (update) => {
if (update.status === "IN_PROGRESS" && update.logs) {
update.logs.map((log) => log.message).forEach(console.log);
}
},
});
// Download and save result
const outputUrl = result.data.image.url;
const response = await fetch(outputUrl);
const buffer = Buffer.from(await response.arrayBuffer());
const dir = dirname(imagePath);
const nameWithoutExt = basename(imagePath, basename(imagePath).match(/\.[^.]+$/)?.[0] || "");
const outputPath = join(dir, `${nameWithoutExt}-nobg.png`);
writeFileSync(outputPath, buffer);
console.log("Saved:", outputPath);
EOF
```
Replace `INPUT_IMAGE_PATH` with the actual path to the image.
## Model Options
The BiRefNet model supports different configurations:
### Model Variants
- `"General Use (Light)"` - Fast, good for most images (default)
- `"General Use (Heavy)"` - Higher quality, slower processing
- `"Portrait"` - Optimized for human subjects
- `"Matting"` - Best for complex edges like hair
### Operating Resolutions
- `"1024x1024"` - Standard quality (default)
- `"2048x2048"` - Higher detail for large images
### Additional Options
- `refine_foreground: true` - Improve edge quality
- `output_format: "png"` - Always use PNG for transparency
## Configuration Example
For high-quality portrait extraction:
```bash
bun run - << 'EOF'
import { fal } from "@fal-ai/client";
import { readFileSync, writeFileSync } from "fs";
import { basename, dirname, join } from "path";
const imagePath = "INPUT_IMAGE_PATH";
const imageBuffer = readFileSync(imagePath);
const fileName = basename(imagePath);
const mimeType = imagePath.endsWith(".png") ? "image/png" : "image/jpeg";
const file = new File([imageBuffer], fileName, { type: mimeType });
const imageUrl = await fal.storage.upload(file);
const result = await fal.subscribe("fal-ai/birefnet/v2", {
input: {
image_url: imageUrl,
model: "Portrait",
operating_resolution: "2048x2048",
refine_foreground: true,
output_format: "png"
},
logs: true,
onQueueUpdate: (update) => {
if (update.status === "IN_PROGRESS" && update.logs) {
update.logs.map((log) => log.message).forEach(console.log);
}
},
});
const response = await fetch(result.data.image.url);
const buffer = Buffer.from(await response.arrayBuffer());
const dir = dirname(imagePath);
const nameWithoutExt = basename(imagePath, basename(imagePath).match(/\.[^.]+$/)?.[0] || "");
const outputPath = join(dir, `${nameWithoutExt}-nobg.png`);
writeFileSync(outputPath, buffer);
console.log("Saved:", outputPath);
EOF
```
## Key Principles
1. **Check prerequisites**: Always verify Bun is installed before running
2. **Ask before installing**: Get user permission before `npm install -g bun`
3. **Use heredocs**: Run inline scripts for one-off operations
4. **Preserve location**: Save output next to input with `-nobg` suffix
5. **Always PNG**: Output format must be PNG for transparency
## Workflow
1. **Verify Bun** is installed (offer to install if not)
2. **Verify FAL_KEY** is set
3. **Run the script** with the input image path
4. **Check the output** - view the saved PNG with transparent background
## Error Recovery
If a script fails:
1. Check FAL_KEY is set: `echo $FAL_KEY`
2. Verify image path exists and is readable
3. Check FAL.ai dashboard for quota/billing issues
4. Try a smaller image if upload fails
## API Response Format
The BiRefNet model returns:
```json
{
"image": {
"url": "https://...",
"width": 1024,
"height": 1024,
"content_type": "image/png",
"file_name": "birefnet-output.png"
}
}
```
## Advanced Usage
For batch processing, URL-based inputs, or integration with other tools, see `references/guide.md`.Related Skills
bgo
Automates the complete Blender build-go workflow, from building and packaging your extension/add-on to removing old versions, installing, enabling, and launching Blender for quick testing and iteration.
debug
Debug container agent issues. Use when things aren't working, container fails, authentication problems, or to understand how the container system works. Covers logs, environment variables, mounts, and common issues.
debug-validator-checkpoint-inconsistency
Debug validator checkpoint inconsistencies where some validators are behind others. Use when alerts mention "checkpoint inconsistency", "validators behind", or "inconsistent latest checkpoints", or when asked to debug validator sets, investigate validator delays, or troubleshoot metadata fetch failures for a chain. Defaults to default_ism app context if not specified.
debug-log-patterns
Language-specific debug logging patterns and best practices. Reference when adding instrumentation for Dart/Flutter, Kotlin/Android, Swift/iOS, or JavaScript/TypeScript applications.
debug-detective
Systematic debugging approach for ANY codebase, ANY language, ANY bug type. Use when facing unexpected behavior, crashes, performance issues, or intermittent problems.
debug:angular
Debug Angular applications systematically with expert-level diagnostic techniques. This skill provides comprehensive guidance for troubleshooting dependency injection errors, change detection issues (NG0100), RxJS subscription leaks, lazy loading failures, zone.js problems, and common Angular runtime errors. Includes structured four-phase debugging methodology, Angular DevTools usage, console debugging utilities (ng.probe), and performance profiling strategies for modern Angular applications.
De-novo-motif-discovery
This skill identifies novel transcription factor binding motifs in the promoter regions of genes, or directly from genomic regions of interest such as ChIP-seq peaks, ATAC-seq accessible sites, or differentially acessible regions. It employs HOMER (Hypergeometric Optimization of Motif Enrichment) to detect both known and previously uncharacterized sequence motifs enriched within the supplied genomic intervals. Use the skill when you need to uncover sequence motifs enriched or want to know which TFs might regulate the target regions.
ddd-tactical-patterns
Apply DDD tactical patterns in code using entities, value objects, aggregates, repositories, and domain events with explicit invariants.
ddd-context-mapping
Map relationships between bounded contexts and define integration contracts using DDD context mapping patterns.
dd-logs
Log management - search, pipelines, archives, and cost control.
dd-apm
APM - traces, services, dependencies, performance analysis.
dcg
Destructive Command Guard - High-performance Rust hook for Claude Code that blocks dangerous commands before execution. SIMD-accelerated, modular pack system, whitelist-first architecture. Essential safety layer for agent workflows.