docs(agents): require commit-then-revert for reverse verification - #7839
Merged
Conversation
`CLAUDE.md`'s "Never `git stash`" block offered four replacements, and the first one — `git checkout origin/main -- <path>` / `git checkout <your-branch> -- <path>` — silently destroys uncommitted work in exactly the situation it reads as designed for. `git checkout <branch> -- <path>` copies the file *as committed*; it knows nothing about working-tree edits. During reverse verification the fix is typically not committed yet, so the "restore" half restores the branch's older version and the edit is gone — exit 0, no warning, no conflict, no "would be overwritten" refusal. Already realized, not theoretical: #7739's dev agent (PR #7791) lost an in-flight edit to this recipe and recovered it only by retyping from context. Adopt the correction `objectui` merged this afternoon (c880799, "docs(agents): require commit-then-revert for reverse verification", objectui#4301/#4339) so the two repos' agent docs read the same: - `CLAUDE.md`: drop the hazardous line. The block's purpose is a reflex that is safe *without thinking about it*, and a recipe whose safety depends on an unstated precondition does not serve that. The remaining three forms capture the uncommitted state first and cover the same use case. This leaves the block identical in shape to objectui's copy. - `AGENTS.md` (source of truth) carried the same recipe in its own stash block: removed there too, and the commit-then-revert requirement objectui added is stated in the adjacent prose. Also replaces the weak-verification reach the issue flagged alongside: a matching `git diff --stat` insertion count is not byte-identity, so a retyped recovery is proved with `git diff` against a saved patch or `git hash-object`. Docs-only; no changeset. Fixes #7800 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011r5id7DkZrVUTZdL3guCC8
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
huangyiirene
marked this pull request as ready for review
August 11, 2026 20:39
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.
Fixes #7800
The hazard
CLAUDE.md's "Nevergit stash" block offered four replacements. The first onesilently destroys uncommitted work in exactly the situation it reads as designed for.
git checkout <branch> -- <path>copies the file as committed; it knows nothing about working-tree edits. During reverse verification the fix is typically not committed yet — that is the whole point of the exercise — so the "restore" half restores the branch's older version and the edit is gone. Exit 0, no warning, no conflict, no "would be overwritten" refusal.Already realized, not theoretical: #7739's dev agent (PR #7791) lost an in-flight edit to this recipe today and recovered it only by retyping from context. An agent that hit this after a context compaction would not have recovered.
Adopting objectui's correction, not inventing a second one
objectuimerged the equivalent correction this afternoon — verified against the actual commit rather than the issue text:Its fix has two halves, and this PR mirrors both:
CLAUDE.mdlists only the three safe forms — thegit checkout origin/main -- <path>line is not present in its copy at all.c880799added a positive commit-then-revert rule to objectui'sAGENTS.md, verbatim:This also settles a factual conflict in the issue thread: the body states objectui "lists only the three safe forms" (true, and so this is a delete for
CLAUDE.md), while triage points atc880799as a commit-then-revert replacement (also true — it lives inAGENTS.md). Both are right about different files. This PR reconciles them.What lands here
CLAUDE.md— drop the hazardous line (−1). The block exists to give agents a reflex that is safe without thinking about it; a recipe whose safety depends on remembering an unstated precondition does not serve that purpose, and the remaining three forms each capture the uncommitted state first and cover the same use case. This leaves the block identical in shape to objectui's copy. Matches the PM ruling on the issue (delete, not annotate).AGENTS.md(source of truth) — grep hit: its own stash block at line 194 carried the same recipe. Removed there too, and the commit-then-revert requirement objectui added is stated in the adjacent prose, in this file's English style, citing both repos' incidents (objectui The schemaless nodes' designer forms live only in objectui's hand-written table, and nothing reconciles them —scriptoffers three broken options and cannot author the one that works #4278/sys_migration由 service-storage 注册——账本是平台基础设施,不该由一个可选服务持有 #4243, this repo's external-datasource-federated-read: external-write refusal (ExternalWriteForbiddenError) leaks to the client as a bare 500 INTERNAL_ERROR #7739).The AGENTS.md paragraph also picks up the issue's second, smaller point: a matching
git diff --statinsertion count is not byte-identity, so a retyped recovery is proved withgit diffagainst a saved patch orgit hash-object— the weak reach is what a silent failure mode invites.Scope notes
pnpm check:doc-authoring→✓ doc authoring guard: 375 files clean.objectui(already fixed),.claude/skills/**,content/docs/releases/**..claude/agents/os-dev.md:488,.claude/hooks/guard-shared-stash.sh:32,170(comment + help text), and.claude/skills/pm-dispatch/SKILL.md:2120. All outside this card's stated file surface; the skills path is explicitly the manual-review channel. Worth a follow-up card.Generated by Claude Code