merge-policy
Skill6 starsChanged 2 days agoMITView on GitHub
The software-factory rule that main must always be green, and how to land PRs under it — when a bypass/admin merge is and is not allowed, how to handle a hung required check, and what to do when main goes red. Use before merging or landing any PR, before running `gh pr merge --admin` or any merge that skips required checks, when a required check is stuck or failing, or when a test fails on main.
In this repository5 other files it gives its agents.
- AGENTS.mdAGENTS.md
- docs/agents.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- run-evalsSkill
- verifySkill
The file
We split this skill into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Very specific: line 12
Never use gh pr merge --admin, or any merge that bypasses required status checks, to get past a check that is actually FAILURE.
- Very specific: line 18
Run bash scripts/verify.sh --no-e2e locally and get it green.
- Very specific: line 19
Run targeted checks for anything the fast path skips (coverage: npm run test then npm run coverage-ratchet).
- Distinctive: line 28
Treat it as the top-priority task.
≈ “Common” is an estimate: at least 1 in 5 of the 372,429 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Merge policy: main must always be green
main must never carry a genuinely failing test, type error, or lint violation.
The rule
Never use gh pr merge --admin, or any merge that bypasses required status checks, to get past a check that is actually FAILURE. Fix the failure instead.
The only two legitimate bypasses
- The factory's own auto-merge. It bypasses the review-approval requirement, which a bot cannot obtain. Its CI gate (
waitForMergeinpackages/cli/src/cli/index.ts) still refuses to merge unless CI reported a realsuccess. It never merges on a failure or an unresolved or hung outcome. - A human confirms a required check is hung, not failed (for example the #739 CI deadlock). Before merging:
- Run
bash scripts/verify.sh --no-e2elocally and get it green. - Run targeted checks for anything the fast path skips (coverage:
npm run testthennpm run coverage-ratchet). - Say explicitly in the merge or PR comment that the check was hung and what you ran instead.
- Run
A bypass under case 2 is a workaround for an infra bug, not a norm. Open or link the issue that fixes the hang.
History: the multi-hour ci hang of #739/#755 was an unbounded microtask-only spin loop in router/index.test.ts, not the integration tests. CI jobs now carry a timeout-minutes ceiling so a future spin cannot strand open PRs.
When main is red
- Treat it as the top-priority task. A red
mainblocks every open PR, and every PR's diff is measured against it. - Reproduce on a fresh branch off
origin/mainwithbash scripts/verify.sh. - Fix the root cause in a small PR. Do not skip or delete the failing test to get green.
- Land the fix with normal required checks. Rebase other open PRs afterwards.
Landing a factory PR
factory shipandfactory run-issuestop at a ready-for-review PR. They never merge.factory land <issue>squash-merges a ready PR and cleans up its worktree.factory runmerges only when auto-merge is on (--auto-merge,.factory/config.yaml, orFACTORY_MERGE=1), and only through the CI gate above.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

