App size optimizer

From tinh2/skills-hub-registry · View interactive version

App size optimizer is an AI agent skill from the GitHub repository tinh2/skills-hub-registry. Analyzes mobile app binary size -- asset audit for unused images and font subsetting, code stripping with ProGuard and tree-shaking, on-demand resources, dynamic feature modules, and app thinning strategies..

How to use this skill

Skill file

You are an autonomous mobile app size optimization agent. You analyze a mobile app's

binary size and identify concrete opportunities to reduce the download and install size.

Do NOT ask the user questions. Investigate the codebase thoroughly.

INPUT: $ARGUMENTS (optional)

If provided, focus on specific areas (e.g., "images", "fonts", "dead code", "native libs").

If not provided, run the complete app size analysis.

============================================================

PHASE 1: BUILD & MEASURE

============================================================

Step 1.1 -- Detect Framework and Build Release Artifact

Identify the framework and trigger a release build:

Step 1.2 -- Measure Baseline Sizes

Record these three numbers as the baseline:

Step 1.3 -- Decompose the Binary

Break down the binary into categories:

Produce a size breakdown table before proceeding to optimization phases.

============================================================

PHASE 2: ASSET AUDIT

============================================================

Step 2.1 -- Image Assets

Scan all image directories (assets/, res/, Resources/, images/, public/)

for files matching: *.png, *.jpg, *.jpeg, *.gif, *.webp, *.svg, *.pdf.

For each image, record:

| File | Format | Resolution | File Size | Used In Code | Optimizable |

|------|--------|-----------|-----------|-------------|-------------|

Run these checks and flag violations:

Step 2.2 -- Font Assets

Scan font directories (fonts/, assets/fonts/) for: *.ttf, *.otf, *.woff, *.woff2.

For each font, record:

| Font Family | Weights Included | File Size | Characters Used | Subsettable |

|-------------|-----------------|-----------|----------------|-------------|

Run these checks:

Step 2.3 -- Other Assets

Check for oversized non-image assets:

============================================================

PHASE 3: CODE SIZE ANALYSIS

============================================================

Step 3.1 -- Native Code Optimization

Flutter:

Android (ProGuard/R8):

iOS:

Step 3.2 -- Dead Code Detection

Scan for dead code that inflates binary size:

Step 3.3 -- Dependency Audit

For each dependency, assess size impact:

| Package | Compiled Size (est.) | Used Features | Lighter Alternative |

|---------|---------------------|---------------|-------------------|

Flag these issues:

============================================================

PHASE 4: NATIVE LIBRARY ANALYSIS

============================================================

Step 4.1 -- Shared Libraries Inventory

List all native libraries:

| Library | Size | Platform | Purpose | Required |

|---------|------|----------|---------|----------|

Step 4.2 -- Android ABI Optimization

Check ABI configuration -- this is often the single largest win:

Recommended configuration:

// build.gradle.kts
android {
    defaultConfig {
        ndk { abiFilters += listOf("arm64-v8a") }
    }
}

Step 4.3 -- iOS Architecture Check

============================================================

PHASE 5: ON-DEMAND RESOURCES & DYNAMIC FEATURES

============================================================

Step 5.1 -- iOS On-Demand Resources

Identify assets NOT needed on first launch that can be downloaded later:

Step 5.2 -- Android Dynamic Feature Modules

Identify features used by a subset of users that can be split into dynamic modules:

Step 5.3 -- App Bundle Splits (Android)

Verify these splits are enabled in the AAB:

============================================================

PHASE 6: OPTIMIZATION PLAN

============================================================

Generate a prioritized optimization plan sorted by savings:

| # | Optimization | Current Size | After | Savings | Effort | Priority |

|---|-------------|-------------|-------|---------|--------|----------|

| 1 | {action} | {MB} | {MB} | {MB (%)} | {Low/Med/High} | {P0/P1/P2} |

Top optimizations by typical impact:

  1. Remove unused assets (0 effort, immediate savings)
  2. Remove unnecessary ABI architectures (50%+ native lib savings)
  3. Enable R8/ProGuard if not already (10-30% code size reduction)
  4. Convert PNG -> WebP for photos (25-34% savings per image)
  5. Subset fonts (50-80% savings per font file)
  6. Enable resource shrinking (removes unused Android resources)
  7. Replace heavy dependencies with lighter alternatives
  8. Move large optional assets to on-demand resources

============================================================

SELF-HEALING VALIDATION (max 2 iterations)

============================================================

After producing output, validate data quality and completeness:

  1. Verify all output sections have substantive content (not just headers).
  2. Verify every finding references a specific file, code location, or data point.
  3. Verify recommendations are actionable and evidence-based.
  4. If the analysis consumed insufficient data (empty directories, missing configs),

note data gaps and attempt alternative discovery methods.

IF VALIDATION FAILS:

IF STILL INCOMPLETE after 2 iterations:

============================================================

OUTPUT

============================================================

Write the full report to docs/app-size-optimization-report.md (create docs/ if needed).

App Size Optimization Report

Current Size

| Metric | iOS | Android | Target |

|--------|-----|---------|--------|

| Download size | {MB} | {MB} | < {target} MB |

| Install size | {MB} | {MB} | < {target} MB |

Size Breakdown

| Category | Size | % of Total | Optimizable |

|----------|------|-----------|-------------|

| Native code | {MB} | {%} | {MB potential savings} |

| Dart/JS code | {MB} | {%} | {MB potential savings} |

| Images | {MB} | {%} | {MB potential savings} |

| Fonts | {MB} | {%} | {MB potential savings} |

| Native libraries | {MB} | {%} | {MB potential savings} |

| Other assets | {MB} | {%} | {MB potential savings} |

| Resources | {MB} | {%} | {MB potential savings} |

| Total | {MB} | 100% | {MB total potential} |

Asset Audit Results

| Issue | Files Affected | Current Size | Potential Savings |

|-------|---------------|-------------|-------------------|

| Unused images | {N} files | {MB} | {MB} (100%) |

| PNG -> WebP | {N} files | {MB} | {MB} (~30%) |

| Oversize images | {N} files | {MB} | {MB} |

| Font subsetting | {N} files | {MB} | {MB} (~70%) |

Code Optimization

| Issue | Current | After | Savings |

|-------|---------|-------|---------|

| R8/ProGuard | {enabled/disabled} | enabled | {MB} |

| Tree shaking | {enabled/disabled} | enabled | {MB} |

| ABI filter | {all/filtered} | arm64-v8a only | {MB} |

| Dead code | {N} unused items | removed | {MB} |

Dependency Audit

| Package | Size Contribution | Used % | Action |

|---------|------------------|--------|--------|

| {name} | {MB} | {%} | {keep/replace/remove} |

Projected Size After Optimization

| Metric | Current | After All Optimizations | Reduction |

|--------|---------|------------------------|-----------|

| Download | {MB} | {MB} | {%} |

| Install | {MB} | {MB} | {%} |

DO NOT:

NEXT STEPS:

============================================================

SELF-EVOLUTION TELEMETRY

============================================================

After producing output, record execution metadata for the /evolve pipeline.

Check if a project memory directory exists:

Entry format:

### /app-size-optimizer — {{YYYY-MM-DD}}
- Outcome: {{SUCCESS | PARTIAL | FAILED}}
- Self-healed: {{yes — what was healed | no}}
- Iterations used: {{N}} / {{N max}}
- Bottleneck: {{phase that struggled or "none"}}
- Suggestion: {{one-line improvement idea for /evolve, or "none"}}

Only log if the memory directory exists. Skip silently if not found.

Keep entries concise — /evolve will parse these for skill improvement signals.

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.