Files
claude-howto/openspec/changes/add-context-tracking-hooks/tasks.md
T
Luong NGUYEN 0fcac18357 docs: Add blog post and new slash commands for development workflow
- Add blog post: 4 Essential Slash Commands I Use in Every Project
- Add new slash commands: /doc-refactor, /setup-ci-cd, /unit-test-expand
- Update slash-commands README with comprehensive documentation
- Simplify /push-all command structure
- Archive add-blog-post-slash-commands change
- Add blog-post spec and pending openspec changes
2025-12-26 11:02:19 +01:00

1.5 KiB

Tasks: Add Context Usage Tracking Documentation

1. Documentation Updates

  • 1.1 Add "Context Tracking Hook Pairs" section to README explaining pre-message/post-response concept
  • 1.2 Document how UserPromptSubmit serves as pre-message hook
  • 1.3 Document how Stop serves as post-response hook
  • 1.4 Explain token delta calculation methodology

2. Example Scripts

  • 2.1 Create context-tracker.py example script with character estimation (zero dependencies)
  • 2.2 Create context-tracker-tiktoken.py example script with tiktoken method (more accurate)
  • 2.3 Implement UserPromptSubmit handler (save pre-message count)
  • 2.4 Implement Stop handler (calculate and report delta)
  • 2.5 Add clear inline comments explaining both approaches

3. Configuration Examples

  • 3.1 Add hook configuration example for UserPromptSubmit event
  • 3.2 Add hook configuration example for Stop event
  • 3.3 Provide combined configuration showing both hooks together

4. Token Counting Methods Documentation

  • 4.1 Document tiktoken with p50k_base method (more accurate, ~90-95%)
  • 4.2 Document character-based estimation method (simple, ~80-90%)
  • 4.3 Create comparison table of both offline methods
  • 4.4 Explain what's included/excluded from transcript
  • 4.5 Add caveat that no official Claude offline tokenizer exists

5. Validation

  • 5.1 Test example script with sample JSON input
  • 5.2 Verify configuration examples have valid JSON syntax
  • 5.3 Run openspec validate to confirm proposal is complete