Files
claude-howto/openspec/changes/add-context-usage-hook-example/tasks.md
T
Luong NGUYEN 9c5c7c5049 docs: Add context usage reporter hook example
Add Example 6 showing how to create a hook that reports context/token
usage after each Claude response:

- Python script reads transcript_path to access conversation history
- Estimates tokens using ~4 chars/token heuristic
- Outputs one-line report: "Context: ~45k/200k tokens (77% remaining)"
- Documents both Stop and UserPromptSubmit hook configurations
- Explains limitations (estimate vs exact /context command)
2025-12-24 23:21:38 +01:00

498 B

Tasks: Add Context Usage Reporting Hook Example

1. Documentation Update

  • 1.1 Add new example section "Context Usage Reporter" to 06-hooks/README.md
  • 1.2 Write Python hook script that reads transcript and estimates tokens
  • 1.3 Add configuration example for UserPromptSubmit hook
  • 1.4 Document how transcript_path provides access to conversation history
  • 1.5 Explain token estimation approach and limitations
  • 1.6 Show sample output format for the one-line report