claude-code - 💡(How to fix) Fix Expose session statistics in Stop hook [1 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#46089Fetched 2026-04-11 06:29:16
View on GitHub
Comments
1
Participants
2
Timeline
3
Reactions
0
Timeline (top)
labeled ×2commented ×1
RAW_BUFFERClick to expand / collapse

Claude Code should expose session statistics when the Stop hook fires (session exit), allowing users to display summary stats.

Requested statistics:

  • Number of messages sent/received
  • Tokens used (input and output)
  • Session duration
  • Files modified (created, edited, deleted)

This would enable users to build custom status reporting or analytics on session completion.

extent analysis

TL;DR

Implementing a session statistics exposure feature when the Stop hook fires will allow users to access and utilize key session metrics.

Guidance

  • Identify the Stop hook event in Claude Code and determine the best approach to capture and calculate the required session statistics.
  • Consider adding a callback function or an event listener to the Stop hook to collect and return the requested statistics, such as message counts, token usage, session duration, and file modifications.
  • Evaluate the existing data structures and APIs in Claude Code to determine how to efficiently gather and provide the necessary statistics.
  • Develop a data format or structure to organize and return the session statistics in a usable and accessible way for users.

Notes

The implementation details may vary depending on the specific architecture and design of Claude Code, and additional information about the codebase and its components may be necessary to provide a more comprehensive solution.

Recommendation

Apply workaround: Implement a custom solution to expose session statistics when the Stop hook fires, as this will allow users to access key metrics and build custom status reporting or analytics on session completion.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING