Skip to content

Installer: pre-install CLAUDE.md conflict analysis (surface user-edited sections before overwrite) #127

@virtualian

Description

@virtualian

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

  1. Read current ~/.claude/CLAUDE.md and the release template.
  2. Section-diff by ## / ### headings, and by line-hash for prose.
  3. 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
  4. 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)
  5. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions