Skip to content

sync overwrites .claude/settings.json wholesale, deleting project-owned hook matcher groups #1078

Closed

Description

@admarble

Summary

sequant sync copies templates/settings.json over a project's
.claude/settings.json wholesale. Any hook matcher group the project added
is deleted — silently, with no warning and no error. A deleted hook is
indistinguishable from a hook with nothing to say, so the loss is invisible in
normal use.

This has now happened twice to the same guard in the same downstream project,
five days apart:

Date Sync What was deleted
2026-09-12 2.10.0 → 2.15.0 the guard's logic, inlined in pre-tool.sh (827 → 1612 lines)
2026-09-15 2.15.0 → 2.15.1 the guard's registration in .claude/settings.json

Why the documented mitigation doesn't work

After the first loss, the downstream fix was to move the project's hook out of
the vendored pre-tool.sh and register it as its own matcher group in
.claude/settings.json, on the stated understanding that a sync only rewrites
the vendored hook scripts. That understanding is wrong:

$ diff templates/settings.json <(git -C <project> show <sync-commit>:.claude/settings.json)
$ echo $?
0

The post-sync project file is byte-identical to the template. The file is
replaced, not merged, so no placement inside .claude/settings.json survives
a sync. Sequant's own docs point users toward .claude/.local/ for overrides,
but that mechanism covers skills only — there is no hook extension point.

Impact

Downstream projects lose safety hooks with no signal. In this case the guard
that asks for confirmation before a commit lands on main was inactive for
some period after each sync. The only thing that caught either loss was a
project-authored integration test asserting the registration exists — the diff
review did not, because "a JSON file changed after a version bump" reads as
expected.

Repro

  1. In a sequant-initialized project, add a second PreToolUse matcher group to
    .claude/settings.json pointing at a project-owned hook script.
  2. Run any npx sequant command that triggers a sync.
  3. git diff .claude/settings.json — the added group is gone. Exit status 0,
    no warning printed.

Suggested direction

Merge rather than overwrite. Some options, roughly in order of preference:

  • Merge hook arrays by command path. Ensure sequant's own entries are
    present; leave every other matcher group untouched. This is the behavior the
    file's structure already implies.
  • Provide a real hook extension point — e.g. .claude/hooks/project/ is
    auto-registered, or .claude/.local/settings.json is merged in — so projects
    have a location that is theirs by contract rather than by luck.
  • At minimum, refuse to clobber silently. If the project's
    .claude/settings.json contains entries the template doesn't, print them and
    require --force. A loud failure is recoverable; this one wasn't.

Acceptance criteria

  • A sync against a project with an extra PreToolUse matcher group leaves
    that group intact.
  • Sequant's own hook entries are still guaranteed present after the sync.
  • A test covers the extra-group case specifically (the existing
    settings-template tests all assert on a pristine project).
  • If a merge is not feasible for some field, the sync reports what it is
    about to discard instead of discarding it silently.

Context

Both occurrences were observed in the same downstream project, tracked
privately. Happy to supply further detail on request.

Activity

  1. added
    bug
    on Sep 16, 2026
  2. admarble commented on Sep 17, 2026

    @admarble
    ContributorAuthor

    Closing — this was filed on a wrong premise, and docs/guides/customization.md:167 already answers it:

    The supported, update-safe mechanism is .claude/settings.local.json. Claude Code merges it over the package-managed .claude/settings.json, and sequant update/sync never touch it.

    The issue claimed there is no hook extension point. There is one, it is documented, and #711 has a test enforcing it. The project that hit this had registered its hook in the package-managed .claude/settings.json instead, so the overwrite at src/lib/templates.ts:828 was doing exactly what it is designed to do.

    The one thing possibly worth keeping: .claude/settings.json is Claude Code's canonical user-editable path, so a user can reasonably assume it is theirs to edit, and the overwrite carries no warning and leaves no marker in the file. That is a docs/UX papercut rather than the data-loss bug described here. Happy to open a narrower issue for it if that seems useful — not reopening this one.

  3. added 2 commits that reference this issue on Sep 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions