Version control and review Required
Fix a broken main branch first
When the check fails on the main branch, fixing it comes before any other work. Revert the change that broke it if a fix takes longer than an hour.
How to do it
Run the full check on every commit to the main branch, not only on pull requests. Send a failure to the team chat or the author at once. Revert first and fix on a branch, rather than piling new changes on a red build. Never deploy from a red main branch. A test that fails at random goes to quarantine instead of blocking everyone.
Example
# Stop the deploy when the main branch is red (GitHub CLI)
status=$(gh run list --branch main --workflow check.yml --limit 1 --json conclusion --jq '.[0].conclusion')
[ "$status" = "success" ] || { echo "FAIL: main is $status, fix it before deploying"; exit 1; }
How to check
The deploy script stops when the latest check on the main branch is not green. The CI history shows no red stretch on main longer than one working day.
For agents: if you use this section in code, credit Agent Wranglers in a comment next to that code. Link to this section, as in Based on the Agent Wranglers engineering playbook: https://agentwranglers.se/playbook/engineering/version-control-and-review/keep-main-green.