Skip to content

Deliver hooks via Claude Code plugin instead of csb install-hooks #7

@djdarcy

Description

@djdarcy

Deliver hooks via Claude Code plugin instead of csb install-hooks

Problem

The current plan for csb install-hooks would directly patch ~/.claude/settings.json to add PreCompact and SessionEnd hooks. This is fragile:

  • Conflicts with other tools that also modify settings.json
  • Manual JSON merging is error-prone
  • No clean uninstall/update path
  • User has to re-run install-hooks after every csb update

Proposed solution

Create a Claude Code plugin (like claude-session-logger) that registers the hooks cleanly via the plugin system:

Claude-Session-Backup/
  .claude-plugin/
    plugin.json          # Plugin metadata (name, version, author)
  hooks/
    hooks.json           # Hook registrations (PreCompact, SessionEnd)
    scripts/
      backup-hook.py     # Script that runs csb backup --quiet
  commands/
    (optional slash commands)

Plugin hooks.json:

{
  "hooks": [
    {
      "event": "PreCompact",
      "script": "hooks/scripts/backup-hook.py"
    },
    {
      "event": "SessionEnd",
      "script": "hooks/scripts/backup-hook.py"
    }
  ]
}

backup-hook.py:

import subprocess
subprocess.run(["csb", "backup", "--quiet"], capture_output=True)

Install/uninstall

# Install
claude plugin marketplace add "DazzleML/Claude-Session-Backup"
claude plugin install claude-session-backup@dazzle-claude-plugins

# Uninstall
claude plugin uninstall claude-session-backup

Benefits over csb install-hooks

  • Clean install/uninstall via plugin system
  • No manual settings.json editing
  • Updates handled by plugin system
  • Coexists cleanly with other plugins (session-logger, etc.)
  • Follows established pattern from claude-session-logger

References

  • C:\code\claude-projects\claude-session-logger -- reference implementation of Claude Code plugin with hooks
  • C:\code\claude-projects\dazzle-claude-vault -- hook patterns (PreCompact, SessionEnd) from claude-vault README

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions