- Home
- Skills
- APIs & Backend
- bazel go hygiene
bazel go hygiene
Keep Bazel Go repositories green by automating Gazelle, Buildifier, and bzlmod dependency synchronization.
Free
Works with the AI Agents you already use
bazel go hygiene
Example session with this skill installed
I just added a new dependency to go.mod and updated my imports in main.go. Can you make sure Bazel is updated and everything builds?
- Read your context and instructions
- Compiled the bazel go hygiene
I have synchronized your Go dependencies with Bazel and updated the generated build files. I ran go mod tidy followed by bazel mod tidy to update your MODULE.bazel file, then executed Gazelle to update your go_library targets.
Hygiene Results
| Action | Command | Result |
|---|---|---|
| Dependency Sync | go mod tidy && bazel mod tidy | Success: Updated use_repo in MODULE.bazel |
| BUILD Generation | bazel run //:gazelle | Success: Updated deps for //cmd/app:app_lib |
| Formatting | bazel run //:buildifier | Success: Formatted 2 files |
| Build Validation | bazel build //... | Success: 14 targets built |
| Static Analysis | bazel test //... | Success: nogo passed |
Updated MODULE.bazel snippet
go_deps = use_extension("@gazelle//:extensions.bzl", "go_deps")
go_deps.from_file(go_mod = "//:go.mod")
use_repo(
go_deps,
"com_github_rs_zerolog", # New dependency added
"org_golang_x_sys",
)
Updated cmd/app/BUILD.bazel snippet
go_library(
name = "app_lib",
srcs = ["main.go"],
importpath = "github.com/user/repo/cmd/app",
visibility = ["//visibility:public"],
deps = [
"@com_github_rs_zerolog//:zerolog", # Gazelle injected
],
)
Next steps
- Verify the new dependency functions as expected by running
bazel test //cmd/app/.... - Check if you need to add any
gazelle_overrideinMODULE.bazelif the dependency has non-standard build requirements. - Commit the changes to
MODULE.bazelandBUILD.bazelbefore opening your PR.
Connects securely to your tools. The creator never sees your data.
About this skill
Maintaining a Bazel-managed Go repository often feels like fighting two build systems at once. Code compiles with the Go toolchain but fails in Bazel due to stale BUILD files, missing dependencies in MODULE.bazel, or nogo static analysis failures. Manual edits to use_repo lists or deps arrays lead to brittle repositories that break in CI.
This skill automates the hygiene required to keep rules_go, gazelle, and bzlmod in sync. It ensures your go.mod changes propagate correctly to your Bazel workspace and that your Starlark files remain formatted.
What it does
- Synchronizes dependencies by mapping
go.modupdates toMODULE.bazelviabazel mod tidy. - Regenerates BUILD files using Gazelle to track added, removed, or renamed Go files and imports.
- Enforces formatting across
BUILD.bazel,.bzl, andMODULE.bazelfiles using Buildifier. - Validates builds against the source of truth, ensuring
nogostatic analysis passes within the Bazel sandbox. - Resolves pathing issues for transitive dependencies and OS/CPU specific
select()statements.
How it works
- Analyze changes to identify if the user updated Go source, dependencies, or Bazel configuration.
- Execute hygiene pipeline by running the sequence of
go mod tidy,bazel mod tidy, andgazelle. - Audit against nogo to catch static analysis failures that
go buildignores but Bazel rejects. - Format Starlark to ensure all configuration files meet the repository's style standards.
Frameworks & tools
Bazel, Go, rules_go, Gazelle, Buildifier, bzlmod, and nogo static analysis.
Why this beats prompting it yourself
Generic AI agents often suggest standard Go commands that bypass Bazel's sandbox. This skill understands the specific requirements of bzlmod and the use_repo extension, preventing the common "no such package" errors that occur when manually editing Bazel files.
Use cases
- Adding new internal Go packages and generating their corresponding
go_librarytargets. - Upgrading third-party dependencies and updating the
go_depsextension inMODULE.bazel. - Fixing CI failures where Gazelle indicates a diff between source code and BUILD files.
- Implementing OS-specific build tags or platform-dependent dependencies correctly.
Known limitations
Requires a functional Bazel installation and a pre-configured gazelle target in the root BUILD.bazel file. Hermetic Go SDK settings may require a matching host Go version for local linting.
How to use
Skills on Agensi run inside your AI agent. Copy the prompt, paste it into your agent, and it connects to Agensi and installs this skill for you. If a payment is needed, your agent shows it to you first.
Reviews
No reviews yet
Be one of the first to try it. Every listed skill passes our trust checks below.
Security scanned
Passed our 8-point scan before listing
1 install
Downloaded by developers to date
Free forever
No account required to browse
Trust & safety
Security scanned
Verified clean 4 days ago
- Free to download with an account
Requires