| name | precheck |
| description | Run pre-commit checks (gofmt, goimports, gazelle, code generators, build) before committing Prysm changes. Required before every commit. |
Pre-commit checks
Run these in order from the repo root before every commit. Stop and report if any step fails.
-
gofmt — format changed Go files:
gofmt -l $(git diff --name-only --diff-filter=ACM HEAD | grep '\.go$')
If output is non-empty, run gofmt -w on those files.
-
goimports — organize imports:
goimports -l $(git diff --name-only --diff-filter=ACM HEAD | grep '\.go$')
If output is non-empty, run goimports -w on those files.
-
Gazelle — sync deps.bzl (when go.mod changed):
bazel run //:gazelle -- update-repos -from_file=go.mod -to_macro=deps.bzl%prysm_deps -prune=true
git diff --exit-code deps.bzl
-
Gazelle — sync BUILD.bazel:
bazel run //:gazelle -- fix --mode=diff
If the diff is non-empty, run bazel run //:gazelle -- fix.
-
Regenerate protobuf (when .proto files changed):
hack/update-go-pbs.sh
-
Regenerate SSZ (when SSZ-tagged structs changed):
hack/update-go-ssz.sh
-
Regenerate mocks (when proto service interfaces changed):
hack/update-mockgen.sh
-
Smoke run with Bazel:
bazel run //cmd/beacon-chain:beacon-chain -- --help
bazel run //cmd/validator:validator -- --help
Hack scripts are idempotent — if unsure which generated files are affected, run all three.
Report
- Success: "✅ All pre-checks passed. Ready to commit."
- Failure: name the failed check and the fix command.