4 ms·
Can you expand on this? How do you achieve it? Just a WIP JJ commit after every change or something more clever?
by eproxus 6mo ago
Can you expand on this? How do you achieve it? Just a WIP JJ commit after every change or something more clever?
- Meleagris 6mo agoIn .claude/settings.json you can trigger shell commands on events like SessionStart, Stop, PreCompact, and PostToolUse [1]. I have all of them run `jj status`, because jj snapshots the working copy every time it's invoked. You can have Claude write the hooks, but mine is: `[[ -d .jj ]] && jj status >/dev/null 2>&1; exit 0` [1] https://code.claude.com/docs/en/agent-sdk/hooks https://code.claude.com/docs/en/agent-sdk/hooks
- dwb 6mo ago"hooks": { "PreToolUse": [ { "matcher": "Edit|Write", "hooks": [ { "type": "command", "command": "if command -v jj >/dev/null && jj root >/dev/null 2>&1; then if ! jj status >/dev/null 2>&1; then echo 'WARNING: failed to snapshot jj repository, tell user to fix'; fi; fi" } ] } ], "PostToolUse": [ { "matcher": "Edit|Write", "hooks": [ { "type": "command", "command": "if command -v jj >/dev/null && jj root >/dev/null 2>&1; then if ! jj status >/dev/null 2>&1; then echo 'WARNING: failed to snapshot jj repository, tell user to fix'; fi; fi" } ] }, In newer jj there’s a dedicated snapshot command but I’ve not updated yet. Pop this in your Claude Code settings.json. It will snapshot the repository, thus recording any changes. Explore with jj evolog.
- steveklabnik 6mo agoThe others use `jj status`, but if I were to do this, I'd use `jj log -n0`, which has no output. All you really need is any read-only jj command. You could also turn on watchman and have this property on every save of a file and not even need to worry about hooks.
- yencabulator 6mo ago`jj util snapshot` sounds like it was meant for this.
- steveklabnik 6mo agoI know there was a debug command that would do it, but that was considered an unstable interface. That sounds like a better command, I’ll have to check it out, thanks!