Skip to content

docs(agents): require commit-then-revert for reverse verification - #7839

Merged
huangyiirene merged 1 commit into
mainfrom
claude/issue-7800-stash-alternative-hazard
Aug 11, 2026
Merged

docs(agents): require commit-then-revert for reverse verification#7839
huangyiirene merged 1 commit into
mainfrom
claude/issue-7800-stash-alternative-hazard

Conversation

@huangyiirene

Copy link
Copy Markdown
Collaborator

Fixes #7800

The hazard

CLAUDE.md's "Never git stash" block offered four replacements. The first one

git checkout origin/main -- <path>     # then: 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 — 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

objectui merged the equivalent correction this afternoon — verified against the actual commit rather than the issue text:

c880799bc398cfbdda24adb749dfd780776a39bd
docs(agents): require commit-then-revert for reverse verification (#4301) (#4339)
2026-08-11 17:40:19 +0000
 AGENTS.md | 1 +

Its fix has two halves, and this PR mirrors both:

  1. objectui's CLAUDE.md lists only the three safe forms — the git checkout origin/main -- <path> line is not present in its copy at all.
  2. c880799 added a positive commit-then-revert rule to objectui's AGENTS.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 at c880799 as a commit-then-revert replacement (also true — it lives in AGENTS.md). Both are right about different files. This PR reconciles them.

What lands here

The AGENTS.md paragraph also picks up the issue's second, smaller point: 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 — the weak reach is what a silent failure mode invites.

Scope notes

  • Docs-only. No changeset — skip-changeset handling is the PM's.
  • pnpm check:doc-authoring✓ doc authoring guard: 375 files clean.
  • Not touched, deliberately: objectui (already fixed), .claude/skills/**, content/docs/releases/**.
  • Out-of-scope copies found, for the PM to route: the same recipe also appears in .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

`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
@vercel

vercel Bot commented Aug 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
objectstack Ignored Ignored Aug 11, 2026 8:09pm

Request Review

@github-actions github-actions Bot added the documentation Improvements or additions to documentation label Aug 11, 2026
@huangyiirene
huangyiirene marked this pull request as ready for review August 11, 2026 20:39
@huangyiirene
huangyiirene added this pull request to the merge queue Aug 11, 2026
Merged via the queue into main with commit 3338ee7 Aug 11, 2026
20 of 21 checks passed
@huangyiirene
huangyiirene deleted the claude/issue-7800-stash-alternative-hazard branch August 11, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/s

Projects

None yet

2 participants