Skip to content

feat: implement claude-sync auto enable/disable/status#39

Open
jimjawn wants to merge 1 commit into
tawanorg:mainfrom
jimjawn:feat/auto-hooks
Open

feat: implement claude-sync auto enable/disable/status#39
jimjawn wants to merge 1 commit into
tawanorg:mainfrom
jimjawn:feat/auto-hooks

Conversation

@jimjawn

@jimjawn jimjawn commented Jun 12, 2026

Copy link
Copy Markdown

Summary

Implements the claude-sync auto subcommand that was documented in the README but not yet functional.

claude-sync auto enable   # Install auto-sync hooks into Claude Code
claude-sync auto disable  # Remove auto-sync hooks
claude-sync auto status   # Show current hook status

How it works

Reads and writes ~/.claude/settings.json using the Claude Code hook format. On enable, two hooks are added:

  • SessionStartclaude-sync pull -q (pull latest on session start)
  • Stopclaude-sync push -q (push changes on session end)

On disable, only the claude-sync entries are removed — all other hooks are left exactly as they were.

Implementation details

  • New package internal/claudesettings handles settings.json read/write
  • Uses a raw map[string]json.RawMessage round-trip so all unknown fields are preserved — no data loss on save
  • Settings file written with 0600 permissions
  • Idempotent: enable is a no-op if hooks already present, disable is a no-op if not installed
  • Creates ~/.claude/settings.json if it doesn't exist yet

Tested

  • status correctly reports not-installed / enabled state
  • enable merges with existing hooks (pre-existing Stop hooks survive intact)
  • disable removes only claude-sync entries, leaves other hooks untouched
  • Round-trip verified: settings.json fields outside hooks are preserved

Closes the gap noted in issue #26.

Add `claude-sync auto enable/disable/status` subcommands that install and
remove claude-sync pull/push hooks in ~/.claude/settings.json, merging with
existing hooks without clobbering them. Backed by new internal/claudesettings
package that round-trips the full settings file via a raw JSON map.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@jimjawn jimjawn mentioned this pull request Jun 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant