Skip to main content

Command Palette

Search for a command to run...

Announcing bazel-starters

Introducing Bazel template repositories from Aspect Build

Updated
2 min read
Announcing bazel-starters
A

Fixing Bazel!

Aspect’s command line interface (CLI) has long had an init command to get started with a new full-featured Bazel workspace. It’s a wizard that leads you through some questions, resulting in some languages or features being enabled/disabled in the resulting project.

We think this is a great way to customize your new workspace, but it has some downsides:

  • You have to start by installing the Aspect Build CLI (or the scaffold tool that the templating is based on).

  • It’s hard to point to a link on GitHub that says “here’s why we have Bazel configured this way” or to copy-paste some boilerplate from it.

  • You don’t get a green “Use this Template” button on GitHub to press that creates a new repo, which is useful for one-off reproductions, playgrounds, or training courses.

  • We didn’t have a nice README explaining how you can use the new workspace.

  • It’s Aspect-branded, and so any training courses we might donate to Linux Foundation would likely trigger objections from competitors.

Introducing template repositories

The continuous integration (CI) setup for our template has always had “presets” — one for each language, plus a zero-language “minimal” preset and one with everything thrown in (the “kitchen sink”). We now publish the output of the generator for each preset to its own repo under its own org:

https://github.com/bazel-starters

The README here explains a whole bunch of features that are included:

  • 📦 Curated bazelrc flags via bazelrc-preset.bzl

  • 🧰 Developer environment setup with bazel_env.bzl

  • 🎨 Formatting and linting built-in, using rules_lint

  • Pre-commit hooks for automatic linting and formatting

  • 📚 Language-specific package manager integration (e.g. pip, go.mod, npm, etc.)

  • 🧱 Latest Bazel version pinned and working

  • 🐳 Docker container support using rules_oci

  • 🧪 Code generation tools (e.g. copier, scaffold, yeoman) to help you and your team stamp out new services or components quickly

We also found a clever trick to make a Markdown file directly executable as a Bourne Shell script. So each of the README files, such as https://github.com/bazel-starters/cpp are actually executed as part of our CI process. That means you can trust those instructions will actually work after you clone the repo.

What’s next

We are always improving the state-of-the-art for to get started more easily with Bazel. Look for an Aspect Build announcement coming up in November for BazelCon 2025 where these starters will get a lot more useful!