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-runScans and estimates file size savings without modifying or overwriting any files in your directories.
-c, --changedFilters 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.
--forceForces reprocessing of all image targets, completely bypassing local SHA-256 caching checks.
--no-animationsDisables 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.
assetflow init2. 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.
assetflow optimize --src=public/images --dest=public/dist --widths=640,12803. 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.
assetflow watch --src=src/assets --dest=public/dist4. 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.
assetflow doctor5. Historical Savings Metrics: report
Displays total savings, compression stats, configuration details, and logs historic runs. Can export findings to JSON using the --json option.
assetflow report --jsonConfiguration File Schema
Customize defaults permanently by updating keys inside your local assetflow.config.json:
{
"format": "webp",
"quality": 80,
"preset": "balanced",
"responsive": false,
"deleteOriginal": false,
"keepMetadata": false
}