Agent skill

Bazel for C and C++

by mohitmishra786 in mohitmishra786/low-level-dev-skills

Guides your agent through Bazel for C/C++ projects: BUILD files, Bzlmod dependencies, toolchain registration, remote execution, dependency queries and sandbox debugging.

MITAuto-check passedDevelopment

Install Bazel for C and C++

skills CLI
$ npx skills add mohitmishra786/low-level-dev-skills --skill bazel -a claude-code

Project install by default; add -g for ~/.claude/skills/.

GitHub CLI
$ gh skill install mohitmishra786/low-level-dev-skills bazel --agent claude-code

Project scope by default; add --scope user for a personal install. Needs GitHub CLI 2.90.0 or later (public preview).

Manual copy
$ git clone --depth 1 https://github.com/mohitmishra786/low-level-dev-skills.git skills-src && mkdir -p .claude/skills && cp -r skills-src/skills/build-systems/bazel .claude/skills/bazel && rm -rf skills-src

Use ~/.claude/skills/ instead of .claude/skills for a personal install. The folder must contain SKILL.md.

Claude Code skills documentation · loads skills from .claude/skills/

Facts

Skill name
bazel
GitHub stars
253
Token cost
~1.5k tokens
SKILL.md length
146 words
Files
2 (incl. references)
Skills in repo
138
Repo updated
First seen
Licence
MIT

At a glance

Guides your agent through Bazel for C/C++ projects: BUILD files, Bzlmod dependencies, toolchain registration, remote execution, dependency queries and sandbox debugging.

  • Works in 7 steps: Workspace structure → Basic BUILD file — cc_library / cc_binary → Bzlmod — modern dependency management → …
  • Writing a BUILD file for a C++ library and the binary that uses it
  • SKILL.md covers Purpose, Triggers, Workflow and Related skills
  • Calls bazel and jq

What it does

The agent is walked through seven areas of working with Bazel on C and C++ code: laying out a workspace with `MODULE.bazel`, writing `cc_library` and `cc_binary` rules, managing dependencies with Bzlmod, querying the dependency graph, registering toolchains, building on a remote executor and debugging sandbox failures. Each area comes with a short command or BUILD snippet to adapt.

Representative commands include `bazel build //src:main`, `bazel query` for the dependencies of a target, `bazel mod graph`, the `--remote_executor` flag and `--sandbox_debug`. A reference note, `references/bazel-cpp-toolchain.md`, goes deeper into C++ toolchain configuration, and the skill points to sibling skills for CMake, build acceleration with sccache and compiler flags for `copts`. The description also mentions migrating from CMake, though the excerpt shows no migration steps.

When your agent uses it

  • Writing a BUILD file for a C++ library and the binary that uses it
  • Adding external dependencies to a Bazel project with Bzlmod
  • Debugging Bazel sandbox errors in a failing build
  • Querying the dependency graph of a Bazel target
  • Registering a custom C++ toolchain or setting up remote execution

Example prompts

  • “Write a Bazel BUILD file for the C++ library in lib/ and a cc_binary in src/ that links it.”
  • “Add an external dependency to my project using Bzlmod in MODULE.bazel.”
  • “My Bazel build fails inside the sandbox; help me debug it with sandbox_debug.”
  • “Show me every dependency of //src:main using bazel query.”

Requirements

  • Bazel and a C or C++ project

Workflow steps

7 steps, taken from the step headings in SKILL.md.

  1. Workspace structure
  2. Basic BUILD file — cc_library / cc_binary
  3. Bzlmod — modern dependency management
  4. Dependency graph queries
  5. Toolchain registration
  6. Remote execution
  7. Sandbox debugging

What it can do on your machine

Read from SKILL.md and the folder at commit bdc5847. It shows what the files ask for, not the result of running them.

  • Tool permissions

    Pre-approves nothing: there is no allowed-tools line, so your agent's usual permission prompts apply.

    From allowed-tools in the SKILL.md frontmatter.

  • Runs code

    Shell commands in SKILL.md call:

    • bazel
    • jq

    From the folder's file list and the shell code blocks in SKILL.md.

  • Network

    No URLs in SKILL.md.

    From URLs in SKILL.md, links to its own repository left out.

  • Credentials

    Names no API keys, tokens, secrets or passwords.

    From names ending in _API_KEY, _TOKEN, _SECRET, _KEY or _PASSWORD in SKILL.md.

Context cost

Bazel for C and C++ loads about 1.5k tokens when it runs, and up to ~2.2k if it reads all its reference files. Until then it costs about 105 tokens; SKILL.md has 146 words of instructions outside code blocks.

Always · name and description, kept in context so the agent knows when to use it
~105
When it runs · the whole SKILL.md, loaded when a task matches
~1.5k
With references · SKILL.md plus every file in references/, read only if the agent opens them
~2.2k

Estimates: characters ÷ 4, the usual rule of thumb; real counts depend on the model's tokenizer. Scripts and assets cost tokens only if the agent reads them.

Safety

Auto-check passed

The automated check found no risky patterns in SKILL.md.

Automated static check — not a guarantee. Review scripts before installing. It scans the text of SKILL.md for risky patterns (piping downloads into a shell, reading credential files, hidden Unicode, destructive commands); files beside SKILL.md are not scanned.

SKILL.md

The full file from mohitmishra786/low-level-dev-skills at commit bdc5847, republished under its MIT licence (© mohitmishra786). 146 words, ~1,490 tokens.

Download SKILL.mdSave it as .claude/skills/bazel/SKILL.md (or your agent's skills folder). This skill also uses 1 other file; get the full folder from GitHub.
name
bazel
description
Bazel build system skill for C/C++ projects. Use when writing BUILD files with cc_library and cc_binary rules, registering toolchains, configuring remote execution, debugging sandbox issues, using query and cquery for dependency graphs, or migrating from CMake to Bazel. Activates on queries about Bazel, BUILD files, cc_library, cc_binary, Bzlmod, bazel query, remote execution, or Bazel toolchain registration.

Bazel

Purpose

Guide agents through Bazel for C/C++ projects: writing BUILD files, cc_library/cc_binary rules, toolchain registration, remote execution, dependency graph queries, Bzlmod dependency management, and sandbox debugging.

Triggers

  • "How do I write a Bazel BUILD file for a C++ library?"
  • "How do I add external dependencies with Bzlmod?"
  • "How do I debug Bazel sandbox errors?"
  • "How do I query the Bazel dependency graph?"
  • "How do I set up remote execution with Bazel?"
  • "How do I register a custom C++ toolchain?"

Workflow

1. Workspace structure
my-project/
├── MODULE.bazel         # Bzlmod dependency file (Bazel ≥6)
├── WORKSPACE            # legacy (still needed for some features)
├── BUILD                # root build file
├── src/
│   ├── BUILD
│   └── main.cc
└── lib/
    ├── BUILD
    ├── mylib.cc
    └── mylib.h
2. Basic BUILD file — cc_library / cc_binary
python
# lib/BUILD
cc_library(
    name = "mylib",
    srcs = ["mylib.cc"],
    hdrs = ["mylib.h"],
    copts = ["-Wall", "-Wextra", "-std=c++17"],
    visibility = ["//visibility:public"],
    deps = [
        "@com_google_absl//absl/strings",     # external dep
        "//util:helpers",                      # internal dep
    ],
)

cc_test(
    name = "mylib_test",
    srcs = ["mylib_test.cc"],
    deps = [
        ":mylib",
        "@com_google_googletest//:gtest_main",
    ],
)
python
# src/BUILD
cc_binary(
    name = "main",
    srcs = ["main.cc"],
    deps = ["//lib:mylib"],
    linkopts = ["-lpthread"],
)
bash
# Build
bazel build //src:main
bazel build //...           # build everything

# Test
bazel test //lib:mylib_test
bazel test //...            # run all tests

# Run
bazel run //src:main -- arg1 arg2

# Output path
bazel-bin/src/main
3. Bzlmod — modern dependency management
python
# MODULE.bazel
module(
    name = "my_project",
    version = "1.0",
)

bazel_dep(name = "abseil-cpp", version = "20240116.2")
bazel_dep(name = "googletest", version = "1.14.0")
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "platforms", version = "0.0.8")

