CLI Reference

Image Optimization CLI Guide

AssetFlow CLI provides a terminal-first workflow to audit, optimize, and watch project assets entirely offline. Learn how to configure flags, use caching daemon rules, and run git hooks.

Global Configuration Flags

These flags can be appended to any optimization command to customize target formatting, quality standards, and execution logs:

-d, --dry-run

Scans and estimates file size savings without modifying or overwriting any files in your directories.

-c, --changed

Filters optimization targets using Git. Processes only modified, staged, or untracked changes. Perfect for pre-commit hooks!

-f, --format <type>

Overrides default format settings. Choose between webp, avif, or both.

-q, --quality <num>

Set custom compression quality score (1 to 100). Default value is set to 80.

--force

Forces reprocessing of all image targets, completely bypassing local SHA-256 caching checks.

--no-animations

Disables CLI terminal loading states, progress bars, and animations. Highly recommended for automated CI/CD logs.

CLI Commands Reference

AssetFlow supports five primary subcommands to configure, run, and audit your assets:

1. Initialize Default Config: init

Generates a clean configuration file assetflow.config.json in your project root with sensible, optimized default parameters.

bash
assetflow init

2. Optimize Target Directory: optimize

Discovers and optimizes assets matching standard image types. Uses high-performance local compilation and automatically caches SHA-256 signatures to skip un-modified assets on consecutive runs.

bash
assetflow optimize --src=public/images --dest=public/dist --widths=640,1280

3. Watch Daemon Mode: watch

Spawns a local folder watcher daemon that monitors additions, modifications, or deletions in real-time, optimizing new assets instantly upon saving.

bash
assetflow watch --src=src/assets --dest=public/dist

4. Image Optimization Doctor: doctor

Performs a complete diagnostic scan on your project asset structures. Generates a performance health scorecard, flags unoptimized images, identifies potential LCP (Largest Contentful Paint) risks, and outlines solutions.

bash
assetflow doctor

5. Historical Savings Metrics: report

Displays total savings, compression stats, configuration details, and logs historic runs. Can export findings to JSON using the --json option.

bash
assetflow report --json

Configuration File Schema

Customize defaults permanently by updating keys inside your local assetflow.config.json:

json
{
  "format": "webp",
  "quality": 80,
  "preset": "balanced",
  "responsive": false,
  "deleteOriginal": false,
  "keepMetadata": false
}
format"webp" | "avif" | "both"
preset"balanced" | "quality" | "compression"
deleteOriginalDelete original files after export