Skip to content

Commit 53d1da9

Browse files
thefallentreeclaude
andcommitted
AGENTS.md §10.5: warn against git stash in the shared working tree
git stash operates unconditionally on the entire working tree, unlike git checkout -- <path> which can at least be scoped. Used it briefly during my own debugging (comparing a pre/post-fix compile result) while several batch agents had concurrent uncommitted work in flight, and a different lib's NOTES.md write went missing afterward -- plausible but not conclusively proven as the stash's fault, which is itself the lesson: documented as a hard "never do this" rule rather than a case-by-case judgment call, with git show <rev>:<path> as the safe read-only alternative. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VyQCUoTo1Z93Py9aVFHQi1
1 parent 74edff7 commit 53d1da9

1 file changed

Lines changed: 22 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2440,6 +2440,28 @@ same interface via `scripts/wasm_client.js` (§1.2).
24402440
immediately `git restore --staged` what you didn't mean to stage.
24412441
Never `git add -A`/commit broadly while other sessions may have
24422442
work in flight; commit exact paths.
2443+
- **NEVER `git stash` in this shared working tree, for ANY reason,
2444+
even briefly for debugging.** `git stash` operates on the ENTIRE
2445+
working tree unconditionally — unlike `git checkout -- <path>`,
2446+
there's no way to scope it to files you own. If any concurrent batch
2447+
agent is mid-write to a file at the moment you stash, your stash
2448+
captures whatever partial/complete state that file was in, resets it
2449+
to HEAD, and if the other agent's tool (Edit/Write) touches that file
2450+
again before your `stash pop`, the pop can silently clobber or lose
2451+
their newer edit with no conflict warning — `git stash pop` reporting
2452+
success is not proof nothing was lost. Hit directly: debugging a
2453+
suspected regression by stashing/popping around a `git diff`
2454+
comparison coincided with another concurrent agent's `NOTES.md`
2455+
write for an unrelated lib, and that agent's documented "深度功能测试"
2456+
section was missing from the file afterward even though its actual
2457+
code fixes (committed separately, timestamped after the stash
2458+
window) survived intact — plausible but not conclusively proven as
2459+
the stash's fault, and that ambiguity is itself the lesson: this
2460+
class of interference is very hard to detect after the fact. If you
2461+
need to compare against a prior committed version while other work
2462+
may be in flight, use `git show <rev>:<path> > /tmp/scratch` (reads
2463+
without touching the working tree) instead of stash/checkout/reset
2464+
on the real path.
24432465
- Runtime state must not be committed: player saves, visitor counters,
24442466
ban lists generated during testing (the repo `.gitignore` has a
24452467
per-lib section — extend it when a new lib's testing dirties a new

0 commit comments

Comments
 (0)