# Bazel Build Optimization > Optimize Bazel builds for large-scale monorepos. Use when configuring Bazel, implementing remote execution, or optimizing build performance for enterprise codebases. Source: https://skillsagentes.com/skills/wshobson/agents/bazel-build-optimization Repository: https://github.com/wshobson/agents Author: wshobson License: MIT Updated: hace 2 meses Context cost: 41 tok installed, 523 tok once triggered, 2.4k tok with every bundled file Bundle: 2 files, 10 KB Permissions requested: none declared ## Install ```bash npx -y skills add wshobson/agents --skill bazel-build-optimization --agent claude-code ``` ## What it does - Aporta patrones de producción para configurar Bazel en monorepos a gran escala - Define la arquitectura de workspace con WORKSPACE.bazel, .bazelrc, BUILD.bazel y reglas personalizadas - Explica conceptos clave: Target, Package, Label, Rule y Aspect - Da buenas prácticas de caching, dependencias fijadas y visibilidad de targets ## Use it when - Configurar Bazel para monorepos - Configurar caching/ejecución remota - Optimizar tiempos de build - Escribir reglas Bazel personalizadas o migrar a Bazel ## What triggers it - "Ayúdame a configurar Bazel para nuestro monorepo" - "Cómo habilito la ejecución remota en Bazel" - "Necesito optimizar los tiempos de build de Bazel" - "Quiero escribir una regla Bazel personalizada" ## Before you install - Los templates y ejemplos detallados están en references/details.md. ## Files - SKILL.md — 2 KB - references/details.md — 7 KB ## SKILL.md Reproduced verbatim from wshobson/agents under MIT. This section is the upstream document and is in English. # Bazel Build Optimization Production patterns for Bazel in large-scale monorepos. ## When to Use This Skill - Setting up Bazel for monorepos - Configuring remote caching/execution - Optimizing build times - Writing custom Bazel rules - Debugging build issues - Migrating to Bazel ## Core Concepts ### 1. Bazel Architecture ``` workspace/ ├── WORKSPACE.bazel # External dependencies ├── .bazelrc # Build configurations ├── .bazelversion # Bazel version ├── BUILD.bazel # Root build file ├── apps/ │ └── web/ │ └── BUILD.bazel ├── libs/ │ └── utils/ │ └── BUILD.bazel └── tools/ └── bazel/ └── rules/ ``` ### 2. Key Concepts | Concept | Description | | ----------- | -------------------------------------- | | **Target** | Buildable unit (library, binary, test) | | **Package** | Directory with BUILD file | | **Label** | Target identifier `//path/to:target` | | **Rule** | Defines how to build a target | | **Aspect** | Cross-cutting build behavior | ## Templates and detailed worked examples Full template library and detailed worked examples live in `references/details.md`. Read that file when you need the concrete templates. ## Best Practices ### Do's - **Use fine-grained targets** - Better caching - **Pin dependencies** - Reproducible builds - **Enable remote caching** - Share build artifacts - **Use visibility wisely** - Enforce architecture - **Write BUILD files per directory** - Standard convention ### Don'ts - **Don't use glob for deps** - Explicit is better - **Don't commit bazel-\* dirs** - Add to .gitignore - **Don't skip WORKSPACE setup** - Foundation of build - **Don't ignore build warnings** - Technical debt --- Skills Agentes — https://skillsagentes.com/skills/wshobson/agents/bazel-build-optimization