# For http_archive deps not yet in BCR (Bazel Central Registry)
# Use module extensions
bash
# Check available versions
bazel mod graph | head -30

# Show dependency tree
bazel mod deps --depth=2
4. Dependency graph queries
bash
# Show all dependencies of a target
bazel query "deps(//src:main)"

# Find reverse dependencies (who depends on this?)
bazel query "rdeps(//..., //lib:mylib)"

# Find what changed between builds
bazel query "filter('//lib', deps(//src:main))"

# cquery — configuration-aware query
bazel cquery "deps(//src:main)" --output=files

# Show include paths for a target
bazel cquery "//lib:mylib" --output=build

# Find cycles in the build graph
bazel query --nohost_deps --noimplicit_deps \
  "somepath(//src:main, //lib:mylib)"

# aquery — action graph (shows compiler flags, inputs, outputs)
bazel aquery "//src:main"
bazel aquery "//src:main" --output=jsonproto | jq '.actions[0].arguments'
5. Toolchain registration
python
# platforms/BUILD
platform(
    name = "linux_x86_64",
    constraint_values = [
        "@platforms//os:linux",
        "@platforms//cpu:x86_64",
    ],
)

# toolchains/BUILD
cc_toolchain_suite(
    name = "my_toolchain",
    toolchains = {
        "k8": ":my_k8_toolchain",
    },
)

cc_toolchain(
    name = "my_k8_toolchain",
    all_files = ":empty",
    compiler_files = ":compiler_wrapper",
    # ... other file groups
)

toolchain(
    name = "my_cc_toolchain",
    toolchain = ":my_k8_toolchain",
    toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
    target_compatible_with = ["@platforms//os:linux"],
)
python
# MODULE.bazel — register toolchain
register_toolchains("//toolchains:my_cc_toolchain")
6. Remote execution
bash
# Use --remote_executor flag
bazel build //... \
  --remote_executor=grpc://buildgrid.example.com:50051 \
  --remote_instance_name=main

# Google Cloud Build Remote Execution
bazel build //... \
  --remote_executor=remotebuildexecution.googleapis.com \
  --remote_instance_name=projects/my-project/instances/default \
  --google_default_credentials

# Caching (without remote execution)
bazel build //... \
  --remote_cache=grpc://cache.example.com:9092

# Show what's cached
bazel build //... --remote_upload_local_results=true
7. Sandbox debugging
bash
# Show sandbox inputs and outputs
bazel build //src:main --sandbox_debug

# Run build with verbose sandboxing
bazel build //src:main --verbose_failures --sandbox_debug

# Disable sandbox entirely (for debugging)
bazel build //src:main --spawn_strategy=local

# Common sandbox errors
# "No such file or directory" → missing data dependency
#   Fix: add file to `data = [...]` attribute
# "Permission denied" → trying to write outside sandbox
#   Fix: use genrule output paths instead of hardcoded paths
# "FAILED: Build did NOT complete successfully" → check verbose output

# See the exact command Bazel ran
bazel build //src:main --subcommands

For Bazel C++ toolchain configuration, see references/bazel-cpp-toolchain.md.

  • Use skills/build-systems/cmake for CMake as an alternative build system
  • Use skills/build-systems/build-acceleration for sccache integration with Bazel remote cache
  • Use skills/compilers/gcc or skills/compilers/clang for compiler flags used in Bazel copts

© mohitmishra786, MIT. Rendered from Markdown: HTML in the file is shown as text, images as links, and headings moved down two levels. Raw file

Files

SKILL.md and 1 other file (references) in skills/build-systems/bazel of mohitmishra786/low-level-dev-skills.

  • SKILL.md
  • references/bazel-cpp-toolchain.md

Open the folder on GitHubat commit bdc5847

Compare with similar skills

Bazel for C and C++ next to the 5 skills that share the most tags, products or categories with it. Stars are the repository's; “used in” counts other GitHub owners with a copy.

