Skip to content

Commit 9aeeede

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) <noreply@anthropic.com>
1 parent c0cee06 commit 9aeeede

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

CLAUDE.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,3 +236,26 @@ find . -type f -name "*.py" | xargs dos2unix
236236

237237
Prefer simple shell commands.
238238
Avoid chaining with && or pipes.
239+
## Never rewrite history
240+
241+
NEVER perform these operations on any repo with a remote:
242+
243+
- `git init` in a directory already tracked by git
244+
- `rm -rf .git && git init`
245+
- Commit with subject "Initial commit", "Fresh start", "Start fresh", "Reset
246+
for AI workflow", or any equivalent message on a branch with a remote
247+
- `git push --force` to `main` (or any branch tracked as `origin/HEAD`)
248+
- `git filter-repo` / `git filter-branch` on shared branches
249+
- `git rebase -i` rewriting commits already pushed to a shared branch
250+
251+
If the working tree needs a clean state, the **only** correct sequence is:
252+
253+
git fetch origin
254+
git reset --hard origin/main
255+
git clean -fd
256+
257+
This applies equally to humans, local Claude Code, cloud Claude agents, Codex,
258+
and any other agent. The "Initial commit — fresh start for AI workflow" pattern
259+
that appeared independently on origin and local for three workspace repos is
260+
exactly what this rule prevents — it costs ~40 commits of redundant local work
261+
every time it happens.

0 commit comments

Comments
 (0)