Measuring Off-Task Token Spend in Claude Code: The 'Undeclared-Intent' Metric

A developer building custom hooks for Claude Code created a metric called undeclared-intent spend to measure token usage outside the declared objective.
Key Findings
- In one session, total compute was 5,137 tokens, with 1,173 (22.8%) classified as undeclared and 3,964 (77.2%) on-declared.
- Undeclared spend captures cost of retries, loops, reasoning drift, and off-task execution — not just governance violations.
- The metric treats cost as a behavioral signal, not billing telemetry alone.
Implementation Challenge
The hook surface doesn't always expose enough context to distinguish true drift from indeterminable intent. The author notes two distinct failure modes: genuine drift (wandered into unrelated files/systems) vs. indeterminable from hook data. Different responses needed per mode.
Example output format:
Total compute 5,137 tokens
Undeclared 1,173 tokens (22.8%)
Declared 3,964 tokens (77.2%)
No tool or library is shared in the source; the post is a discussion prompt. The author is interested whether others are measuring off-task compute or still treating token spend purely as billing/optimization.
📖 Read the full source: r/ClaudeAI
👀 See Also

Claude's 171 Internal Emotion Vectors Influence Output: Toolkit Based on Anthropic Research
Anthropic's research paper reveals Claude has 171 internal activation patterns that function like emotion vectors, causally driving its behavior before it writes. A developer created a toolkit with 7 practical prompting principles and system prompts based on these findings.

jsongrep: A DFA-Based JSON Query Tool That Outperforms jq in Benchmarks
jsongrep is a Rust-based command-line tool for querying JSON documents using a regular language syntax that compiles to deterministic finite automata (DFA), achieving faster search times than jq, jmespath, jsonpath-rust, and jql in benchmarks.

ClawHost Open-Source OpenClaw One-Click Deploy Hits 200+ GitHub Stars
ClawHost, an open-source tool for one-click OpenClaw installation with full server access and control, has reached 200+ GitHub stars. The project addresses issues with unstable commercial wrappers by providing a free, self-hostable solution.

LORE.md: An Open Standard for Extracting Structured Knowledge from AI Conversations
LORE.md is an open standard for extracting durable knowledge from AI conversations into a structured format. It captures decisions with rationale, insights, patterns, open questions, and next steps, with everything linking across sessions.