Skip to content
Skills Library
Programming · Building & coding

optimize-assets

/optimize-assets

Make every asset of a finished three.js web game as small as web use allows before it is published — GLB textures and geometry, 2D images, music and sound effects — without quietly changing how it looks or sounds. Writes design/optimize.json, which `pnpm release` applies to the dist/ copies only, so public/ keeps the full-quality sources. Near-lossless settings are applied after screenshots prove them identical; bigger savings are measured one by one and shown to the user as one table to pick from. Use when a game is ready to publish, when the user asks to shrink the download, or when a releas

Licence
Apache-2.0
Last repository change
13.11.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
4
Scripts
2
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 13.11.2026, without references to retired models or APIs.

Licence

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

What to check before installing
  • 2 scripts in this package. Review them before installing, as Claude may execute them.

Scripts: scripts/compare-shots.ts, scripts/optimize-assets.ts

What it does and when to use it

Make every asset of a finished three.js web game as small as web use allows before it is published — GLB textures and geometry, 2D images, music and sound effects — without quietly changing how it looks or sounds. Writes design/optimize.json, which `pnpm release` applies to the dist/ copies only, so public/ keeps the full-quality sources. Near-lossless settings are applied after screenshots prove them identical; bigger savings are measured one by one and shown to the user as one table to pick from. Use when a game is ready to publish, when the user asks to shrink the download, or when a releas

Original author description

Make every asset of a finished three.js web game as small as web use allows before it is published — GLB textures and geometry, 2D images, music and sound effects — without quietly changing how it looks or sounds. Writes design/optimize.json, which `pnpm release` applies to the dist/ copies only, so public/ keeps the full-quality sources. Near-lossless settings are applied after screenshots prove them identical; bigger savings are measured one by one and shown to the user as one table to pick from. Use when a game is ready to publish, when the user asks to shrink the download, or when a releas

How it works

  1. 1. Baseline
  2. 2. Near-lossless defaults
  3. 3. Measure each visible candidate
  4. 4. One table for the user
  5. 5. Verify and report
  6. Gotchas
Original SKILL.md headings · 67 lines, 897 words
SKILL.md preview
---
name: optimize-assets
description: Make every asset of a finished three.js web game as small as web use allows before it is published — GLB textures and geometry, 2D images, music and sound effects — without quietly changing how it looks or sounds. Writes design/optimize.json, which `pnpm release` applies to the dist/ copies only, so public/ keeps the full-quality sources. Near-lossless settings are applied after screenshots prove them identical; bigger savings are measured one by one and shown to the user as one table to pick from. Use when a game is ready to publish, when the user asks to shrink the download, or when a release build is over its size budget.
---

# optimize-assets

Games are built fidelity-first (`make-web-game`): assets match the reference with no budgets. This is the pass that makes them web-sized once the user likes the game. Two rules:
- **Sources stay full quality.** Every setting goes in `design/optimize.json`; `pnpm release` applies it to the copies in `dist/`. Art iteration keeps working on `public/` and `assets/src/` as before, and the next release re-applies the settings.
- **The look and sound only change with the user's OK.** Near-lossless settings are kept only when the release screenshots are identical; anything bigger is shown to the user with its measured gain.

Files:
- `scripts/optimize-assets.ts`: `inventory`, `propose`, `trial <id>`, `check`, `apply <id...>` and `decline <id...>`.
- `scripts/compare-shots.ts`: SSIM per screenshot between two playtest runs ("same" at ≥ 0.985), with side-by-side images for changed shots.
- `references/settings.md`: every setting, what it saves, whether it is near-lossless or visible, and the options not automated yet.

Uses sibling skills by name: `game-judge` (playtest, visual panel), `publish-web-game` (`pnpm release` applies the settings), `blender-assets` (asset scripts, for changes a setting can't make).

Run from the game project. Needs the template's devDependencies (gltf-transform, meshoptimizer, sharp) and ffmpeg.

## 1. Baseline
```bash
node scripts/release.ts --optimize none.json            # today's release, no settings applied
node <game-judge>/scripts/playtest.ts --perf 0 --out .lab/optimize/base-run
node <skill>/scripts/optimize-assets.ts inventory       # where the bytes are, biggest first
```
Read the inventory before changing anything. It shows per GLB the triangles, the three biggest meshes and the textures; per audio file the length, channels and bitrate; per image its size. The shipped sizes (after the release's lossless GLB compression, plus JS and wasm) are in `dist/release-report.json`.

## 2. Near-lossless defaults
```bash
node <skill>/scripts/optimize-assets.ts propose         # writes design/optimize.json + .lab/optimize/candidates.json
pnpm release                                            # applies it; prints a line per optimized file
node <game-judge>/scripts/playtest.ts --perf 0 --out .lab/optimize/opt-run
node <skill>/scripts/compare-shots.ts .lab/optimize/base-run .lab/optimize/opt-run --backend webgpu
node <skill>/scripts/compare-shots.ts .lab/optimize/base-run .lab/optimize/opt-run --backend webgl2
node <skill>/scripts/optimize-assets.ts check           # images the screenshots never show (splash, icon)
```
Keep the defaults only if the playtest passes, every screenshot is "same" and `check` passes. If something moved, remove the setting that moved it from `optimize.json` (or raise its quality) and run again. `propose` keeps entries already in the file, so a second pass never undoes the user's choices.

## 3. Measure each visible candidate
`propose` lists them in `.lab/optimize/candidates.json`: GLB simplification for big meshes, smaller textures, lower music bitrate, lower image quality. For each one:
```bash
node <skill>/scripts/optimize-assets.ts trial <id>      # releases with and without it: KB saved (gzip and raw)
node <game-judge>/scripts/playtest.ts --perf 0 --out <trial dir>/run
node <skill>/scripts/compare-shots.ts .lab/optimize/opt-run <trial dir>/run
```
Drop a candidate that saves nothing: hosts gzip GLBs (GitHub Pages does), and simplified geometry can compress *worse* than the regular original. Note what a screenshot cannot judge: audio (listen to it on the dev link), and anything off screen in the scenarios.

## 4. One table for the user
Show every candidate that saves something in **one table**: asset · change · KB saved (gzip) · screenshots (SSIM, worst) · side-by-side image path · what gets worse, in plain words. Ask once which to apply. Then:
```bash
node <skill>/scripts/optimize-assets.ts apply <id...>
node <skill>/scripts/optimize-assets.ts decline <id...>
```
Both write to `decisions` in `optimize.json`, so a later pass doesn't ask again. In unattended runs, apply none and put the table in the report.

## 5. Verify and report
- `pnpm release` passes and the playtest passes on WebGPU and WebGL2 with no console errors.
- If an accepted change moved a gameplay screenshot, re-run the `game-judge` visual-fidelity panel and report the score before and after. With every shot "same" the panel would only re-score identical images: say so instead.
- Report the shipped size before and after (total MB gzip and the biggest files), each accepted and declined trade, and what is still big and why: wasm, or an asset whose fix belongs in its asset script (see Gotchas).
- Commit `design/optimize.json`. `.lab/` is generated.

## Gotchas
- **Look at the inventory's biggest meshes first.** If one GLB is mostly a repeated small mesh (grass blades: 216k of Blossom Swing's 330k triangles), the fix is in the asset script: `L.instances` (blender-assets) stores the blade once with a transform per copy. Blossom Swing's shipped world.glb fell from 886 to 395 KB gzip, and the simplify it had accepted before then grew the file: re-trial simplify after instancing.
- **Music loops keep their exact length.** The release re-encodes with LAME and refuses a result whose sample count differs from the source, so the seam can't drift. Count samples from files, never through a pipe: from a pipe ffmpeg can't read the gapless header and adds about 224 samples.
- **PNG stays lossless.** sharp's `effort` or `palette` options quantize PNGs to a palette. The release writes PNGs with `compressionLevel` only, and keeps a re-encode only when it is smaller.
- **A texture re-encode can grow a GLB.** A small JPEG made by `import_glb` is often smaller than WebP q90, so the release builds both and keeps the smaller one.
- **Never simplify by wildcard.** Thin parts (ropes, blades, fences) can break up, so name each GLB in `models`.
- **UVs out of [0,1] are not quantized.** Tube UVs in metres for bark grain stay float32. That costs some bytes, but quantizing them would break the effect.
- **Release-only bugs.** Quantization moves each mesh's dequantize transform into its node. Compare release screenshots, not dev ones (see `publish-web-game`).
Files in this package (4)
  • SKILL.md 7 KB
  • references/settings.md 3 KB
  • scripts/compare-shots.ts 4 KB
  • scripts/optimize-assets.ts 16 KB

Versions

The database has no other skills named optimize-assets.

Database snapshot: 13.11.2026 · package version 01d214b69448 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 0 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100optimize-web-game
    Make a finished three.js web game run well on a target device (laptop, phone, low-end) and download fast, without quietly degrading how it looks. Measures first, applies the changes that leave the image unchanged, and asks the user before any trade of visual quality for speed or…
  • 100game-assets
    Plan games and create, edit, upgrade, animate, and prepare production-ready game assets with Meowa. Use for Game Designer research and design documents, pixel or HD sprites, consistent variants, multi-view or Spine characters, UI sheets, image and frame edits, Pindou bead art,…
  • 100add-audio
    Add music and sound effects to a game using the Web Audio API — background music, gameplay themes, and SFX. Zero dependencies. Use when the user says "add music", "add sound effects", "add audio", "make it sound good", "add BGM", or "add SFX to my game". Do NOT use for gameplay…
  • 100assetcat
    Find, check and pull game assets (sprites, tilesets, sounds, music, fonts, 3D models) from the user's indexed asset library with the `assetcat` CLI. Use when the user asks for assets for a game or prototype, wants to know what they own ("do I have a pixel-art dungeon tileset?"),…
  • 100game-size-and-performance
    Reduce mobile-game download size, installed footprint and asset/SDK bloat while protecting quality and runtime performance. Use for compression, app-store size limits, Godot import/export tuning and release size regressions.
  • 90build-hybrid-game-assets
    Plan, create, integrate, or audit a hybrid asset pipeline for a Three.js or web game. Use when choosing among imported meshes, procedural 3D geometry, AI-generated reference art, 2D UI media, sprites, VFX, and performance-ready runtime asset delivery.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.