Summary
Before overwriting ~/.claude/CLAUDE.md with a new release template, the installer should diff the user's current file against the outgoing template and surface any user-edited content that would be lost. Silent overwrites of runtime edits are data loss — and the #111 backport exists because 14KB of runtime drift accumulated silently between PR #101 (Apr 6) and Apr 14. Without this feature, the next time someone makes runtime improvements, the same gap re-appears.
This is the "sophisticated" companion to #126 (preserve @-imports). Where #126 is narrow and mechanical (preserve a specific class of line at the top), this one is a full content-diff and merge workflow.
Proposed behaviour
- Read current
~/.claude/CLAUDE.md and the release template.
- Section-diff by
## / ### headings, and by line-hash for prose.
- Classify each section:
- Template section the user has modified — they have custom content that would be overwritten
- Template section the user has removed entirely — user opted out of this feature
- User-added section not in the template — purely user content, must be preserved
- Present the diff to the user with options:
- Merge (three-way merge with manual conflict resolution)
- Accept template (lose user edits — current default behaviour)
- Keep current (skip the write — user will upgrade manually later)
- Block install/upgrade until user resolves, unless one of:
--force-template — accept template silently (equivalent to current behaviour)
--keep-current — skip CLAUDE.md write silently
--merge-auto — attempt a three-way merge and fail loudly on conflicts
Why
Users routinely edit CLAUDE.md as part of normal learning-cycle iteration — this is how #111 came to exist. The runtime had 14KB of divergence from the release template for weeks before anyone noticed. Any future runtime improvement faces the same risk: valuable edits accumulate in ~/.claude/CLAUDE.md, then a reinstall silently destroys them.
Scope
This is design-heavy — probably needs its own plan doc in Plans/ before implementation. The section-diff tooling overlaps with what Tools/lint-*.ts proposed in #111 (cross-doc consistency check). Consider factoring shared primitives.
Out of scope
- Diff for files other than CLAUDE.md (Algorithm, PRDFORMAT, etc.) — those are binary-copy files, not user-editable in the same sense
- Automatic merging — start with surface-and-ask; auto-merge is a later refinement
Related
Summary
Before overwriting
~/.claude/CLAUDE.mdwith a new release template, the installer should diff the user's current file against the outgoing template and surface any user-edited content that would be lost. Silent overwrites of runtime edits are data loss — and the #111 backport exists because 14KB of runtime drift accumulated silently between PR #101 (Apr 6) and Apr 14. Without this feature, the next time someone makes runtime improvements, the same gap re-appears.This is the "sophisticated" companion to #126 (preserve
@-imports). Where #126 is narrow and mechanical (preserve a specific class of line at the top), this one is a full content-diff and merge workflow.Proposed behaviour
~/.claude/CLAUDE.mdand the release template.##/###headings, and by line-hash for prose.--force-template— accept template silently (equivalent to current behaviour)--keep-current— skip CLAUDE.md write silently--merge-auto— attempt a three-way merge and fail loudly on conflictsWhy
Users routinely edit CLAUDE.md as part of normal learning-cycle iteration — this is how #111 came to exist. The runtime had 14KB of divergence from the release template for weeks before anyone noticed. Any future runtime improvement faces the same risk: valuable edits accumulate in
~/.claude/CLAUDE.md, then a reinstall silently destroys them.Scope
This is design-heavy — probably needs its own plan doc in
Plans/before implementation. The section-diff tooling overlaps with whatTools/lint-*.tsproposed in #111 (cross-doc consistency check). Consider factoring shared primitives.Out of scope
Related