PluginBench
Skill
Pass
Audit score 90

bazel-build-optimization

wshobson/agents

Optimize Bazel builds for large-scale monorepos with remote caching and custom rules.

What is bazel-build-optimization?

Bazel build optimization provides production patterns for configuring Bazel in large-scale monorepos, including remote caching/execution setup, custom rule writing, and build performance tuning. Use this when setting up Bazel, migrating to it, or debugging build issues in enterprise codebases.

  • Configure Bazel workspace structure with WORKSPACE.bazel, BUILD.bazel, and .bazelrc files
  • Set up remote caching and remote execution for distributed builds
  • Write custom Bazel rules and aspects for project-specific build logic
  • Optimize build times through fine-grained targets and dependency management
  • Debug build issues and enforce architecture constraints with visibility rules
  • Migrate existing projects to Bazel with reproducible build setup

How to install bazel-build-optimization

npx skills add https://github.com/wshobson/agents --skill bazel-build-optimization
Claude Code
Cursor
Windsurf
Cline

How to use bazel-build-optimization

  1. 1.Create WORKSPACE.bazel file to declare external dependencies
  2. 2.Set up .bazelrc with build configurations and remote caching settings
  3. 3.Write BUILD.bazel files per directory with fine-grained targets
  4. 4.Configure remote execution backend if using distributed builds
  5. 5.Pin dependency versions for reproducible builds
  6. 6.Enable visibility rules to enforce architectural boundaries
  7. 7.Test builds locally before deploying to remote execution

Use cases

Good for
  • Setting up Bazel for a new monorepo with multiple apps and shared libraries
  • Implementing remote caching to share build artifacts across team members
  • Optimizing CI/CD pipeline by enabling remote execution for faster builds
  • Writing custom rules for domain-specific build requirements
  • Migrating a legacy build system to Bazel while maintaining reproducibility
Who it's for
  • Build engineers managing large-scale monorepos
  • DevOps engineers optimizing CI/CD pipelines
  • Platform teams standardizing build infrastructure
  • Software architects designing modular codebases

bazel-build-optimization FAQ

What is the difference between a target, package, and label in Bazel?

A package is a directory containing a BUILD file. A target is a buildable unit (library, binary, test) defined in that BUILD file. A label is the unique identifier for a target, formatted as //path/to:target.

Why should I use fine-grained targets instead of glob patterns?

Fine-grained targets enable better caching and incremental builds. Explicit dependencies are more maintainable and prevent unnecessary rebuilds when unrelated files change.

How do I enable remote caching for my Bazel builds?

Configure remote caching in .bazelrc by specifying a remote cache backend URL and enabling the --remote_cache flag. This allows build artifacts to be shared across team members and CI/CD runs.

What should I add to .gitignore for Bazel projects?

Add bazel-* directories (bazel-bin, bazel-genfiles, bazel-out, bazel-testlogs) to .gitignore to avoid committing generated build artifacts.

How do I migrate an existing project to Bazel?

Start by setting up WORKSPACE.bazel with external dependencies, create BUILD files incrementally per directory, pin all dependency versions, and test builds locally before enabling remote execution.

Full instructions (SKILL.md)

Source of truth, from wshobson/agents.


name: bazel-build-optimization description: Optimize Bazel builds for large-scale monorepos. Use when configuring Bazel, implementing remote execution, or optimizing build performance for enterprise codebases.

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