New to Claude Skills? Learn how to install them →

Bwshobson on GitHub

Bazel Build Optimization

Free

Streamline your Bazel builds for large monorepos.

by wshobson38.7k stars on wshobson/agents
2 views
Updated Jul 18, 2026
Get this skill

Free · Opens the source repo

What Bazel Build Optimization does

Bazel Build Optimization is designed for developers and teams working with large-scale monorepos using Bazel. This skill provides essential guidance on setting up Bazel, configuring remote execution, and optimizing build performance. It is particularly useful for enterprise codebases where efficiency and speed are critical. The skill offers a structured approach to understanding Bazel's architecture and best practices for managing dependencies and build configurations.

The skill covers core concepts such as targets, packages, labels, rules, and aspects, which are fundamental to effectively using Bazel. It also includes a detailed directory structure that illustrates where to place various files, such as the WORKSPACE and BUILD files. Users can leverage this knowledge to write custom Bazel rules, debug build issues, and migrate existing projects to Bazel, ensuring a smoother transition and better performance.

Included in the skill are templates and worked examples that can be found in the bundled references/details.md file. These resources provide practical, concrete templates that can be directly applied to real-world scenarios, enhancing the learning experience and enabling users to implement best practices effectively. The skill emphasizes the importance of fine-grained targets, dependency pinning, and proper workspace setup, which are critical for maintaining reproducible builds and optimizing caching.

Overall, Bazel Build Optimization is an invaluable resource for developers looking to enhance their Bazel usage, particularly in environments with complex build requirements and large codebases. By following the guidance provided, users can significantly improve their build times and project organization, leading to more efficient development workflows.

When to use it

Use this skill when configuring Bazel for monorepos, implementing remote execution, or troubleshooting build performance issues.

When not to use it

This skill may not be suitable for small projects or teams not utilizing Bazel, as its focus is on large-scale monorepo optimization.

What you can build with it

Setting Up a New Monorepo

Use this skill to configure Bazel for a new monorepo, ensuring best practices are followed from the start.

Improving Build Times

Leverage optimization techniques provided in this skill to reduce build times in existing Bazel projects.

Debugging Build Issues

Refer to the guidelines for troubleshooting and resolving common build issues encountered in Bazel.

How to install Bazel Build Optimization

View source

1. Install with the skills CLI

npx skills add wshobson/agents/bazel-build-optimization --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by wshobson

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

ConceptDescription
TargetBuildable unit (library, binary, test)
PackageDirectory with BUILD file
LabelTarget identifier //path/to:target
RuleDefines how to build a target
AspectCross-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

Frequently asked questions about Bazel Build Optimization

Similar skills