Wiring pre-build image optimization into Astro and Next.js
Run command-line image compression automatically before static site exports hit production.
Use Claude Code or Codex to run @pipic/cli during development, processing local assets in place without manually managing terminal commands.
AI coding agents operating in your terminal do more than generate functions or fix typos. They run shell commands, clean build directories, and manage project files. When you build a web project containing heavy graphics, asking an agent to handle file reduction removes manual steps from your development workflow.
Instead of switching windows to drag files into a browser tool or writing custom bash loops, you can instruct terminal agents like Claude Code or Codex to execute @pipic/cli directly. The utility processes local assets in place or writes them to a new output directory while preserving exact image dimensions and file extensions.
The command-line utility is open-sourced on GitHub and published as @pipic/cli on npm. You can inspect every line of the source code before installing it in your workspace.
To let terminal agents run the tool without manual prompts, complete the sign-in step once. After authenticating, local scripts, continuous integration builds, and interactive agents execute unattended without requiring ongoing credentials.
The free tier for @pipic/cli includes 100 image compressions per month. For larger codebases or recurring batch optimization, the Pro plan increases the monthly limit to 5,000 images. If you need to review standalone command syntax before delegating tasks to an agent, consult our guide on automating static asset compression from the command line.
When prompting Claude Code or Codex inside your workspace, keep instructions direct and specific. Name the target folder clearly and specify whether the operation should replace files in place or output to a separate directory.
A clear prompt tells the agent: "Compress all images inside public/images in place using @pipic/cli."
The agent inspects the target directory, identifies supported files, and executes the optimization. JPG, PNG, WebP, and AVIF formats are compressed and written directly over the original files using an atomic in-place replace. File extensions and pixel dimensions remain identical, so local relative imports and HTML image tags continue working without modification.
If your project structure requires preserving original uncompressed assets, adjust the prompt instruction: "Run @pipic/cli on assets/raw and save the output to assets/dist." The agent will create the target destination and write compressed copies without altering source files.
Delegating local file tasks to command-line utilities requires strict guarantees around asset handling and data tracking. The @pipic/cli tool sends exactly one payload over the network: the specific image file selected for compression. It collects no telemetry about your local machine, repository name, system environment, or developer identity.
When an image reaches the processing server, it undergoes compression and is deleted immediately afterward. No copies remain on disk, no persistent server backups are generated, and uploaded assets are never reused or processed as training data. This zero-retention model makes agent-driven execution safe when working inside private client codebases or proprietary asset repositories.
Running interactive compression commands during active development prevents uncompressed images from accumulating in your git history. Asking an agent to compress newly added asset folders before committing code reduces repository bloat early.
This terminal workflow fits into broader site preparation alongside optimizing raw asset directories before static site deployment. Terminal agents can audit raw folders, compress files via @pipic/cli, and confirm directory sizes before site static exports trigger.
For quick one-off tasks where terminal access is unavailable, the free web compressor at pipic.cc handles batches of up to 100 images and 8 MB per file in the browser without an account. For developers working primarily inside terminal windows, prompting Claude Code or Codex to execute @pipic/cli keeps asset management fully contained within your active coding session.
Run command-line image compression automatically before static site exports hit production.
Evaluating browser apps, build scripts, local utilities, and terminal tools for modern image optimization.
A practical guide to shrinking JPG, PNG, WebP, and AVIF folders using browser drops or terminal commands without breaking existing paths.