Skip to content

Quick Start

This guide will help you install bz and start using it to manage Bazel module dependencies.

Installation

Terminal window
go install github.com/albertocavalcante/bz@latest

Verify the installation:

Terminal window
bz version

Basic Usage

  1. Initialize a Bazel module

    Create a new MODULE.bazel file:

    Terminal window
    bz init --name=my_project

    This creates a MODULE.bazel with:

    module(
    name = "my_project",
    version = "0.0.0",
    )
  2. Add dependencies

    Add modules from the Bazel Central Registry:

    Terminal window
    bz mod add rules_go@0.50.1
    bz mod add rules_python@0.35.0

    Your MODULE.bazel now includes:

    bazel_dep(name = "rules_go", version = "0.50.1")
    bazel_dep(name = "rules_python", version = "0.35.0")
  3. List your dependencies

    View all dependencies in your MODULE.bazel:

    Terminal window
    bz mod list

    Output:

    rules_go@0.50.1
    rules_python@0.35.0
  4. Check for updates

    See if newer versions are available:

    Terminal window
    bz mod outdated

    Output:

    Module Current Latest
    ------ ------- ------
    rules_go 0.50.1 0.50.2
  5. Update dependencies

    Update to the latest versions:

    Terminal window
    bz mod update

Explore Your Dependencies

Visualize the dependency graph

Terminal window
bz mod graph

Output:

my_project
├── rules_go@0.50.1
│ ├── bazel_skylib@1.5.0
│ └── platforms@0.0.8
└── rules_python@0.35.0
└── bazel_skylib@1.5.0

Get dependency statistics

Terminal window
bz mod stats

Output:

Dependency Statistics:
Direct dependencies: 2
Transitive dependencies: 3
Total modules: 5
Max depth: 2
Dev dependencies: 0

Find out why a module is included

Terminal window
bz mod why bazel_skylib

Output:

bazel_skylib is required by:
my_project -> rules_go@0.50.1 -> bazel_skylib@1.5.0
my_project -> rules_python@0.35.0 -> bazel_skylib@1.5.0

Security Checks

Scan for vulnerabilities

Terminal window
bz audit

Check license compliance

Terminal window
bz mod licenses
bz mod licenses --check --deny=GPL-3.0

Shell Completions

Enable tab completion for your shell:

Terminal window
bz completion bash > /etc/bash_completion.d/bz

Check Your Setup

Run the doctor command to verify everything is configured correctly:

Terminal window
bz doctor

Output:

Checking Bazel setup...
✓ Bazel installed (7.0.0)
✓ MODULE.bazel found
✓ .bazelversion found (7.0.0)
✓ Bzlmod enabled (default in Bazel 7+)
✓ Registry reachable (bcr.bazel.build)
All checks passed!

What’s Next?