diff --git a/CLAUDE.md b/CLAUDE.md index 5abc290..340be53 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -80,3 +80,26 @@ HowToLens is the teaching companion to `autolens_workspace`. Many tutorials (par - **PyAutoGalaxy** source: `../PyAutoGalaxy` - **autolens_workspace**: `../autolens_workspace` — main user-facing workspace - **PyAutoBuild**: `../PyAutoBuild` — notebook generation and CI/CD tooling +## Never rewrite history + +NEVER perform these operations on any repo with a remote: + +- `git init` in a directory already tracked by git +- `rm -rf .git && git init` +- Commit with subject "Initial commit", "Fresh start", "Start fresh", "Reset + for AI workflow", or any equivalent message on a branch with a remote +- `git push --force` to `main` (or any branch tracked as `origin/HEAD`) +- `git filter-repo` / `git filter-branch` on shared branches +- `git rebase -i` rewriting commits already pushed to a shared branch + +If the working tree needs a clean state, the **only** correct sequence is: + + git fetch origin + git reset --hard origin/main + git clean -fd + +This applies equally to humans, local Claude Code, cloud Claude agents, Codex, +and any other agent. The "Initial commit — fresh start for AI workflow" pattern +that appeared independently on origin and local for three workspace repos is +exactly what this rule prevents — it costs ~40 commits of redundant local work +every time it happens.