Skip to content

Commit 5ee220a

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/PyAutoPrompt#7. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1 parent 7890975 commit 5ee220a

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

CLAUDE.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,26 @@ This pattern is used in `autogalaxy/operate/lens_calc.py` for all `LensCalc` met
179179
## Line Endings — Always Unix (LF)
180180

181181
All files **must use Unix line endings (LF, `\n`)**. Never write `\r\n` line endings.
182+
## Never rewrite history
183+
184+
NEVER perform these operations on any repo with a remote:
185+
186+
- `git init` in a directory already tracked by git
187+
- `rm -rf .git && git init`
188+
- Commit with subject "Initial commit", "Fresh start", "Start fresh", "Reset
189+
for AI workflow", or any equivalent message on a branch with a remote
190+
- `git push --force` to `main` (or any branch tracked as `origin/HEAD`)
191+
- `git filter-repo` / `git filter-branch` on shared branches
192+
- `git rebase -i` rewriting commits already pushed to a shared branch
193+
194+
If the working tree needs a clean state, the **only** correct sequence is:
195+
196+
git fetch origin
197+
git reset --hard origin/main
198+
git clean -fd
199+
200+
This applies equally to humans, local Claude Code, cloud Claude agents, Codex,
201+
and any other agent. The "Initial commit — fresh start for AI workflow" pattern
202+
that appeared independently on origin and local for three workspace repos is
203+
exactly what this rule prevents — it costs ~40 commits of redundant local work
204+
every time it happens.

0 commit comments

Comments
 (0)