Optimize size

From casedash/CaseDash · View interactive version

Optimize size is an AI agent skill from the GitHub repository casedash/CaseDash. Use only when explicitly invoked: reduce CaseDash executable size.

How to use this skill

Skill file

Optimize Size

Overview

Use this skill to run measured, high-leverage executable-size experiments for CaseDash. Aim for a retained build\CaseDash.exe reduction of at least 10 KiB when plausible, and keep going past the first small win while credible larger hypotheses remain.

Required Context

  1. Read AGENTS.md.
  2. Read docs/optimize_size.md before forming hypotheses. Treat it as the source of truth for size constraints, retained size shape, active negative guidance, map workflow, current baseline, and size pitfall notes.
  3. Read docs/build.md for build and validation entrypoints.
  4. Read docs/profile_benchmark.md before changing renderer, widget layout, layout resolver, telemetry, provider sampling, or other hot paths.
  5. Read docs/architecture.md and the relevant docs/architecture/*.md files before removing or bypassing package boundaries, middle-man layers, or shared abstractions.

Baseline

  1. Inspect git status --short; ignore unrelated dirty work and do not revert changes made by others.
  2. Build a fresh Release app with .\build.cmd.
  3. Record the shipped executable size:
(Get-Item .\build\CaseDash.exe).Length
  1. Generate maps with .\build_maps.cmd.
  2. Inspect build\CaseDash.map.summary.txt. Use focused ad hoc map analysis when needed:
python .\tools\analyze_link_map.py .\build\CaseDash.map --top 25
  1. Compare the largest sections, project objects, and symbols against the maintained notes in docs/optimize_size.md. Treat MSVC map symbol sizes as estimates.

Hypothesis Selection

Prioritize changes that can delete whole families of generated code, metadata, unwind data, resources, descriptors, or repeated cold-path machinery. Look for:

Do not spend the main effort on tiny localized cleanups unless they are part of a broader measured pattern or unblock a larger deletion. Avoid experiments covered by active negative guidance in docs/optimize_size.md unless new surrounding code makes the old measurement stale, and record why the retry is justified.

Experiment Discipline

  1. Rank hypotheses by expected executable delta, behavioral risk, performance risk, and blast radius.
  2. Change one coherent hypothesis at a time.
  3. Prefer cold-path, resource, metadata, and linker-shape wins before changing renderer, widget draw, layout resolver, or telemetry hot paths.
  4. Preserve the full feature set: supported hardware providers, diagnostics, layout-edit, localization, embedded default config/localization, app icon behavior, and /default-config behavior.
  5. Keep normal builds free of map generation; use build_maps.cmd only for size analysis.
  6. Rebuild and remeasure after each serious experiment. If an experiment is neutral or regresses and does not improve source clarity enough to keep, revert only your own changes from that experiment.
  7. Leave concise Size: comments near non-obvious retained code shapes where a conventional cleanup would likely reintroduce larger code.
  8. Keep going until the retained executable reduction reaches at least 10 KiB, or until the remaining plausible hypotheses are too risky, already disproven, or only tiny localized wins.

Validation

.\build\CaseDash.exe /default-config /fake /exit /trace:build\size_optimization_validation_trace.txt /dump:build\size_optimization_validation_dump.txt /screenshot:build\size_optimization_validation_screenshot.png /layout-guide-sheet:build\size_optimization_validation_sheet.png /app-icon:build\size_optimization_validation_app_icon.png /app-icon-size:64 /save-full-config:build\size_optimization_validation_full_config.ini

Documentation

Update docs/optimize_size.md when an experiment changes the retained size shape, active negative guidance, current baseline, or a recurring project-specific pitfall. Keep entries grouped, present-tense, and concise, with baseline/final executable sizes and important section or object deltas only when they help future decisions.

Update other maintained docs only when behavior, commands, architecture boundaries, diagnostics behavior, or provider requirements change.

Output

Summarize:

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.