Bazel for C and C++ compared with similar skills
SkillStarsUsed inTokensAuto-checkLicenceRepo updated
Bazel for C and C++ this skillmohitmishra786/low-level-dev-skills253—~1.5kAutomated safety check: PassMIT
Extempore JIT Debugging Guidedigego/extempore1.5k—~4.4kAutomated safety check: PassNone
OBS Plugin Dependency Upgradesorayuki/obs-multi-rtmp5.1k—~609Automated safety check: PassGPL-2.0
OpenROAD Bug FixerThe-OpenROAD-Project/OpenROAD3.2k—~784Automated safety check: PassBSD-3-Clause
Cppcrazyguitar/cppcheatsheet290—~1.8kAutomated safety check: PassMIT
MCP Debuggerdebugmcp/mcp-debugger171—~3.8kAutomated safety check: PassMIT

Similar skills

  • Debugging guide for Extempore covering its three layers, compilation paths, startup sequence and the batch, eval and interactive modes used to isolate JIT problems.

    1.5k GitHub stars~4.4k tokensUpdated 14 days ago
    DevelopmentAuto-check passed
  • OBS Plugin Dependency Upgrade

    sorayuki/obs-multi-rtmp

    Updates the obs-multi-rtmp plugin repo to the latest upstream plugin template and OBS Studio version, including dependency metadata, then rebuilds it with CMake.

    5.1k GitHub stars~609 tokensUpdated 6 days ago
    DevelopmentAuto-check passed
  • OpenROAD Bug Fixer

    The-OpenROAD-Project/OpenROAD

    Fixes an OpenROAD bug from a GitHub issue or error code: finds the root cause, implements the fix, adds a regression test and prepares a signed-off commit.

    3.2k GitHub stars~784 tokensUpdated yesterday
    DevelopmentAuto-check passed
  • Cpp

    crazyguitar/cppcheatsheet

    Comprehensive C/C++ programming reference covering everything from C11-C23 and C++11-C++23, system programming, CUDA GPU computing, debugging tools, Rust interop, and advanced topics.

    290 GitHub stars~1.8k tokensUpdated yesterday
    DevelopmentAuto-check passed
  • MCP Debugger

    debugmcp/mcp-debugger

    A skill your agent uses when investigating a bug, failing test, or unexpected runtime behavior and the mcp-debugger MCP server is available — drives real step-through debuggers (breakpoints, stack…

    171 GitHub stars~3.8k tokensUpdated yesterday
    DevelopmentAuto-check passed
  • Dbg

    theodo-group/debug-that

    Debug applications using the dbg CLI debugger. An agent skill from theodo-group/debug-that.

    158 GitHub stars~2.2k tokensUpdated yesterday
    DevelopmentAuto-check passed

More from mohitmishra786/low-level-dev-skills

All 138 skills in this repo
  • ARM and AArch64 Assembly

    mohitmishra786/low-level-dev-skills

    Guides reading and writing AArch64 and ARM Thumb assembly: compiler output, inline asm, registers, the AAPCS calling convention and NEON or SVE basics.

    253 GitHub stars~1.9k tokensUpdated 3 mo ago
    Auto-check passed
  • RISC-V Assembly Guide

    mohitmishra786/low-level-dev-skills

    Reference for RISC-V assembly on RV32 and RV64: register names and calling convention, extension naming, GCC and Clang inline asm, and QEMU with GDB debugging.

    253 GitHub stars~1.8k tokensUpdated 3 mo ago
    Auto-check passed
  • x86-64 Assembly Reference

    mohitmishra786/low-level-dev-skills

    Explains x86-64 registers, the System V AMD64 calling convention, and how to read compiler-generated or inline assembly.

    253 GitHub stars~1.5k tokensUpdated 3 mo ago
    Auto-check passed
  • Binary Hardening

    mohitmishra786/low-level-dev-skills

    Binary hardening skill for security-hardened C/C++ builds. An agent skill from mohitmishra786/low-level-dev-skills.

    253 GitHub stars~2k tokensUpdated 3 mo ago
    Auto-check passed
  • Binutils

    mohitmishra786/low-level-dev-skills

    GNU binutils skill for binary manipulation and analysis. An agent skill from mohitmishra786/low-level-dev-skills.

    253 GitHub stars~1.2k tokensUpdated 3 mo ago
    Auto-check passed
  • Build Acceleration

    mohitmishra786/low-level-dev-skills

    Build acceleration skill for C/C++ projects. An agent skill from mohitmishra786/low-level-dev-skills.

    253 GitHub stars~1.4k tokensUpdated 3 mo ago
    Auto-check passed

Works with

Categories

Questions about Bazel for C and C++

What does Bazel for C and C++ do?

Guides your agent through Bazel for C/C++ projects: BUILD files, Bzlmod dependencies, toolchain registration, remote execution, dependency queries and sandbox debugging. bazel`, writing `cc_library` and `cc_binary` rules, managing dependencies with Bzlmod, querying the dependency graph, registering toolchains, building on a remote executor and debugging sandbox failures. Each area comes with a short command or BUILD snippet to adapt.

When should I use Bazel for C and C++?

Bazel for C and C++ fits situations like: writing a BUILD file for a C++ library and the binary that uses it; adding external dependencies to a Bazel project with Bzlmod; debugging Bazel sandbox errors in a failing build; querying the dependency graph of a Bazel target.

How do I install Bazel for C and C++ in Claude Code?

Run `npx skills add mohitmishra786/low-level-dev-skills --skill bazel -a claude-code`. Or copy the skill folder (skills/build-systems/bazel in mohitmishra786/low-level-dev-skills) into .claude/skills/bazel in your project. Claude Code loads it when a task matches its description.

How do I install Bazel for C and C++ in Codex?

Run `npx skills add mohitmishra786/low-level-dev-skills --skill bazel -a codex`. Or copy the skill folder (skills/build-systems/bazel in mohitmishra786/low-level-dev-skills) into .agents/skills/bazel in your project. Codex loads it when a task matches its description.

Can I use Bazel for C and C++ in Cursor, Gemini CLI or GitHub Copilot?

Cursor, Gemini CLI, GitHub Copilot and OpenCode also load SKILL.md folders. With the skills CLI, run `npx skills add mohitmishra786/low-level-dev-skills --skill bazel -a cursor` (or -a gemini-cli, github-copilot or opencode for the others). To copy it by hand, put the folder in .cursor/skills/bazel, .gemini/skills/bazel, .github/skills/bazel and .opencode/skills/bazel in your project.

What does Bazel for C and C++ need to run?

Going by SKILL.md and its folder, Bazel for C and C++ needs the command-line tools its instructions call (bazel and jq). Our summary lists: Bazel and a C or C++ project.

Does Bazel for C and C++ access the network?

SKILL.md contains no URLs. Any network use would come from the scripts or tools the agent runs. This is read from the text; nothing was executed.

Is Bazel for C and C++ safe to install?

Our automated static check of SKILL.md found no risky patterns, such as piping downloads into a shell, reading credential files or hidden Unicode. It is not a guarantee. Review the folder before installing.

What licence does Bazel for C and C++ use?

Bazel for C and C++ is published under the MIT licence (the repository's licence). It allows redistribution, so the full SKILL.md is shown on this page.

How many tokens does Bazel for C and C++ use?

About 1.5k tokens (SKILL.md is roughly 6k characters). Agents keep only the skill's name and description in context until a task matches; then they load SKILL.md in full. Its references folder adds about 749 tokens, read only when the agent opens those files.

What are the alternatives to Bazel for C and C++?

Skills that share tags, products or a category with Bazel for C and C++: Extempore JIT Debugging Guide (digego/extempore, 1.5k stars), OBS Plugin Dependency Upgrade (sorayuki/obs-multi-rtmp, 5.1k stars), OpenROAD Bug Fixer (The-OpenROAD-Project/OpenROAD, 3.2k stars) and Cpp (crazyguitar/cppcheatsheet, 290 stars). The comparison table on this page puts their stars, adoption, token cost, safety result and licence side by side.

Who maintains Bazel for C and C++?

mohitmishra786 (a GitHub user) maintains it in mohitmishra786/low-level-dev-skills, which has 253 GitHub stars. The repository holds 138 skills in this directory. The repository was last updated on June 27, 2026.

Source: mohitmishra786/low-level-dev-skills on GitHub. Facts on this page come from the repository at the commit we read; the author's words are quoted as theirs.