Skip to content

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

Open
waleedlatif1 wants to merge 10 commits into
stagingfrom
chore-ship-skill-sync-check
Open

chore(skill): check branch is synced with origin/staging before pushing#5529
waleedlatif1 wants to merge 10 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 Building Building Preview, Comment Jul 9, 2026 2:37am

Request Review

@cursor

cursor Bot commented Jul 9, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Changes are limited to agent/Cursor command documentation; no application runtime, auth, or data paths are modified.

Overview
Extends /ship with a mandatory origin/staging sync before commit/push: compare the actual git log origin/staging..HEAD commit list (not just count), recover via stash → rebase → re-verify, and if stray history remains, rebuild with selective cherry-picks onto ship-sync-tmp. After opening the PR, it adds a post-push verify that git log --reverse matches gh pr view commit headlines.

Adds a new /babysit workflow (.agents/skills/babysit + .cursor/commands/babysit) to loop on Greptile 5/5 and zero unresolved review threads: triage findings, reply then resolve threads, re-run the full ship sync and pre-ship gates each round, push with --force-with-lease when history was rewritten, and re-trigger @greptile and @cursor review as separate comments.

The agents ship skill keeps its UI /cleanup and /db-migrate steps (renumbered); the Cursor ship.md only gains sync + verify (babysit still points agents ship for those conditional gates).

Reviewed by Cursor Bugbot for commit 59eec9a. 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 instructions to catch stale-base branches before they produce oversized PRs. The main changes are:

  • Adds a pre-push sync check against origin/staging.
  • Documents a cherry-pick rebuild flow for polluted branches.
  • Adds repeated babysit-loop verification before and after pushes.
  • Mirrors the updated instructions across agent and Cursor command files.

Confidence Score: 4/5

This is close, but the verification command should be fixed before merging.

  • The recovery flow now covers the stale-base cases called out earlier.
  • The final commit comparison can falsely report a mismatch because one command includes SHAs and the other does not.
  • That can send a clean branch back through rebuild and force-push steps unnecessarily.

.agents/skills/ship/SKILL.md and mirrored verification snippets

Important Files Changed

Filename Overview
.agents/skills/ship/SKILL.md Adds the main stale-base detection, recovery flow, and final commit-content verification.
.cursor/commands/ship.md Mirrors the ship recovery and verification instructions for Cursor.
.agents/skills/babysit/SKILL.md Adds full sync recovery and repeated post-push verification to babysit loops.
.cursor/commands/babysit.md Mirrors the babysit loop updates with Cursor-specific ship step references.

Comments Outside Diff (1)

  1. .agents/skills/ship/SKILL.md, line 80 (link)

    P1 Normalize commit subjects The verification still compares different output shapes. git log --oneline --reverse includes the abbreviated SHA before each subject, while gh pr view ... .messageHeadline returns only the subject. A clean PR can therefore look mismatched and send the agent back through the rebuild and force-push flow even though the branch history is already correct. Use a subject-only git format, and mirror the same normalization in the Cursor ship and babysit copies.

Reviews (8): Last reviewed commit: "fix(ship-skill,babysit): rebuild was rep..." | 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

@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.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 59eec9a. Configure here.

7. **Push to origin** using the current branch name
8. **Create a PR** to staging with a description in the user's voice
7. **Stage and commit** the changes with the generated message
8. **Push to origin** using the current branch name

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Ship push omits force-with-lease

Medium Severity

Step 2’s sync recovery (git rebase or cherry-pick rebuild) rewrites commits already on the remote, but step 8 only says to push the branch name with no --force-with-lease. That contradicts babysit’s push guidance and leaves the common polluted-remote case failing at push before step 9’s recovery text applies.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 59eec9a. Configure here.

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