Skip to content

Guide · Agent skill

How to use the Image Compressor agent skill (baoyu-compress-image)

Updated · written with AI from the project's own documentation and checked against our catalogue data

baoyu-compress-image is an agent skill that lets an AI agent shrink images or convert them to WebP, a web-friendly format, without you running the tool yourself. This guide is for people who have never installed an agent skill before and want smaller image files for websites, email or uploads. By the end you will know how to install the skill, ask for compression in plain language, and check the results.

Image CompressorJimLiu/baoyu-skills · MIT

Quick start

  1. 1Get the ZIP. Download the baoyu-compress-image skill ZIP from this page.
  2. 2Install the folder. Unzip it into ~/.claude/skills/ for personal use, or into .claude/skills/ inside a project.
  3. 3Or upload in the Claude apps. Go to Settings → Capabilities → Skills and upload the ZIP.
  4. 4Check Bun. Make sure bun is installed, or that npx is available to run it.
  5. 5Back up your images. Copy anything you cannot afford to lose, since the default replaces originals.
  6. 6Ask in plain language. Request compression by file or folder name, for example compress image.png to WebP.
  7. 7Review the savings. Read the before and after sizes the agent reports and check the output looks right.

What an agent skill is and what this one does

An agent skill is a folder of instructions and scripts that an AI agent can load when a task matches it. This skill contains a SKILL.md file describing the task and a TypeScript script, scripts/main.ts, that does the actual compression.

Once installed, the agent can take a single image or a whole folder and make the files smaller. It converts them to WebP by default, and it can also output PNG or JPEG. It chooses the best compression tool available on your computer from sips (macOS), cwebp, ImageMagick or the Sharp library, and reports how much space was saved.

  • Default output: WebP at quality 80
  • Other formats: PNG and JPEG
  • Reports size before and after, with the percentage reduction
  • By default it replaces the original file unless you ask it to keep a copy

What you need before installing

The skill runs through the Bun runtime. The skill's metadata lists bun or npx as acceptable. If bun is installed, the agent uses it directly. If npx is available, it runs bun through npx -y bun. If neither is present, the agent will suggest installing bun.

The image tools are optional. The skill detects whatever is on your machine and uses the best one available, in the order sips, cwebp, ImageMagick, then Sharp.

  • Bun, or npx (to run bun)
  • Optional: sips (macOS), cwebp, ImageMagick or the Sharp library

Install the skill in Claude

Option 1, personal install: download the skill ZIP from this page and unzip it into ~/.claude/skills/ so the folder sits there as baoyu-compress-image. This makes it available across your projects.

Option 2, project install: unzip it into the .claude/skills/ folder inside a specific project. It then applies only to that project.

Option 3, Claude apps: upload the ZIP in the Claude apps under Settings → Capabilities → Skills.

  • Personal: ~/.claude/skills/
  • Project: .claude/skills/ inside your project folder
  • Claude apps: Settings → Capabilities → Skills

Trigger the skill with natural requests

You do not need to type a command. The skill's description tells the agent when to use it, so ordinary requests work. The description lists phrases such as "compress image", "optimize image", "convert to webp" and "reduce image file size".

Name the file or folder and, if you care, the format or quality. The agent will then run the script for you.

  • "Compress image.png to WebP."
  • "Optimize every image in ./images/ including subfolders."
  • "Convert hero.png to webp at quality 75."
  • "Reduce the file size of photo.jpg but keep the original."

Run it yourself from the command line

If you prefer to run the script directly, the usage pattern is below. The {baseDir} placeholder is the skill's own folder, and ${BUN_X} is bun or npx -y bun depending on what you have installed.

Options: --output (-o) sets an output path, defaulting to the same path with a new extension. --format (-f) accepts webp, png or jpeg, default webp. --quality (-q) takes 0 to 100, default 80. --keep (-k) keeps the original, default off. --recursive (-r) processes subfolders, default off. --json switches to JSON output.

  • --output / -o: output path
  • --format / -f: webp, png or jpeg (default webp)
  • --quality / -q: 0 to 100 (default 80)
  • --keep / -k: keep the original (default false)
  • --recursive / -r: include subdirectories (default false)
  • --json: JSON output
${BUN_X} {baseDir}/scripts/main.ts <input> [options]

Examples you can adapt

These are the examples from the skill's documentation. A single file is converted to WebP and the original is replaced. Adding -f png --keep writes a PNG and leaves the source in place. Pointing at a folder with -r -q 75 processes subfolders at quality 75. The --json flag prints machine-readable output.

A typical result line looks like this: the file is converted and the size change and percentage are printed.

${BUN_X} {baseDir}/scripts/main.ts image.png ${BUN_X} {baseDir}/scripts/main.ts image.png -f png --keep ${BUN_X} {baseDir}/scripts/main.ts ./images/ -r -q 75 ${BUN_X} {baseDir}/scripts/main.ts image.png --json

Set personal defaults with EXTEND.md

You can save preferences so you do not repeat them. The skill checks three EXTEND.md locations in order and uses the first one it finds: a project file at .baoyu-skills/baoyu-compress-image/EXTEND.md, then ${XDG_CONFIG_HOME:-$HOME/.config}/baoyu-skills/baoyu-compress-image/EXTEND.md, then $HOME/.baoyu-skills/baoyu-compress-image/EXTEND.md. If none exists, defaults apply.

The file can set a default format, a default quality and a keep-original preference.

Safety notes: overwriting, scripts and network

By default the script replaces the original image. Lossy compression is irreversible, and the default quality of 80 is lossy. Back up files first, or use the keep option. The script can delete originals, so review what the agent is about to process when working on important folders.

The skill runs scripts, so it executes code on your machine through Bun. It does not use the network, according to its metadata.

  • Back up originals before batch runs
  • Use --keep (or keep-original in EXTEND.md) to retain sources
  • Avoid it for lossless archival or print work where quality loss matters

What people use it for

  • Shrinking blog or website images to WebP before upload
  • Reducing photo sizes for email attachments
  • Batch-converting a folder of PNGs to WebP with -r
  • Keeping PNG output with --keep while still reducing file size where possible
  • Scripting conversions with --json for further processing

Frequently asked questions

Is the baoyu-compress-image skill free?

The skill is published under the MIT licence, as stated on this page. Check the licence file in the source repository for the full terms before redistributing it.

How do I install baoyu-compress-image?

Download the ZIP from this page and unzip it into ~/.claude/skills/ for personal use or .claude/skills/ inside a project. You can also upload the ZIP in the Claude apps under Settings → Capabilities → Skills.

What does baoyu-compress-image require?

It requires the Bun runtime, or npx so that bun can be run. Image tools are optional: sips on macOS, cwebp, ImageMagick or Sharp, detected automatically.

Does it overwrite my original images?

Yes, by default the original is replaced. Use the keep option (--keep or -k) or set keep-original in EXTEND.md to retain the source file.

Does the skill send my images over the internet?

The skill's metadata says it does not use the network. It does run scripts on your machine, so it executes code locally through Bun.

Why is my image quality lower after compression?

The default quality is 80 and compression is lossy, so some detail is discarded and cannot be recovered. Raise the value with --quality or -q, for example 90, or keep the original.

New agent skills, repos and AI tools — every week

The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.

Our verdict

Use this skill if you want an agent to shrink images or convert them to WebP quickly, especially across folders, and you keep backups. Pick another approach if you need lossless archives or print-quality files, since the default settings are lossy and overwrite originals.

Download the skill