bazel

Author Bazel BUILD files and configure C++ toolchains for C and C++ projects.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/awfixers-stuff/opencode-config --skill bazel-awfixers-stuff
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: bazel
Source: https://github.com/awfixers-stuff/opencode-config/tree/main/skills/bazel
Command: npx skills add https://github.com/awfixers-stuff/opencode-config --skill bazel-awfixers-stuff

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Navigating Bazel's C and C++ workflows can be complex: developers need clear BUILD file patterns, dependency management with Bzlmod, toolchain registration, remote execution configuration, and sandbox debugging guidance to build, test, and run reliably across environments.

Core Features & Use Cases

  • BUILD file guidance: How to author cc_library, cc_binary, and cc_test rules with correct srcs, hdrs, deps, copts, and visibility.
  • Dependency management with Bzlmod: Add and inspect external dependencies, view the module graph, and transition from legacy WORKSPACE layouts.
  • Toolchain registration & platforms: Define platforms, cc_toolchain_config, cc_toolchain, and register toolchains for custom or cross-compilation workflows.
  • Remote execution & caching: Configure remote_executor, remote_cache, and instance names for distributed builds and caching strategies.
  • Querying and debugging: Use bazel query, cquery, aquery and sandbox_debug techniques to explore dependency graphs, action arguments, and common sandbox failures.
  • Use case example: Migrate a small CMake-based project to Bazel by creating BUILD files for libraries and binaries, adding external deps via MODULE.bazel, registering a custom toolchain, and enabling remote cache for CI.

Quick Start

Create a BUILD file for a C++ library named mylib with its sources and headers, add abseil and googletest as Bzlmod dependencies, and outline steps to register and use a custom cc toolchain.

Frequently Asked Questions about bazel

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write BUILD files for cc_library and cc_binary rules in Bazel?▼

To write Bazel BUILD files, define cc_library, cc_binary, and cc_test rules by specifying srcs, hdrs, deps, copts, and visibility. This Skill provides templates and guidance for correctly structuring C and C++ build targets.

How do I configure C++ toolchains and platforms for cross-compilation in Bazel?▼

Configuring C++ toolchains in Bazel involves defining platforms, cc_toolchain_config, and cc_toolchain rules, then registering toolchains for custom or cross-compilation workflows to ensure correct environment selection.

What is the best way to migrate from legacy WORKSPACE to Bzlmod for external dependencies?▼

Migrating to Bzlmod from legacy WORKSPACE layouts requires adding external dependencies via MODULE.bazel and inspecting the module graph. This Skill outlines steps to transition dependency management smoothly.

Why does my Bazel sandbox fail and how do I debug action-level errors?▼

Bazel sandbox failures and action-level errors are diagnosed using sandbox_debug techniques, bazel query, cquery, and aquery. These tools help explore dependency graphs and inspect action arguments to resolve issues.

How do I set up remote execution and caching for distributed Bazel builds?▼

Setting up remote execution and caching in Bazel requires configuring remote_executor, remote_cache, and instance names. This provides strategies for distributed builds and caching across CI environments.