Feature Request - Include exection time in JSON sent to stop hook
Currently the JSON sent to the stop hook looks like this:
{
"session_id": "abc123",
"transcript_path": "~/.claude/projects/.../00893aaf-19fa-41d2-8238-13269b9b3ca0.jsonl",
"hook_event_name": "Stop",
"stop_hook_active": true
}
It would be handy (to me, at least) if this also included an execution time indicating how long Claude Code took before it finished work. For example:
{
"session_id": "abc123",
"transcript_path": "~/.claude/projects/.../00893aaf-19fa-41d2-8238-13269b9b3ca0.jsonl",
"hook_event_name": "Stop",
"stop_hook_active": true,
"execution_time": "3000"
}
This is useful because it would allow execution-time-relative conditional behavior in the hook. For example, I may wish to play a sound when the stop hook is executed. But, that may be annoying if it plays after every single prompt. In my case, I only want to play the audio if the prompt took more than 30 seconds to complete, since I am more likely to have tabbed away from the chat session and it would be convenient to be called back.
The only way I can think of to accomplish this right now is to use a combination of UserPromptSubmit to write a temp file for the session with the current time, and then to read that again in my stop hook to determine if the time has passed. Addition of execution_time to the stop hook would make this easier and cleaner.
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