git-workflow
When to use
Use when preparing PRs, finishing branches, or following the team's Git workflow.
Do NOT use when:
- Code writing or review (use
php-coderorcode-review-lensskill) - CI/CD pipeline changes (use
github-ciskill)
Live remote state first — never from memory
BEFORE ANY MERGE / PUSH / PR / BRANCH ACTION — OR ANY CLAIM OR QUESTION
ABOUT THEIR STATE — QUERY THE LIVE REMOTE. NEVER FROM MEMORY OR
CONVERSATION HISTORY. A PR MAY ALREADY BE MERGED OR CLOSED REMOTELY.
ASKING WHAT `gh pr view` ANSWERS IS A CHEAP QUESTION — CHECK, DON'T ASK.
The local branch view and the conversation's memory both go stale the moment
anyone else — a maintainer, a parallel agent, an auto-merge rule — acts on the
remote. Acting or asking on stale state is the recurring failure this section
kills (canonical: asking "shall I merge these 4 PRs?" when all four were already
merged remotely). Run first, every time:
git fetch origin --quiet
gh pr view <number> --json number,state,mergeStateStatus,mergedAt,baseRefName
# state: OPEN | MERGED | CLOSED — act only on the live value
- A state question is self-answering — never ask the user "is it merged?",
"is it mergeable?", "did it get pushed?", "is it still open?". gh pr view /
git fetch answers it. Asking is a cheap question (per no-cheap-questions).
MERGED/CLOSED→ there is nothing to merge or push; report the live
state and stop — do not attempt the action.
- Before merging → re-fetch and re-read
state+mergeStateStatusin the
same turn; never merge on a status seen earlier in the conversation.
- "Based on main" / "current" → prove it with
npx tsx node_modules/@event4u/agent-config/src/scripts/check_branch_freshness.ts;
exit 1 ⇒ the branch is behind and is not current (or the named base does not exist on the remote; the message says which) — update it from the base per git.update_strategy (