XMC Create PR
Automates creating and updating GitHub Pull Requests, running pre-commit hooks, formatting PR body templates, managing CI wait buffers, and enforcing strict confirmation gates for Draft PR conversion.
- License 许可
- Apache-2.0
- 所属仓库
- google/xmc
- 最近更新
- 2026-11-14
- Stars
- ★ 8
- Forks
- 0
01 前言 Front Matter
- name
- XMC Create PR
- description
- Automates creating and updating GitHub Pull Requests, running pre-commit hooks, formatting PR body templates, managing CI wait buffers, and enforcing strict confirmation gates for Draft PR conversion.
03 SKILL.md 正文
GitHub Pull Request Creation & Update Playbook
This skill provides step-by-step procedures for creating, updating, and managing GitHub Pull Requests in the XMC repository.
[!IMPORTANT] All execution steps in this skill MUST strictly adhere to the policy rules defined in GitHub Authoring & PR Creation Standards, Skills & Automation Guidelines, and Core Engineering Standards.
Guidelines for Using CLI Tools
When invoking helper tools under tools/ (e.g., update_pr_description.py):
- Do not read tool source code: Do not open or read the Python source code of helper tools. Refer to Skills & Automation Guidelines.
- Use
--help: Run tools with--helpto inspect parameters and usage. - Parse Structured Output & Handle Errors: All tools output structured JSON; check the exit code per Helper Tool Exit Codes.
- Shell & Payload Safety: Execute standalone
.pyscript files or pass arguments via script parameters. Avoid double-quoted inline commands (python3 -c "...").
1. Branch Check & Formatting Verification
Before making commits or opening a PR:
- Check current branch:
git branch --show-current - Validate branch format:
Ensure the branch name strictly conforms to
<prefix>/<kebab-case-description>(e.g.,feat/enforce-pr-comment-integrity,fix/gke-rollout-timeout). - Rename branch if non-compliant:
If the branch name uses raw worktree directory names, underscores, or lacks a prefix:
git branch -m <prefix>/<kebab-case-description> - Detached HEAD State:
If
git branch --show-currentis empty, create and switch to a compliant branch:git checkout -b <prefix>/<kebab-case-description>
2. Pre-Commit Hooks & Commit Creation
Before creating any commit:
- Stage, Then Run Pre-Commit Formatting & Affected Tests Protocol:
Stage first: the hook auto-restages formatter fixes only for fully staged files (opt out withgit add <changed_paths> ./.githooks/pre-commitXMC_PRECOMMIT_NO_AUTOSTAGE=1). It exits 1 on unfixed lint errors or on fixes to partially staged or unstaged files; review those (git diff), stage them, and re-run. Once linters pass it executespython3 ./tools/run_affected_tests.py --skip-emulator-check, skipped when every staged path is Markdown or underdocs/. - Format Conventional Commit Message:
Format the commit message header using
<type>(<scope>): <summary>(e.g.,feat(auth): add OAuth2 token refresh support). - Include Mandatory Context & Tags:
Append technical rationale, bug references (e.g.,
Fixes bug 12345), and mandatory description tags at the bottom of the commit body:TAG=agy CONV=<conversation_id> - Execute Git Commit via Message File:
To avoid shell double-quoting syntax errors when dealing with multiline commit bodies, write the commit message to a temporary file and commit using
-F:cat << 'EOF' > commit_msg.txt <type>(<scope>): <summary> <Detailed commit body> TAG=agy CONV=<conversation_id> EOF git commit -F commit_msg.txt && rm commit_msg.txt
3. Pull Request Creation & PR Body Population
When creating a new PR or populating its description:
-
Diff Sizing Pre-Flight Check: Run the deterministic diff sizing tool before preparing the PR:
./tools/analyze_diff_size.py --base-ref origin/main...If
should_trigger_split_verifieristrue(Prod $\ge 400$, Total Code $\ge 1,000$, or Docs $\ge 1,000$ lines), STOP and execute the XMC PR Split Verification Skill to audit SRP and construct agh-stackplan before opening a PR. -
Pre-Commit Verification: Verify
./.githooks/pre-commit(formatters, linters, andrun_affected_tests.py) passes cleanly. -
Conventional PR Title: Match the PR title to Conventional Commits syntax (
<type>(<scope>): <summary>). -
Check for Trajectory Benchmark Artifact: Check if
/tmp/benchmark_report_<branch_name>.mdexists (generated by XMC Trajectory Comparison). If present, embed its content into the## Verification & Testingsection. -
Compile the Assumptions List & Verify Blueprint/Downstream Claims: Sweep the session trajectory for decisions made in place of an explicit instruction or verified fact, resolve any that are still cheaply checkable, and disclose the remainder per Mandatory Assumptions Disclosure:
- Verify Blueprint & Downstream Component Settings Before Repeating Task Claims: For changes under
deploy/ortest/helm/, inspect the target blueprint/chart files (e.g., whetherdeploy/ctk_v2/xmanager-cloud.yamlprovisions GKE Standard vs. Autopilot, which components consume aglobal.*Helm setting, and which downstream modules actually opt into a dependency viaset_values) before repeating symptom or impact statements from an issue/task prompt in inline comments or## Motivation & Context. - Operational & Upgrade Assumptions on Deployment PRs: Infrastructure, Helm chart, and blueprint changes carry operational and upgrade assumptions (target cluster policies/versions, upstream chart behavior, in-place
helm upgraderollout and orphaned resource semantics) that must be listed as<assumption> — <why it was assumed> — <impact if wrong>rather than writingNone — requirements were fully specified.. - Stacked / Non-
mainBase Branch Disclosure: When a PR targets a base branch other thanmain, state the stacked base branch and rationale explicitly in## Motivation & Context.
- Verify Blueprint & Downstream Component Settings Before Repeating Task Claims: For changes under
-
Format PR Body Template: Write the PR body to a temporary markdown file (e.g.,
pr_body.md):## Summary <Concise 2-3 sentence overview of what this PR introduces or fixes.> ## Motivation & Context <Explanation of the underlying problem, business/technical rationale, and design choices.> ## Key Changes - <Bulleted highlight of structural code adjustments> - <Targeted package, binary, or deployment modifications> ## Assumptions - <Assumption made during development> — <why it was assumed> — <impact if wrong> - <Deferred scope or unresolved open question, if any> <Replace the bullets above with `None — requirements were fully specified.` when no assumptions were made.> ## Verification & Testing - **Commands Executed**: `<bazel test / go test / ./tools/run_affected_tests.py>` - **Coverage & Test Status**: <Summary of unit/integration test results and pass state.> <!-- Embed Trajectory Benchmark if available --> <details open> <summary><b>🧪 Trajectory & Outcome Benchmark Results</b></summary> [Benchmark Telemetry & Scorecard] </details> ## Related Issues / Bugs Fixes bug <bug_id> (or N/A) TAG=agy CONV=<conversation_id> -
Mandatory User Confirmation Gate Before PR Creation: NEVER execute
gh pr create(draft or non-draft) without explicit, affirmative user confirmation in the current conversation turn. Phrases like "proceed with next phase" authorize local work and verification, but DO NOT authorize opening a remote Pull Request. The agent MUST presentpr_body.md, the planned PR title, body preview, and list of changes to the user for review and explicitly ask:"I have prepared the Pull Request." Title:
<type>(<scope>): <summary>List of Changes:- [List of changes]
Description Preview (from
pr_body.md):
[Markdown Preview]
Shall I proceed with creating the Draft Pull Request on GitHub? (Y/n)"
- [List of changes]
Description Preview (from
-
Create Draft PR via GitHub CLI: All new PRs must be created in Draft state:
gh pr create --draft --title "<type>(<scope>): <summary>" --body-file pr_body.md
4. PR Description Updates via Helper Tool
When updating an existing Pull Request description:
- Format Updated Body: Prepare the updated body markdown in a temporary file (e.g.,
updated_pr_body.md). - User Edit Gate: Present the updated PR description preview to the user and pause for confirmation/edits.
- Execute Update Tool:
./tools/pr_review/update_pr_description.py <pr_number> --body-file updated_pr_body.md[!IMPORTANT] Do NOT use
gh pr editdirectly to update descriptions, as classic project deprecations break description fields.
5. CI Wait Buffer Period
- After creating or updating a Pull Request, pause execution for approximately 2 minutes (120 seconds).
- Allow GitHub CI status checks and automated PR review passes to run and produce initial status checks before proceeding to subsequent workflow steps.
- Wait for CI Completion via Helper Tool: After the buffer, block on CI with:
The tool polls with backoff until every check completes, exits./tools/pr_review/wait_for_ci.py <pr_number> [--repo owner/name] [--timeout 1800] [--interval 30]0when all pass,1on failure or timeout, and2on an unexpected internal error. It judges only the newest run of each check, so runs cancelled because a later push superseded them are not failures. On failure its error JSON listsfailed_checks, each with its workflowrun_id,job_id, and a boundedlog_tail(up to 80 lines of the job log ending at its last##[error]line; tune with--log-lines).[!IMPORTANT] Do NOT poll with bare
gh pr checks(it exits8while checks are pending, breaking&&chains), do NOT pass check/job IDs togh run list --workflowor usegh pr checks --json(unsupported by olderghreleases), and do NOT rely ongh run view --log-failed(prints nothing on someghreleases). Usewait_for_ci.pyoutput instead of dumping full CI logs.
6. Draft PR to Open Conversion Policy (Strict Confirmation Gate)
Pull Requests in XMC MUST always be created as Draft PRs by default.
[!CAUTION] Strict Prohibition Against Automatic Draft-to-Open PR Conversion: Agents MUST NEVER execute
gh pr ready <pr_number>or convert a Draft Pull Request to Open (ready for review) without explicit, separate user confirmation in the current conversation turn.
Rules & Guardrails:
- Draft State Default: All newly created PRs remain in Draft state throughout development, testing, and automated review iterations.
- Generic Authorizations Insufficient: General instructions like "proceed", "continue", "finish", "all done", "looks good", or "resolve comments" authorize local fixes or test verification, but DO NOT authorize converting a Draft PR to Open.
- Mandatory Confirmation Prompt: Even after all CI checks pass (
./tools/pr_review/wait_for_ci.py <pr_number>exits0) and 100% of review comments are resolved, the agent MUST NOT rungh pr ready. Instead, the agent reports completion and explicitly asks:"All CI checks have passed and all review comments have been resolved for Draft PR #<pr_number>."
"Would you like me to convert Pull Request #<pr_number> from Draft to Open (ready for review)? (Y/n)"
- Execution on Explicit Affirmation Only:
- Run
gh pr ready <pr_number>ONLY IF the user explicitly confirms (e.g., "yes", "Y", "convert to open", "mark ready for review"). - If the user declines ("no"), does not respond to the question, or provides any other instruction, the PR MUST REMAIN in Draft state.
- Run
7. Standard 5-Step End-to-End PR Lifecycle
When creating and managing Pull Requests, follow this mandatory 5-step lifecycle:
- Diff Sizing Check & Create Draft PR (Requires Confirmation Gate): Run
./tools/analyze_diff_size.py --base-ref origin/main.... If thresholds are exceeded, invoke XMC PR Split Verification. Otherwise, obtain explicit user confirmation per Section 3, Step 7 (presenting Title, List of Changes, and Description Preview). Once confirmed, execute:gh pr create --draft --title "<type>(<scope>): <summary>" --body-file pr_body.md - Wait for Automated Review Bot: Pause for 2–3 minutes to allow GitHub CI status checks and the automated Gemini review bot to inspect code diffs and post review comments.
- Pull Review Comments:
Fetch unresolved review comments and generate the review checklist artifact:
./tools/pr_review/generate_review_checklist.py <owner> <repo> <pr_number> -o pr_review_checklist.md - Address Review Comments:
Triage each comment's technical validity, rule alignment, and PR scope impact per Comment Validity & Pushback Triage (adopting valid fixes vs. posting technical pushback replies when a suggestion conflicts with repository rules or scope boundaries), commit and push adopted updates, post inline thread replies (
./tools/pr_review/reply_pr_comment.py), and verify 1-to-1 resolution (./tools/pr_review/verify_pr_comment_resolution.py). - Verify CI Checks & Draft Status Report (Requires Explicit Confirmation Gate to Convert):
Verify CI status with
./tools/pr_review/wait_for_ci.py <pr_number>(see Section 5). When checks pass and all comments are resolved, report the final state to the user. Do NOT automatically convert the PR to open. Explicitly ask for user confirmation per Section 6 ('Would you like me to convert Pull Request #<pr_number> from Draft to Open (ready for review)? (Y/n)'). Only if explicitly confirmed by the user, execute:gh pr ready <pr_number>
04 同仓库更多 Skills
XMC Upgrade Environment
Upgrades an existing XManager on Cloud (XMC) environment on GKE to the latest current branch state using the deployment configuration YAML.
XMC Trajectory Comparison
Validates proposed skill or rule changes by executing concurrent A/B benchmark subagents on clean baseline vs candidate worktrees, comparing trajectories, and tearing down test resources.
XMC Review PR
Interactive multi-agent PR review workflow enforcing code rules, open direction discussions, explicit confirmation gates, inline comment deduplication, and follow-up re-review verification.
XMC Release
Orchestrates an end-to-end XMC release workflow — deploying the latest main to nightly, running and verifying e2e tests, capturing visual snapshot galleries, generating and iterating on structured release notes with the user, and publishing the release. Use when preparing, orchestrating, or publishing a formal XMC release from main.
XMC PR Split Verification
Analyzes pull request diffs exceeding size thresholds (400 prod / 1000 total / 1000 docs) to enforce Single Responsibility Principle (SRP), evaluate vertical slice splitting feasibility, eliminate dead code, and plan gh-stack PR stacks.
XMC Iterative Reflection
Audits active session trajectory, thought history, and PR review comments to identify friction points, rule gaps, missing helper tools, and token inefficiencies. Use when requested by the user, after major implementations, or following PR review comment resolutions.