Skip to content

CLAUDE.md edits not detected by auto-commit when file is restructured #69

@albertgwo

Description

@albertgwo

Problem

When ~/.claude/CLAUDE.md is edited directly (the natural workflow), claude-sync auto-commit does not detect the changes if the file's structure has changed. It compares fragment content hashes against the old fragment store, so reorganizations, renamed sections, and new sections are invisible.

Steps to Reproduce

  1. Have a synced CLAUDE.md with fragments in ~/.claude-sync/claude-md/
  2. Edit ~/.claude/CLAUDE.md directly: reorganize sections, rename headings, add new sections
  3. Run claude-sync auto-commit --if-changed
  4. Observe: the commit message references other changes (e.g., "update MCP servers") but the CLAUDE.md restructuring is not captured
  5. claude-sync push does not include the CLAUDE.md changes
  6. The fragment store retains the old structure with stale section names

Expected Behavior

auto-commit should detect when the assembled CLAUDE.md has diverged from what the fragment store would produce, and either:

  • Re-fragment the live file back into the sync store, or
  • Flag the divergence so the user can resolve it

Current Workaround

Manually update each fragment file in ~/.claude-sync/claude-md/, create/delete fragment files for renamed/new/removed sections, update manifest.yaml, and update the claude_md.include list in config.yaml. This is error-prone and tedious.

Proposed Solution

Add a claude-sync claude-md import command (or similar) that:

  1. Reads the live ~/.claude/CLAUDE.md
  2. Splits it back into fragments by heading structure
  3. Updates manifest.yaml with the new fragment inventory
  4. Updates config.yaml's claude_md.include list
  5. Removes orphaned fragment files

This would close the round-trip: pull assembles fragments into CLAUDE.md, import disassembles CLAUDE.md back into fragments.

Alternatively, auto-commit could compare the assembled output of the current fragments against the live file and trigger re-fragmentation when they diverge.

Context

This came up while reorganizing a global CLAUDE.md into logical groups (Style & Principles, Tools & Environment, Git & Output, Workflow) and adding a new Python Zen section. The restructuring required manually updating 15+ fragment files, the manifest, and the config.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions