AGENT SKILL

image-optimizer

Optimize images to WebP format. Scans a directory, converts jpg/png/gif/bmp/tiff to WebP using sharp, reports compression results. Run with input/output path arguments.

License 许可
MIT
最近更新
2026-03-27
Stars
★ 3
Forks
1

01 前言 Front Matter

name
image-optimizer
description
Optimize images to WebP format. Scans a directory, converts jpg/png/gif/bmp/tiff to WebP using sharp, reports compression results. Run with input/output path arguments.
argument-hint
[input directory] [optional: output directory]

02 资源文件 1

03 SKILL.md 正文

Image Optimizer

Convert project images to WebP. Uses the bundled optimize-images.js script with sharp.

When to Use

  • After adding new images to the project
  • Before deployment to reduce asset size
  • When Lighthouse flags image optimization
  • Pre-optimized WebP avoids Next.js build-time conversion overhead

Procedure

1. Determine paths

  • If $ARGUMENTS provides paths, use them
  • Otherwise scan for common image directories: public/images/, public/assets/, src/assets/, assets/
  • Ask: "Replace originals or save to separate directory?"

2. Ensure sharp is available

node -e "require('sharp')" 2>/dev/null || npm install --no-save sharp

3. Run the optimizer

The script is at .claude/skills/image-optimizer/optimize-images.js:

# Replace originals with WebP
node .claude/skills/image-optimizer/optimize-images.js public/images

# Separate output directory
node .claude/skills/image-optimizer/optimize-images.js public/images public/images-webp

# Custom quality (90) and max dimensions (2560x1440)
node .claude/skills/image-optimizer/optimize-images.js public/images public/images 90 2560 1440
Argument Default Description
input_dir (required) Directory to scan for images
output_dir same as input Where to write WebP files. Same dir = replace originals
quality 80 WebP quality 1-100
max_width 1920 Downscale wider images (no upscaling)
max_height 1080 Downscale taller images (no upscaling)

4. Update source references

After conversion, find and replace old image references:

grep -rn "\.png\|\.jpg\|\.jpeg" --include="*.tsx" --include="*.ts" --include="*.css" src/ app/

Replace .png / .jpg extensions with .webp in source code.

5. Verify

npx tsc --noEmit   # or npx next build

Notes

  • Supported inputs: jpg, jpeg, png, gif, bmp, tiff
  • Animated GIFs lose animation in WebP — warn user before converting
  • Sharp is the same library Next.js uses internally

04 同仓库更多 Skills

ByeongminLee
ByeongminLee/nextjs-claude-code

zustand

Zustand state management guide. Use when working with store code (src/store/**), implementing actions, managing state, or creating slices. Triggers on Zustand store development, state management questions, or action implementation.

★ 3
ByeongminLee
ByeongminLee/nextjs-claude-code

web-vitals

暂无简介

★ 3
ByeongminLee
ByeongminLee/nextjs-claude-code

vercel-storage

Vercel storage expert guidance — Blob, Edge Config, and Marketplace storage (Neon Postgres, Upstash Redis). Use when choosing, configuring, or using data storage with Vercel applications.

★ 3
ByeongminLee
ByeongminLee/nextjs-claude-code

vercel-functions

Vercel Functions expert guidance — Serverless Functions, Edge Functions, Fluid Compute, streaming, Cron Jobs, and runtime configuration. Use when configuring, debugging, or optimizing server-side code running on Vercel.

★ 3
ByeongminLee
ByeongminLee/nextjs-claude-code

ui-ux-pro-max

UI/UX design intelligence for web and mobile. Includes 50+ styles, 161 color palettes, 57 font pairings, 161 product types, 99 UX guidelines, and 25 chart types across 10 stacks (React, Next.js, Vue, Svelte, SwiftUI, React Native, Flutter, Tailwind, shadcn/ui, and HTML/CSS). Actions: plan, build, create, design, implement, review, fix, improve, optimize, enhance, refactor, and check UI/UX code. Projects: website, landing page, dashboard, admin panel, e-commerce, SaaS, portfolio, blog, and mobile app. Elements: button, modal, navbar, sidebar, card, table, form, and chart. Styles: glassmorphism, claymorphism, minimalism, brutalism, neumorphism, bento grid, dark mode, responsive, skeuomorphism, and flat design. Topics: color systems, accessibility, animation, layout, typography, font pairing, spacing, interaction states, shadow, and gradient. Integrations: shadcn/ui MCP for component search and examples.

★ 3
ByeongminLee
ByeongminLee/nextjs-claude-code

turborepo

Turborepo monorepo build system guidance. Triggers on: turbo.json, task pipelines, dependsOn, caching, remote cache, the "turbo" CLI, --filter, --affected, CI optimization, environment variables, internal packages, monorepo structure/best practices, and boundaries. Use when user: configures tasks/workflows/pipelines, creates packages, sets up monorepo, shares code between apps, runs changed/affected packages, debugs cache, or has apps/packages directories.

★ 3