claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

Feature Request: Additional Claude Code Hook Events for Better Automation

Open evx2 opened this issue 5 months ago • 5 comments

Claude Code currently supports 6 hook events, but there's a significant gap for common development workflow automation. Here's what's available versus what would be tremendously beneficial:

Current Hook Events:

  • PreToolUse - runs before tool calls, can block them
  • PostToolUse - runs after tool calls complete successfully
  • Notification - runs when Claude Code sends notifications
  • Stop - runs when main Claude Code agent finishes responding
  • SubagentStop - runs when Claude Code subagent (Task tool) finishes responding
  • PreCompact - runs before Claude Code compact operation (manual or auto)

Missing Hook Events That Would Be Game-Changing:

after_task_completion - Triggers when Claude marks a task as complete in its internal memory

  • Use case: Automatically sync task completion to external project management tools, update documentation, or trigger deployment workflows
  • Current workaround: Using SubagentStop which fires on every subagent completion, not just task completion

after_edit - Triggers after any file modification operation

  • Use case: Auto-format code, update documentation, log changes, or trigger automated testing
  • Current workaround: PostToolUse with Edit|MultiEdit|Write matcher, but misses other edit operations

after_commit - Triggers specifically after git commit operations

  • Use case: Auto-backup, trigger CI/CD, update project logs, or sync with external systems
  • Current workaround: PostToolUse with Bash matcher + parsing scripts to detect git commits

after_response - Triggers after Claude completes a response, with pattern matching support

  • Use case: Parse responses for specific patterns (like task completion indicators) and trigger corresponding actions
  • Current workaround: Stop hook + transcript parsing scripts

Why These Would Be Superior to Current Workarounds:

Precision: Native events would trigger exactly when intended, not on broad categories of actions that require additional filtering

Performance: Direct event triggering without overhead of parsing scripts, JSON processing, or transcript searching

Reliability: Built-in events eliminate parsing failures, missed triggers, and dependencies on file availability

Maintainability: Clean, direct script execution versus complex wrapper scripts with detection logic

API Efficiency: By automating routine tasks (updating external task lists, documentation, backups) through hooks instead of prompting Claude to do them, you reduce API calls and extend your usage limits

Workflow Consistency: Forces Claude into reliable patterns by automatically executing follow-up actions, preventing it from "forgetting" to update task lists or documentation

Real-World Impact: These hooks would enable developers to create robust, automated workflows where Claude's actions automatically trigger complementary system updates. Instead of manually guiding Claude back on track when it forgets to update external systems, these hooks would ensure consistency and reliability in development workflows.

The current workarounds require complex detection scripts and aren't foolproof - native hook events would provide the precision and reliability needed for production development workflows.

evx2 avatar Jul 13 '25 14:07 evx2

after_task_completion would be fantastic!

Kristoffer88 avatar Jul 24 '25 15:07 Kristoffer88

I'm not sure if there are already some open discussions about this, but it would be good if we could have a hook like this:

       {
         "matcher": "", // just a placeholder, ignore this
         "hooks": [
           {
             "type": "chat", // currently it only supports "command", but I would like to call a custom Claude command
             "message": "/my-custom-command"
           }
         ]
       },

The idea behind this is to be able to call a custom command that I created called "/document-session", which saves a markdown follow-up documentation as it would be passing the knowledge to another dev (or AI assistant), so then later, I can call my custom command "/session-load" which automatically gets the latest document session created. I'm currently doing that manually, but it would be good if I could automate it.

matheusslg avatar Aug 01 '25 17:08 matheusslg

"type": "chat"

+100500!

deksden avatar Aug 04 '25 06:08 deksden

This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.

github-actions[bot] avatar Dec 06 '25 10:12 github-actions[bot]

It's still needed

BertrandDecoster avatar Dec 10 '25 13:12 BertrandDecoster