Skip to content

chore(skill): check branch is synced with origin/staging before pushing#5529

Merged
waleedlatif1 merged 11 commits into
stagingfrom
chore-ship-skill-sync-check
Jul 9, 2026
Merged

chore(skill): check branch is synced with origin/staging before pushing#5529
waleedlatif1 merged 11 commits into
stagingfrom
chore-ship-skill-sync-check

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • The /ship skill now checks git log --oneline origin/staging..HEAD before pushing, so a branch/worktree cut from a stale or diverged local staging doesn't silently drag dozens of extraneous commits into a PR
  • Documents the fallback fix (rebuild via cherry-pick onto origin/staging) when a plain rebase would otherwise walk through unrelated history

Type of Change

  • Chore

Testing

Verified the recovery steps against PR #5527, which had exactly this problem (branch's local base had a stray commit not in origin/staging, ballooning the PR to 100+ commits) — rebuilt cleanly via cherry-pick per the new instructions.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

…pushing

Prevents PRs from silently picking up extraneous commits when a
branch/worktree is cut from a stale or diverged local staging/main.
@vercel

vercel Bot commented Jul 9, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
docs Ready Ready Preview, Comment Jul 9, 2026 2:47am

Request Review

@cursor

cursor Bot commented Jul 9, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Documentation-only changes to agent/Cursor command skills; no runtime application code.

Overview
/ship now requires a pre-commit origin/staging sync check: inspect commits ahead of staging (not just a count), recover polluted branches via rebase or selective cherry-pick onto ship-sync-tmp, use --force-with-lease after history rewrites, and after opening the PR verify local vs GitHub commit headlines with git log --reverse.

Adds /babysit (.agents/skills/babysit/SKILL.md and .cursor/commands/babysit.md) to run PRs through Greptile/Cursor until 5/5 and zero unresolved review threads—triage, reply, resolve, re-sync/re-ship checks each round, separate @greptile / @cursor review pings, and loop with pacing (including ScheduleWakeup in the agent skill).

Reviewed by Cursor Bugbot for commit 04017a8. Configure here.

Comment thread .agents/skills/ship/SKILL.md Outdated
Comment thread .agents/skills/ship/SKILL.md Outdated
@greptile-apps

greptile-apps Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR updates the ship and babysit workflows to catch stale branch history before it reaches a PR. The main changes are:

  • Added an origin/staging..HEAD sync check before shipping.
  • Documented the cherry-pick rebuild path for polluted branches.
  • Added pre-push and post-push sync checks to the babysit loop.
  • Mirrored the workflow updates in the Cursor command files.

Confidence Score: 5/5

This looks safe to merge.

  • No blocking issues found in the changed code.

Important Files Changed

Filename Overview
.agents/skills/ship/SKILL.md Adds the main stale-branch sync check, recovery flow, force-with-lease guidance, and final PR commit verification.
.cursor/commands/ship.md Mirrors the ship workflow updates for Cursor.
.agents/skills/babysit/SKILL.md Adds the babysit workflow with repeated sync recovery, review-loop handling, and post-push verification.
.cursor/commands/babysit.md Mirrors the babysit workflow for Cursor.

Reviews (9): Last reviewed commit: "fix(ship-skill): push step needs force-w..." | Re-trigger Greptile

