Make @claude prompt demand a commit before finishing#897
Conversation
Run 27045987736 (PR #896) finished "success" with the head SHA unchanged: Claude used Edit/Write to modify files, posted a "Done. Here's a summary of what I implemented" comment, but never ran `git add` + `git commit`, so the post-step fell through to the prose-post path and the edits were discarded with the runner. Sharpens the prompt's step 4 to make it explicit that uncommitted working-tree edits are lost, and that "I edited files" is not the same as "I committed". Adds a mandatory step 5 self-check: run `git status --porcelain` (must be empty) and `git log --oneline -5` (must show the new commits) immediately before stopping. If nothing was committed, the session must either commit the work or explicitly say "no changes needed" — describing edits that weren't committed is a task failure, not a completion. Also makes the `git push` exclusion louder so a denied push doesn't prompt Claude to wrap up before committing.
|
Claude finished @d-morrison's task in 2m 4s —— View job Code Review: PR #897 — Strengthen @claude commit-before-finish instructions
Overall verdict: LGTM with one nit. The changes are well-targeted at the documented failure mode. The core fix — Findings[Strength] [Strength] [Strength] "Task failure" framing
Strong, unambiguous instruction. Explicitly naming the "no changes needed" path prevents Claude from going silent when it genuinely decided not to edit anything. [Nit] Step 5 says:
The phrase "on top of the branch you started on" assumes Claude knows the session-start SHA. It doesn't — the prompt doesn't surface it. On a PR branch with prior commits, Claude is eyeballing whether the top 5 entries include something it authored, which is a heuristic rather than a hard check. This is a secondary concern (the porcelain check is the primary guard), but a more precise instruction would be something like: git log --oneline $(git merge-base HEAD origin/${{ github.base_ref }})..HEADor, for the issue-trigger case where a fresh branch was created from git log --oneline main..HEADA simpler alternative: capture the starting SHA as a GitHub Actions expression and embed it in the prompt context block (the PR trigger already captures This nit doesn't block the fix (the [Minor wording] "confirm your commits are present" is misleading on no-change sessions The line immediately preceding the code block reads:
If the correct outcome is "no changes needed," there are no commits to confirm. The instruction later handles this correctly, but the inline comment |
- Tightens the existing "up to date with main" rule from "before requesting review" to "before pushing", which catches stale-branch CI failures earlier and avoids the case where I push, then have to push again immediately after merging main. - Adds the rule that workflow / `.github/` / CI / infra changes go in their own PRs, never mixed with book-content changes.
|
Claude finished @d-morrison's task in 5m 20s —— View job Code Review: PR #897 — Make @claude prompt demand a commit before finishing
Overall verdict: LGTM with two nits. The core fix — step 5's One structural finding worth noting before the nits: Key asymmetry between PR and issue triggersThe post-step auto-commit sweep ( This means for issue triggers, uncommitted edits are caught by the post-step even if Claude ignores step 5. For PR triggers, the new step 5 self-check in the prompt is the only guard (short of Claude's commits simply not being pushed). The PR is addressing the right failure mode with the right tool (prompt instruction), but adding the same auto-commit sweep to the PR trigger post-step would give belt-and-suspenders coverage there too. That's a separate PR, not a blocker here. Nit 1 —
|
Addresses both claude-bot reviews on PR #897: - Nit 1: `git log --oneline -5` had no baseline, so Claude had to eyeball whether the last few commits included anything from this session. Now the pre-resolved context block surfaces the session-start SHA (from `steps.head_before.outputs.sha` on PR triggers or `steps.issue_branch.outputs.starting_sha` on issue triggers), and step 5 says `git log --oneline <START>..HEAD` — zero lines means nothing was committed, no eyeballing required. - Nit 2: the inline comment `# confirm your commits are present` read as an unconditional expectation, contradicting the "no changes needed" path documented just below. Relaxed to `# check whether you committed`, which matches both outcomes.
|
Claude finished @d-morrison's task in 1m 56s —— View job Code Review: PR #897 — Make @claude prompt demand a commit before finishing
Overall verdict: LGTM. Both nits flagged in prior reviews have been resolved by commit What's fixed vs. prior reviewsNit 1 (baseline SHA for Nit 2 ( Remaining nit[Nit] comment ("no changes
needed because X") rather than describing edits that
weren't committed.In the YAML block scalar, this becomes a hard line break in the rendered prompt — Claude sees comment ("no changes needed because X") rather than
describing edits that weren't committed.Minor; the instruction is clear enough as-is. Fix this → Strengths
|
The YAML block scalar was wrapping mid-phrase, so the rendered prompt
showed `("no changes\nneeded because X")` with a literal newline.
Combine onto one line.
|
Claude finished @d-morrison's task in 2m 42s —— View job Code Review: PR #897 — Make @claude prompt demand a commit before finishing
Overall verdict: LGTM. All three nits raised in prior reviews have been addressed. The core fix is correct, the CLAUDE.md additions are clean, and this PR is ready to merge. Status of prior nitsNit 1 — Step 5 now reads: and
The Nit 2 — Now reads Nit 3 — split phrase introducing a hard line break ✅ resolved by The phrase is now on one line: comment ("no changes needed because X") rather than
describing edits that weren't committed.No YAML block-scalar newline mid-phrase. Observation — working tree has CLAUDE.md reverted
-- Always merge `main` into the feature branch before pushing — not just before requesting review
+- Ensure branch is up to date with `main` before requesting review
...
-- Workflow / `.github/` / CI / infra changes go in their own dedicated PRs — never mix them with book-content PRsThe HEAD commit has the correct content, so this won't affect the PR or merge. It's likely an artifact from the previous Strengths (unchanged from prior reviews, still valid)
|
|
Claude finished @d-morrison's task in 3m 9s —— View job Code Review: PR #897 — Make @claude prompt demand a commit before finishing
Overall verdict: LGTM. All three nits raised in prior reviews have been resolved. The core fix is correct and the PR is appropriately scoped.
What the PR does
Prior nits — all resolvedNit 1 —
Zero lines = nothing committed; no eyeballing. Verified: Nit 2 — Now reads Nit 3 — split phrase introducing a hard line break ✅ resolved The phrase New minor observation
If Claude runs this verbatim without substituting the SHA, git interprets Not a blocker — the instruction above the block is clear, and a git error would prompt Claude to fix it. Just noting it as the one remaining rough edge. Strengths
|
Summary
@claudeaction prompt in.github/workflows/claude.ymlto make explicit that uncommitted working-tree edits are lost when the runner exits, and that "I edited files" is not the same as "I committed".git status --porcelain(must be empty) andgit log --oneline -5(must show the new commits). If nothing was committed, either commit or explicitly say "no changes needed" — describing edits that weren't committed is a task failure.git pushexclusion louder so a denied push doesn't lead Claude to wrap up before committing.Why
Run 27045987736 on PR #896 finished with
subtype: success,permission_denials_count: 1, andSHA_BEFORE == SHA_AFTER. Claude used Edit/Write to modify files and posted a "Done. Here's a summary of what I implemented" comment, but never invokedgit add+git commit— so the post-step correctly fell through to the prose-post path and the edits were discarded with the runner. The fix is in the prompt, not the permission model: keepinggit pushout of Claude's hands remains the right design.Test plan
@claudemention on a PR that requires file edits and confirm the new commits land on the PR head.@claudemention where no edits are needed and confirm Claude says so explicitly rather than describing edits.Generated by Claude Code