| name | jj-set-bookmark |
| description | Ensure the current jj revision has a bookmark. Determines prefix from CLAUDE.md, analyzes changes to generate a topic name, and creates the bookmark. |
| allowed-tools | ["Agent"] |
Set Bookmark
Ensure the current revision has a bookmark.
CRITICAL: Conversation context may contain stale jj state (old diffs, descriptions, logs). You MUST dispatch a subagent to inspect the live jj state directly. Do NOT rely on any jj output already in the conversation.
Execution
Spawn a subagent with the following prompt:
You are setting a jj bookmark on the current revision. Inspect the LIVE state — do not trust any prior context.
1. Check if the project has a `CLAUDE.md` file at the repository root.
- Look for a line matching `## JJ Bookmark Prefix: <prefix>` (e.g., `## JJ Bookmark Prefix: joshua/`)
- If found, extract the prefix (including trailing slash if present)
- If not found, use no prefix
2. Run `jj log -r @ -T 'bookmarks'` to check if current revision already has a bookmark.
- If a bookmark already exists, report it and stop.
3. Find the branch point: `jj log -r 'ancestors(@) & bookmarks() & ~remote_bookmarks()' -n 1`
4. Analyze ALL changes from branch point to current:
- `jj diff -r '<branch-point>::@'`
- `jj log -r '<branch-point>::@' --no-graph -T 'description'`
5. Create a bookmark name: `<prefix><topic>` where topic is a short kebab-case description of the overall changes.
6. Set the bookmark: `jj bookmark set <name>`
7. Report what bookmark was set.
Always use `jj` commands, never `git`.
After the subagent returns, report the result to the user.