optimize-bundle-size — команда для Claude Code: как установить
Анализирует и уменьшает размер фронтенд-сборки через настройку бандлера, код-сплиттинг и удаление мёртвого кода. Пригодится при росте веса JS-бандла и падении скорости загрузки страниц.
npx claude-code-templates@latest --command performance/optimize-bundle-sizeЧто делает optimize-bundle-size
Команда запускает пошаговую оптимизацию клиентского бандла. Агент находит тяжёлые зависимости с помощью инструментов вроде webpack-bundle-analyzer, проверяет конфигурацию сборщика и фиксирует базовые замеры веса. Затем настраивает динамические импорты для маршрутов, сжатие ассетов и правила tree shaking, исключая неиспользуемые модули.
Сценарий рассчитан на работу с Webpack, Vite или Rollup через флаги --webpack, --vite или --rollup. Команде разрешён доступ к инструментам Bash, Read, Grep и Glob, поэтому Claude Code сможет напрямую исследовать проект и запускать профилирование в консоли.
Для устойчивого контроля команда помогает настроить проверку бюджетов производительности и валидацию размера бандла в CI/CD. Без установленного бандлера или возможности собрать проект в терминале выполнить замеры не получится.
Какие задачи решает
- найти тяжёлые библиотеки и неиспользуемый код в клиентской сборке
- настроить разделение кода и динамическую загрузку компонентов
- сконфигурировать параметры tree shaking для Webpack, Vite или Rollup
- внедрить автоматическую проверку размера бандла в пайплайн CI/CD
Примеры запросов агенту
- /optimize-bundle-size --vite
- /optimize-bundle-size --webpack
- Проанализируй бандл проекта через /optimize-bundle-size --rollup и настрой ленивую загрузку маршрутов
Как установить optimize-bundle-size
1Через claude-code-templates
npx claude-code-templates@latest --command performance/optimize-bundle-size2Вручную: положить файлы
.claude/commands/optimize-bundle-size.mdВызов — /optimize-bundle-size. Для всех проектов — ~/.claude/commands/
Вручную: положить файлы
~/.codex/prompts/optimize-bundle-size.mdВызов — /prompts:optimize-bundle-size. В Codex этот формат помечен устаревшим, замена — скиллы
Вручную: положить файлы
.github/prompts/optimize-bundle-size.prompt.mdВручную: положить файлы
.gemini/commands/optimize-bundle-size.tomlGemini хранит команды в TOML: текст запроса — в поле prompt
Вопросы о optimize-bundle-size
Как установить optimize-bundle-size в Claude Code?
Выполните команду npx claude-code-templates@latest --command performance/optimize-bundle-size. Она добавит файл команды .claude/commands/optimize-bundle-size.md в ваш проект.
Какие сборщики поддерживает команда optimize-bundle-size?
Инструкции ориентированы на Webpack, Vite и Rollup. Нужный инструмент сборки передаётся через аргументы --webpack, --vite или --rollup.
Какие инструменты Claude Code нужны для работы команды?
Команда использует системные инструменты Read, Bash, Grep и Glob. Они позволяют агенту читать конфигурационные файлы, искать импорты и выполнять скрипты анализа в консоли.
Исходный текст
optimize-bundle-size.md · MIT
---
allowed-tools: Read, Bash, Grep, Glob
argument-hint: "[build-tool] | --webpack | --vite | --rollup"
description: Reduce and optimize bundle sizes through analysis, configuration, and code splitting strategies
---
# Optimize Bundle Size
Reduce and optimize bundle sizes: **$ARGUMENTS**
## Instructions
1. **Bundle Analysis and Assessment**
- Analyze current bundle size and composition using webpack-bundle-analyzer or similar tools
- Identify large dependencies and unused code across all bundles
- Assess current build configuration and optimization settings
- Create baseline measurements for optimization tracking
- Document current performance metrics and loading times
2. **Build Tool Configuration**
- Configure build tool optimization settings for production builds
- Enable code splitting and chunk optimization features
- Configure tree shaking and dead code elimination
- Set up bundle analyzers and visualization tools
- Optimize build performance and output sizes
3. **Code Splitting and Lazy Loading**
- Implement route-based code splitting for single-page applications
- Set up dynamic imports for components and modules
- Configure lazy loading for non-critical resources
- Optimize chunk sizes and loading strategies
- Implement progressive loading patterns
4. **Tree Shaking and Dead Code Elimination**
- Configure build tools for optimal tree shaking
- Mark packages as side-effect free where appropriate
- Optimize import statements for better tree shaking
- Use ES6 modules and avoid CommonJS where possible
- Implement babel plugins for automatic import optimization
5. **Dependency Optimization**
- Analyze and audit package dependencies for size impact
- Replace large libraries with smaller alternatives
- Use specific imports instead of importing entire libraries
- Implement dependency deduplication strategies
- Configure external dependencies and CDN usage
6. **Asset Optimization**
- Optimize images through compression and format conversion
- Implement responsive image loading strategies
- Configure asset minification and compression
- Set up efficient file loaders and processors
- Optimize font loading and subsetting
7. **Module Federation and Micro-frontends**
- Implement module federation for large applications
- Configure shared dependencies and runtime optimization
- Set up micro-frontend architecture for code sharing
- Optimize remote module loading and caching
- Implement federation performance monitoring
8. **Performance Monitoring and Measurement**
- Set up bundle size monitoring and tracking
- Configure automated bundle analysis in CI/CD
- Monitor bundle size changes over time
- Set up performance budgets and alerts
- Track loading performance metrics
9. **Progressive Loading Strategies**
- Implement resource hints (preload, prefetch, dns-prefetch)
- Configure service workers for caching strategies
- Set up intersection observer for lazy loading
- Optimize critical resource loading priorities
- Implement adaptive loading based on connection speed
10. **Validation and Continuous Monitoring**
- Set up automated bundle size validation in CI/CD
- Configure bundle size thresholds and alerts
- Implement bundle size regression testing
- Monitor real-world loading performance
- Set up automated optimization recommendations
Focus on optimizations that provide the most significant bundle size reductions while maintaining application functionality. Always measure the impact of changes on both bundle size and runtime performance.
© davila7 · MIT · davila7/claude-code-templates