Skip to content

Commit 18b5458

Browse files
Jammy2211claude
authored andcommitted
docs: add Never-rewrite-history guard to CLAUDE.md / AGENTS.md
Append a `## Never rewrite history` section listing the destructive history operations that NEVER apply on a remote-tracked repo, with the canonical clean-working-tree sequence (`git fetch && reset --hard origin/main && clean -fd`) as the only correct alternative. Why: forensic sweep on 2026-04-27 found three workspace repos with no merge base at all with origin — independent `git init`/"fresh start" rewrites on different machines had produced identical content under entirely different SHAs, costing ~41 commits of redundant local work. This rule prevents that class of error structurally for both human and AI agents. Implements PyAutoLabs/PyAutoMind#7. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 4242060 commit 18b5458

2 files changed

Lines changed: 46 additions & 0 deletions

File tree

AGENTS.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,26 @@ NUMBA_CACHE_DIR=/tmp/numba_cache MPLCONFIGDIR=/tmp/matplotlib python -m pytest t
5050
3. Run the full test suite: `python -m pytest test_autolens/`
5151
4. Ensure all tests pass before opening a PR.
5252
5. If changing public API, note the change in your PR description — downstream workspaces may need updates.
53+
## Never rewrite history
54+
55+
NEVER perform these operations on any repo with a remote:
56+
57+
- `git init` in a directory already tracked by git
58+
- `rm -rf .git && git init`
59+
- Commit with subject "Initial commit", "Fresh start", "Start fresh", "Reset
60+
for AI workflow", or any equivalent message on a branch with a remote
61+
- `git push --force` to `main` (or any branch tracked as `origin/HEAD`)
62+
- `git filter-repo` / `git filter-branch` on shared branches
63+
- `git rebase -i` rewriting commits already pushed to a shared branch
64+
65+
If the working tree needs a clean state, the **only** correct sequence is:
66+
67+
git fetch origin
68+
git reset --hard origin/main
69+
git clean -fd
70+
71+
This applies equally to humans, local Claude Code, cloud Claude agents, Codex,
72+
and any other agent. The "Initial commit — fresh start for AI workflow" pattern
73+
that appeared independently on origin and local for three workspace repos is
74+
exactly what this rule prevents — it costs ~40 commits of redundant local work
75+
every time it happens.

CLAUDE.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,3 +156,26 @@ When importing `autolens as al`:
156156
## Line Endings — Always Unix (LF)
157157

158158
All files **must use Unix line endings (LF, `\n`)**. Never write `\r\n` line endings.
159+
## Never rewrite history
160+
161+
NEVER perform these operations on any repo with a remote:
162+
163+
- `git init` in a directory already tracked by git
164+
- `rm -rf .git && git init`
165+
- Commit with subject "Initial commit", "Fresh start", "Start fresh", "Reset
166+
for AI workflow", or any equivalent message on a branch with a remote
167+
- `git push --force` to `main` (or any branch tracked as `origin/HEAD`)
168+
- `git filter-repo` / `git filter-branch` on shared branches
169+
- `git rebase -i` rewriting commits already pushed to a shared branch
170+
171+
If the working tree needs a clean state, the **only** correct sequence is:
172+
173+
git fetch origin
174+
git reset --hard origin/main
175+
git clean -fd
176+
177+
This applies equally to humans, local Claude Code, cloud Claude agents, Codex,
178+
and any other agent. The "Initial commit — fresh start for AI workflow" pattern
179+
that appeared independently on origin and local for three workspace repos is
180+
exactly what this rule prevents — it costs ~40 commits of redundant local work
181+
every time it happens.

0 commit comments

Comments
 (0)