optimize-image

optimize-image is a command for Claude Code from armanzeroeight/fastagent-plugins. It costs 14 tokens per session (1,058 once invoked), scanned A, original, MIT.

A Dockerfile review command that examines how a container image is built. A container image is a packaged application with the files and software it needs to run.

In plain words
What is it for?
Use it to review a Dockerfile and get recommendations about base images, build stages, dependency layers, caching, unused packages, secrets, and non-root users.
Why use it?
It helps identify ways to reduce image size and build time while improving basic image security. It points out issues such as missing multi-stage builds, poor layer ordering, or running as root.

Command for Claude Code

Written for Claude Code: allowed-tools in frontmatter. Also seen: positional $N argument.

Good fit Use it to review a Dockerfile and get recommendations about base images, build stages, dependency layers, caching, unused packages, secrets, and non-root users.

Compare 6 commands from other repositories ↓
Install with agentmods
npx agentmods add commands/armanzeroeight/fastagent-plugins/optimize-image
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/armanzeroeight/fastagent-plugins

Made for: Claude Code.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for optimize-image

README.md
[![agentmods](https://agentmods.dev/badge/commands/armanzeroeight/fastagent-plugins/optimize-image/github.svg)](https://agentmods.dev/commands/armanzeroeight/fastagent-plugins/optimize-image)
Your own site
<a href="https://agentmods.dev/commands/armanzeroeight/fastagent-plugins/optimize-image"><img src="https://agentmods.dev/badge/commands/armanzeroeight/fastagent-plugins/optimize-image/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for optimize-image

Your own site · 80×15
<a href="https://agentmods.dev/commands/armanzeroeight/fastagent-plugins/optimize-image"><img src="https://agentmods.dev/badge/commands/armanzeroeight/fastagent-plugins/optimize-image.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 14 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 1,058 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00014 $0.01058
Opus 5.5 $0.00006 $0.00423
Sonnet 5.5 $0.00003 $0.00212
Haiku 4.5 $0.00001 $0.00106

Measured 3mo ago against content hash b631e5d894a4, method: parsed. Prices are Anthropic first-party input rates as of 2026-10-07, from the pricing page.

Security

Grade A, and why

optimize-image scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 3mo ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/docker-toolkit/commands/optimize-image.md · 181 lines

How it starts

The opening of the file, as written. The whole thing — 181 lines — stays where its author put it; the contents beside it link to each section on GitHub.

Optimize Image

Context

  • Dockerfile location: !find . -name "Dockerfile" -o -name "dockerfile" | head -5
  • Current images: !docker images --format "table {{.Repository}}\t{{.Tag}}\t{{.Size}}" | head -10
  • Docker version: !docker --version

Your Task

Analyze the Dockerfile and provide comprehensive optimization recommendations.

Arguments

  • $1 (optional): Path to Dockerfile (default: ./Dockerfile)

Steps

  1. Read and analyze Dockerfile:

    cat Dockerfile
    
  2. Identify optimization opportunities:

    Base Image:

    • Is alpine or slim variant used?
    • Is specific tag used (not latest)?
    • Can distroless be used?

    Multi-Stage Build:

    • Is multi-stage build used?
    • Are build dependencies separated from runtime?
    • Can final image be smaller?

    Layer Optimization:

    • Are dependencies copied before code?
    • Are RUN commands combined appropriately?
    • Is .dockerignore present?

    Security:

    • Is non-root user used?
    • Are secrets avoided in image?
    • Are unnecessary packages removed?

    Caching:

    • Are layers ordered by change frequency?
    • Are package manager caches cleared?
    • Can build cache mounts be used?
  3. Calculate current image size:

    docker build -t temp-analysis .
    docker images temp-analysis --format "{{.Size}}"
    docker rmi temp-analysis
    
  4. Generate optimized Dockerfile:

    Create Dockerfile.optimized with improvements:

    • Minimal base image
    • Multi-stage build (if applicable)
    • Optimized layer order
    • Security hardening
    • Cache optimization
  5. Provide comparison:

    Before:

    • Image size: X MB
    • Layers: Y
    • Security issues: Z

    After (estimated):

    • Image size: A MB (B% reduction)
    • Layers: C
    • Security improvements: D
  6. Create optimization report:

    # Dockerfile Optimization Report
    
    ## Current Analysis
    - Base image: node:18 (990MB)
    - Build type: Single-stage
    - Security: Running as root
    - Layers: 12
    
    ## Recommendations
    
    ### High Priority
    1. Use alpine base (node:18-alpine)
       - Savings: ~800MB
       - Impact: High
    
    2. Implement multi-stage build
       - Savings: ~200MB
       - Impact: High
    
    3. Run as non-root user
       - Security: Critical
       - Impact: High
    
    ### Medium Priority
    4. Optimize layer caching
       - Build time: -50%
       - Impact: Medium
    
    5. Add .dockerignore
       - Build time: -20%
       - Impact: Medium
    
    ### Low Priority
    6. Combine RUN commands
       - Savings: ~10MB
       - Impact: Low
    
    ## Implementation
    
    See Dockerfile.optimized for complete implementation.
    
    ## Next Steps
    1. Review Dockerfile.optimized
    2. Test build: `docker build -f Dockerfile.optimized -t myapp:optimized .`
    3. Compare sizes: `docker images myapp`
    4. Test functionality
    5. Replace Dockerfile when satisfied
    

Read the full file on GitHub · 181 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 3mo ago First seen · 181 lines · 14 tokens per session scan A b631e5d894a4

Subscribe to this mod's changes

optimize-image is a command published in the GitHub repository armanzeroeight/fastagent-plugins (30 stars, last pushed 4mo ago), licensed MIT. It adds 14 tokens to every session and 1,058 once invoked, about $0.0001 per session on Opus 5.5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

optimize-image compared with commands from other repositories

optimize-image next to 6 commands from other repositories
ModTypeStarsLast pushLicenceScanTokensWorks with
optimize-imagearmanzeroeight/fastagent-pluginsCommand304mo agoMITA14Claude Code
aidd-churnparalleldrive/aiddCommand3905mo agoMITA15Claude Code
trace-regressionyeaight7/agent-powerupsCommand102mo agoApache-2.0A18Claude Code
multi-workflowDekaPrayoga/AurixAgentCommand624mo agononeA19Claude Code
resume-sessionDekaPrayoga/AurixAgentCommand624mo agononeA26Claude Code
flutter-buildDekaPrayoga/AurixAgentCommand624mo agononeA25Claude Code
skill-healthDekaPrayoga/AurixAgentCommand624mo agononeA12Claude Code