feat(branch-finish): pre-flight gate + auto-promote drafts after pass#572
Merged
NagyVikt merged 1 commit intoMay 13, 2026
Conversation
Shifts agent verification from billable Actions minutes to free local CPU.
`gx branch finish` now runs `scripts/agent-preflight.sh` in the worktree
BEFORE pushing; non-zero refuses the push so a broken commit never reaches
CI or the merge funnel. On pass, any draft PR is promoted to ready-for-
review via `gh pr ready` so the budget-friendly CI defaults fire once on
a known-passing commit.
Default `scripts/agent-preflight.sh` auto-detects the project stack and
runs conventional verification:
- Node+pnpm: pnpm typecheck && pnpm lint && pnpm test (each only if the
script exists in package.json)
- Node+npm: npm test (only if defined)
- Rust: cargo check --quiet
- Python: ruff check . (only if ruff is installed)
Unknown stacks pass with a warn-only message.
CLI flags: --no-preflight / --preflight / --preflight-script <path> /
--no-auto-promote / --auto-promote. Env vars: GUARDEX_FINISH_PREFLIGHT,
GUARDEX_FINISH_PREFLIGHT_SCRIPT, GUARDEX_FINISH_AUTO_PROMOTE.
Templates seeded via TEMPLATE_FILES so `gx setup` scaffolds the script
into downstream projects. scripts/agent-preflight.sh is a symlink to
the template per the existing paired-script convention and is enforced
by scripts/check-script-symlinks.sh.
Docs at docs/preflight.md.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This was referenced May 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Shifts agent verification from billable Actions minutes to free local CPU.
gx branch finishnow runsscripts/agent-preflight.shin the worktree before any push. Non-zero refuses the push, so a broken commit never reaches CI or the merge funnel.gh pr ready. With the budget-friendly CI defaults (draft PRs skip CI), this is the moment CI fires — once, on a known-passing commit.templates/scripts/agent-preflight.shauto-detects the project stack and runs conventional verification (Node+pnpm, Node+npm, Rust, Python). Unknown stacks pass with a warn-only message.Flags:
--no-preflight/--preflight/--preflight-script <path>/--no-auto-promote/--auto-promote. Env vars:GUARDEX_FINISH_PREFLIGHT,GUARDEX_FINISH_PREFLIGHT_SCRIPT,GUARDEX_FINISH_AUTO_PROMOTE. Documented indocs/preflight.md.scripts/agent-preflight.shis a symlink intotemplates/scripts/per the paired-script convention (enforced byscripts/check-script-symlinks.sh).TEMPLATE_FILESships it to downstream projects viagx setup.Test plan
bash -n templates/scripts/agent-branch-finish.shcleanbash -n templates/scripts/agent-preflight.shcleannode --check src/context.jscleanscripts/check-script-symlinks.sh— 11 paired scripts verifiedtemplates/scripts/agent-preflight.shagainst gitguardex itself — picks upnpm testgx branch finishcall from a Node-stack worktree should hitpnpm test/npm testbefore pushingPre-existing failures on
mainnot introduced here: 4test/metadata.test.jsassertions about CI/CodeQL PR triggers and README copy — stale after PR #571 dropped those triggers. Should be cleaned up in a follow-up.🤖 Generated with Claude Code