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
Deliver hooks via Claude Code plugin instead of
csb install-hooksProblem
The current plan for
csb install-hookswould directly patch~/.claude/settings.jsonto add PreCompact and SessionEnd hooks. This is fragile:install-hooksafter every csb updateProposed solution
Create a Claude Code plugin (like
claude-session-logger) that registers the hooks cleanly via the plugin system:Plugin hooks.json:
{ "hooks": [ { "event": "PreCompact", "script": "hooks/scripts/backup-hook.py" }, { "event": "SessionEnd", "script": "hooks/scripts/backup-hook.py" } ] }backup-hook.py:
Install/uninstall
Benefits over
csb install-hooksReferences
C:\code\claude-projects\claude-session-logger-- reference implementation of Claude Code plugin with hooksC:\code\claude-projects\dazzle-claude-vault-- hook patterns (PreCompact, SessionEnd) from claude-vault README