Remind to show diff on gh pr/issue edit; let classifier handle gh issue edit - #311
Merged
Conversation
gh pr edit / gh issue edit with --title, --body, or --body-file silently replaces existing content, and a mistaken value is otherwise easy to lose without a round-trip to git history. Add a PostToolUse hook that reminds the agent to present the before/after diff whenever such a command runs, and codify the same expectation in the git-essentials rule, pointing at the existing procedure in the git-workflow skill. Also drop the ask-permission entry for gh issue edit so the classifier decides instead of always prompting. Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Three review agents flagged: (1) MESSAGE told the model to re-fetch to recover the prior value, but by PostToolUse the edit is already applied and re-fetch returns the new body; (2) `--flag=value` tokens like `--title=NEW` slipped past exact set-membership matching; (3) short flags (`-t`, `-b`, `-F`) matched anywhere in compound commands like `... && grep -F pat`. - Anchor matcher to `tokens[0:3] == [gh, (pr|issue), edit]` and stop scanning at the first shell operator, so compound commands don't over-fire while short flags remain supported for the intended shape - Split `=` before flag lookup so `--title=X` and friends match - Rewrite MESSAGE: acknowledge recovery is only possible when the prior value is still in context; point at the git-workflow skill's `Update a PR / issue` procedure for future edits instead of framing it as retroactive - Add `isinstance(tool_input, dict)` guard so schema drift fails open silently instead of raising AttributeError - Rule bullet: drop the trailing rationale clause and switch the skill reference to the section name (numeric anchors drift when the skill is renumbered) - Add doctests covering the `=`-form, short flags, compound commands, and the create-vs-edit boundary Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
ikuwow
marked this pull request as ready for review
July 20, 2026 13:16
ikuwow
added a commit
that referenced
this pull request
Jul 20, 2026
…allowlist-187 Resolve claude/settings.json conflicts: - deny: union of this branch push --delete/--mirror/colon-refspec and checkout -- denies with main force-with-lease denies - ask: apply this branch removal of the git claw-back entries (they fall through to default ask), keep main gh api patterns, and do not restore gh issue edit which main removed in #311 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01RGD2NDthkx859WNGeDKKBN
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose
Two friction points around
gh pr edit/gh issue edit:gh issue edit *was inpermissions.ask, so every invocation stopped for a dialog even in auto mode.--title/--body/--body-filesilently replace the existing value, and a mistake was hard to catch until after the fact.Key changes
claude/settings.json: drop"Bash(gh issue edit *)"frompermissions.askso the auto-mode classifier decides (gh pr edit *is already inallowand stays there); register a newPostToolUsehook on theBashmatcher that invokesremind_show_edit_diff.pyclaude/hooks/remind_show_edit_diff.py(new): matchedgh {pr,issue} editcalls with a title/body-overwrite flag get anadditionalContextreminder to show the before/after diff. Matches are anchored totokens[0:3]and stop scanning at the first shell operator (so... && grep -F patdoesn't over-fire), and split on=so--title=NEWis caught. Match rules and kill switch in the module docstring.claude/rules/git-essentials.md: add a slim## PR / issue body editssection stating the pre-edit-diff expectation, pointing at the git-workflow skill'sUpdate a PR / issueprocedureDesign choice: kept the rule short (rule = mandate, skill procedure = how). Kept the hook stateless (fires every edit) since the diff reminder is cheap for the model and the failure mode of missing a diff is user-visible content loss. The reminder honestly notes that recovery only works when the prior value is still in context — re-fetching post-edit returns the new value.
Verification
python3 -m py_compile claude/hooks/remind_show_edit_diff.py— cleanpython3 -m doctest claude/hooks/remind_show_edit_diff.py— 12 tests passgh pr edit 123 --body-file /tmp/x→ firesgh issue edit 5 --title "new title"→ firesgh pr edit 123 --title=NEW(=-form) → firesgh pr edit 123 -t new(short flag) → firesgh pr edit 123 --add-label foo(edit without overwrite flag) → no outputgh pr edit 123 --add-label foo && grep -F pat log(short flag in compound command) → no outputgh pr edit 123 --add-label foo | tee -a out(pipe) → no outputBashtool call → no outputgh pr create --body-file /tmp/x(create, not edit) → no outputjq . claude/settings.json→ valid JSON after the ask-list removal and the newPostToolUseblock./scripts/deploy.sh: run an actualgh issue editto confirm the classifier path (no ask dialog stall) and see the reminder land asadditionalContextin the next turn