Comment thread .agents/skills/ship/SKILL.md Outdated
Comment thread .agents/skills/ship/SKILL.md Outdated
@waleedlatif1 waleedlatif1 changed the title chore(ship-skill): check branch is synced with origin/staging before pushing chore(skill): check branch is synced with origin/staging before pushing Jul 9, 2026
Ships (via /ship's sync check), waits for Greptile/Cursor Bugbot,
triages every open thread (fix real findings, push back on false
positives), replies + resolves each thread, re-triggers review, and
loops until Greptile is 5/5 with zero open threads.
@waleedlatif1 waleedlatif1 force-pushed the chore-ship-skill-sync-check branch from fddabad to 7eaec2c Compare July 9, 2026 01:37
Keeps the Cursor /commands mirrors of ship and babysit in sync with
the Claude Code .agents/skills versions so they don't drift.
…rebase, avoid fixed temp branch name

- Final verify now diffs actual commit subjects between git log and
  the PR, not just a count — a corrupted branch's inflated count could
  coincidentally match a later count check
- The pre-commit count in step 2 was being compared against the
  post-commit PR in step 9, which would mismatch even on success; now
  compares content at the point it's actually available
- Recovery flow stashes uncommitted work before rebasing so it isn't
  blocked by a dirty tree, and checks for an existing tmp branch
  before reusing the name
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread .agents/skills/ship/SKILL.md Outdated
Comment thread .agents/skills/babysit/SKILL.md Outdated
Comment thread .agents/skills/ship/SKILL.md Outdated
Comment thread .agents/skills/babysit/SKILL.md Outdated
…p-branch name blocks recovery

- A clean git rebase can replay stray commits with zero conflicts, so
  'rebase succeeded' was being treated as sufficient — now the log is
  always re-checked after rebasing, clean or not, before trusting it
- The recovery text told the agent to 'pick another name' if
  ship-sync-tmp was taken but then hardcoded that literal name anyway;
  now it just deletes the leftover (disposable, single-purpose) branch
  instead of introducing a naming scheme
- babysit's step 5 pointed at re-running the log check alone; it now
  points at the full /ship step 2 recovery flow, since a review loop
  spanning a long session is exactly where drift compounds silently
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread .agents/skills/ship/SKILL.md
Comment thread .agents/skills/ship/SKILL.md
Comment thread .agents/skills/babysit/SKILL.md
Comment thread .agents/skills/babysit/SKILL.md Outdated
…verify, paginate threads, verify after every push

- ship-sync-tmp deletion is now conditional on the branch existing —
  a bare 'git branch -D' on a first recovery attempt with no leftover
  would fail and block the rebuild before it started
- step 9's final commit-content verify now fetches origin/staging
  first, matching step 2; a stale local ref could mask real drift
- babysit's reviewThreads query now checks pageInfo.hasNextPage and
  pages through all threads instead of assuming 50 is always enough
- babysit now re-runs the sync-content verify after every push, not
  just before it, so a bad push or a PR that drifted mid-loop doesn't
  go unnoticed across review rounds
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread .agents/skills/ship/SKILL.md Outdated
Comment thread .agents/skills/babysit/SKILL.md Outdated
Comment thread .cursor/commands/babysit.md Outdated
…ing wrong line, stale step reference

- git log --oneline is newest-first, gh pr view commits is oldest-first
  — the two content-verify commands now use --reverse so a positional
  comparison doesn't spuriously fail on any multi-commit branch
- 'select(...) | .body | tail -1' pipes every matching comment's full
  body through the pipeline and keeps only the last LINE of the
  combined output (the review-count footer), not the last COMMENT —
  demonstrated this myself this session reading the footer instead of
  the actual score. Now uses '[.comments[]] | last | .body'
- Cursor's babysit.md pointed at '/ship step 9', but Cursor's ship.md
  only has 7 steps (no cleanup/migration steps) — now points at step 7
  and cross-references the 9-step Claude Code skill copy
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread .agents/skills/ship/SKILL.md Outdated
Comment thread .agents/skills/ship/SKILL.md
Comment thread .cursor/commands/ship.md Outdated
…oldest-first

- git refuses to delete the branch currently checked out, so if an
  earlier interrupted recovery left the agent sitting on ship-sync-tmp,
  the conditional delete would find the branch and then fail to remove
  it, blocking the rest of the rebuild. Now checks out the original
  branch first (a no-op if already there).
- git log's default order is newest-first; cherry-picking session SHAs
  in that displayed order applies the newest commit before older ones,
  which can fail or produce the wrong history with 2+ session commits.
  Now explicit: cherry-pick oldest-first, using --reverse to get them
  in that order directly.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread .agents/skills/ship/SKILL.md Outdated
Comment thread .agents/skills/ship/SKILL.md Outdated
…p branch, make tmp delete idempotent

- Step 4 of the rebuild checks out ship-sync-tmp at origin/staging, so
  HEAD no longer contains the session's commits by the time the old
  step 4 (now step 5) ran 'origin/staging..HEAD' to find them — that
  range was always empty by then, following the steps literally would
  cherry-pick nothing. Now captures the SHA list first, against the
  original branch name explicitly, before any branch switch.
- The show-ref-guarded delete still exits 1 (git show-ref's own
  failure) on the common first-attempt case where there's no leftover
  branch, which could halt a caller that stops on nonzero exit before
  ever reaching the rebuild. Replaced with a plain delete + || true,
  which always succeeds whether or not there was anything to delete.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread .agents/skills/ship/SKILL.md
Comment thread .agents/skills/ship/SKILL.md
Comment thread .agents/skills/babysit/SKILL.md Outdated
Comment thread .agents/skills/babysit/SKILL.md Outdated
…s it was meant to leave behind

- The 'capture the range' step from the previous round's fix captured
  origin/staging..<original-branch> wholesale — but in exactly the
  scenario that triggers this rebuild, that range also contains the
  unrecognized/stray commits, so cherry-picking 'all of it' recreated
  the same polluted branch. Now explicit: read the log, write down
  only the SHA(s) you recognize as your own, never the whole range.
- babysit's pre-push gate list named lint/typecheck/boundary-validation
  but dropped ship's conditional /cleanup and /db-migrate steps, which
  a review-fix round can trip just as easily as the original commit.
- babysit's force-with-lease condition only covered the cherry-pick
  rebuild path, but a plain 'git rebase origin/staging' that completes
  with no conflicts also rewrites already-published history and needs
  the same force push.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

Comment thread .agents/skills/ship/SKILL.md Outdated
…it's

Step 2's sync recovery rewrites already-pushed commits on a branch
that's been pushed before, but the push step only said 'push using
the current branch name' with no force-with-lease — a plain push
would be rejected in exactly the polluted-remote case step 2 exists
to fix. babysit already got this fix; ship's own push step didn't.
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cursor review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 04017a8. Configure here.

@waleedlatif1 waleedlatif1 merged commit 472457b into staging Jul 9, 2026
12 of 13 checks passed
@waleedlatif1 waleedlatif1 deleted the chore-ship-skill-sync-check branch July 9, 2026 02:46
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