跳到正文
cccskills
免费在 GitHub 公开

images

Responsive image generation and audit through a deterministic hook. It encodes every declared master into AVIF and WebP at the widths devices actually render, detects drift between masters and their generated variants, and pairs with the Picture component so pages serve the smallest fitting source. Use when adding, changing, or auditing raster images.

中文简介正在准备中。当前显示原文说明。

wellwelwel/weslley.io星标 13(GitHub 13 + cccskills 0)

实测评分 未实测

查看安装方法

包含的文件(1)

  • SKILL.md5.2 KB

SKILL.md(原文)

安装前可以查看交给 AI 代理的指令内容。

Responsive images

This skill owns how raster images reach the browser. Masters stay the only edited files, and everything a device downloads is derived from them by the hook: modern formats at a ladder of widths, a catalog the Picture component reads to build its sources, and a lock that ties the generated set to the exact master bytes that produced it.

Generate, never hand-export

Every derived image comes from the hook, so the whole set is reproducible from the masters and the manifest alone. A claim that an image is optimized is a verdict printed by the hook, not an impression from a file listing. When a master or the recipe that encoded it changes, the lock stops matching and the drift is a failing check, never a silent regression.

When to use it

Reach for it when a raster image enters the project, when a master is edited or replaced, when a page ships more image bytes than its layout can display, and as a gate before releasing a change that touches images. Vector files are out of scope, since they already scale.

How it works

The manifest declares each master, the widths its usages need, and whether its group encodes lossless. A build encodes every declared master into AVIF and WebP at those widths, writes the variants beside the master named by width, content stamp, and format, refreshes the catalog that maps each public path to its ladder, stamp, and intrinsic size, and records the master's hash and encode recipe in the lock. The stamp derives from the master bytes and the recipe, so any change also changes every variant URL, no cache can keep serving old bytes, and the build removes the variants a previous recipe produced. Verify replays that contract read-only and fails on any divergence. Scan inventories every raster under the static assets, heaviest first, and marks the ones the manifest does not cover.

On the page, the Picture component looks the image up in the catalog. A covered image renders as a picture element offering AVIF and WebP ladders with the master as fallback. An uncovered image renders as a plain img, so adopting it is never a breaking change.

Conventions

  • Widths come from the rendered size multiplied by the device pixel ratios worth serving, never from the master's own size. Small flat art lists those products exactly, so the browser picks a one-to-one source and never resamples what the hook already resized once.
  • Photographic and soft content compresses lossy at the default qualities. Flat-color art (logos, icons, badges with text) declares lossless in its group, since hard edges are exactly where lossy artifacts live.
  • The ladder never upscales: a width above the master clamps to the master, and the srcset only declares real pixels.
  • The caller passes a sizes attribute describing the slot the layout gives the image, since only the call site knows it.
  • The layout owns the rendered size through its own styles, on both axes or one axis plus a CSS aspect ratio. The component writes no dimension attributes, because a height hint sets a used height that defeats a CSS aspect ratio, and the catalog records each master's intrinsic size instead.
  • Images below the fold or outside the first viewport load lazily, and only the likely largest contentful paint carries a high fetch priority.
  • Generated variants, the catalog, and the lock are committed, so a build is reproducible without re-encoding and a stale set fails verification anywhere.

Dependencies

The hook needs sharp. Check it with npm ls sharp and install it as a development dependency with the package manager the root lockfile points to when it is missing.

Running it

The hook lives in the project, at tools/images.ts, and is exposed as npm scripts:

npm run images:scan
npm run images:build
npm run images:verify
FlagPurpose
--manifestManifest to read, tools/images.json by default
--dirDirectory scan walks, the static assets directory by default

Verdicts

CommandVerdicts
buildbuilt when variants were encoded, fresh when the lock already matched
verifyok, stale on hash mismatch, missing on absent files, orphan for lock leftovers
scanmanaged when the manifest covers the file, unmanaged when it does not, heaviest first

verify exits non-zero on anything but ok, and build and scan exit non-zero only on failure, so both gates fit CI unchanged.

评价

还没有评价。欢迎分享你的使用感受。

评论

无需登录即可发表。欢迎分享使用感受、提问,或说明在哪些环境下无法运行。

还没有评论。来写第一条吧。

提交后会立即公开。请勿填写邮箱、电话等个人信息。URL 最多 2 个。

0 / 1000 字

此表单受 reCAPTCHA 保护,适用 Google 的隐私权政策和服务条款。

同一仓库的技能

cdp

免费

Visual verification of a running page through Chrome's DevTools Protocol, capturing screenshots and measuring the rendered DOM. Use when a frontend change can only be confirmed once rendered, for layout, spacing, alignment, overflow, or theme tokens.

中文简介正在准备中。当前显示原文说明。

wellwelwel/weslley.io132026年10月26日 更新

Authoritative engineering reference covering code conventions, comments, TypeScript type rules, testing, and commit messages. Use before writing or changing any source file, and when suggesting a commit message.

中文简介正在准备中。当前显示原文说明。

wellwelwel/weslley.io132026年10月26日 更新

ui

免费

Design engineering principles for making interfaces feel polished. Use when building UI, reviewing frontend code, or working on any visual detail, from animations, hover states, shadows, borders, and typography to optical alignment and tabular numbers.

中文简介正在准备中。当前显示原文说明。

wellwelwel/weslley.io132026年10月26日 更新

writer

免费

Authoritative reference for writing the project's prose. Use before writing, editing, or translating any document, command text, comment, or user-facing message.

中文简介正在准备中。当前显示原文说明。

wellwelwel/weslley.io132026年10月26日 更新

查看 wellwelwel 的全部技能

报告此技能的问题