You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Support Claude Code hooks with org-mode task tracking
- Add claude-code-event-hook system for unified event handling
- Implement claude-code-org-notifications.el for persistent task tracking
- Add smart notification system with queue management and workspace integration
- Support auto-advance queue mode for streamlined task processing
- Include perspective.el integration for workspace navigation
- Add comprehensive documentation for hooks and notification features
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
claude-code.el notifies you when Claude finishes processing and is waiting for input. By default, it displays a message in the minibuffer and pulses the modeline for visual feedback.
@@ -290,113 +306,133 @@ For Windows, you can use PowerShell to create toast notifications:
290
306
291
307
*Note: Linux and Windows examples are untested. Feedback and improvements are welcome!*
292
308
293
-
### Claude Code Hooks Integration
309
+
### Enhanced Notification System
310
+
311
+
The enhanced notification system provides smart, context-aware notifications with queue management:
294
312
295
-
claude-code.el provides integration to **receive** hook events from Claude Code CLI via emacsclient.
313
+
-**Smart Visibility Detection**: Popup notifications only appear when the Claude buffer is not currently visible in your active perspective
314
+
-**Always Queue**: Task entries are always added to the taskmaster.org file regardless of buffer visibility
315
+
-**Queue Counter**: Notifications show the current number of entries in the task queue
316
+
-**Auto-dismiss**: Simple notifications auto-dismiss after 2 seconds to reduce clutter
317
+
-**No Duplicates**: Each buffer is limited to one queue entry (existing entries are replaced)
318
+
-**Automatic Cleanup**: Queue entries are automatically removed when Claude buffers are closed
296
319
297
-
See [`examples/hooks/claude-code-hook-examples.el`](examples/hooks/claude-code-hook-examples.el) for comprehensive examples of hook listeners and setup functions.
320
+
### Org Mode Task Tracking
298
321
299
-
#### Hook API
322
+
claude-code.el includes an optional Org mode integration that automatically tracks completed Claude tasks in a persistent log:
300
323
301
-
-`claude-code-event-hook` - Emacs hook run when Claude Code CLI triggers events
302
-
-`claude-code-handle-hook` - **Unified entry point** for all Claude Code CLI hooks. Call this from your CLI hooks with `(type buffer-name &rest args)` and JSON data as additional emacsclient arguments
324
+
#### Features
325
+
326
+
-**Persistent Task Log**: All completed Claude tasks are saved to `~/.claude/taskmaster.org`
327
+
-**Automatic Timestamps**: Each task entry includes completion timestamp
;; Configure Claude Code CLI hooks in settings.json (this will set up the CLI side)
346
+
(claude-code-setup-hooks)
314
347
```
315
348
316
-
#### Custom Hook Listener
349
+
This will:
350
+
1. Set up the Emacs hook listener to receive Claude Code events
351
+
2. Create the necessary directory structure (`~/.claude/`)
352
+
3. Generate or update your Claude Code settings.json with notification hooks
353
+
4. Enable automatic task logging to the taskmaster.org file
354
+
355
+
#### Hook Integration
356
+
357
+
The org-mode notifications now use the new Claude Code hooks system introduced in the supportClaudeCodeHooks branch. This provides better integration and more reliable event handling.
317
358
318
-
Hook listeners receive a message plist with these keys:
319
-
-`:type` - Hook type (e.g., `'notification`, `'stop`, `'pre-tool-use`, `'post-tool-use`)
320
-
-`:buffer-name` - Claude buffer name from `$CLAUDE_BUFFER_NAME`
321
-
-`:json-data` - JSON payload from Claude CLI
322
-
-`:args` - List of additional arguments (when using extended configuration)
359
+
#### Manual Hook Configuration
360
+
361
+
If you prefer to manually configure hooks or already have a settings.json file, you can call:
323
362
324
363
```elisp
325
-
;; Define your own hook listener function
326
-
(defun my-claude-hook-listener (message)
327
-
"Custom listener for Claude Code hooks.
328
-
MESSAGE is a plist with :type, :buffer-name, :json-data, and :args keys."
329
-
(let ((hook-type (plist-get message :type))
330
-
(buffer-name (plist-get message :buffer-name))
331
-
(json-data (plist-get message :json-data))
332
-
(args (plist-get message :args)))
333
-
(cond
334
-
((eq hook-type 'notification)
335
-
(message "Claude is ready in %s! JSON: %s" buffer-name json-data))
336
-
((eq hook-type 'stop)
337
-
(message "Claude finished in %s! JSON: %s" buffer-name json-data))
338
-
(t
339
-
(message "Claude hook: %s with JSON: %s" hook-type json-data)))))
340
-
341
-
;; Add the hook listener using standard Emacs hook functions
See the examples file for complete listeners that demonstrate notifications, logging, org-mode integration, and using extra arguments from the `:args` field.
346
-
347
-
#### Claude Code CLI Configuration
348
-
349
-
Configure Claude Code CLI hooks to call `claude-code-handle-hook` via emacsclient by passing JSON data as an additional argument:
This function intelligently merges notification hooks with your existing configuration.
368
+
369
+
#### Hook Context Variables
370
+
371
+
Claude Code automatically exports the `CLAUDE_BUFFER_NAME` environment variable to the shell session, making it available to hooks and child processes. This allows hooks to:
372
+
373
+
- Identify which Claude buffer triggered the notification
374
+
- Pass buffer context to external notification handlers
375
+
- Enable buffer-specific actions in custom scripts
376
+
377
+
The environment variable contains the full buffer name (e.g., `*claude:/path/to/project:default*`) and is automatically set when Claude starts.
378
+
379
+
#### Queue Browser and Navigation
380
+
381
+
The notification system includes a powerful queue browser for managing multiple completed tasks:
-**Queue Browser**: Use `C-c c q` to browse and select from the task queue using minibuffer completion
384
+
-**Numbered Entries**: Tasks are displayed as numbered list (e.g., "1. *claude:/path/to/project:default*")
385
+
-**Direct Navigation**: Select any queue entry to instantly jump to that Claude buffer and workspace
386
+
-**Position Tracking**: The system remembers your current position in the queue across commands
387
+
388
+
#### Workspace Integration
389
+
390
+
The notification system includes workspace support that integrates with project-based workflows:
391
+
392
+
-**Automatic Workspace Detection**: Claude automatically detects your current project/workspace directory when starting
393
+
-**Clickable Workspace Links**: Org mode entries include clickable workspace links that switch to the workspace directory
394
+
-**Workspace Buttons**: Notification popups include "Open Workspace" and "Open & Clear" buttons for quick workspace switching
395
+
-**Multiple Instance Support**: Works seamlessly with multiple Claude instances in the same workspace
396
+
-**Keyboard Commands**: Use `C-c c w` to go to the most recent workspace or `C-c c W` to go there and clear the org entry
397
+
398
+
When Claude completes a task, the workspace information is automatically extracted from the buffer name and included in both the org mode log entries and notification popups. The "Open & Clear" button and `C-c c W` command allow you to quickly navigate to a workspace and mark the corresponding org entry as DONE, helping you maintain a clean task queue.
399
+
400
+
#### Queue Navigation Commands
401
+
402
+
The notification system includes several commands for navigating and managing the task queue:
403
+
404
+
-**Browse Queue**: Use `claude-code-queue-browse` to view and select from all queue entries using minibuffer completion
405
+
-**Next Entry**: Use `claude-code-queue-next` to advance to the next entry in the queue
406
+
-**Previous Entry**: Use `claude-code-queue-previous` to go back to the previous queue entry
407
+
-**Skip Entry**: Use `claude-code-queue-skip` to delete the current queue entry and advance to the next
408
+
-**Queue Status**: Use `claude-code-queue-status` to show your current position and total queue size
409
+
410
+
These commands maintain queue position tracking, so you can navigate through your completed tasks systematically. The queue browser provides the most user-friendly interface with numbered entries and completion.
411
+
412
+
#### Auto-Advance Queue Mode
413
+
414
+
Claude-code.el includes an optional auto-advance mode for streamlined queue processing:
415
+
416
+
-**Auto-Advance Mode**: Enable `claude-code-auto-advance-queue` to automatically advance through the task queue
417
+
-**Seamless Workflow**: When enabled, pressing enter in any Claude buffer clears it from the queue and jumps to the next waiting task
418
+
-**Smart Navigation**: Automatically switches to a different Claude buffer's workspace and enters insert mode (with evil-mode)
419
+
-**Intelligent Filtering**: Only advances to different Claude buffers, never stays in the current buffer
420
+
-**Queue Status**: Shows remaining queue count when advancing
421
+
-**Toggle Command**: Use `claude-code-toggle-auto-advance-queue` to quickly enable/disable the mode
422
+
423
+
To enable auto-advance mode in your configuration:
424
+
425
+
```elisp
426
+
(setq claude-code-auto-advance-queue t)
383
427
```
384
428
385
-
Where:
386
-
-`"$(cat)"` - JSON data from stdin (always required)
387
-
-`ARG1` is `"$PWD"` - current working directory
388
-
-`ARG2` is `"$(date -Iseconds)"` - timestamp
389
-
-`ARG3` is `"$$"` - process ID
429
+
Or toggle it interactively:
390
430
391
-
`claude-code-handle-hook` creates a message plist sent to listeners:
392
431
```elisp
393
-
(list :type 'notification
394
-
:buffer-name "$CLAUDE_BUFFER_NAME"
395
-
:json-data "$(cat)"
396
-
:args '("ARG1" "ARG2" "ARG3"))
432
+
M-x claude-code-toggle-auto-advance-queue
397
433
```
398
434
399
-
See the [Claude Code hooks documentation](https://docs.anthropic.com/en/docs/claude-code/hooks) for details on setting up CLI hooks.
435
+
This mode is perfect for processing multiple completed Claude tasks efficiently - just respond to each task and you'll automatically be taken to the next different one. The system ensures you never get stuck in the same buffer and always advance to a truly different Claude instance.
400
436
401
437
## Tips and Tricks
402
438
@@ -410,19 +446,19 @@ See the [Claude Code hooks documentation](https://docs.anthropic.com/en/docs/cla
0 commit comments