@@ -13,15 +13,17 @@ Complete work: validate, commit, push, create PR, and handle CI/bot feedback aut
1313```
1414/ship
1515 ↓
16- Pre-PR Validation (absorbed from /pre-pr )
16+ Sync with base branch (rebase if needed )
1717 ↓
18- Commit changes
18+ Pre-PR Validation (build & test)
19+ ↓
20+ Commit changes (delegates to /commit)
1921 ↓
2022Push to remote
2123 ↓
2224Create PR
2325 ↓
24- Wait for CI
26+ Wait for CI (3 min initial, then poll)
2527 ↓
2628If CI fails: Debug and fix (up to 3 attempts)
2729 ↓
@@ -43,9 +45,31 @@ GITHUB_REPO=$(echo "$GITHUB_REMOTE" | sed -E 's#.*/([^/]+?)(\.git)?$#\1#')
4345
4446Use ` $GITHUB_OWNER ` and ` $GITHUB_REPO ` in all ` gh api ` calls instead of hardcoded values.
4547
46- ### 1. Pre-PR Validation
48+ ### 1. Sync with Base Branch
49+
50+ Always sync before validation to ensure tests run against rebased code:
51+
52+ ``` bash
53+ git fetch origin
54+ BEHIND=$( git rev-list --count HEAD..origin/main)
55+
56+ if [ " $BEHIND " -gt 0 ]; then
57+ # Check for commits already in main (stale branch scenario)
58+ UNIQUE=$( git log --oneline origin/main..HEAD --cherry-pick --right-only 2> /dev/null | wc -l)
59+ TOTAL=$( git rev-list --count origin/main..HEAD)
60+
61+ if [ " $UNIQUE " -lt " $TOTAL " ]; then
62+ echo " Branch has $(( $TOTAL - $UNIQUE )) commits already in main, auto-resolving..."
63+ fi
64+
65+ # Use -X theirs to auto-resolve when commits match main
66+ git rebase -X theirs origin/main
67+ fi
68+ ```
69+
70+ ### 2. Pre-PR Validation
4771
48- Run all validation checks before creating the PR :
72+ Run all validation checks on rebased code :
4973
5074** Build & Test:**
5175``` bash
@@ -66,36 +90,18 @@ git rm .claude/design.md 2>/dev/null || true
6690git rm docs/tui/POLISH_TRACKER.md 2> /dev/null || true
6791```
6892
69- ### 1b. Sync with Base Branch (BEFORE push )
93+ ### 3. Commit (if needed )
7094
71- Always rebase before pushing to ensure bot reviewers see only your actual changes :
95+ If uncommitted changes exist, delegate to ` /commit ` :
7296
73- ``` bash
74- git fetch origin
75- BEHIND=$( git rev-list --count HEAD..origin/main)
97+ 1 . Run ` /commit ` which will:
98+ - List changed files and ask user to confirm
99+ - Detect phase and generate appropriate commit message
100+ - Create the commit with ` Co-Authored-By ` trailer
76101
77- if [ " $BEHIND " -gt 0 ]; then
78- # Check for commits already in main (stale branch scenario)
79- UNIQUE=$( git log --oneline origin/main..HEAD --cherry-pick --right-only 2> /dev/null | wc -l)
80- TOTAL=$( git rev-list --count origin/main..HEAD)
102+ See ` /commit ` command for full behavior.
81103
82- if [ " $UNIQUE " -lt " $TOTAL " ]; then
83- echo " Branch has $(( $TOTAL - $UNIQUE )) commits already in main, auto-resolving..."
84- fi
85-
86- # Use -X theirs to auto-resolve when commits match main
87- git rebase -X theirs origin/main
88- fi
89- ```
90-
91- ### 2. Commit (if needed)
92-
93- If uncommitted changes exist:
94- 1 . Stage all: ` git add -A `
95- 2 . Generate conventional commit message
96- 3 . Commit with ` Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> `
97-
98- ### 3. Push (if needed)
104+ ### 4. Push (if needed)
99105
100106``` bash
101107git push -u origin " $( git rev-parse --abbrev-ref HEAD) "
@@ -106,7 +112,7 @@ If `--amend` was used:
106112git push --force-with-lease
107113```
108114
109- ### 4 . Create PR (if none exists)
115+ ### 5 . Create PR (if none exists)
110116
111117``` bash
112118gh pr create --title " PR title" --body " $( cat << 'EOF '
124130) "
125131```
126132
127- ### 5 . Wait for Required CI Checks
133+ ### 6 . Wait for Required CI Checks
128134
129135After PR creation, poll only REQUIRED checks (don't wait for optional ones):
130136
@@ -140,23 +146,32 @@ After PR creation, poll only REQUIRED checks (don't wait for optional ones):
140146- ` claude ` , ` claude-review ` - optional AI review
141147- ` codecov/* ` - informational coverage
142148
143- ** Polling approach:**
149+ ** Polling approach (optimized for context efficiency):**
150+
151+ 1 . Wait 3 minutes after PR creation (CI needs time to start)
152+ 2 . Poll once for required checks
153+ 3 . If all passed → proceed to bot review
154+ 4 . If still running → wait 2 more minutes, poll again
155+ 5 . If failed → start autonomous fix (step 8)
156+
144157``` bash
145158# Get SHA of PR head commit (use gh CLI's built-in --jq, NOT external jq)
146159SHA=$( gh pr view {pr} --json headRefOid --jq ' .headRefOid' )
147160
148- # Poll required checks every 30 seconds until all complete
149- # Use $GITHUB_OWNER and $GITHUB_REPO from step 0
161+ # Initial 3-minute wait
162+ sleep 180
163+
164+ # Poll required checks
150165gh api repos/$GITHUB_OWNER /$GITHUB_REPO /commits/$SHA /check-runs \
151166 --jq ' .check_runs[] | select(.name | test("^(build|test|extension|Analyze|CodeQL|dependency)"))
152167 | {name: .name, status: .status, conclusion: .conclusion}'
153168```
154169
155170** Important:** Do NOT use ` gh pr checks --watch ` - it waits for ALL checks including optional ones.
156171
157- ** Timeout:** If required checks don't complete within 15 minutes, update session status to ` Shipping ` and continue to bot review phase.
172+ ** Timeout:** If required checks don't complete after 2 poll cycles ( ~ 7 minutes) , update session status to ` Shipping ` and continue to bot review phase.
158173
159- ### 5b . Wait for Bot Reviews (parallel to CI)
174+ ### 6b . Wait for Bot Reviews (parallel to CI)
160175
161176Bot reviews can complete before or after CI. Check for them independently:
162177
@@ -180,7 +195,7 @@ gh api "repos/$GITHUB_OWNER/$GITHUB_REPO/code-scanning/alerts?ref=refs/pull/{pr}
180195
181196Update session status to ` ReviewsInProgress ` once at least one bot has commented.
182197
183- ### 6 . Enumerate ALL Bot Reviewers
198+ ### 7 . Enumerate ALL Bot Reviewers
184199
185200** CRITICAL: Before addressing ANY comments, enumerate all reviewers:**
186201
@@ -221,7 +236,7 @@ gh api repos/$GITHUB_OWNER/$GITHUB_REPO/pulls/{pr}/comments \
2212362 . If bot comments reference files not in your diff, they may be stale (rebase should fix this)
2222373 . If you rebased, bots will re-review the updated PR
223238
224- ### 7 . Handle CI Failures
239+ ### 8 . Handle CI Failures
225240
226241** If CI fails (up to 3 attempts):**
227242
@@ -243,9 +258,9 @@ gh run view [run-id] --log-failed
243258
244259After 3 failed attempts, update session status to ` stuck ` and escalate.
245260
246- ### 8 . Address Bot Comments
261+ ### 9 . Address Bot Comments
247262
248- Using the comments enumerated in step 6 , for each finding determine verdict:
263+ Using the comments enumerated in step 7 , for each finding determine verdict:
249264
250265| Verdict | Action |
251266| ---------| --------|
@@ -276,7 +291,7 @@ gh pr comment {pr} --body "Addressed bot feedback: ..."
276291gh api graphql -f query=' mutation { resolveReviewThread(input: {threadId: "ID"}) { thread { isResolved } } }'
277292```
278293
279- ### 9 . Update Session Status
294+ ### 10 . Update Session Status
280295
281296After all checks pass:
282297
0 commit comments