| name | bazel-pre-pr |
| description | Runs pre-flight checks and deep code reviews on local commits of a feature branch before push or PR creation. |
Bazel Pre-PR Pre-Flight Review (bazel-pre-pr)
This skill defines the pre-flight checks and local commit code review workflow to execute before a branch is pushed to remote or a pull request is created. It helps catch common Bazel migration bugs and style violations early.
When to Use This Skill
- Run this skill before staging a commit for upload or pushing a new feature branch to GitHub.
- Trigger when the user requests "run pre-pr check", "review my local commits", or "verify my feature branch before PR".
📋 Operational Workflow
Step 1: Feature Branch Validation (VCS Gate)
Before initiating any code analysis, you MUST verify that the local repository is in a valid state for code review:
- Branch Check: Get the current git branch name (e.g., using
git branch --show-current).
- Gate Criterion: The current branch MUST NOT be
main (or the default base branch). If it is main, stop immediately and print a hard-stop error:
Error: Cannot run bazel-pre-pr on the 'main' branch. Please create a feature branch, commit your changes, and try again.
- Commit Check: Ensure there is at least one local commit distinguishing the current branch from the base branch. Safely resolve the base branch (falling back to
main if origin/main is not configured) and run the log:
BASE_BRANCH=$(git rev-parse --verify origin/main >/dev/null 2>&1 && echo "origin/main" || echo "main")
git log $BASE_BRANCH..HEAD --oneline
If this returns empty, stop immediately and print:
Error: No local commits found on this branch compared to the base branch.
Step 2: Spin Up Code Review Subagent
If the branch checks pass, spin up a subagent of type self (inheriting all tools and rules) to run the code review in the background:
- Role:
Bazel Code Reviewer
- Initial Task:
- Retrieve the full diff of the local commits. Safely resolve the base branch (falling back to
main if origin/main is not configured) and run the diff:
BASE_BRANCH=$(git rev-parse --verify origin/main >/dev/null 2>&1 && echo "origin/main" || echo "main")
git diff $BASE_BRANCH...HEAD
- Read the active migration guidelines from the repository root:
docs/bazel-migration/GUIDELINES.md.
- Surgically audit all modifications in the diff against the guidelines listed in that file.
- Conduct a general, highly skeptical engineering review of the diff: check for logical robustness, verify assumptions, look for edge cases, resource cleanup misses, or race conditions, and identify opportunities to simplify the code.
- Write a triage report artifact named
bazel_pre_pr_review.md to the repository root directory.
- The report MUST structure issues exactly like
github-pr-triage:
- Header:
# Pre-PR Review: <branch_name>
- Metadata: Commits analyzed, date, status.
- Issues Grouped by Category:
- For each issue:
- Context: File path and line range.
- Urgency:
🔥 Critical (causes compile/test failures or sandboxing violations), ⚠️ Warning (style/performance degradation), 💡 Suggestion.
- The Flaw: Description of the guideline violated.
- The Recommended Fix: Correct vs. Incorrect code block comparison.
Step 3: Present Triage Report to User
Once the subagent finishes and writes the bazel_pre_pr_review.md to the repository root:
- Load the triage report from the repository root and present it to the user.
- The report file MUST be created as a user-facing artifact with
RequestFeedback: true in the metadata to render the Proceed button.
- If no critical issues are found, notify the user that the branch is ready for push. If issues are found, prompt the user to approve the planned refactorings or fixes.