O

Optimize Build Instant

A command template for performance workflows. Streamlines development with pre-configured patterns and best practices.

CommandClipticsperformancev1.0.0MIT
0 views0 copies

Optimize Build Instant

Instantly analyze and optimize your build system configuration for faster compilation, smaller output, and more efficient caching across Webpack, Vite, Rollup, Gradle, and other build tools.

When to Use This Command

Run this command when...

  • Build times have grown unacceptably long and you need immediate improvements to the build pipeline
  • You want to optimize build configuration without deep expertise in your specific build tool
  • A clean build takes more than a few minutes and you suspect misconfiguration or missing optimizations
  • You need to compare clean build, incremental build, and development server startup performance
  • You are migrating build tools and want to ensure optimal configuration for the new system

Quick Start

# .claude/commands/optimize-build-instant.md --- name: Optimize Build Instant description: Analyze and optimize build system for speed and output size command: true --- Optimize build: $ARGUMENTS 1. Identify build system and analyze configuration 2. Measure baseline build performance 3. Apply optimizations for speed, caching, and output 4. Verify improvements with comparative measurements
# Invoke the command claude "/optimize-build-instant webpack production build" # Expected output # > Detected: Webpack 5 with babel-loader, ts-loader, css-loader # > Baseline measurements: # > Clean build: 47s | Incremental: 12s | Output: 4.2MB # > Applying optimizations: # > 1. Enable persistent caching (filesystem cache) # > 2. Configure parallel thread-loader for ts-loader # > 3. Switch to esbuild-loader for transpilation # > 4. Add module concatenation and tree shaking # > 5. Configure split chunks for vendor separation # > After optimization: # > Clean build: 18s | Incremental: 3s | Output: 2.8MB # > Improvement: 62% faster clean build, 75% faster incremental

Core Concepts

ConceptDescription
Build System DetectionIdentifies the build tool, version, plugins, and loader chain automatically
Performance BaselineMeasures clean build, incremental build, and dev server times before changes
Cache OptimizationConfigures filesystem, memory, and module caches for maximum reuse
ParallelizationEnables multi-threaded compilation where supported by the build tool
Output OptimizationReduces bundle size through tree shaking, code splitting, and minification tuning
Build Optimization Pipeline
=============================

  Detect Build System
         |
  +------+------+------+------+
  |      |      |      |      |
  Webpack Vite  Rollup Gradle Other
         |
  [Measure Baseline]
  Clean | Incremental | Dev Server
         |
  [Apply Optimizations]
  Cache | Parallel | Loaders | Splitting
         |
  [Measure After]
  Clean | Incremental | Dev Server
         |
  [Report Delta]
  47s->18s (62% faster)

Configuration

ParameterDescriptionDefaultExampleRequired
$ARGUMENTSBuild system or specific build target to optimizeauto-detect"webpack production"No
build_toolSpecific build tool if auto-detection failsauto-detect"vite", "rollup"No
target_metricPrimary metric to optimize forbuild_time"output_size", "dev_startup"No
aggressiveApply more aggressive optimizations that may affect debuggingfalsetrueNo
measure_iterationsNumber of build runs for baseline measurement25No

Best Practices

  1. Measure before optimizing -- Always capture baseline numbers so you can quantify improvements. Build time varies between runs, so use multiple iterations for reliable baselines.

  2. Optimize incrementally -- Apply one category of optimization at a time (caching, then parallelization, then loaders) to isolate which changes have the most impact.

  3. Keep development and production configs separate -- Dev builds should prioritize speed and source maps over output size. Production builds should prioritize output size and minification.

  4. Verify output correctness after optimization -- Run your full test suite and manually check the built application after each optimization to ensure no functionality was broken.

  5. Document build configuration changes -- Build configs are notoriously hard to debug. Add comments explaining why each optimization is configured the way it is.

Common Issues

Cache invalidation causes stale builds: Filesystem caching can serve outdated modules after dependency updates. Clear the cache directory after major dependency changes or add cache-busting configuration.

Thread-loader breaks certain plugins: Not all loaders and plugins are thread-safe. If parallel compilation causes cryptic errors, identify the incompatible loader and exclude it from threading.

Tree shaking removes needed code: Side-effect-free module annotations may incorrectly mark modules as shakeable. Add affected modules to the sideEffects list in package.json to prevent removal.

Community

Reviews

Write a review

No reviews yet. Be the first to review this template!

Similar Templates