Skip to content

feat(branch-finish): pre-flight gate + auto-promote drafts after pass#572

Merged
NagyVikt merged 1 commit into
mainfrom
agent/claude/gx-finish-preflight-and-auto-promote-2026-05-14-01-09
May 13, 2026
Merged

feat(branch-finish): pre-flight gate + auto-promote drafts after pass#572
NagyVikt merged 1 commit into
mainfrom
agent/claude/gx-finish-preflight-and-auto-promote-2026-05-14-01-09

Conversation

@NagyVikt
Copy link
Copy Markdown
Collaborator

Summary

Shifts agent verification from billable Actions minutes to free local CPU.

  • gx branch finish now runs scripts/agent-preflight.sh in the worktree before any push. 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. With the budget-friendly CI defaults (draft PRs skip CI), this is the moment CI fires — once, on a known-passing commit.
  • Default templates/scripts/agent-preflight.sh auto-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 in docs/preflight.md.

scripts/agent-preflight.sh is a symlink into templates/scripts/ per the paired-script convention (enforced by scripts/check-script-symlinks.sh). TEMPLATE_FILES ships it to downstream projects via gx setup.

Test plan

  • bash -n templates/scripts/agent-branch-finish.sh clean
  • bash -n templates/scripts/agent-preflight.sh clean
  • node --check src/context.js clean
  • scripts/check-script-symlinks.sh — 11 paired scripts verified
  • Smoke test of templates/scripts/agent-preflight.sh against gitguardex itself — picks up npm test
  • First real run: next gx branch finish call from a Node-stack worktree should hit pnpm test/npm test before pushing

Pre-existing failures on main not introduced here: 4 test/metadata.test.js assertions 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

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>
@NagyVikt NagyVikt merged commit 1f11a7c into main May 13, 2026
1 of 2 checks passed
@NagyVikt NagyVikt deleted the agent/claude/gx-finish-preflight-and-auto-promote-2026-05-14-01-09 branch May 13, 2026 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant