name: buck2-stack-maintainer description: Maintain the Buck2 BuildBuddy patch stack in a local Buck2 checkout by rebasing fork/stack onto origin/main, publishing bazel-rbe-style merge commits to fork/main with origin/main as first parent, triggering or polling BuildBuddy Workflows, and fixing failed stack commits.
Buck2 Stack Maintainer
Use this skill for the Buck2 fork stack in a local Buck2 checkout, usually
${BUCK2_CHECKOUT:-$HOME/work/facebook/buck2}. The durable stack branch is
fork/stack. The public CI branch is fork/main. The retired
fork/sluongng/codex-bes branch is not part of normal maintenance.
Invariants
origin/mainis the upstream source of truth.fork/stackis the linear review stack rebased ontoorigin/main.fork/mainis a merge-commit branch. Its HEAD must be a non-FF merge commit whereHEAD^1 == origin/mainandHEAD^2 == fork/stack.- Do not delete or rewrite old branches without an explicit backup ref and a lease. Preserve unrelated dirty or untracked files.
- Validate stack prefixes in order. If prefix N fails, fix the corresponding stack commit with fixup/autosquash, then rerun from that prefix.
Standard Workflow
Inspect state before mutating anything:
git status --short --branch git remote -v git ls-remote --heads fork main stackIn automation worktrees, ensure only
.buckconfig.localis linked from the primary checkout before using--wait-buildbuddy:primary="${BUCK2_CHECKOUT:-$HOME/work/facebook/buck2}" ln -s "$primary/.buckconfig.local" .buckconfig.localDry-run the maintainer script from the Buck2 checkout. Use
--source-ref HEADonly when the source should be the current local stack tip instead offork/stack.skill_root="${BUCK2_STACK_SKILL_DIR:-<path-to-this-skill>}" python3 "$skill_root/scripts/sync_stack.py" \ --dry-run \ --source-ref HEADCheck BuildBuddy setup before any branch rewriting. This verifies the current
fork/mainmerge-parent invariant and tries the workflow preflight against the current merge commit:skill_root="${BUCK2_STACK_SKILL_DIR:-<path-to-this-skill>}" python3 "$skill_root/scripts/sync_stack.py" \ --check-buildbuddy-setup \ --attempt-buildbuddy-linkIf this reports that
sluongng/buck2is not known to BuildBuddy, stop and complete the GitHub App / Workflows setup fromreferences/buildbuddy-workflows.mdbefore pushing more merge commits. After GitHub App access has been granted, link the repo through the logged-in BuildBuddy browser session, then rerun the setup check. The bundledscripts/buildbuddy_link_repo_browser.pydrives this via the Codex Chrome native host (codex-linux-extension-host), which is not present under Claude Code — instead use thechrome-devtoolsskill (or do the linking manually in your browser) to open the BuildBuddy workflows page and connect the repo.Apply locally in an isolated automation worktree or a deliberately prepared checkout. Use the bootstrap flag only until
fork/stackexists: Use--source-ref <sha-or-ref>whenever the source should be an explicit local stack tip rather than the currentfork/stackremote branch.skill_root="${BUCK2_STACK_SKILL_DIR:-<path-to-this-skill>}" python3 "$skill_root/scripts/sync_stack.py" \ --apply \ --source-ref HEADPublish only after reviewing the plan and local invariants. This pushes stack-prefix merge commits to
fork/mainsequentially and updatesfork/stackat the end:skill_root="${BUCK2_STACK_SKILL_DIR:-<path-to-this-skill>}" python3 "$skill_root/scripts/sync_stack.py" \ --apply --push --wait-buildbuddy --attempt-buildbuddy-link \ --source-ref HEADIf the checked-in BuildBuddy workflow harness changed, add
--revalidate-all --skip-buildbuddy-preflightso every prefix is tested with the new workflow and the old workflow is not started by the unpolled preflight.On failure, inspect the BuildBuddy invocation and the stack commit that introduced it. Prefer the existing Buck2 validation helpers: When
sync_stack.py --push --wait-buildbuddyobserves a polled BuildBuddy failure, it restoresfork/mainto the previous head by default before exiting. Use--leave-failed-mainonly when deliberately keeping the public branch on the failing prefix for manual debugging.buildbuddy/run_stack_test_matrix.sh --from origin/main --to HEAD --mode remote --matrix app-rust buildbuddy/run_buck2_test_matrix.sh --mode both --matrix app-rust --clean-output
References
- Read
references/merge-commit-strategy.mdbefore changing the branch model or force-pushingfork/main. - Read
references/buildbuddy-workflows.mdbefore changing workflow trigger or polling behavior.