Skip to content

Commit e0137b6

Browse files
joshsmithxrmclaude
andcommitted
chore(commands): improve commit/ship workflow documentation
- Add confirmation step to /commit before staging changes - Reorder /ship to sync with base branch before validation - Delegate /ship commit step to /commit for consistency - Optimize CI polling with 3-min initial wait Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 3168b9b commit e0137b6

File tree

2 files changed

+86
-48
lines changed

2 files changed

+86
-48
lines changed

.claude/commands/commit.md

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,23 @@ Create recovery checkpoints during long work sessions. Unlike `/ship`, this:
1818

1919
## Process
2020

21-
### 1. Detect Current Phase
21+
### 1. Acknowledge Uncommitted Changes
22+
23+
Before committing, list what will be included:
24+
25+
```bash
26+
git status --short
27+
```
28+
29+
**If changes exist:**
30+
1. Display the list of changed/new files
31+
2. Ask user to confirm: "Including these changes. Proceed? [Y/n]"
32+
3. If user declines, abort without changes
33+
34+
**If no changes exist:**
35+
- Report "Nothing to commit" and exit
36+
37+
### 2. Detect Current Phase
2238

2339
Analyze the work context to determine phase:
2440

@@ -28,13 +44,13 @@ Analyze the work context to determine phase:
2844
| Code changes, no test changes | `implementation` |
2945
| Test files changed | `testing` |
3046

31-
### 2. Stage All Changes
47+
### 3. Stage All Changes
3248

3349
```bash
3450
git add -A
3551
```
3652

37-
### 3. Generate Commit Message
53+
### 4. Generate Commit Message
3854

3955
Based on detected phase:
4056

@@ -69,7 +85,7 @@ test(scope): add tests for feature
6985
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
7086
```
7187

72-
### 4. Create Commit
88+
### 5. Create Commit
7389

7490
```bash
7591
git commit -m "$(cat <<'EOF'
@@ -83,8 +99,15 @@ EOF
8399
```
84100
Commit
85101
======
102+
Changes to include:
103+
M src/PPDS.Cli/Services/PluginService.cs
104+
M src/PPDS.Cli/Commands/PluginCommands.cs
105+
A tests/PPDS.Cli.Tests/PluginServiceTests.cs
106+
107+
Including these changes. Proceed? [Y/n] y
108+
86109
[✓] Phase detected: implementation
87-
[✓] Files staged: 5
110+
[✓] Files staged: 3
88111
[✓] Committed: feat(plugins): add registration service
89112
90113
Checkpoint saved. Continue working or run /ship when ready.

.claude/commands/ship.md

Lines changed: 58 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -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
2022
Push to remote
2123
2224
Create PR
2325
24-
Wait for CI
26+
Wait for CI (3 min initial, then poll)
2527
2628
If 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

4446
Use `$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
6690
git 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
101107
git push -u origin "$(git rev-parse --abbrev-ref HEAD)"
@@ -106,7 +112,7 @@ If `--amend` was used:
106112
git push --force-with-lease
107113
```
108114

109-
### 4. Create PR (if none exists)
115+
### 5. Create PR (if none exists)
110116

111117
```bash
112118
gh pr create --title "PR title" --body "$(cat <<'EOF'
@@ -124,7 +130,7 @@ EOF
124130
)"
125131
```
126132

127-
### 5. Wait for Required CI Checks
133+
### 6. Wait for Required CI Checks
128134

129135
After 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)
146159
SHA=$(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
150165
gh 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

161176
Bot 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

181196
Update 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 \
221236
2. If bot comments reference files not in your diff, they may be stale (rebase should fix this)
222237
3. 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

244259
After 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: ..."
276291
gh api graphql -f query='mutation { resolveReviewThread(input: {threadId: "ID"}) { thread { isResolved } } }'
277292
```
278293

279-
### 9. Update Session Status
294+
### 10. Update Session Status
280295

281296
After all checks pass:
282297

0 commit comments

Comments
 (0)